# TypeError: 'module' object is not iterable Error

**URL:** <https://forum.djangoproject.com/t/typeerror-module-object-is-not-iterable-error/41604>\
**Category:** Mystery Errors\
**Created:** [June 28, 2025, 3:53am UTC](https://forum.djangoproject.com/t/typeerror-module-object-is-not-iterable-error/41604 "2025-06-28T03:53:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Moali2009](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/moali2009/32/29045_2.png) [@Moali2009](https://forum.djangoproject.com/u/Moali2009)\
**Post date:** [June 28, 2025, 3:53am UTC](https://forum.djangoproject.com/t/typeerror-module-object-is-not-iterable-error/41604/1 "2025-06-28T03:53:01Z")

</div>

I don’t understand why I have this error whenever I run the code. Plz help.

```auto
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Users\Mohamed Ali\AppData\Local\Programs\Python\Python313\Lib\site-packages\django\urls\resolvers.py", line 720, in url_patterns
    iter(patterns)
    ~~~~ ^^^^^^^^^^
TypeError: 'module' object is not iterable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\Mohamed Ali\AppData\Local\Programs\Python\Python313\Lib\threading.py", line 1043, in _bootstrap_inner
    self.run()
    ~~~~~~~~ ^^
  File "C:\Users\Mohamed Ali\AppData\Local\Programs\Python\Python313\Lib\threading.py", line 994, in run
    self._target(*self._args, **self._kwargs)
    ~~~~~~~~~~~~ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Mohamed Ali\AppData\Local\Programs\Python\Python313\Lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
    ~~^^^^^^^^^^^^^^^^^
  File "C:\Users\Mohamed Ali\AppData\Local\Programs\Python\Python313\Lib\site-packages\django\core\management\commands\runserver.py", line 134, in inner_run
    self.check(**check_kwargs)
    ~~~~~~~~~~ ^^^^^^^^^^^^^^^^
  File "C:\Users\Mohamed Ali\AppData\Local\Programs\Python\Python313\Lib\site-packages\django\core\management\base.py", line 492, in check
    all_issues = checks.run_checks(
        app_configs=app_configs,
    ...<2 lines>...
        databases=databases,
    )
  File "C:\Users\Mohamed Ali\AppData\Local\Programs\Python\Python313\Lib\site-packages\django\core\checks\registry.py", line 89, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "C:\Users\Mohamed Ali\AppData\Local\Programs\Python\Python313\Lib\site-packages\django\core\checks\urls.py", line 16, in check_url_config
    return check_resolver(resolver)
  File "C:\Users\Mohamed Ali\AppData\Local\Programs\Python\Python313\Lib\site-packages\django\core\checks\urls.py", line 26, in check_resolver
    return check_method()
  File "C:\Users\Mohamed Ali\AppData\Local\Programs\Python\Python313\Lib\site-packages\django\urls\resolvers.py", line 532, in check
    messages.extend(check_resolver(pattern))
                    ~~~~~~~~~~~~~~ ^^^^^^^^^
  File "C:\Users\Mohamed Ali\AppData\Local\Programs\Python\Python313\Lib\site-packages\django\core\checks\urls.py", line 26, in check_resolver
    return check_method()
  File "C:\Users\Mohamed Ali\AppData\Local\Programs\Python\Python313\Lib\site-packages\django\urls\resolvers.py", line 531, in check
    for pattern in self.url_patterns:
                   ^^^^^^^^^^^^^^^^^
  File "C:\Users\Mohamed Ali\AppData\Local\Programs\Python\Python313\Lib\site-packages\django\utils\functional.py", line 47, in __get__
    res = instance. __dict__ [self.name] = self.func(instance)
                                         ~~~~~~~~~ ^^^^^^^^^^
  File "C:\Users\Mohamed Ali\AppData\Local\Programs\Python\Python313\Lib\site-packages\django\urls\resolvers.py", line 728, in url_patterns
    raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) from e
django.core.exceptions.ImproperlyConfigured: The included URLconf '<module 'hello.urls' from 'C:\\Users\\Mohamed Ali\\Desktop\\lecture3\\hello\\urls.py'>' does not appear to have any patterns in it. If you see the 'urlpatterns' variable with valid patterns in the file then the issue is probably caused by a circular import.

```

---

<div class="post-metadata">

**Author:** ![philgyford](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/philgyford/32/14295_2.png) [@philgyford](https://forum.djangoproject.com/u/philgyford)\
**Post date:** [June 28, 2025, 7:04am UTC](https://forum.djangoproject.com/t/typeerror-module-object-is-not-iterable-error/41604/2 "2025-06-28T07:04:40Z")

</div>

See the final line of the error:

> [@Moali2009](#):
>
> The included URLconf ‘\<module ‘hello.urls’ from ‘C:\Users\Mohamed Ali\Desktop\lecture3\hello\urls.py’\>’ does not appear to have any patterns in it. If you see the ‘urlpatterns’ variable with valid patterns in the file then the issue is probably caused by a circular import.`

What does your `hello/urls.py` file look like?

---

<div class="post-metadata">

**Author:** ![Moali2009](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/moali2009/32/29045_2.png) [@Moali2009](https://forum.djangoproject.com/u/Moali2009)\
**Post date:** [June 28, 2025, 5:44pm UTC](https://forum.djangoproject.com/t/typeerror-module-object-is-not-iterable-error/41604/3 "2025-06-28T17:44:01Z")

</div>

My urlpatterns are correct, I followed the exact way a tutorial did it.

hello/urls.py:

```auto
from django.http import HttpResponse

def index(request):
    return HttpResponse("Hello, world!")

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [June 28, 2025, 6:25pm UTC](https://forum.djangoproject.com/t/typeerror-module-object-is-not-iterable-error/41604/4 "2025-06-28T18:25:19Z")

</div>

> [@Moali2009](#):
>
> My urlpatterns are correct, I followed the exact way a tutorial did it.

No, they are not.

The contents you are showing are more appropriate for a `views.py` file and **not** a `urls.py` file. Recheck your file contents more closely.

(Or, if the tutorial you are following does show this as the urls.py file, then that tutorial is wrong and you should find a better tutorial.)

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [June 28, 2025, 6:48pm UTC](https://forum.djangoproject.com/t/typeerror-module-object-is-not-iterable-error/41604/5 "2025-06-28T18:48:01Z")

</div>

Side Note: When posting code here, enclose the code between lines of three  
backtick - ` characters. This means you’ll have a line of ```, then your code,  
then another line of ```. This forces the forum software to keep your code  
properly formatted. (I have taken the liberty of correcting your original posts.  
Please remember to do this in the future.)

---

<div class="post-metadata">

**Author:** ![Moali2009](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/moali2009/32/29045_2.png) [@Moali2009](https://forum.djangoproject.com/u/Moali2009)\
**Post date:** [June 28, 2025, 10:06pm UTC](https://forum.djangoproject.com/t/typeerror-module-object-is-not-iterable-error/41604/6 "2025-06-28T22:06:46Z")

</div>

Ok, I appreciate the help.
