Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#16861 closed Bug (invalid)

Fixtures do not work with namespaced apps

Reported by: jlsherrill@… Owned by: nobody
Component: Uncategorized Version: 1.3
Severity: Normal Keywords:
Cc: jlsherrill@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


If you have an app that is "" 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
    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/", line 169, in handle
    for obj in objects:
  File "~/beer-env/lib/python2.7/site-packages/django/core/serializers/", line 54, in Deserializer
    for obj in PythonDeserializer(yaml.load(stream), **options):
  File "~/beer-env/lib/python2.7/site-packages/django/core/serializers/", line 84, in Deserializer
    Model = _get_model(d["model"])
  File "~/beer-env/lib/python2.7/site-packages/django/core/serializers/", 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/ is splitting the 'model' from the fixture which doesn't seem correct.

Affected code (/django/core/serializers/

def _get_model(model_identifier):
    Helper to look up a model from an "app_label.module_name" string.
        #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

Change History (2)

comment:1 Changed 4 years ago by carljm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

Models in fixtures are referred to by "app_label.ModelName", where "app_label" is the final component of the app's dotted path (same as what you'd pass to e.g. " dumpdata"). So the string you're looking for is "facebook.FacebookApp" - "allauth" should be omitted entirely.

comment:2 Changed 4 years ago by anonymous

Ahhh. Thanks! That worked just fine.

Note: See TracTickets for help on using tickets.
Back to Top