ConoscereLinux / asso-django

An open source Django Framework to manage Events, Member and basic Accounting for an Italian Association
GNU General Public License v3.0
0 stars 3 forks source link

Member | Convert Member to a subclass of User #49

Closed giobber closed 1 year ago

giobber commented 1 year ago

One of the ways to extend a model in django is via inheritance, essentially when i subclass a model in django it create a hidden OneToOneField relation (unique=True, primary=True, null=False) by using Base class index as index for children.

For more info see Django Documentation

Pro

Contro

Sample code

from ..core.models import User

class Member(User):
  ...
giobber commented 1 year ago

After discussion and some other tests, Member as User subclass is not the best way to manage situation In Admin User could be created inside Member page, Teacher should be free to be without a User The only lost feature is the possibility to see first_name, last_name and email as Member fields in admin table page but this is not a great loss

NOTE: first_name and last_name are removed from Member and make required as email field

commit 809f2e9815010b7a1f220ad01fac54b9ff3deb60 closes this issues