Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What are the functions of django admin and manage.py

Shulou Source: shulou.com Published: 2022-06-01 18:38:32 10月03日 Update

This article mainly explains "what is the role of django admin and manage.py". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what are the functions of django admin and manage.py"?

Opening remarks:

In our Django development process, the most command line execution should be python manage.py. Let's talk about the command manage.py today.

Main points of record:

Django-admin and manage.py can do the same thing.

Like our commonly used python manage.py runserver, you can also operate with django-admin: django-admim runserver

Note:

Django-admin needs to configure the DJANGO_SETTINGS_MODULE environment variable in advance, or specify settings:django-admin runserver-- settings=mysite.settings when executing.

Manage.py is recommended because it is easier to use and does not need to be configured.

Diffsettings

Lists the changes between the current settings.py content and the default created settings.py, followed by "#" after the settings that do not appear in the default settings.

Fulsh

Under Linux, we often tease, if you can't solve the problem, then try: rm-rf / (joke, please don't practice)

Django also has a type of command: python manage.py flush, which deletes default databases by default. If multiple databases are configured in setting.py, you can specify: python manage.py flush-- database DATABASE

Showmigrations

Showmigrations [app_label [app_label...]] Displays all migrations in the project.

If you have a database, you can add the parameter:-- database DATABASE

The output effect is as follows:

Admin

[X] 0001_initial

[X] 0002_logentry_remove_auto_add

[] 0003_logentry_add_action_flag_choices

Startapp

Generally, we create an app that works like this: python manage.py startapp appname.

If app2, 3 times, we can do this directly. But knowing that there will be a lot of app under our project, we can create a python package in the project directory in advance, and then directly specify the path: python manage.py startapp appname [filepath] to avoid moving later.

Test

Common command: python manage.py test

If we want to keep the test data, we can take the parameter-- keepdb,-k, so that the test data will be retained.

There will be an article on test at a later stage, please look forward to it.

Collectstatic

This command is needed when the style of the admin management background of django is set to True, which results in the loss of page style when DEBUG is set to.

At this point, I believe you have a deeper understanding of "what is the role of django admin and manage.py". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Commands data functions content databases projects configurations parameters commonly used styles learning testing practical deeper things things interests variables background follow Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Technology MariaDB Linux MySQL