Django admin and manage.py
are essential tools for managing your Django project.
Django Admin:
Django admin is a built-in web interface that lets you manage your project's data and objects. It provides a user-friendly way to:
- Create, read, update, and delete (CRUD) data: Easily interact with your models and their instances.
- Manage users: Create, edit, and delete users and assign permissions.
- Customize the interface: Extend the admin with custom actions and views.
You can access the Django admin interface at http://your-project-url/admin/
.
Manage.py:
manage.py
is a command-line utility that provides a wide range of commands for managing your Django project. It allows you to:
- Start the development server: Run
python manage.py runserver
to start a local web server for development. - Create models: Generate new model classes using
python manage.py makemigrations
andpython manage.py migrate
. - Create apps: Add new Django applications to your project with
python manage.py startapp <app_name>
. - Manage database: Run database commands like
python manage.py dbshell
andpython manage.py flush
. - Run tests: Execute unit tests for your project with
python manage.py test
.
Common Manage.py Commands:
Here are some of the commonly used manage.py
commands:
python manage.py runserver
: Starts a local web server to run your Django application.python manage.py makemigrations
: Creates migrations for your database changes.python manage.py migrate
: Applies migrations to your database.python manage.py startapp <app_name>
: Creates a new Django application.python manage.py createsuperuser
: Creates an administrative user for your project.python manage.py shell
: Opens an interactive Python shell with your project's environment.python manage.py test
: Runs unit tests for your project.
Conclusion:
Django admin and manage.py
are powerful tools that streamline Django project development and management. They provide a convenient way to interact with your project's data, create new components, and manage your database.