Django Getting started with Django Django Concepts

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

django-admin is a command line tool that ships with Django. It comes with several useful commands for getting started with and managing a Django project. The command is the same as ./manage.py , with the difference that you don't need to be in the project directory. The DJANGO_SETTINGS_MODULE environment variable needs to be set.

A Django project is a Python codebase that contains a Django settings file. A project can be created by the Django admin through the command django-admin startproject NAME. The project typically has a file called manage.py at the top level and a root URL file called urls.py. manage.py is a project specific version of django-admin, and lets you run management commands on that project. For example, to run your project locally, use python manage.py runserver. A project is made up of Django apps.

A Django app is a Python package that contains a models file (models.py by default) and other files such as app-specific urls and views. An app can be created through the command django-admin startapp NAME (this command should be run from inside your project directory). For an app to be part of a project, it must be included in the INSTALLED_APPS list in settings.py. If you used the standard configuration, Django comes with several apps of it's own apps preinstalled which will handle things like authentication for you. Apps can be used in multiple Django projects.

The Django ORM collects all of the database models defined in models.py and creates database tables based on those model classes. To do this, first, setup your database by modifying the DATABASES setting in settings.py. Then, once you have defined your database models, run python manage.py makemigrations followed by python manage.py migrate to create or update your database's schema based on your models.



Got any Django Question?