Top Related Projects
Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly.
Full stack, modern web application template. Using FastAPI, React, SQLModel, PostgreSQL, Docker, GitHub Actions, automatic HTTPS and more.
Quick Overview
DjangoX is a production-ready Django starter project that extends the official Django template with additional features and best practices. It aims to provide a solid foundation for building Django web applications, incorporating modern tools and configurations out of the box.
Pros
- Includes pre-configured user authentication and authorization
- Integrates popular third-party packages like django-allauth and django-crispy-forms
- Provides a Docker setup for easy development and deployment
- Includes pre-configured static files handling and custom user model
Cons
- May include more features than needed for simple projects
- Requires familiarity with Django and related packages to fully utilize
- Potential overhead in maintaining and updating multiple dependencies
- Some developers may prefer to set up their own custom configurations
Code Examples
- Custom User Model:
from django.contrib.auth.models import AbstractUser
from django.db import models
class CustomUser(AbstractUser):
# Add additional fields here
age = models.PositiveIntegerField(null=True, blank=True)
- Django Allauth Configuration:
AUTHENTICATION_BACKENDS = (
"django.contrib.auth.backends.ModelBackend",
"allauth.account.auth_backends.AuthenticationBackend",
)
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_SIGNUP_PASSWORD_ENTER_TWICE = False
ACCOUNT_SESSION_REMEMBER = True
ACCOUNT_AUTHENTICATION_METHOD = "email"
ACCOUNT_UNIQUE_EMAIL = True
- Docker Compose Configuration:
version: '3.8'
services:
web:
build: .
command: python /code/manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- 8000:8000
depends_on:
- db
db:
image: postgres:13
volumes:
- postgres_data:/var/lib/postgresql/data/
environment:
- "POSTGRES_HOST_AUTH_METHOD=trust"
volumes:
postgres_data:
Getting Started
-
Clone the repository:
git clone https://github.com/wsvincent/djangox.git
-
Change into the project directory:
cd djangox
-
Install dependencies:
pip install -r requirements.txt
-
Apply migrations:
python manage.py migrate
-
Run the development server:
python manage.py runserver
Visit http://127.0.0.1:8000 in your browser to see the application running.
Competitor Comparisons
Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly.
Pros of cookiecutter-django
- More comprehensive and feature-rich, offering a wider range of built-in functionalities
- Highly customizable with numerous configuration options during project setup
- Includes Docker support out of the box for easier deployment and development
Cons of cookiecutter-django
- Steeper learning curve due to its complexity and extensive features
- May include unnecessary components for simpler projects, potentially leading to bloat
- Requires more setup time and configuration compared to DjangoX
Code Comparison
DjangoX:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
]
cookiecutter-django:
INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.forms',
]
The code comparison shows that cookiecutter-django includes more default apps in its INSTALLED_APPS
setting, reflecting its more comprehensive approach to project setup.
Full stack, modern web application template. Using FastAPI, React, SQLModel, PostgreSQL, Docker, GitHub Actions, automatic HTTPS and more.
Pros of full-stack-fastapi-template
- Built on FastAPI, offering superior performance and async capabilities
- Includes Docker setup for easier deployment and development
- Provides a more comprehensive full-stack solution with frontend integration
Cons of full-stack-fastapi-template
- Steeper learning curve due to more complex architecture
- Less mature ecosystem compared to Django
- May be overkill for smaller projects or those not requiring high performance
Code Comparison
DjangoX (settings.py):
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
]
full-stack-fastapi-template (main.py):
from fastapi import FastAPI
from starlette.middleware.cors import CORSMiddleware
app = FastAPI(title=PROJECT_NAME, openapi_url=f"{API_V1_STR}/openapi.json")
app.add_middleware(
CORSMiddleware,
allow_origins=BACKEND_CORS_ORIGINS,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
The code comparison highlights the difference in setup between Django's declarative style and FastAPI's more explicit configuration. FastAPI offers more granular control over middleware and API documentation, while Django provides a more opinionated structure out of the box.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
A batteries-included Django starter project. To learn more visit LearnDjango.com.
https://github.com/wsvincent/djangox/assets/766418/a73ea730-a7b4-4e53-bf51-aa68f6816d6a
ð Features
- Django 5.0 & Python 3.12
- Install via Pip or Docker
- User log in/out, sign up, password reset via django-allauth
- Static files configured with Whitenoise
- Styling with Bootstrap v5
- Debugging with django-debug-toolbar
- DRY forms with django-crispy-forms
- Custom 404, 500, and 403 error pages
Table of Contents
ð Installation
DjangoX can be installed via Pip or Docker. To start, clone the repo to your local computer and change into the proper directory.
$ git clone https://github.com/wsvincent/djangox.git
$ cd djangox
Pip
$ python -m venv .venv
# Windows
$ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
$ .venv\Scripts\Activate.ps1
# macOS
$ source .venv/bin/activate
(.venv) $ pip install -r requirements.txt
(.venv) $ python manage.py migrate
(.venv) $ python manage.py createsuperuser
(.venv) $ python manage.py runserver
# Load the site at http://127.0.0.1:8000
Docker
To use Docker with PostgreSQL as the database update the DATABASES
section of django_project/settings.py
to reflect the following:
# django_project/settings.py
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": "postgres",
"USER": "postgres",
"PASSWORD": "postgres",
"HOST": "db", # set in docker-compose.yml
"PORT": 5432, # default postgres port
}
}
The INTERNAL_IPS
configuration in django_project/settings.py
must be also be updated:
# config/settings.py
# django-debug-toolbar
import socket
hostname, _, ips = socket.gethostbyname_ex(socket.gethostname())
INTERNAL_IPS = [ip[:-1] + "1" for ip in ips]
And then proceed to build the Docker image, run the container, and execute the standard commands within Docker.
$ docker compose up -d --build
$ docker compose exec web python manage.py migrate
$ docker compose exec web python manage.py createsuperuser
# Load the site at http://127.0.0.1:8000
Next Steps
- Add environment variables. There are multiple packages but I personally prefer environs.
- Add gunicorn as the production web server.
- Update the EMAIL_BACKEND and connect with a mail provider.
- Make the admin more secure.
django-allauth
supports social authentication if you need that.
I cover all of these steps in tutorials and premium courses over at LearnDjango.com.
ð¤ Contributing
Contributions, issues and feature requests are welcome! See CONTRIBUTING.md.
âï¸ Support
Give a âï¸ if this project helped you!
License
Top Related Projects
Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly.
Full stack, modern web application template. Using FastAPI, React, SQLModel, PostgreSQL, Docker, GitHub Actions, automatic HTTPS and more.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot