Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import Error :cannot import name get_model

File "C:\Python27\Lib\site-packages\file_picker\forms.py,line 5 in <module>
from django.db.models import Q,get_model
ImportError:cannot import name get_model

I am using django 1.9.7 and file_picker 0.2.2 I don't seem to have any solution to this problem

like image 454
Durodola Opemipo Avatar asked Oct 31 '25 20:10

Durodola Opemipo


2 Answers

Try using django.apps instead:

from django.apps import apps

apps.get_model('Model')

https://docs.djangoproject.com/en/dev/ref/applications/#django.apps.AppConfig.get_model

like image 182
jape Avatar answered Nov 03 '25 11:11

jape


Try this,

from django.apps import apps

model_obj = apps.get_model('app_name', 'model_name')

Where "app_name" is your app name and "model_name" is your model name.

like image 33
2 revsNitheesh MN Avatar answered Nov 03 '25 11:11

2 revsNitheesh MN