The purpose of this project is to provide a django project template with authorization, authentication, etc. This template can be used by anyone. The template is fully customizable.
The template is based on django 4.1 and python 3.9.
- App with custom user model
- Ajax forms
- Authorization
- Registration
- Password change
- Password reset
- Password reset confirm
- All html Templates for registration, authorization, etc.
- BootStrap 5
- JS form validators
- ReCaptcha v2 (checkbox)
- PostgreSQL
- The project supports 6 languages: de, fr, ja, ru, tr, uk (translated using my script).
All forms are submitted using Ajax. Implemented a little spam protection for sending requests from forms: all "submit" buttons have been converted into regular buttons, which check all filled fields for errors before submitting. Example: 1 field is not filled, 2 is filled, but with an error - when you click on the "submit" button, the form will not be sent until the user fills in all the fields correctly.
Includes next fields:
- Username
- Password
- "Remember me" checkbox
Authorization is carried out by username or email. When you try to log into an account with unconfirmed mail, a confirmation email is sent again. There is a context processor for the login modal window on any page of the site.
Includes next fields:
- Username
- Password1
- Password2
- Captcha
- Accepting the privacy policy
Immediately after registration, an email is sent to the specified address.
Includes next fields:
- Old password
- New password
- New password confirmation
You cannot change the password to the current one.
Includes next fields:
- Captcha
If the specified email address exists in the database, an email is sent.
Includes next fields:
- New password
- New password confirmation
All emails (confirmation of the email and password reset) are sent using celery + redis.
There is also protection against an attack on sending emails: a delay that is configured in settings.py
All project settings are taken from the "conf.txt" file. The repository has a file "confEXAMPLE.txt" - with a minimum of constants.
- PostgreSQL
- Redis
- ReCaptcha
- Any smtp
You can also use another database and another broker.
Note that requirements.py already contains libraries for working with PostgreSQL and Redis.
- Create a PostgreSQL database, then exit postgres (CTRL + d):
foo@bar:~$ sudo -i -u postgres
postgres@bar:~$ createdb Auth
- Create a virtual environment and activate it:
foo@bar:~$ python3.9 -m venv venv
foo@bar:~$ source venv/bin/activate
- Clone the repository from Github and switch to the new directory:
(venv) foo@bar:~$ git clone https://github.com/SOSREBET/DJAuth
(venv) foo@bar:~$ cd DJAuth/
- Install project dependencies:
(venv) foo@bar:~/DJAuth$ pip install -r requirements.txt
- Rename "confEXAMPLE.txt" to "conf.txt" and fill in each field:
(venv) foo@bar:~/DJAuth$ mv confEXAMPLE.txt conf.txt
You can get the values for RECAPTCHA_PUBLIC_KEY
and RECAPTCHA_PRIVATE_KEY
here.
If you want to use Console Backend sending email see here.
- Create migrations and apply them:
(venv) foo@bar:~/DJAuth$ python3 manage.py makemigrations
(venv) foo@bar:~/DJAuth$ python3 manage.py migrate
- Now you can start the server:
(venv) foo@bar:~/DJAuth$ python3 manage.py runserver
To send emails you need to open 2 more terminal windows.
Start Redis in the first window
foo@bar:~$ sudo service redis-server start
foo@bar:~$ redis-cli
In the second run celery worker (don't forget to activate virtual environment)
(venv) foo@bar:~/DJAuth$ celery -A Project worker -l info
Bug reports are welcome