On Mon, Apr 13, 2009 at 7:32 PM, Glenn Maynard <[email protected]> wrote: > Well, you might want to do that for any model, and the admin API > provides a more generic approach to managing this sort of task--but > OK.
It's true you *might* want to do it for any particular model, but the specific case of user profiles is such a common situation that it seems a shame to require everybody to come up with their own system and their own helpers and such. That's why Django has a standard API for handling user profiles. > It also assumes that there's just one type of profile--I'd think that > an app that wants to store information per user would want to have its > own model, since expecting the "main" user of the site to add some > boilerplate entries to his profile model doesn't seem very nice. The > reverse OneToOne mappings mostly scale to this sort of thing cleanly. It does assume only one profile model, but that's by far the common case, and so that's what's supported. More complex multi-profile situations veer off into the realm of things that can't really be supported by an API that's both simple and generic, and have such varied use-cases (e.g., how do you decide which type of user gets which type of profile? Do some users get multiple profiles? Do users move from one type to another over time?) that asking people to write their own custom code is more acceptable, since so many of those will be one-off/highly-specialized systems anyway. > I don't think "user.get_profile()" is measurably clearer than > "user.profile", though I guess it would be if you named your profile > class "Teapot". Well, the thing is that Django's had this API for years now, and people are familiar with it; while I'm sure it's possible to come up with other options which may or may not be "clearer", get_profile() has the advantage of already being a known, standard idiom in Django, which means people are more likely to recognize it and know what your code is doing than if you come up with your own system. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---
