Skip to content Skip to sidebar Skip to footer

'module' Object Is Not Iterable When Running Django Website To The Server

i wanted to run my django website to their server so i open cmd and go to manage.py directory : C:\Users\computer house>cd desktop/newproject then i type this code : python m

Solution 1:

This error seems like either you don't have a /videos/urls.py file or it doesn't contain any valid url patterns.

Step 1. Create a urls.py inside your videos folder(if there is a one, no need to create) Step 2. add the following code to /videos/urls.py

urlpatterns = []

Empty urlpatterns considered as a valid patter in Django

Solution 2:

The problem is with spellings urlpatterns = []

and urls.py instead of url.py

Solution 3:

Two comments:

  1. urlpatternesshould be urlpatterns
  2. In my case, the error was actually in views.py. So the python generated error message was a bit misleading because all of the urls.py files in my project were fine. I was able to get passed this error, once I commented out 90% of my code in views.py (except for a basic index(request) method). Once I had a working homepage, I was able to uncomment my code until I discovered the error.

Solution 4:

Perhaps useful for someone else who finds this. In my case the error was being caused by an exception further down the import chain, there was nothing wrong with my urls (they hadn't changed since they were last working).

The way to approach an error like this, when the real exception is being masked by something else, is basically to remove all your urls and then add them back in one at a time each time checking whether you get the exception in order to isolate where it's coming from. So start by removing all but one url or url include, check if it runs, if it does then add the next back in and repeat until you get the error.

Then you can apply the same principle to your views, remove all and then re-add until you find the error. At this point you roughly know where your problem is so use the django shell (python manage.py shell) and import the view that you've isolated as having caused the error. This should give you the actual exception which will most likely lead to actually being able to approach the problem.

If just importing the view isn't enough you may want to isolate it into a test case where you can mock a request to give to the view but you shouldn't really need to in cases like this the issue is with the import since you're not actually running the view at the stage of just running your server.

Solution 5:

My problem was renaming typo

it should be

urlpatterns = []

Post a Comment for "'module' Object Is Not Iterable When Running Django Website To The Server"