Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>django-registration allows you to write a <a href="http://docs.b-list.org/django-registration/0.8/backend-api.html">custom backend</a> to handle custom activation needs.</p> <p>So what you'd do is create your own backend, implementing the <code>register</code> and <code>activate</code> yourself.</p> <p>Here's an example of how you could implement the <code>register</code> function:</p> <pre><code>def register(self, request, **kwargs): username, email, password = kwargs['username'], kwargs['email'], kwargs['password1'] if Site._meta.installed: site = Site.objects.get_current() else: site = RequestSite(request) new_user = RegistrationProfile.objects.create_inactive_user(username, email, password, site, send_email=False) # send an email to the admins with user information send_new_user_notification(new_user) # you would write this function signals.user_registered.send(sender=self.__class__, user=new_user, request=request) return new_user </code></pre> <p>The key point is to make sure <code>send_email</code> is set to false; that will prevent the user from getting an activation link. Then you can decide whether the email sent to the admins has an activation link or if you're content with them going to admin and just checking the "Active" box.</p> <p>If you use <code>AuthenticationForm</code> from <code>django.contrib.auth</code> then it will automatically reject users whose <code>is_active</code> is False, but if you're not using that then make sure to run the following check for any request where an active user is required:</p> <pre><code>def restricted_view(request): if request.user and request.user.is_active: #continue with the code </code></pre> <p>You can also write your own decorator (look at <code>@login_required</code> for pointers). Note that <code>@login_required</code> does <em>not</em> check for <code>is_active</code>. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload