質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Django

DjangoはPythonで書かれた、オープンソースウェブアプリケーションのフレームワークです。複雑なデータベースを扱うウェブサイトを開発する際に必要な労力を減らす為にデザインされました。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

解決済

1回答

2257閲覧

DjangoのmakemigrationsのところでTypeError: 'module' object is not iterableエラー

退会済みユーザー

退会済みユーザー

総合スコア0

Django

DjangoはPythonで書かれた、オープンソースウェブアプリケーションのフレームワークです。複雑なデータベースを扱うウェブサイトを開発する際に必要な労力を減らす為にデザインされました。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2020/05/06 12:50

編集2020/05/06 12:51

PythonのDjangoにて、アプリを作っています。

#悩んでいること

models.pyを作ってmakemigrationsをしたところエラーが出ました。

Traceback (most recent call last): File "C:\Users\Windows\Documents\pythonfiles\django\venv\tutorial\lib\site-packages\django\urls\resolvers.py", line 590, in url_patterns iter(patterns) TypeError: 'module' object is not iterable During handling of the above exception, another exception occurred: Traceback (most recent call last): File "manage.py", line 21, in <module> main() File "manage.py", line 17, in main execute_from_command_line(sys.argv) File "C:\Users\Windows\Documents\pythonfiles\django\venv\tutorial\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line utility.execute() File "C:\Users\Windows\Documents\pythonfiles\django\venv\tutorial\lib\site-packages\django\core\management\__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Users\Windows\Documents\pythonfiles\django\venv\tutorial\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv self.execute(*args, **cmd_options) File "C:\Users\Windows\Documents\pythonfiles\django\venv\tutorial\lib\site-packages\django\core\management\base.py", line 366, in execute self.check() File "C:\Users\Windows\Documents\pythonfiles\django\venv\tutorial\lib\site-packages\django\core\management\base.py", line 395, in check include_deployment_checks=include_deployment_checks, File "C:\Users\Windows\Documents\pythonfiles\django\venv\tutorial\lib\site-packages\django\core\management\base.py", line 382, in _run_checks return checks.run_checks(**kwargs) File "C:\Users\Windows\Documents\pythonfiles\django\venv\tutorial\lib\site-packages\django\core\checks\registry.py", line 72, in run_checks new_errors = check(app_configs=app_configs) File "C:\Users\Windows\Documents\pythonfiles\django\venv\tutorial\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config return check_resolver(resolver) File "C:\Users\Windows\Documents\pythonfiles\django\venv\tutorial\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver return check_method() File "C:\Users\Windows\Documents\pythonfiles\django\venv\tutorial\lib\site-packages\django\urls\resolvers.py", line 408, in check messages.extend(check_resolver(pattern)) File "C:\Users\Windows\Documents\pythonfiles\django\venv\tutorial\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver return check_method() File "C:\Users\Windows\Documents\pythonfiles\django\venv\tutorial\lib\site-packages\django\urls\resolvers.py", line 407, in check for pattern in self.url_patterns: File "C:\Users\Windows\Documents\pythonfiles\django\venv\tutorial\lib\site-packages\django\utils\functional.py", line 48, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "C:\Users\Windows\Documents\pythonfiles\django\venv\tutorial\lib\site-packages\django\urls\resolvers.py", line 597, in url_patterns raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) django.core.exceptions.ImproperlyConfigured: The included URLconf '<module 'twitterdata.urls' from 'C:\Users\Windows\Documents\pythonfiles\django\venv\twitterproject\twitterdata\urls.py'>' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.

modeles.pyのコードは下記です。

modeles.py

1from django.db import models 2 3# Create your models here. 4class TwitterModel(models.Model): 5 6 class Meta: 7 #テーブル名の指定 8 db_table ="category" 9 10 user_name = models.CharField(max_length=140) 11 user_id = models.CharField(max_length=140) 12 user_img = models.CharField(max_length=140) 13 user_text = models.TextField(null=True) 14 user_created_at = models.CharField(max_length=140)

#解決のために試したこと
コードを修正したりして、何度もmakemigrationsしてみたのですが、
同じエラーとなります。

OS、環境
Django 3.0.5
Python3.7.3
仮想環境:venv

調べているのですが、解決策が見つかりません。

お知恵お貸しいただけると助かります。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

djangoでプロジェクトを作成した時に最初に
urls.pyでアプリ下のまだ作成していないurls.pyをincludeで呼び出していたのが原因でした。

urls.py

1from django.contrib import admin 2from django.urls import path, include 3 4urlpatterns = [ 5 path('admin/', admin.site.urls), 6 path('', include('twitterdata.urls')), 7]

urls.py

1from django.contrib import admin 2from django.urls import path, include 3 4urlpatterns = [ 5 path('admin/', admin.site.urls), 6]

のように修正して解決しました。

投稿2020/05/06 13:09

退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問