asifpy / django-crudbuilder

Generic CRUD implementation in Django
https://django-crudbuilder.readthedocs.org/en/latest/index.html
Apache License 2.0
193 stars 67 forks source link

Erro in work with models managed=False #56

Closed marcoshemann closed 6 years ago

marcoshemann commented 6 years ago

Hi Asif, I got a error when I want create a crud with a table with managed = False, and manually set like app_label = 'portal_db', in this case, show this error: ( if possible, help me to fix this)

File "/home/devteam/.pyenv/versions/mh-lab2/lib/python3.5/site-packages/crudbuilder/abstract.py", line 52, in get_model_class c = ContentType.objects.get(app_label=self.app, model=self.model) File "/home/devteam/.pyenv/versions/mh-lab2/lib/python3.5/site-packages/django/db/models/manager.py", line 82, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/home/devteam/.pyenv/versions/mh-lab2/lib/python3.5/site-packages/django/db/models/query.py", line 401, in get self.model._meta.object_name django.contrib.contenttypes.models.DoesNotExist: ContentType matching query does not exist.

During handling of the above exception, another exception occurred:

asifpy commented 6 years ago

Seems like the ContentType is not created for your un-managed model. Make sure you performed the below steps for your un-managed models:

marcoshemann commented 6 years ago

Tks, but the solution to fix this is create a APP with name portal_db, add in INSTALLED_APPS. portal_db is the name of second db ( non default) .