pycharm中创建运行django

1>file —–new project..—-选择django
2>pycharm中创建运行django_第1张图片
选择Edit configurations —–script:选择manage.py所有在的目录,
script parameters : runserver
3>添加应用:tools–>run manage.py Task——-在控制台写:startapp blog (创建一个名称为blog的应用)
4>对项目数据进行迁移以保证数据库中的数据和models中定义的相同:tools——-run manage.py Task——–makemigrate 然后在执行一次 migrate
5>直接运行项目即可

wang@ubuntu:/home/wpython/blog$ python manage.py shell
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
Type “copyright”, “credits” or “license” for more information.

IPython 2.4.1 – An enhanced Interactive Python.
? -> Introduction and overview of IPython’s features.
%quickref -> Quick reference.
help -> Python’s own help system.
object? -> Details about ‘object’, use ‘object??’ for extra details.

In [1]: from django import template
In [2]: t=template.Template(‘my name is {{name}}’)
In [3]: c = template.Context({‘name’:’wang’})
In [4]: t.render(c)
Out[4]: ‘my name is wang’

你可能感兴趣的:(Python)