现在,您已经安装了Django。现在是时候开始一个新的项目和应用程序了。
在任何版本的django中,您都可以使用以下命令启动新项目:
项目目录最初将如下所示:
project_name/ manage.py project_name/ __init__.py settings.py urls.py asgi.py wsgi.py
之后,您可以移动到项目目录。 具有项目名称的外部文件夹仅仅是容纳您的项目, manage.py 和数据库的集合。
manage.py 通过允许您运行与 django-admin 相同的命令行参数来帮助您管理项目。
Available subcommands: [auth] changepassword createsuperuser [contenttypes] remove_stale_contenttypes [django] check compilemessages createcachetable dbshell diffsettings dumpdata flush inspectdb loaddata makemessages makemigrations migrate sendtestemail shell showmigrations sqlflush sqlmigrate sqlsequencereset squashmigrations startapp startproject test testserver [sessions] clearsessions [staticfiles] collectstatic findstatic runserver
迁移(migrate) 用于应用迁移或发布更改。通常在 makemigrations 之后。 这里使用 migrate 的目的是为内置应用(例如 admin,auth,contentypes和session )应用迁移。
Operations to perform: Apply all migrations: admin, auth, contenttypes, sessions Running migrations: Applying contenttypes.0001_initial... OK Applying auth.0001_initial... OK Applying admin.0001_initial... OK Applying admin.0002_logentry_remove_auto_add... OK Applying contenttypes.0002_remove_content_type_name... OK Applying auth.0002_alter_permission_name_max_length... OK Applying auth.0003_alter_user_email_max_length... OK Applying auth.0004_alter_user_username_opts... OK Applying auth.0005_alter_user_last_login_null... OK Applying auth.0006_require_contenttypes_0002... OK Applying auth.0007_alter_validators_add_error_messages... OK Applying auth.0008_alter_user_username_max_length... OK Applying sessions.0001_initial... OK
现在无涯教程的django骨架项目已经准备就绪,只需要运行内置的本地开发服务器即可。
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)