5.安装&卸载子应用 投票

另起一个新的Django项目 djangoProject_poll_test

image

........

把.tar.gz包下载到某个路径

D:\此电脑下分类\桌面\django-polls\dist\django-polls-0.1.tar.gz

image

安装子应用

定位到压缩包位置 执行

(venv) D:\此电脑下分类\桌面\django-polls\dist>
(venv) D:\此电脑下分类\桌面\django-polls\dist>python -m pip install django-polls-0.1.tar.gz
Processing d:\此电脑下分类\桌面\django-polls\dist\django-polls-0.1.tar.gz
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Requirement already satisfied: Django>=4.0 in e:\python\0code\studybuddy\venv\lib\site-packages (from django-polls==0.1) (4.0.5)
Requirement already satisfied: tzdata in e:\python\0code\studybuddy\venv\lib\site-packages (from Django>=4.0->django-polls==0.1) (2022.1)
Requirement already satisfied: sqlparse>=0.2.2 in e:\python\0code\studybuddy\venv\lib\site-packages (from Django>=4.0->django-polls==0.1) (0.4.2)
Requirement already satisfied: asgiref<4,>=3.4.1 in e:\python\0code\studybuddy\venv\lib\site-packages (from Django>=4.0->django-polls==0.1) (3.5.2)

DEPRECATION: Source distribution is being reinstalled despite an installed package having the same name and version as the installed package. pip 2
1.2 will remove support for this functionality. A possible replacement is use --force-reinstall. You can find discussion regarding this at https://
github.com/pypa/pip/issues/8711.
Building wheels for collected packages: django-polls
  Building wheel for django-polls (PEP 517) ... done
  Created wheel for django-polls: filename=django_polls-0.1-py3-none-any.whl size=529100 sha256=e1b1dc64f611731e5e9e9bd0ad1784571b86c43a9cc8912b1a7
5abda32eec09a
  Stored in directory: c:\users\大飞斗\appdata\local\pip\cache\wheels\8d\95\18\87a91d3e9c9b7975ad9909d81d99733f5a863ee9e320a85e55
Successfully built django-polls
Installing collected packages: django-polls
  Attempting uninstall: django-polls
    Found existing installation: django-polls 0.1
    Uninstalling django-polls-0.1:
      Successfully uninstalled django-polls-0.1
Successfully installed django-polls-0.1
WARNING: You are using pip version 21.1.2; however, version 23.0 is available.
You should consider upgrading via the 'E:\PYTHON\0CODE\StudyBuddy\venv\Scripts\python.exe -m pip install --upgrade pip' command.

(venv) D:\此电脑下分类\桌面\django-polls\dist>
(venv) D:\此电脑下分类\桌面\django-polls\dist>

按照README.rst编辑配置文件

=====
Polls
=====

Polls is a Django app to conduct web-based polls. For each question,
visitors can choose between a fixed number of answers.

Detailed documentation is in the "docs" directory.

Quick start
-----------

1. Add "polls" to your INSTALLED_APPS setting like this::

    INSTALLED_APPS = [
        ...
        'polls',
    ]

2. Include the polls URLconf in your project urls.py like this::

    path('polls/', include('polls.urls')),

3. Run ``python manage.py migrate`` to create the polls models.

4. Start the development server and visit http://127.0.0.1:8000/admin/
   to create a poll (you'll need the Admin app enabled).

5. Visit http://127.0.0.1:8000/polls/ to participate in the poll.
  1. urls.py

image

  1. settings.py

image

启动

可见数据还是空的

image

也无法用之前的用户登录

image

新建用户 newf 并登录

(venv) E:\PYTHON\0CODE\djangoProject_poll_test>
(venv) E:\PYTHON\0CODE\djangoProject_poll_test>
(venv) E:\PYTHON\0CODE\djangoProject_poll_test>python manage.py createsuperuser
Username: newf
Email address: newf@qq.com
Password:
Password (again):
The password is too similar to the username.
This password is too short. It must contain at least 8 characters.
Bypass password validation and create user anyway? [y/N]: y
Superuser created successfully.

(venv) E:\PYTHON\0CODE\djangoProject_poll_test>
(venv) E:\PYTHON\0CODE\djangoProject_poll_test>
(venv) E:\PYTHON\0CODE\djangoProject_poll_test>python manage.py runserver 5000
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
February 17, 2023 - 21:28:03
Django version 4.0.5, using settings 'djangoProject_poll_test.settings'
Starting development server at http://127.0.0.1:5000/
Quit the server with CTRL-BREAK.
[17/Feb/2023 21:28:05] "POST /admin/login/?next=/admin/ HTTP/1.1" 302 0
[17/Feb/2023 21:28:05] "GET /admin/ HTTP/1.1" 200 4394
[17/Feb/2023 21:28:06] "GET /static/admin/img/icon-changelink.svg HTTP/1.1" 200 380
[17/Feb/2023 21:28:06] "GET /static/admin/img/icon-addlink.svg HTTP/1.1" 200 331

效果

image

image

image

回忆之前

我们设置的后台风格修改的html文件

在这里

都没有生效,因为

他们都被隔离到主项目的templages里面了

卸载

(venv) E:\PYTHON\0CODE\djangoProject_poll_test>
(venv) E:\PYTHON\0CODE\djangoProject_poll_test>
(venv) E:\PYTHON\0CODE\djangoProject_poll_test>python -m pip uninstall django-polls
Found existing installation: django-polls 0.1
Uninstalling django-polls-0.1:
  Would remove:
    e:\python\0code\studybuddy\venv\lib\site-packages\django_polls-0.1.dist-info\*
    e:\python\0code\studybuddy\venv\lib\site-packages\polls\*
Proceed (y/n)? y
  Successfully uninstalled django-polls-0.1

(venv) E:\PYTHON\0CODE\djangoProject_poll_test>
(venv) E:\PYTHON\0CODE\djangoProject_poll_test>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

JFLEARN

CSDN这么拉会有人打赏?

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值