5👍
Try the following:
class CustomUserAdminForm(forms.ModelForm):
registration_key = forms.IntegerField()
class Meta:
model = User
class CustomUserAdmin(UserAdmin):
def registration_key(self, obj):
"""Special method for looking up and returning the user's registration key
"""
return 'the_key'
list_display = ('email', 'first_name', 'last_name', 'is_active', 'is_staff',
'registration_key') # <- this works
fields = ('email', 'first_name', 'last_name', 'is_active', 'is_staff',
'registration_key')
- Django: What's the use of the context_instance parameter in the render shortcut function?
- Printing Django QuerySet SQL with ""
1👍
I’ve done this before by overriding the template for the change form, and accessing custom methods on the model. Using fields
is asking the admin to try to add a form field for your method.
👤Bob
- Decorators run before function it is decorating is called?
- How to release the occupied GPU memory when calling keras model by Apache mod_wsgi django?
- About index and primary key in SQL?
- How To Upload File with Django Rest APi
Source:stackexchange.com