Linux command
django-admin 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Start a new project
django-admin startproject [project_name]
Start a new app
django-admin startapp [app_name]
Run development server
django-admin runserver
Create database migrations
django-admin makemigrations
Apply database migrations
django-admin migrate
Create superuser
django-admin createsuperuser
Open Django shell
django-admin shell
说明
django-admin is Django's command-line utility for administrative tasks. It provides commands for project setup, database management, testing, and development server operation. The tool requires a Django settings module to function. When inside a project directory, it automatically discovers the settings; otherwise, the DJANGO_SETTINGS_MODULE environment variable or --settings flag specifies the configuration. django-admin is typically aliased or replaced by manage.py within projects, which automatically configures the settings module. Both provide identical functionality.
参数
- startproject _NAME_
- Create new Django project.
- startapp _NAME_
- Create new Django app.
- runserver _PORT_
- Run development server.
- makemigrations _APP_
- Create migration files.
- migrate _APP_
- Apply migrations.
- createsuperuser
- Create admin user.
- shell
- Open interactive Python shell with Django context.
- --settings _MODULE_
- Settings module to use.
- --help
- Display help information.
FAQ
What is the django-admin command used for?
django-admin is Django's command-line utility for administrative tasks. It provides commands for project setup, database management, testing, and development server operation. The tool requires a Django settings module to function. When inside a project directory, it automatically discovers the settings; otherwise, the DJANGO_SETTINGS_MODULE environment variable or --settings flag specifies the configuration. django-admin is typically aliased or replaced by manage.py within projects, which automatically configures the settings module. Both provide identical functionality.
How do I run a basic django-admin example?
Run `django-admin startproject [project_name]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does startproject _NAME_ do in django-admin?
Create new Django project.