第一个Django程序和pycharm中导入django项目

简介:

Mac系统

1、django创建项目


sh-3.2# cd /Users/wulili/

sh-3.2# django-admin.py startproject mysite   创建项目

sh-3.2# ls -l

total 56

-r--------   1 wulili  staff      9  8  3 16:14 .CFUserTextEncoding

-rw-r--r--@  1 wulili  staff  10244 10 27 16:39 .DS_Store

drwx------   4 wulili  staff    136 10 27 09:10 .Trash

-rw-r--r--   1 wulili  staff   2538 10 26 20:52 .bash_history

drwxr-xr-x  92 wulili  staff   3128 10 26 20:52 .bash_sessions

drwxr-xr-x   2 wulili  staff     68 10  6 19:48 .matplotlib

drwx------   3 wulili  staff    102 10 13 08:56 .ssh

-rw-------   1 wulili  staff   4413 10 25 10:52 .viminfo

drwx------+  5 wulili  staff    170 10 13 18:09 Desktop

drwx------+  9 wulili  staff    306 10 13 10:07 Documents

drwx------+ 12 wulili  staff    408 10 28 11:13 Downloads

drwx------@ 56 wulili  staff   1904  8 24 17:51 Library

drwx------+  3 wulili  staff    102  8  3 16:16 Movies

drwx------+  5 wulili  staff    170  9 17 09:59 Music

drwx------+  5 wulili  staff    170 10  2 22:01 Pictures

drwxr-xr-x+  5 wulili  staff    170  8  3 16:16 Public

drwxr-xr-x   5 wulili  staff    170 10 27 16:24 PycharmProjects

drwxr-xr-x   6 wulili  staff    204  8  5 22:44 VirtualBox VMs

drwxr-xr-x   4 wulili  staff    136 10 25 10:52 cgi-bin

drwxr-xr-x   4 root    staff    136 10 28 14:59 mysite

sh-3.2# cd mysite/  一定是先创建项目,在进入到项目的目录,里面有 manage.py才能进行下面的命令。。我就是直接运行了下面的命令,百度了好半天才找到原因,5555555是不是很脑残

sh-3.2# ls -l

total 8

-rwxr-xr-x  1 root  staff  804 10 28 14:59 manage.py

drwxr-xr-x  6 root  staff  204 10 28 14:59 mysite

sh-3.2# python manage.py -help

Unknown command: '-help'

Type 'manage.py help' for usage.

sh-3.2# python manage.py help


Type 'manage.py help <subcommand>' for help on a specific subcommand.


Available subcommands:


[auth]

    changepassword

    createsuperuser


[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

sh-3.2# python manage.py runserver  启动服务端

Performing system checks...


System check identified no issues (0 silenced).


You have 13 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.


October 28, 2016 - 07:01:21

Django version 1.10.2, using settings 'mysite.settings'

Starting development server at http://127.0.0.1:8000/   访问地址

Quit the server with CONTROL-C.

[28/Oct/2016 07:01:49] "GET / HTTP/1.1" 200 1767

Not Found: /favicon.ico

[28/Oct/2016 07:01:49] "GET /favicon.ico HTTP/1.1" 404 1936


sh-3.2# python manage.py runserver 10.226.108.190:8001   设定IP和端口

Performing system checks...


System check identified no issues (0 silenced).


You have 13 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.


October 28, 2016 - 07:33:38

Django version 1.10.2, using settings 'mysite.settings'

Starting development server at http://10.226.108.190:8001/

Quit the server with CONTROL-C.



2、把django项目导入到pycharm中

下面内容是参考https://my.oschina.net/hevakelcj/blog/384070,感谢这位网友,非常棒。

wKioL1gTEFvBYYyhAADFH3GX4GA336.png-wh_50


wKioL1gTEITwxqlVAABqFSmkXxg060.png-wh_50

wKioL1gTEM7CHfD3AAGGoCMUXwY224.png-wh_50

wKioL1gUAtHi8RwaAAMB2LdmRmQ432.png-wh_50

这是我配置的


wKiom1gTEQDiG5aBAADAn2vvd7U356.png-wh_50


在我操作的第一遍,运行失败了,也不知道怎么回事,就是报错,无法导入django模块。。。。。

百度了好多也没解决,我就重新创建project,重新弄了一次就好了



本文转自aaa超超aaa 51CTO博客,原文链接:http://blog.51cto.com/10983441/1866774

相关文章
|
4月前
|
IDE 开发工具 Python
解决pycharm运行项目时控制台乱码
解决pycharm运行项目时控制台乱码
36 0
|
5月前
|
API 索引 Python
Python 教程之 Django(13)使用 Django 的天气应用程序
Python 教程之 Django(13)使用 Django 的天气应用程序
32 0
|
1天前
|
Python
【python】在pycharm创建一个新的项目
【python】在pycharm创建一个新的项目
4 0
|
4月前
|
搜索推荐 算法 前端开发
美食物管理与推荐系统Python+Django网站开发+协同过滤推荐算法应用【计算机课设项目推荐】
美食物管理与推荐系统Python+Django网站开发+协同过滤推荐算法应用【计算机课设项目推荐】
114 4
美食物管理与推荐系统Python+Django网站开发+协同过滤推荐算法应用【计算机课设项目推荐】
|
21天前
|
Python
PyCharm Community Edition 2023.3.1安装django模块
PyCharm Community Edition 2023.3.1安装django模块
|
26天前
|
前端开发 Python
(三)整合 React 项目静态文件到 Django 项目
(三)整合 React 项目静态文件到 Django 项目
|
26天前
|
Linux 网络安全 Python
解决方案:Centos7运行Django项目报错no module named _ssl
解决方案:Centos7运行Django项目报错no module named _ssl
21 0
|
29天前
|
Python
Django项目怎么关闭CFRS
Django项目怎么关闭CFRS
14 1
|
29天前
|
Python
Django项目如何通过修改manage.py指定运行的地址和端口号
Django项目如何通过修改manage.py指定运行的地址和端口号
16 2
|
29天前
|
前端开发 Python
在vscode中如何配置Django项目
在vscode中如何配置Django项目
18 0