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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:40:03+00:00 2026-06-13T11:40:03+00:00

I’m trying to serialize an instance of a (customized) Django User Model like so:

  • 0

I’m trying to serialize an instance of a (customized) Django User Model like so:

In models.py:

Class Employee(User):
    company = models.ForeignKey('Company')
    additionalField1
    additionalField2
    etc....

In the Employee model above, in addition to the attributes inherited from the User model, I use the following model field types: CharField(), NullBooleanField(), IntegerField(), DateField(), DecimalField()

The code in question:

employee = Employee()
(snip large amounts of code that sets various attributes for employee)
serializers.serialize("json", [employee, ])

(I have WadOfStuff’s Django full serializer plugin installed, btw, in case that matters — but in this case I believe it should be defaulting to the standard Django serializer because I’m not using any of the full serializer’s functionality in this case)

The employee __dict__ (with a few key fields anonymized) right before serialization is attempted:

{'status': u'Act', 'last_name': u'Doe', 'payFrequency': u'Mo', '_state':
 <django.db.models.base.ModelState object at 0x15be890>, 'sex': u'M', 'user_ptr_id': 
None, 'is_staff': False, 'isRegistered': False, 'hireDate': u'2012-08-01', 'id': None, 
'date_joined': datetime.datetime(2012, 10, 25, 2, 39, 22, 793015, tzinfo=<UTC>), 
'city': u'San Francisco', 'first_name': u'John', 'zip': u'94114', u'employmentType': 
u'FT', 'company_id': 4, 'compType': u'S', 'is_superuser': False, 'state': u'CA', 
'last_login': datetime.datetime(2012, 10, 25, 2, 39, 22, 792983, tzinfo=<UTC>), 
'email': '', 'username': 'tu7wwhyskewcpheyoq4lk3i3l', 'address2': '', 'is_active': 
True, 'phone': '', 'address': u'111 Cherry Lane', 'password': 
'pbkdf2_sha256$10000$OAlOtfQClAV2$OC9oCe/9P5hjc4nWd1ZW6cY117PmW1pny8J41axr6mM=', 
'salary': u'10833.00', 'standardHours': None, 'dob': u'1980-04-01', 'socialSecurity': 
u'555555555', 'middleInitial': '', 'payRate': None}

Partial traceback:

File "/usr/lib/python2.6/site-packages/django/core/serializers/__init__.py", l                                                                                                                     ine 98, in serialize
s.serialize(queryset, **options)
File "/usr/lib/python2.6/site-packages/wadofstuff/django/serializers/base.py",                                                                                                                      line 52, in serialize
self.handle_field(obj, field)
File "/usr/lib/python2.6/site-packages/wadofstuff/django/serializers/python.py                                                                                                                     ", line 71, in handle_field
self._fields[field.name] = field.value_to_string(obj)
File "/usr/lib/python2.6/site-packages/django/db/models/fields/__init__.py", l                                                                                                                     ine 722, in value_to_string
return '' if val is None else val.isoformat()
AttributeError: 'unicode' object has no attribute 'isoformat'

Any ideas what might be causing the error or how I can get serialization working in this case? Presumably there is some kind of attribute that the Serializer doesn’t like — how can I figure out which one?

  • 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-13T11:40:03+00:00Added an answer on June 13, 2026 at 11:40 am

    isoformat is a method that’s typically used on a datetime.datetime or datetime.date object, it looks like it’s attempting to do this on a string.

    My suspicion is that either “hireDate” or “dob,” should be an object date/datetime object but isn’t. Based on the traceback you could try setting those attributes to be None and see if you encounter the error again. Alternatively, you should try seeing if Django will save the model to the database with the data you have. If not that’s probably what’s causing your problem, in which case the data is being put into the Employee object with the wrong type.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.