After running django-admin startproject mysite, the following standard structure is created:
mysite/
├── manage.py # Command-line utility
└── mysite/
├── __init__.py
├── settings.py # Project settings
├── urls.py # Root URL router
├── wsgi.py # WSGI server (production)
└── asgi.py # ASGI server (async)
manage.py
The entry point for all Django management commands:
python manage.py runserver # start the development server
python manage.py migrate # apply migrations
python manage.py createsuperuser
python manage.py shell
settings.py — Key Settings
# Secret key — never commit this!
SECRET_KEY = 'django-insecure-...'
# Always False in production
DEBUG = True
ALLOWED_HOSTS = [] # ['mysite.com'] in production
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'myapp', # your application
]
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
urls.py — Root Router
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('tasks/', include('tasks.urls')), # include app URLs
]
Application Structure
python manage.py startapp tasks
tasks/
├── __init__.py
├── admin.py # model registration for the Admin site
├── apps.py # app configuration
├── models.py # database models
├── views.py # request handling logic
├── urls.py # app URL routes
├── forms.py # forms (create manually)
└── templates/ # HTML templates (create manually)
└── tasks/
💬 Comments (0)
No comments yet
Be the first to share your opinion about this article!