admin.py 420 B

123456789101112131415161718
  1. from django.contrib import admin
  2. from .models import Link
  3. # Register your models here.
  4. class LinkAdmin(admin.ModelAdmin):
  5. readonly_fields = ('created', 'updated')
  6. def get_readonly_fields(self, request, obj=None):
  7. if request.user.groups.filter(name='Personal').exists():
  8. return ('key', 'name')
  9. else:
  10. return ('created', 'updated')
  11. admin.site.register(Link, LinkAdmin)