Login

Tag "registration"

Snippet List

easy signal registration

Django signals can live anywhere you like. I like them in *app/signals.py* file. This snippet imports signal modules from all installed apps.

  • registration
  • signal
Read More

Password Validation - Require Letters and Numbers - no regex

Simple password validation for user registration - requires that password be 7 or more characters and contain both letters and numbers. Original validation with regex approach developed by kurtis. Optimized no-regex version based on code from watchedman ran as fast or significantly faster on all systems on which we tested it.

  • registration
  • model
  • regex
  • user
  • validation
  • form
  • password
Read More

Registration with confirmation email

This registers a users taking data from a submitted form, sends a confirmation email, activates the account when the confirmation link is clicked and logs the user in

  • registration
  • email
  • register
  • confirmation
Read More

Ensure submitted slugs do not conflict with existing resolvable URLs

This code overrides the existing RegistrationForm in django-registration and adds a new validation step. In this step, the username (my example slug) is compared against all the existing URLs that the application currently resolves and, if it *does* successfully resolve, throws a validation exception. This indicates that the username chosen would be overriden (or, if you wrote your urls.py file badly, would override) an existing URL already recognized by your application. A much longer explanation can be found at [Dynamic names as first-level URL path objects in Django](http://www.elfsternberg.com/2009/06/26/dynamic-names-as-first-level-url-path-objects-in-django/).

  • registration
  • slug
  • reverse
  • resolve
Read More

Simple E-mail registration

This is a simplified rip-off of django-registration and the built-in forms and views in contrib.auth. It requires no models and is very customizable. Saving the form creates a user with an unusable password and sends a password reset email (by default, uses the password reset template too). You must create templates/registration_form.html and the view registration_complete. I ripped this out of my site, which has a more complicated form, so I may be missing a few other things here.

  • registration
  • email
Read More

Django Registration without username

A simple adaptation of RegistrationFormUniqueEmail from django-registration http://code.google.com/p/django-registration to allow users to register without using a username. This works great with the code from this comment: http://www.djangosnippets.org/snippets/74/#c195 to allow users to completely eliminate the need for a username.

  • registration
  • auth
Read More

Django Registration with GMail account

This code works with Django-registration app found here: http://code.google.com/p/django-registration/ If you plan to use this django-registrtion code in your website to allow user registration but do not run your own email server,this snippet can be handy. It uses gmail server to send out email. You have to install libgmail module first. Add two lines to your `settings.py` GMAIL_USERNAME = '[email protected]' GMAIL_PASSWORD = 'your_password' Change models.py - create_inactive_user(...) as given above

  • registration
  • email
  • gmail
  • django-registration
Read More

Using manager methods

This is part of the user-registration code used on this site (see [the django-registration project on Google Code](http://code.google.com/p/django-registration/) for full source code), and shows a couple of interesting tricks you can do with manager methods. 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. 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.

  • managers
  • registration
Read More

9 snippets posted so far.