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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:42:35+00:00 2026-06-03T03:42:35+00:00

I have 2 django models like this: class UserProfile(models.Model): user = models.OneToOneField(User) organisation =

  • 0

I have 2 django models like this:

class UserProfile(models.Model):
    user             = models.OneToOneField(User)
    organisation     = models.CharField(max_length=200)

class Submission(models.Model):
    user             = models.ForeignKey(User)
    date_submission  = models.DateTimeField(db_index=True, default=datetime.now())
    date_published   = models.DateTimeField(db_index=True, null=True)
    status           = models.CharField(db_index=True, max_length=4000)
    logfile          = models.TextField(db_index=False)

where each ‘Submission’ object is owned by a normal django user, and each user has a UserProfile configured using the AUTH_PROFILE_MODULE in the normal way.

This works as you would expect, i can see the organisation field of the UserProfile object:

Submission.objects.all()[0].user.userprofile.organisation

When i want to serialize the Submissions list (for export to json) normally i use:

Submission.objects.all().values()
# or for more control of fields
Submission.objects.all().values('status', 'date_submission')
# to traverse a relationship.. get info from the User object
Submission.objects.all().values('user__username')

.. these work fine. BUT my problem is that i cannot:

Submission.objects.all().values('user__userprofile__organisation')

raise FieldError("Invalid field name: '%s'" % name)
django.core.exceptions.FieldError: Invalid field name: 'user__userprofile__organisation'

so it seems that the UserProfile is a ‘special case’. This was discussed here:
Django query : Call values() on user__userprofile

but the solution doesn’t help me (i’m fairly sure..)

Is this a limitation of the values() method ? does anyone know a way to get the same output of values() but able to traverse the UserProfile model ?

thanks for any ideas

-i

  • 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-03T03:42:36+00:00Added an answer on June 3, 2026 at 3:42 am

    Turns out upgrading to version 1.4 of Django solved the problem, the comment by Jingo suggests 1.3.1 would also be ok.

    so now i can:

    query_set = Submission.objects.filter()
    query_set.values('user__userprofile__organisation')
    [{'user__userprofile__organisation': u'organisation test 1'}]
    

    cheers

    -i

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

Sidebar

Related Questions

I have a basic Django model like: class Business(models.Model): name = models.CharField(max_length=200, unique=True) email
I want to have a django model like this: class Model(models.Model): string = models.CharField()
I have the following two models: class Position(models.Model): position = models.CharField(max_length=100) class UserProfile(models.Model): user
I have problem with model built like this: class Topping(models.Model): name = models.CharField(max_length=30) class
For example, I have a model like this: Class Doggy(models.Model): name = models.CharField(u'Name', max_length
Hey, I have models like this: class Galleries(models.Model): creation_date = models.DateTimeField() name = models.CharField(max_length=255,
Newbie question. I have Django models that look like this: class Video(models.Model): uploaded_by =
I have the following abstract Django models: class Food(models.Model): name = models.CharField(max_length=100) class Meta:
I have Django model that looks like this: class Categories(models.Model): Model for storing the
I have an extended UserProfile model in django: class UserProfile(models.Model): user = models.ForeignKey(User, unique=True)

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.