Задать вопрос

Тел: +7 965 3737 888





Using manager methods

<p>This is part of the user-registration code used on this site (see <a href="http://code.google.com/p/django-registration/">the django-registration project on Google Code</a> for full source code), and shows a couple of interesting tricks you can do with manager methods.</p>
<p>In this case there's a separate RegistrationProfile model used to store an activation key and expiration time for a new user's account, and the manager provides a couple of useful methods for working with them: create_inactive_user creates a new user and a new RegistrationProfile and emails an activation link, activate_user knows how to activate a user's account, and delete_expired_users knows how to clean out old accounts that were never activated.</p>
<p>Putting this code into custom manager methods helps a lot with re-use, because it means that this code doesn't have to be copied over into different views for each site which uses registration, and also makes more sense in terms of design, because these are methods which need to "know about" the model and work with it, and so they belong in a place close to the model.</p>

Вопрос полезен? Да0/Нет0

Ответы (2):

Ответ полезен? Да0/Нет0

FWIW, the pre & code markup rendered correctly in Preview, but posted as escaped HTML.

Ответ полезен? Да0/Нет0

Is [HTML_REMOVED]activation_key_expired[HTML_REMOVED] a method and not a property? I think line #88 should read: