A compilation of useful code snippets to create, set up, and develop a Django project.
Code Of Conduct:
- TBA...
Styling Guidelines:
- TBA...
Requirements:
- Python
- Pip
- Django
- Installing Django
- Creating a project
- Creating a Django app
- Starting the Server
- Django Models
- Django Views
- URL Patterns
- Rendering a page using views.py
- Creating a Migration
- Applying the Migration
pip install django
django-admin startproject project-name
python manage.py runserver
python manage.py startapp AppName
from django.db import models
class ModelName(models.Model):
ModelName_id = models.AutoField
- Views.py
from django.http import HttpResponse
def index(request):
return HttpResponse("cheatsheet")
from django.contrib import admin
from django.urls import path
from . import views
urlpatterns = [
path('admin/', admin.site.urls),
path('', views.index, name='index'),
path('about/', views.about, name='about'),
path('contact/', views.contact, name='contact'),
]
def index(request):
return render(request, 'index.html')
python manage.py makemigrations
python manage.py migrate
Here (TBA)