> For the complete documentation index, see [llms.txt](https://openai.gitbook.io/code-cheatsheets/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://openai.gitbook.io/code-cheatsheets/all/python/django.md).

# Django

MVC web framework from 2003

* comes with ORM, form system, template, caching, middleware support, unit testing, and internationalization

## Running

```bash
poetry run python manage.py runserver
poetry run python manage.py runserver 4000 #set port
poetry run python manage.py shell #shell with settings.py so DB access
```

## Basics

#### Default Project Files

* mysite/ [manage.py](https://docs.djangoproject.com/en/4.1/ref/django-admin/) - same as django-admin but uses settings.py mysite/ \_*init*\_.py [settings.py](https://docs.djangoproject.com/en/4.1/topics/settings/) [urls.py](https://docs.djangoproject.com/en/4.1/topics/http/urls/) - routes asgi.py - entrypoint for asgi web servers wsgi.py - entrypoint for wsgi web servers

### Default App Files

* polls/ \_*init*\_.py admin.py apps.py migrations/ \_*init*\_.py models.py tests.py urls.py views.py
