Answer the question
In order to leave comments, you need to log in
Where is main_app.urls?
It says in my code that the error is: File "/Users/.../Firstapp/Firstapp/urls.py", line 18, in
import main_app.urls
ImportError: No module named main_app.urls
I think there is something I need to change this, but I don’t know how /Users/.../Firstapp/Firstapp/urls.py.
It looks in 2 Firstapp but should look in main_app.
URLS.PY
from django.conf.urls import include, url
from django.contrib import admin
import main_app.urls
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^', include("main_app.urls")),
]
from django.shortcusts import render
from django.http import HttpResponse
import urls
def index(request):
return HttpResponse('<h1>Time To Buy!</h1>')
from django.conf.urls import urls
from . import views
urlpatterns = [
url(r'^$', views.index)
]
Answer the question
In order to leave comments, you need to log in
include("main_app.urls")
you include urls, which you should probably have inside the application you created with
manage.py startapp main_app, and it's actually called main_app.
See if your file is there! If not, then take action.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question