运行的时候报错了

运行的时候报错了

我将prcharm重新安装了一下换了一个安装目录

ERRORS:

?: (urls.E004) Your URL pattern " # 地址列表\n    url(r'^user/address/list/$', views.address_list, name='address_list'),\n    # 地址的修改和编辑\n    # user/address/edit/add/   user/ad

dress/edit/12/\n    url(r'^user/address/edit/(?P<pk>\\S+)/$', views.address_edit, name='address_edit'),\n    url(r'^user/address/delete/(?P<pk>\\d+)/$', views.address_delete, name='add

ress_delete')," is invalid. Ensure that urlpatterns is a list of url() instances.

        HINT: Try removing the string ' # 地址列表

    url(r'^user/address/list/$', views.address_list, name='address_list'),

    # 地址的修改和编辑

    # user/address/edit/add/   user/address/edit/12/

    url(r'^user/address/edit/(?P<pk>\S+)/$', views.address_edit, name='address_edit'),

    url(r'^user/address/delete/(?P<pk>\d+)/$', views.address_delete, name='address_delete'),'. The list of urlpatterns should not have a prefix string as the first element.

accounts.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.

        HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.

accounts.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.

        HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.

auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.

        HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.

auth.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.

        HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.


System check identified 5 issues (0 silenced).


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

1回答
好帮手慕小猿 2020-09-10 18:20:34

1、看下报错的url 所在位置,将urlpatterns=[]改为urlpatterns=()例如:
    http://img1.sycdn.imooc.com//climg/5f59fd54091e942c03980096.jpg
2、检查数据库是否连接正确,删处数据库中的表,每个模块中的migrations文件夹的文件都删除只留下__init__.py(注意:每个模块的migrations文件夹都只留下__init__.py其余删除)
http://img1.sycdn.imooc.com//climg/5f59fd7109d5b5e802940148.jpg
3、重新迁移数据库
   python manage.py makemigrations 
   python manage.py migrate   
4、重新启动项目

   python manage.py runserver 

如果我的回答解决了你的疑惑,请采纳,祝学习愉快~

  • 提问者 Buck_messic #1
    老师修改后,运行python manage.py makemigrations 报错代码:Microsoft Windows [版本 6.1.7601] 版权所有 (c) 2009 Microsoft Corporation。保留所有权利。 (django) C:\Users\Administrator\Desktop\py_learn\django_mall>python manage.py makemigrations SystemCheckError: System check identified some issues: ERRORS: accounts.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'. HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'. accounts.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'. HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'. auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'. HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'. auth.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'. HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'. (django) C:\Users\Administrator\Desktop\py_learn\django_mall>
    2020-09-11 15:09:22
  • 好帮手慕元宝 回复 提问者 Buck_messic #2
    同学你好: 在settings.py中加入 AUTH_USER_MODEL ="app.models"其中user为app名,models为模型名。同学加入之后再试一下 祝同学学习愉快!
    2020-09-11 15:53:32
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
3.从网页搭建入门Python Web
  • 参与学习           人
  • 提交作业       218    份
  • 解答问题       3562    个

本阶段带你用Python开发一个网站,学习主流框架Django+Flask是Python Web开发的第一步,在基础知识上实现积分商城的项目开发,体验真实的项目开发流程,提高解决编程问题和效率的能力。

了解课程
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师