0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Django】'ModelBase' object is not a mappingエラーがでた

Last updated at Posted at 2018-09-01

#問題

Djangoプロジェクトを実行したら次のようなエラーが出ました。

TypeError: 'ModelBase' object is not a mapping

#解決策

アプリケーションのurls.py

myapp/urls.py
from django.urls import path
from . import views

from myapp.models import mymodel

urlpatterns=[
	path('function/<int:key>', views.function, model, name='function'),
]

となっていたのですが、path('search/<int:request_id>', views.function, mymodel, name='function'),でモデルをkwargsに代入してはいけないっぽいです。

私の場合は、これで値を渡せると思っていたのですが、渡せないそうです。

urlpatternsのここを実行しなくても出るので注意してください。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?