在django中,我一直得到这个ModuleNotFoundError:没有名为receipts的模块.其他的似乎都运行正常

t3psigkw  于 2023-04-22  发布在  Go
关注(0)|答案(1)|浏览(108)

我分叉并克隆了一个gitlab仓库。它包含了一堆测试你
除了test_feature_08.py,所有测试都通过了,我不知道现在还能做些什么来让它通过
receipts.views.py

from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from receipts.models import Receipt



@login_required
    def receipt_list(request):
    receipts = Receipt.objects.filter(purchaser=request.user)
    context = {
        "receipts": receipts,
    }
    return render(request, "receipts/list.html", context)


receipts.urls.py

from django.urls import path
from receipts.views import receipt_list



urlpatterns = [
    path("", receipt_list, name="home"),
]

expenses.urls.py


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



def return_home(request):
    return redirect("home")

urlpatterns = [
    path("", return_home),
    path("admin/", admin.site.urls),
    path("receipts/", include("receipts.urls")),
    path("accounts/", include("accounts.urls")),
]
                      

Traceback (most recent call last):
  File "/Users/tommyg/django-two-shot/receipts/views.py", line 3, in <module>
    from receipts.models import Receipt
ModuleNotFoundError: No module named 'receipts'
bvn4nwqk

bvn4nwqk1#

"receipts",添加到settings.py文件中的INSTALLED_APPS列表中。

相关问题