dimanche 26 février 2017

Django. How to add an extra field in User model and have it displayed in the admin interface

I'm learning Django and need some help.

I need to include an extra boolean field in my User Model (auth_user table in the db I believe) and have it be displayed in the admin interface when managing users, like the staff status field in this image...

127:0.0.1:8000/admin/user : http://ift.tt/2lKQ53H

and...

127.0.0.1:8000/admin/auth/user/2/change/ : http://ift.tt/2lppdmU

I'm unsure on how to approach this. I understand I'll have to extend the AbstractUser model and then perhaps manually add the field into the db, but then how do I update the new field for the view, form and templates for the admin interface? Will I have to rewrite the django admin source code for all of these or is there an simpler way?




Aucun commentaire:

Enregistrer un commentaire