如何使用Jupyter创建Django项目?

我有一些需要与HTML页面进行交互的python代码。为此,我必须使用Django Framework。因为我对此很陌生,所以我不怎么做。

我已使用以下命令在系统上安装了Django: pip install django

运行此命令后,我得到以下输出:

Collecting django
  Downloading https://files.pythonhosted.org/packages/b2/79/df0ffea7bf1e02c073c2633702c90f4384645c40a1dd09a308e02ef0c817/Django-2.2.6-py3-none-any.whl (7.5MB)
Requirement already satisfied: pytz in c:\users\hisingh\appdata\local\continuum\anaconda3\lib\site-packages (from django) (2019.1)
Collecting sqlparse (from django)
  Downloading https://files.pythonhosted.org/packages/ef/53/900f7d2a54557c6a37886585a91336520e5539e3ae2423ff1102daf4f3a7/sqlparse-0.3.0-py2.py3-none-any.whl
Installing collected packages: sqlparse,django
Successfully installed django-2.2.6 sqlparse-0.3.0
Note: you may need to restart the kernel to use updated packages.

现在,我想创建我的第一个django项目。我正在尝试通过运行以下命令来通过Jupyter笔记本执行此操作:

django-admin FirstProject

输出:

File "<ipython-input-5-c29723f55035>",line 1
    django-admin FirstProject
                            ^
SyntaxError: invalid syntax

有人可以指导我这样做吗?任何帮助将不胜感激。

wei981106811 回答:如何使用Jupyter创建Django项目?

因此,在浏览了100多个博客或文章之后,我能够使用Jupyter创建我的第一个DJango项目。这是我制作的完整指南,可以解决我的问题:

步骤1 :通过打开任何ipynb文件在Jupyter Notebook上运行命令,以安装Django:

    1]pip install django
    2]pip install django-extensions

第2步:转到

    This PC(right click)->properties->Advanced system settings->click->Environment Variables->System Variables->Select Path->Edit->New

    Once you are here,add the below paths in path variable
        1]C:\Users\hisingh\AppData\Local\Continuum\anaconda3\Scripts
        2]C:\Users\hisingh\AppData\Local\Continuum\anaconda3\Library\bin
        3]C:\Users\hisingh\AppData\Local\Continuum\anaconda3

第3步

现在在cmd提示符下使用以下命令创建您的第一个Web项目:

    1]cd C\User\Python Django Project
    2]django-admin startproject YOUR_PROJECT_NAME

第4步

然后将django_extensions附加到INSTALLED_APPS部分下的settings.py文件中。

您可以在YOUR_PROJECT_NAME-> YOUR_PROJECT_NAME中找到“ settings.py”

    INSTALLED_APPS =[
                        ...
                        'django_extensions',]

第5步

然后在cmd提示符下运行jupyter notebook-

    python manage.py shell_plus --notebook

步骤6

现在打开任何Jupyter Notebook并根据需要更改内核。

本文链接:https://www.f2er.com/3168207.html

大家都在问