调试过程出现的问题:

调试过程出现的问题:

  1. 启动出现错误 'Specifying a namespace in include() without providing an app_name ’
    django.core.exceptions.ImproperlyConfigured: Specifying a namespace in include() without providing an app_name is not supported. Set the app_name attribute in the included module, or pass a 2-tuple containing the lis
    t of patterns and app_name instead.

解释:是因为urls中的#django2.1版本该修了include参数 必须是元祖
https://blog.csdn.net/a1007720052/article/details/82108994
错误写法:
urlpatterns = [
url(’’, include((‘apps.urls’, ‘apps’), namespace=‘apps-urls’)),
]
正确写法:
urlpatterns = [
url(’’, include((‘apps.urls’, ‘apps’), namespace=‘apps-urls’)),
]

  1. 使用runserver 0.0.0.0:8000启动后,点击浏览器提示无法访问,拒绝访问:
    解决办法: 用127.0.0.1:8000访问,默认地址是0.0.0.0:8000故访问不到。

3.创建表时报错:
File “C:\Pyxuexi\GithubCode\guest\sign\models.py”, line 20, in Guest
event = models.ForeignKey(Event)
TypeError: init() missing 1 required positional argument: ‘on_delete’
分析:event = models.ForeignKey(Event)在django2以后,强调了使用ForeignKey必须指定on_delete=models.CASCADE(级联删除,关系表中使用级联表)
正确写法:
class Guest(models.Model):
event = models.ForeignKey(Event,on_delete=models.CASCADE)

  1. 问题:
    django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值