damongant

Untitled

May 4th, 2012
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. from news.models import News
  2. from django.contrib import admin
  3.  
  4. class NewsAdmin(admin.ModelAdmin):
  5.         readonly_fields = ('author',)
  6.         ordering = ['-publishDate']
  7.         def save_model(self, request, obj, form, change):
  8.                 if (not change):
  9.                         obj.author = request.user
  10.                 obj.save()
  11.  
  12. admin.site.register(News, NewsAdmin)
Advertisement
Add Comment
Please, Sign In to add comment