Received this very weird exception when using a PlaceholderFIeld outside django-cms (in custom models)
removing (commenting) the FakemlngFixtures class from django-cms / cms / test_utils / fixtures / fakemlng.py, was a quick fix that works for now.
Exception thrown here, lib/python2.7/site-packages/cms/models/placeholdermodel.py in _get_attached_field
field = getattr(self, rel.get_accessor_name())
What's your INSTALLED_APPS setup?
Working on same project as OP.
After a virtual environment reinstall, the problem disappeared. But it is back again after updating packages. For now we've quick fixed the problem.
Problem occurs when using django-cms "PlaceholderField" in our models. When editing the model in the admin, the placeholderfield widget is loaded and ".fakemlng_translations" table does not exist problem arises.
The critical part of the stack trace is below. Starting from the widget.py to the queryset method which throws the exception that the "fakemlng_translations" table doesn't exists.
File "/webapps/.virtualenvs/python2/local/lib/python2.7/site-packages/cms/forms/widgets.py", line 204, in render
File "/webapps/.virtualenvs/python2/local/lib/python2.7/site-packages/cms/models/placeholdermodel.py", line 152, in actions
field = self._get_attached_field()
File "/webapps/.virtualenvs/python2/local/lib/python2.7/site-packages/cms/models/placeholdermodel.py", line 107, in _get_attached_field
The problem I think lies in the "_get_attached_fields" method where "self._meta.get_all_related_objects" is called. All attached models are then queried which is fine for our custom models with the "PlaceholderField". However in the cms folder there is a model only used for testing.
The test model is "cms/test_utils/project/fakemlng/models.py: Translations". The table for this model only seems to be created when running test and not when using simple syncdb and migrate commands. But it is related by django at runtime to the placeholder model and so produces the problem. The "pythonpath" environmental variable is set to the "site-packages" folder which may cause django to recognize the related test model.
The quick fix was once again commenting "Translations" model in "test_utils/project/fakemlng/models.py".
Coming back to the question of the INSTALLED_APPS. Given that the problem is already pinpointed I hope only listing the django and cms versions is enough:
So how does django find this model?
It seems to be loaded by the wsgi module of apache. The python path points to the project root and site packages inside a virtual environment. That is:
When running the benign functions through the shell I don't get the errors. Indicating that only the wsgi module has the cms test language model loaded.
Seems the WSGIPythonPath setup in combination with having "cms" as an installed app is causing all this. But it seems like a valid setup.