Changes to Make to the settings.py File for django-registration-redux 


               


Changes to Make to the settings.py File for django-registration-redux



Python


In this article, we show the changes that you have to make to the settings.py file for django-registration-redux.

django-registration-redux is a third-party application that allows us to build a website with users, registration, logins, etc.

So once you have installed, django-registration-redux, with the line, pip install django-registration-redux, and it has been successfully installed, there are a few changes that you must make to your settings.py file of your project directory.

There are basically 3 changes.


Add Registration to INSTALLED_APPS

The first thing you must do is add 'registration' to the list of of INSTALLED_APPS.

This allows the registration-redux app that you've installed with the installation of django-registration-redux to be activated.

Make sure that 'registration' is lowercase. Uppercase will not be recognized and will cause an error.



So we have 'registration' now added to the list of INSTALLED_APPS.

Later you will need to migrate your site, so that these changes are updated sitewide.

Before we do, let's now add the remaining 2 lines we must add to the settings.py file.

So the other thing we must do is add the following lines, shown below.



So what ACCOUNT_ACTIVATION_DAYS means is it sets the number of days that a user must activate their account by before the account is nullified.

As stated by the offical site, ACCOUNT_ACTIVATION_DAYS is the number of days users will have to activate their accounts after registering. If a user does not activate within that period, the account will remain permanently inactive and may be deleted by maintenance scripts provided in django-registration-redux.

So the way we have it now, we provide a one-week activation window. You, however, can change this to suit your liking.

The REGISTRATION_AUTO_LOGIN is a an optional parameter. The default value is equal to False. If this is True, users will automatically log in when they click on the activation link in their email.

Next, we have to add in a line where the user will be redirected to after s/he has logged into your site.

This is a single line of code.



Besides specifying the hardcoded URL, you can also set this variable equal to the url name, identified in the urls.py page of the app that you want to bring the user to.

One last thing that you must do in the settings.py file is add email settings.

Usually, when a user registers on a website, s/he receives email confirmation of this, alerting that the registration was successful and that s/he needs to activate the account.

This the case for django-registration-redux.

So you need to set up an email so that this email account can send an email to the user.

In the example below, we set up a gmail account to have access to SMTP, which is what is need to send outgoing email.



So now we have a gmail account that can send email out to new registrants on the site.

You don't have to use gmail, but if you are using another email service provider, the settings that are specified above may change, such as the port number and the use of TLS, so check all the settings of that email service provider in order to set up SMTP on that email service provider successfully.

And that's all that is needed for django-registration-redux to work.

So these are all the changes you have to make it your settings.py file for django-registration-redux.


Related Resources

How to Randomly Select From or Shuffle a List in Python



HTML Comment Box is loading comments...