Django: 'module' object has no attribute 'index'

前端 未结 3 626
灰色年华
灰色年华 2021-01-02 23:24

I\'ve been trying to learn Django for the past few days, but recently I\'ve stumbled upon a problem I can\'t seem to fix. After finishing Django\'s own tutorial on writing y

3条回答
  •  天涯浪人
    2021-01-02 23:50

    Import the urls.py module into your view. like this;

    from django.http import HttpResponse
    from . import urls
    
    def index(request):
        return HttpResponse("Hello, world. You're at the poll index.")
    

提交回复
热议问题