Here is list of common tasks which we do while developing websites using Django
Installation
Creating Virtual Environment- pip install Django
- python -m venv C:\Users\salah\OneDrive\Desktop\Data\Git1\learning\Projects\venvDynamicInternalPages
- C:\Users\salah\OneDrive\Desktop\Data\Git1\learning\Projects\venvDynamicInternalPages\Scripts>activate
Creating New Django Project
- django-admin startproject dynamicinternalpages
- cd dynamicinternalpages
- python manage.py startapp internal
- python manage.py makemigrations
- python manage.py migrate
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'dynamicinternalpages',
'web',
'rest_framework',
'api'
]
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIR = [
os.path.join('BASE_DIR', 'static')
# BASE_DIR / "static"
]
- python manage.py createsuperuser
- pip freeze requirements.txt
- pip install djangorestframework
- pip install markdown
- pip install django-filter
REST_FRAMEWORK = {
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'PAGE_SIZE': 10
}
- python manage.py runserver
Working with MYSQL Database
pip install mysqlclient
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'dynamicinternalpages',
'HOST': '127.0.0.1',
'PORT': '3306',
'USER': 'root',
'PASSWORD': 'titan#12',
}
}