Reputation: 419
I have the Model Admin like this registered on admin site
site.register(Student, ModelAdmin)
Now i have one more admin which is inherited from Model Admin with some custom data like this
class StudentAdmin(ModelAdmin):
list_display = ('id', 'user', 'created')
search_fields = ('username',)
which i also want to registered like this
site.register(Student, StudentAdmin)
But then i get the error that Student
is already registered
Upvotes: 2
Views: 2942
Reputation: 3467
Perhaps you can use proxy models Like..
class MyStudent(Student):
class Meta:
proxy=True
class MyStudentAdmin(ModelAdmin):
list_display = ('id', 'user', 'created')
search_fields = ('username',)
site.register(Student, ModelAdmin)
site.register(MyStudent, MyStudentAdmin)
Upvotes: 9
Reputation: 6351
First you have to unregister your register declarement
site.register(Student, ModelAdmin)
with
site.unregister(Student, ModelAdmin)
and then register second
site.register(Student,StudentAdmin)
You can not use both at the same time . (1 Model - 1 AdminModel)
Upvotes: -2
Reputation: 11888
ModelAdmin
(sub)class for a single Model
.django.contrib.auth
will raise an error if you attempt this.
Upvotes: -5