﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
16861	Fixtures do not work with namespaced apps	jlsherrill@…	nobody	"
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
}}}"	Bug	closed	Uncategorized	1.3	Normal	invalid		jlsherrill@…	Unreviewed	0	0	0	0	0	0
