#16861: Fixtures do not work with namespaced apps
--------------------------+-------------------------------
Reporter: jlsherrill@… | Owner: nobody
Type: Bug | Status: new
Milestone: | Component: Uncategorized
Version: 1.3 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------+-------------------------------
If you have an app that is "foo.bar" instead of just "foo" it seems as if
it is impossible to create fixtures for them. For example the app
django-allauth includes multiples apps within it:
* allauth.facebook
* allauth.twitter
* etc..
You can use it just fine, but if you try to use a fixture, for example:
{{{
- model: allauth.facebook.models.FacebookApp # (same error with
allauth.facebook.FacebookApp)
pk: 1
fields:
name: TestApp
site: "1"
application_id: 1234
api_key: Foo
application_secret: FOOO
}}}
importing will fail with this traceback:
{{{
Problem installing fixture
'~/project/settings/../../local_apps/accounts/fixtures/initial_data.yaml':
Traceback (most recent call last):
File "~/beer-env/lib/python2.7/site-
packages/django/core/management/commands/loaddata.py", line 169, in handle
for obj in objects:
File "~/beer-env/lib/python2.7/site-
packages/django/core/serializers/pyyaml.py", line 54, in Deserializer
for obj in PythonDeserializer(yaml.load(stream), **options):
File "~/beer-env/lib/python2.7/site-
packages/django/core/serializers/python.py", line 84, in Deserializer
Model = _get_model(d["model"])
File "~/beer-env/lib/python2.7/site-
packages/django/core/serializers/python.py", line 142, in _get_model
raise base.DeserializationError(u"Invalid model identifier: '%s'" %
model_identifier)
DeserializationError: Invalid model identifier: 'allauth.FacebookApp'
}}}
It seems that the get_model() call within _get_model() of
/django/core/serializers/python.py is splitting the 'model' from the
fixture which doesn't seem correct.
Affected code (/django/core/serializers/python.py)
{{{
def _get_model(model_identifier):
"""
Helper to look up a model from an "app_label.module_name" string.
"""
try:
#import pdb; pdb.set_trace()
Model = models.get_model(*model_identifier.split("."))
except TypeError:
Model = None
if Model is None:
raise base.DeserializationError(u"Invalid model identifier: '%s'"
% model_identifier)
return Model
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/16861>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.