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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:59:14+00:00 2026-05-31T00:59:14+00:00

I am getting an error in Django saying Caught TypeError while rendering: sequence item

  • 0

I am getting an error in Django saying Caught TypeError while rendering: sequence item 1: expected string or Unicode, Property found. Here is my code:

def __unicode__( self ) :
    return "{} : {}".format( self.name, self.location )

I even tried

def __unicode__( self ) :
    return unicode( "{} : {}".format( self.name, self.location ) )

but the same error.

From what I know "this is x = {}".format( x ) returns a string right? Why is Python saying it’s a Property?

Full code:

class Item( models.Model ) :
    def __unicode__( self ) :
        return "{} : {}".format( self.name, self.location )

    name       = models.CharField( max_length = 135 )
    comment    = models.TextField( blank = True )
    item_type  = models.ForeignKey( ItemType )
    location   = models.ForeignKey( Location )
    t_created  = models.DateTimeField( auto_now_add = True, verbose_name = 'created' )
    t_modified = models.DateTimeField( auto_now = True, verbose_name = 'modified' )

class Location( models.Model ) :
    def __unicode__( self ) :
        locations = filter( None, [ self.room, self.floor, self.building ] )
        locations.append( self.prop )

        return ", ".join( locations ) # This will look in the form of like "room, floor, building, property"

    comment    = models.TextField( blank = True )
    room       = models.CharField( max_length = 135, blank = True )
    floor      = models.CharField( max_length = 135, blank = True )
    building   = models.CharField( max_length = 135, blank = True )
    prop       = models.ForeignKey( Property )
    t_created  = models.DateTimeField( auto_now_add = True, verbose_name = 'created' )
    t_modified = models.DateTimeField( auto_now = True, verbose_name = 'modified' )

class Property( models.Model ) :
    def __unicode__( self ) :
        return self.name

    name = models.CharField( max_length = 135 )
  • 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-05-31T00:59:15+00:00Added an answer on May 31, 2026 at 12:59 am

    Property isn’t referring to a Python property, but to your Property class. What’s probably happening is this:

    1. Item.__unicode__ gets called.
    2. It grabs self.name and self.location.
    3. self.name returns a unicode string from its __unicode__ method.
    4. self.location is a foreign key, so Location.__unicode__ gets called.
    5. That gets self.room, self.floor, and self.building, which all have __unicode__ methods that return unicode strings.
    6. filter sees that these strings are all empty, so locations is set to [].
    7. self.prop, which is a Property, gets appended to locations.
    8. ", ".join( locations ) Throws a TypeError because a Property isn’t a string.
    9. the str.format call in Item.__unicode__ catches that exception and throws its own, which is what you see.

    Solution: change

    locations.append( self.prop )
    

    to

    locations.append( unicode(self.prop) )
    

    Moral: str.format calls str() on its arguments, but str.join does not.

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

Sidebar

Related Questions

from django import forms class SignUpForm(forms.Form): birth_day = forms.ChoiceField(choices=range(1,32)) I'm getting Caught TypeError while
While using django.core.paginator import ObjectPaginator, I'm getting this error: NeedIndexError: The built-in indices are
I'm getting this error django.db.utils.IntegrityError: django_content_type.name may not be NULL while running tests via
getting error while try to start service
I wrote following code...but i am getting Error like: Error 1 'LoginDLL.Class1.Login(string, string, string)':
Im getting strangest error in django so far: 'if' statement improperly formatted Template that
I am trying to save images in Django and getting the error The ImageOps
I'm migrating a Django project from SQLite to Oracle, and I'm getting an error
I'm getting an IMPORT ERROR with the following error message in Django debug mode
Just moved from Django 1.00 to 1.30 and I'm suddenly getting an error during

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.