Table 'XYZ.fakemlng_translations' doesn't exist" #2142

Closed
stevebma opened this Issue Aug 6, 2013 · 4 comments

Comments

Projects
None yet
5 participants
@stevebma

stevebma commented Aug 6, 2013

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())
if field.count():

@yakky

This comment has been minimized.

Show comment Hide comment
@yakky

yakky Aug 17, 2013

Contributor

What's your INSTALLED_APPS setup?

Contributor

yakky commented Aug 17, 2013

What's your INSTALLED_APPS setup?

@ghost ghost assigned yakky Aug 17, 2013

@RRMoelker

This comment has been minimized.

Show comment Hide comment
@RRMoelker

RRMoelker Nov 21, 2013

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
if ph.actions.can_copy:

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
if field.count():


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:
Django==1.5.5
django-cms==2.4.3

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
if ph.actions.can_copy:

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
if field.count():


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:
Django==1.5.5
django-cms==2.4.3

@digi604

This comment has been minimized.

Show comment Hide comment
@digi604

digi604 Nov 21, 2013

Contributor

So how does django find this model?

Contributor

digi604 commented Nov 21, 2013

So how does django find this model?

@RRMoelker

This comment has been minimized.

Show comment Hide comment
@RRMoelker

RRMoelker Nov 21, 2013

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:
WSGIPythonPath /<path_to_virt_env>/local/lib/python2.7/site-packages

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.

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:
WSGIPythonPath /<path_to_virt_env>/local/lib/python2.7/site-packages

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.

@digi604 digi604 modified the milestones: 3.0, 2.4.X Feb 10, 2014

@yakky yakky removed their assignment Apr 4, 2014

@FinalAngel FinalAngel closed this Nov 2, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment