D
D
danylo_kiz2017-04-02 20:06:19
Django
danylo_kiz, 2017-04-02 20:06:19

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")),
]

VIEWS.PY
from django.shortcusts import render
from django.http import HttpResponse
import urls

def index(request):
  return HttpResponse('<h1>Time To Buy!</h1>')

URLS.PY - MAIN_APP
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

2 answer(s)
A
Andrei Ramanchyk, 2017-04-02
@danylo_kiz

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.

S
sim3x, 2017-04-02
@sim3x

Where is main_app.urls?

/Users/$USER/Firstapp/main_app/urls.py

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question