A Django-based authentication system with email functionality using Mailtrap.
Before running this project, make sure you have the following installed:
- Python 3.10+
- pip
- virtualenv (recommended)
- Git
Check Python version:
python --versiongit clone https://github.com/yourusername/authentication_app.git
cd authentication_appCreate a virtual environment:
python -m venv venvActivate it.
venv\Scripts\activatesource venv/bin/activatepip install -r requirements.txtCreate a .env file in the project root directory.
Example:
SECRET_KEY=your_django_secret_key
DEBUG=True
# Database (example for sqlite)
DB_NAME=db.sqlite3
# Mailtrap Email Configuration
EMAIL_HOST=sandbox.smtp.mailtrap.io
EMAIL_HOST_USER=your_mailtrap_username
EMAIL_HOST_PASSWORD=your_mailtrap_password
EMAIL_PORT=2525
EMAIL_USE_TLS=True
DEFAULT_FROM_EMAIL=hello@example.com- Go to:
https://mailtrap.io
-
Create an account.
-
Go to Email Testing → SMTP Settings
-
Copy credentials and paste them in
.env.
Example credentials:
EMAIL_HOST=sandbox.smtp.mailtrap.io
EMAIL_HOST_USER=123456789
EMAIL_HOST_PASSWORD=abcdef123456
EMAIL_PORT=2525
EMAIL_USE_TLS=TrueRun the following commands:
python manage.py makemigrationspython manage.py migratepython manage.py createsuperuserFollow the prompts to create an admin account.
python manage.py runserverServer will start at:
http://127.0.0.1:8000/
Open:
http://127.0.0.1:8000/admin
Login using the superuser credentials.
project_root/
│
├── authentication_app/
│ ├── settings.py
│ ├── urls.py
│ ├── asgi.py
│ └── wsgi.py
│
├── manage.py
├── requirements.txt
├── .env
└── README.md
Run migrations
python manage.py makemigrations
python manage.py migrateCreate superuser
python manage.py createsuperuserRun development server
python manage.py runserverCollect static files (production)
python manage.py collectstatic- Never commit the
.envfile to GitHub. - Add
.envto.gitignore.
Example .gitignore entry:
.env
venv/
__pycache__/
db.sqlite3
This project is licensed under the MIT License.