Ready with Django 5
Set up a fresh Django project to build your large or small app, with everything configured to be controlled simply from environment variables.
-
Install Python 3.13
-
Clone or download django-startproject
git clone [email protected]:sannjayy/django-startproject.git- Rename the
django-startprojecttoYOUR-PROJECT-NAME - Rename the
YOUR-PROJECT-NAME/.env.Exampleto.env - Remove the existing "origin" remote:
git remote remove origin& Add your new remote repository (Optional)
- Create a virtual environment
python -m venv zenv
source zenv/Scripts/activate # Windows
source zenv/bin/activate # Mac- Install basic requirements
pip install -r requirements.txt
# OR INITIAL INSTALLATION
pip install --upgrade pip
pip install --upgrade setuptools
pip install django "django-phonenumber-field[phonenumberslite]" django-import-export django-filter django-cleanup gunicorn whitenoise django-cors-headers python-dotenv- To create a .env file from the .env.Example file
ENABLE_TEST_PANEL = True # It will enable the testing panel.
ENABLE_SYSINFO = False # It will enable the system info. || pip install psutil
ENABLE_DRF = False # It will enable the django rest framework || pip install djangorestframework djangorestframework-simplejwt
ENABLE_SWAGGER = False # It Enables Swagger-UI || pip install drf-yasg
USE_ASGI_MODE = False # Need to enable the redis for django channels || pip install 'channels[daphne]'
ENABLE_CRON_JOBS = False # Enables Django Crontab || pip install django-crontab
ENABLE_CELERY = False # enables the celery || pip install celery
ENABLE_CELERY_BEAT = False # Enables the celery beat || pip install django-celery-beat django-celery-results
ENABLE_MONGO_ENGINE = False # pip install mongoengine
ENABLE_AWS_S3_STORAGE = False # pip install django-storages boto3- Start Server
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
python manage.py runserverTo use PostgreSQL, set DB_TYPE = 'PostgreSQL' and ENABLE_DB = True make sure you have installed psycopg2:
# stand-alone package
pip install psycopg2
# OR binary package
pip install psycopg2-binaryTo use MySQL, set DB_TYPE = 'MySQL' and ENABLE_DB = True make sure you have installed pymysql:
pip install mysqlclientHelp: Installing mysqlclient on Ubuntu 22.04 / 24.04
To use SQLite, set ENABLE_DB = False
It will automatically use SQLite by default.
Install mongoengine
pip install mongoengineApply the following changes to your .env file.
ENABLE_MONGO_ENGINE = True
MONGODB_CONNECTION_STRING = 'mongodb://username:password@host:27017/db?authSource=admin'You can test the connection from TEST_PANEL.
To activate ASGI mode, enable USE_ASGI_MODE=True and install Django Channels:
pip install 'channels[daphne]'Redis Channels layers are also required for this. To enable Redis, set ENABLE_REDIS=True and REDIS_CHANNEL_LAYER=True, and install Django Channels Channel Layers:
pip install channels-redisYou can test the socket connections from TEST_PANEL.
To activate Celery, enable ENABLE_CELERY=True and make sure Redis is working properly. Run the following commands:
pip install celery
python manage.py makemigrations
python manage.py migrateOpen a new instance of terminal and run the following code:
# Windows
source zenv/Scripts/activate && celery -A project worker -l info -P eventlet
# Ubuntu | Mac
celery -A project worker -l infoYou can test the celery tasks from TEST_PANEL.
Enable ENABLE_CELERY_BEAT=True and then install:
pip install django-celery-beat
pip install django-celery-results
python manage.py makemigrations
python manage.py migrateOpen a new instance of terminal and run the following code:
# Windows
source zenv/Scripts/activate && celery -A project beat -l info
# Ubuntu | Mac
celery -A project beat -l infoHow to Deploy? : https://read.sanjaysikdar.dev/deploy-django-django-rest-framework-on-ubuntu-2204-2404
- π GitHub Repo
- π Website
- π« [email protected]
- π read.sanjaysikdar.dev
- π¦ pypi releases | npm releases
Developed with β€οΈ by sanjaysikdar.dev.
