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 7845095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:06:48+00:00 2026-06-02T17:06:48+00:00

I have serialized 4 apps from my project with manage.py dumpdata. But when I’m

  • 0

I have serialized 4 apps from my project with manage.py dumpdata. But when I’m trying to load it in test as a fixture – i’m getting “Validation Error : This value must be True or False”.

How to understand, which line of dump is wrong? Or in which model I got this error?

UPD:
Problem is coming from invalid fixture. But I can’t understand, why django dumbdata creates invalid fixtures.

I have added

   print field.name

in django.core.serializers.python and found invalid values manually. But it’s not good way.

UPD.
I’m still interested in a way to dump data for any model and reuse it in tests as a fixture. I’m using postgresql for development.

  • 1 1 Answer
  • 0 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-06-02T17:06:49+00:00Added an answer on June 2, 2026 at 5:06 pm

    First of all are you using any custom/3rd party Fields?

    Although if you did and django’s dumpdata couldn’t serialize it, it
    would raise an exception I suppose. Anyway since last time I checked there
    was not any sufficient documentation for writing a custom django serializer,
    here is an example for serializing a custom UUIDField:

    from django.core.serializers.python import Serializer as PythonSerializer
    from django.core.serializers.json import DjangoJSONEncoder
    
    class CustomJSONEncoder(DjangoJSONEncoder):
        def default(self, obj):
            if isinstance(obj, uuid.UUID):
                return obj.hex
            return super(CustomJSONEncoder, self).default(obj)
    
    class Serializer(PythonSerializer):
        internal_use_only = False
        def end_serialization(self):
            json.dump(self.objects, self.stream, cls=CustomJSONEncoder, **self.options)
    
        def getvalue(self):
            if callable(getattr(self.stream, 'getvalue', None)):
                return self.stream.getvalue()
    

    Then in your settting.py add

    SERIALIZATION_MODULES = { 'myjson' : 'path.to.my.module.with.serializer' }
    

    Then from your shell you can do

    python manage.py dumpdata --format myjson > myfixtures.myjson # the extension is important!
    

    You can load it with

    python manage.py loaddata myfixtures.myjson
    

    Strangely enough loaddata does not accept a “format” parameter like dumpdata. It decides the format based on the file extension. Yet I could not find a way to
    hook my custom encoder, so I had to write a “new” serializer 🙁

    That’s what I did months ago when I needed to write a custom serializer and
    I had to dig through the django’s source code to figure it out, since
    the official docs had nothing on the subject. I hope it provides some help.

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

Sidebar

Related Questions

I have a class which is serialized to and from an XML file when
I have the following php code that gets a serialized array from a mysql
I have serialized a class which used to be in namespace Temp, but now
I have 2 networked apps that should send serialized protobuf-net messages to each other.
I'm trying to read multiple files that have been serialized with ProtoBuf.NET using .NET
I've got a few files that have been serialized by directly writing C++ struct
I have the following serialized PHP array stored in a mySQL database: a:2:{i:2070;s:4:0.00;i:1901;s:4:1.00;} Now,
I have a class which gets serialized and deserialized in a session, and I
I have an options column which is serialized. I plan to store user preferences
I have an application that I'm converting to Symfony/Doctrine. It currently stores a serialized

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.