Django_Project_Setup_Guide
Django_Project_Setup_Guide
Ensure Python and `pip` are installed on your system. Install Django globally or in a virtual
environment.
python --version
virtualenv venv
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
3. Install Django
cd myproject
INSTALLED_APPS = [
# Default apps...
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# Your app
'myapp',
]
7. Configure Database
By default, Django uses SQLite. If you want to use another database (e.g., PostgreSQL, MySQL),
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'your_db_name',
'USER': 'your_db_user',
'PASSWORD': 'your_password',
'HOST': 'localhost',
'PORT': '5432',
# For PostgreSQL
# For MySQL
9. Create a Superuser
Define your app's URL routes in myapp/urls.py and include it in the project's myproject/urls.py.
myapp/urls.py
urlpatterns = [
]
myproject/urls.py
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('myapp.urls')),
def home(request):
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR / 'media'
git init
git add .
For deployment, configure settings for production and use a platform like:
- Heroku
- Vercel
- Dockerized environments