Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3933362
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:35:32+00:00 2026-05-19T23:35:32+00:00

I am using the –natural option when dumping one of my model into a

  • 0

I am using the –natural option when dumping one of my model into a fixtures, so that I won’t run into Content_typ ID problem when deploying. Results is here:

{
     "pk": 1, 
     "model": "seo.opportunitymetadatamodel", 
     "fields": {
         "_content_type": [
              "opportunity", 
              "jobopportunity"
         ], 
         "og_description": "", 
         "description": "", 
         "title": "test", 
         "keywords": "", 
         "og_title": "", 
         "heading": ""
     }
}

But when I try to load back the fixture, I get the following error:

Problem installing fixture 'seo/fixtures/initial_data.json': Traceback (most recent call last):
  File "/Users/xx/dev/envs/xx/lib/python2.6/site-packages/django/core/management/commands/loaddata.py", line 167, in handle
    for obj in objects:
  File "/Users/xx/dev/envs/xx/lib/python2.6/site-packages/django/core/serializers/json.py", line 38, in Deserializer
    for obj in PythonDeserializer(simplejson.load(stream), **options):
  File "/Users/xx/dev/envs/xx/lib/python2.6/site-packages/django/core/serializers/python.py", line 84, in Deserializer
    Model = _get_model(d["model"])
TypeError: string indices must be integers, not str

Seems like the method does not accept a string to load. What am I missing ?

  • 1 1 Answer
  • 4 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T23:35:32+00:00Added an answer on May 19, 2026 at 11:35 pm

    I can only guess right now, but after looking at Django’s source code and your error message I think the format of your fixture might be broken. The example you posted, is that the whole content of the file? If yes, then I think you need to put that model in a list, like this (pay attention to the outer brackets):

    [
      {
        "pk": 1, 
        "model": "seo.opportunitymetadatamodel", 
        "fields": {
          "_content_type": [
            "opportunity", 
            "jobopportunity"
          ], 
          "og_description": "", 
          "description": "", 
          "title": "test", 
          "keywords": "", 
          "og_title": "", 
          "heading": ""
        }
      }
    ]
    

    Why? After Django parsed the JSON data successfully, this data is passed to the python deserializer. This iterates over the data as follows:

    82      for d in object_list:
    83          # Look up the model and starting build a dict of data for it.
    84          Model = _get_model(d["model"])
    

    http://code.djangoproject.com/browser/django/trunk/django/core/serializers/python.py#L82

    Now imagine object_list is a json object (equivalent to python’s dictionary), iterating over it will only get you the keys, in this case pk, model, field. In line 84 Django does _get_model(d["model"]), that is, using a string "model" as index to another string, probably pk (which is the first element in object_list). That’s a type error.

    When object_list is an actual list, iterating over it will give you dictionaries, which can be indexed by strings.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using mercurial, I've run into an odd problem where a line from one committer
Using Ninject i would like to rebind one method to another implementation is that
using chrome 15 on osx 10.6.8 When adding event listeners, I've found that putting
Using Browserlab, it appears that the background image is not centred in Firefox7 for
Using jQuery, one can easily find out whether a particular element is visible using
Using MVC2 I have an AJAX form which is posting to a bound model.
using the arcsynthesis opengl tutorial and I'm trying to build the unofficial sdk that
Using the URL Rewrite module, I've got a rule setup that is defined as:
Using report builder 3.0, I have a report that queries a cube. How do
Using Entity Framework CodeFirst, how do I create a created datetime column that gets

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.