Skip to content

Instantly share code, notes, and snippets.

@shivam1283
Last active March 9, 2022 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shivam1283/31ad44cd41aad2231eeea5bb69c28360 to your computer and use it in GitHub Desktop.
Save shivam1283/31ad44cd41aad2231eeea5bb69c28360 to your computer and use it in GitHub Desktop.
[Django setup] django setup and tutorials

Install drf

pip install djangorestframework

Create project

django-admin startproject <project name>

Initial migrations

python manage.py migrate

Run server

python manage.py runserver

Create app

python manage.py startapp <app_name>

Create superuser

python manage.py createsuperuser

Register app

Register the app in INSTALLED_APPS in settings.py file along with the rest_framework app

` . . .

rest_framework, . . . `

Models

Create a basic model class inheriting from models.Models

''' class Article(models.Model): title = models.CharField(max_length=100) author = models.CharField(max_length=100) email = models.EmailField(max_length=100) date = models.DateTimeField(auto_now_add=True) def str(self): return self.title '''

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment