如何使用Pycharm社区免费版创建Django项目

对于python开发者来说,pycharm无疑是一款非常好用的开发ide,她有两个版本,一个社区版(免费),一个个人版(收费)。

免费版如果使用Django创建web项目那么就会提示需要升级到收费版本,那么如何使用免费版创建Django项目呢?

创建空项目

下载安装好pycharm个人版后,创建普通的python项目
file->new project->create

3. 引入Django

打开项目后,settings->Project:xxx->Python interpreter ->点击+号->输入Django->搜到后点击install

4. 控制台使用命令行创建项目

pycharm控制台打开:Terminal
进入刚创建的项目的根目录,
不过通过pycharm打开terminal默认在项目的根目录,
输入django-admin startproject MyWeb .
进入MyWeb目录 cd MyWeb
输入python manage.py runserver,
此时会有错误提示:You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.

按照提示输入python manage.py migrate
等待片刻,发现MyWeb目录下多了若干文件,此时就创建完成了

5. 测试

启动服务进行测试,是否环境配置好:
控制台继续输入: python manage.py runserver
控制台没有报错,并有提示信息:
System check identified no issues (0 silenced).
January 19, 2024 - 05:15:54
Django version 4.2.9, using settings 'MyWeb.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

点击链接,打开了一个显示Django的网页界面,说明配置成功,可以愉快的进行后续开发了

(.venv) (base) gaoyuan.l@bagedeMacBook-Pro WebProject % django-admin startproject MyWeb .
(.venv) (base) gaoyuan.l@bagedeMacBook-Pro WebProject % cd MyWeb 
(.venv) (base) gaoyuan.l@bagedeMacBook-Pro MyWeb % python manage.py runserver 
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
January 19, 2024 - 05:14:53
Django version 4.2.9, using settings 'MyWeb.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

^C%                                                                                                                                                               (.venv) (base) gaoyuan.l@bagedeMacBook-Pro MyWeb % python manage.py migrate 
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 admin.0003_logentry_add_action_flag_choices... 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 auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying auth.0012_alter_user_first_name_max_length... OK
  Applying sessions.0001_initial... OK
(.venv) (base) gaoyuan.l@bagedeMacBook-Pro MyWeb % python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
January 19, 2024 - 05:15:54
Django version 4.2.9, using settings 'MyWeb.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

[19/Jan/2024 05:16:00] "GET / HTTP/1.1" 200 10664
Not Found: /favicon.ico
[19/Jan/2024 05:16:01] "GET /favicon.ico HTTP/1.1" 404 2109
^C%                                                                                                                                                               (.venv) (base) gaoyuan.l@bagedeMacBook-Pro MyWeb % 

你可能感兴趣的:(python,pycharm,django,sqlite)