Hi, On Wednesday, June 6, 2012 4:32:02 PM UTC+2, Anssi Kääriäinen wrote: > > Still, yet another API idea: [snip] > > Then, Model.__new__ will replace the SwappableUser class with the > swapped in class. The 'swappable' in model.Meta tells which concrete > model implementation to use. >
I'd rather not dynamically replace models. The system proposed by Russell is clean and requires no extra magic. The only thing which might look a bit odd is inheriting from a swapped model, eg like: class MyUserProxy(get_user_model()): class Meta: proxy = True etc… (Which obviously can get a bit nicer by using User = get_user_model() and then inheriting from that). > > About the ORM capabilities of the interface: It seems there can not be > any assumptions about the swapped in model here: for example > SomeModel.filter(user__is_staff=True) or > SomeModel.order_by('user__lastname', 'user__firstname') works > currently, but there are no such lookups available for the interface. > Maybe there should be some way to order by "full_name" and > "short_name" at least. But, this gets us quickly to virtual fields or > virtual lookups territory... > Imo it's fine if we require some fields on a Usermodel to be compatible with admin and friends. (eg a first/last_name field which is nullable [or not required in the form validation sense] shouldn't hurt anyone, the admin could check if the field is filled and if not display something else like the username). Cheers, Florian -- You received this message because you are subscribed to the Google Groups "Django developers" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-developers/-/3yOTO--OzlkJ. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.