Sahib Navlani
Sahib Navlani

Reputation: 80

Not able to import views.py in django

I am not able to import the views.py module in urls.py module. I have tried multiple ways,

from . import views

import views

from rango import views

But none of them works , it just raises import error.

Directory structure enter image description here

urls.py file

enter image description here

error :-

enter image description here

I am able to import models.py module in urls.py but not able to import views.py in urls.py even though models.py and views.py are in the same location.

Seems magical !!

Upvotes: 0

Views: 2164

Answers (2)

noonkay
noonkay

Reputation: 123

I usually import explicitly, for example:

from rango.views import add_category

But you can try

from rango import views

Upvotes: 1

DJeanCar
DJeanCar

Reputation: 1593

try this:

from .models import MyModel

I suggest you read this post

Upvotes: 2

Related Questions