Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,732 members, 7,820,534 topics. Date: Tuesday, 07 May 2024 at 04:36 PM

Encountering This Error In Django: TypeError: 'module' Object Is Not Iterable - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Encountering This Error In Django: TypeError: 'module' Object Is Not Iterable (1290 Views)

I Need Help In Django / I'm Encountering Error As A Newbie On Python Language / Computer Based Test (cbtest) In Django (opensource) (2) (3) (4)

(1) (Reply) (Go Down)

Encountering This Error In Django: TypeError: 'module' Object Is Not Iterable by Babyprogrammer: 7:30pm On Apr 15, 2022
I am a newbie in the IT world and so excited to be in.
I have undergone Python training and took up the challenge to learn Django on Udemy.
Following the steps given keenly and perfectly as much as i could, I encountered the error in the screenshot below.

I will be so happy if any of my seniors and any of the gurus in the house to tell me or show me how to rectify the cause of the error.

Re: Encountering This Error In Django: TypeError: 'module' Object Is Not Iterable by GeneralDae: 10:22pm On Apr 15, 2022
Babyprogrammer:
I am a newbie in the IT world and so excited to be in.
I have undergone Python training and took up the challenge to learn Django on Udemy.
Following the steps given keenly and perfectly as much as i could, I encountered the error in the screenshot below.

I will be so happy if any of my seniors and any of the gurus in the house to tell me or show me how to rectify the cause of the error.
Most likely a problem from your Views.Py file. Cross check all files again with the tutorial you are following. If it still doesn't work, then start from a couple of steps back or even start all over again (if you haven't gone too far previously).
Re: Encountering This Error In Django: TypeError: 'module' Object Is Not Iterable by bosman50(m): 2:29am On Apr 16, 2022
In your views you didnt implement challenge. you implemented just index.the path() espects a routh as a first argument.
So django saw that as a module(challange is actually defined as a module.) and as such throws error.
Try and define a proper view for challenge and also include a pattern for index
Re: Encountering This Error In Django: TypeError: 'module' Object Is Not Iterable by bularuz(m): 7:35am On Apr 16, 2022
You didn't put anything in challenges url.py file
Re: Encountering This Error In Django: TypeError: 'module' Object Is Not Iterable by Babyprogrammer: 7:40am On Apr 16, 2022
GeneralDae:

Most likely a problem from your Views.Py file. Cross check all files again with the tutorial you are following. If it still doesn't work, then start from a couple of steps back or even start all over again (if you haven't gone too far previously).
Thanks very much sir.

I will try that sir
Re: Encountering This Error In Django: TypeError: 'module' Object Is Not Iterable by Babyprogrammer: 7:47am On Apr 16, 2022
bularuz:
You didn't put anything in challenges url.py file
I did sir

Re: Encountering This Error In Django: TypeError: 'module' Object Is Not Iterable by Babyprogrammer: 7:49am On Apr 16, 2022
bosman50:
In your views you didnt implement challenge. you implemented just index.the path() espects a routh as a first argument.
So django saw that as a module(challange is actually defined as a module.) and as such throws error.
Try and define a proper view for challenge and also include a pattern for index
Boss, please come down to my level sir cry
Re: Encountering This Error In Django: TypeError: 'module' Object Is Not Iterable by bedfordng(m): 10:50am On Apr 16, 2022
From your screenshots, all looks good. The issue could either be from the way you are trying to access the url.

Seems you are visiting the URL using just

localhost:8000/January

You have to go through

localhost:8000/challenges/January

for it to work. If you can screenshot the URL path you try to use in accessing the view.

Or better still, try and add comma in the URL path since it is a list.
Re: Encountering This Error In Django: TypeError: 'module' Object Is Not Iterable by bedfordng(m): 10:56am On Apr 16, 2022
Babyprogrammer:
Boss, please come down to my level sir cry
what he is trying to say in layman's term is that you didn't use challenges in your URL when accessing the view

If you wish to just access the view from example

localhost:8000/January

Then you have to remove the challenges from the URL py file in the folder where settings is located.

So since you used

path("challenges/", include("challenges.urls" ),

Change it to path("", include("challenges.urls" ),
Re: Encountering This Error In Django: TypeError: 'module' Object Is Not Iterable by flam5: 11:30am On Apr 16, 2022
Just put comma at the end of each path() for your project url and app url. Eg

path('challenges', include ('challenges.urls')),
path('', views.index),
Re: Encountering This Error In Django: TypeError: 'module' Object Is Not Iterable by flam5: 11:36am On Apr 16, 2022
bedfordng:
what he is trying to say in layman's term is that you didn't use challenges in your URL when accessing the view

If you wish to just access the view from example

localhost:8000/January

Then you have to remove the challenges from the URL py file in the folder where settings is located.

So since you used

path("challenges/", include("challenges.urls" ),

Change it to path("", include("challenges.urls" ),
That would have given path error and django would have suggested possible path for him.
Re: Encountering This Error In Django: TypeError: 'module' Object Is Not Iterable by bosman50(m): 3:35pm On Apr 16, 2022
Babyprogrammer:
Boss, please come down to my level sir cry
Be specific. Tell me what exactly you don't understand and I will explain further
Re: Encountering This Error In Django: TypeError: 'module' Object Is Not Iterable by ichidodo: 3:07pm On Apr 17, 2022
Ah sorry, You don go press spoil for this code...

(1) (Reply)

How Can I Trace Who Hacked My Phone Through MMS Messages? / Top 12 Highest Paying Computer Programming Languages You Should Learn / Pls Look In.....

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 20
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.