gpt4 book ai didi

django.core.exceptions.ImproperlyConfigured 错误

转载 作者:行者123 更新时间:2023-12-05 05:57:18 30 4
gpt4 key购买 nike

这是错误信息:

django.core.exceptions.ImproperlyConfigured: 
The included URLconf '<module 'basicsiteApp' from '/Users/msa/trydjango/basicsite/basicsiteApp/__init__.py'>'
does not appear to have any patterns in it.
If you see valid patterns in the file then the issue is probably
caused by a circular import.

我没有在 init.py 中写任何东西,因为我不知道我需要在里面写什么才能让它工作。

下面是我在 views.py 中的内容:

from django.shortcuts import render
from .forms import SignUpForm
from django.contrib import messages

def signup(request):
if request.method == 'POST'
form = SignUpForm(request.POST)
if form.is_valid():
form.save()
messages.success(request, 'Account Created')
return render(request, 'signup.html')
else:
form = SignUpForm()
render(request, 'signup.html')

Basicsite/urls.py:

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
path('', include('basicsiteApp')),
path('admin/', admin.site.urls)
]

basicsiteApp/urls.py:

from django.urls import path
from . import views

app_name = 'basicsiteApp'

urlpatterns = [
path('', views.signup, name='signup')
]

最佳答案

我知道来晚了,但如果有人(像我一样)面临同样的问题:

在你的“Basicsite/urls.py”中

path('', include('basicsiteApp')),

应该是

path('', include('basicsiteApp.urls')),

暗示 django 使用 basicsiteApp/urls.py 文件而不是 basicsiteApp/init.py

关于django.core.exceptions.ImproperlyConfigured 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68856209/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com