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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:28:36+00:00 2026-06-13T17:28:36+00:00

Im getting the error ‘CampSite’ object has no attribute ‘__getitem__’ when I save a

  • 0

Im getting the error

'CampSite' object has no attribute '__getitem__'

when I save a new CampCon entry in the admin interface. I have one application called campsites that handles the database of campsites, and I have another application called content that handles reviews. I am very new to Django and this is my first non-tutorial based project. I have been racking my brain and searching the web for an answer with no luck. Thank you in advance for your help.
Here is my campsite model:

from django.contrib.gis.db import models

class CampSite(models.Model):
    name = models.CharField(max_length=250)
    showers = models.BooleanField()
    flush = models.BooleanField()
    rv = models.BooleanField()
    lonlat = models.PointField(null=True, blank=True)

    objects = models.GeoManager()

    def __unicode__(self):
        return self.name

Here is the content model:

from django.contrib.gis.db import models
from campsites.models import CampSite
from django.contrib.auth.models import User
from activities.models import Activities


class CampCon(models.Model):
    campsite = models.ForeignKey(CampSite)
    trip = models.ForeignKey('Trip')
    Date = models.DateField()
    user = models.ForeignKey(User)
    overall_review = models.TextField()
    facilities_review = models.IntegerField()
    things_to_do = models.IntegerField()
    privacy = models.IntegerField()
    beauty = models.IntegerField()
    overall_rating = models.IntegerField()

    def __unicode__(self):
        return self.campsite

class ImageDB(models.Model):
    campsite = models.ForeignKey(CampSite)
    user = models.ForeignKey(User)
    description = models.CharField(max_length=200)
    image = models.ImageField(upload_to='/home/bobby/Pictures/CampThat')
    date_uploaded = models.DateField()
    date_taken = models.DateField()
    trip = models.ForeignKey('Trip')
    activity = models.ForeignKey(Activities)

    def __unicode__(self):
        return self.campsite

class Trip(models.Model):
    date = models.DateField()
    description = models.CharField(max_length=100)
    title = models.CharField(max_length=100)
    blog = models.TextField()

    def __unicode__(self):
        return self.title

class ActivityCon(models.Model):
    trip = models.ForeignKey(Trip)
    rating = models.IntegerField()
    overall_review = models.TextField()
    activity = models.ForeignKey(Activities)

And here is the full Traceback:

    Environment:


Request Method: POST
Request URL: http://localhost:8000/admin/content/campcon/add/

Django Version: 1.5
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'campsites',
 'auth',
 'trips',
 'content',
 'activities',
 'django.contrib.admin')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  116.                         response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper
  367.                 return self.admin_site.admin_view(view)(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  91.                     response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  89.         response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner
  202.             return view(request, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
  25.             return bound_func(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  91.                     response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
  21.                 return func(self, *args2, **kwargs2)
File "/usr/lib/python2.7/site-packages/django/db/transaction.py" in inner
  208.                 return func(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/django/contrib/admin/options.py" in add_view
  958.                 self.log_addition(request, new_object)
File "/usr/lib/python2.7/site-packages/django/contrib/admin/options.py" in log_addition
  525.             action_flag     = ADDITION
File "/usr/lib/python2.7/site-packages/django/contrib/admin/models.py" in log_action
  18.         e = self.model(None, None, user_id, content_type_id, smart_text(object_id), object_repr[:200], action_flag, change_message)

Exception Type: TypeError at /admin/content/campcon/add/
Exception Value: 'CampSite' object has no attribute '__getitem__'
  • 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-13T17:28:37+00:00Added an answer on June 13, 2026 at 5:28 pm

    Your issue is that your __unicode__ functions are returning model objects when they need to be returning unicode strings.

    You can achieve this by adding the unicode() function to your __unicode__ methods:

    class CampCon(models.Model):
        campsite = models.ForeignKey(CampSite)
        trip = models.ForeignKey('Trip')
        Date = models.DateField()
        user = models.ForeignKey(User)
        overall_review = models.TextField()
        facilities_review = models.IntegerField()
        things_to_do = models.IntegerField()
        privacy = models.IntegerField()
        beauty = models.IntegerField()
        overall_rating = models.IntegerField()
    
        def __unicode__(self):
            return unicode(self.campsite)
    
    class ImageDB(models.Model):
        campsite = models.ForeignKey(CampSite)
        user = models.ForeignKey(User)
        description = models.CharField(max_length=200)
        image = models.ImageField(upload_to='/home/bobby/Pictures/CampThat')
        date_uploaded = models.DateField()
        date_taken = models.DateField()
        trip = models.ForeignKey('Trip')
        activity = models.ForeignKey(Activities)
    
        def __unicode__(self):
            return unicode(self.campsite)
    

    This will call CampSite.__unicode__ which will return campsite.name.

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

Sidebar

Related Questions

I am getting error unfortunately, myapp has stopped when I am trying to open
I am getting error for the code below - I suspect it has to
I am getting error on checkout page: Your card has been declined. Please re-enter
I am getting error ExecuteReader: Connection property has not been initialized. below is the
Getting error at line [theSelectedRoutine addExerciseObject: exercise]; saying method -addExerciseObject not found. Interface: @property
I am getting error : WinRT information: Cannot resolve TargetProperty Canvas.Left on specified object.
The error I'm getting: error C2664: 'v8::FunctionTemplate::New' : cannot convert parameter 1 from 'v8::Handle<T>
I am getting error while i call start on SignalR connection object. I am
I am getting error , There has been an error processing your request when
I'm getting malloc: * error for object 0xbfffe160: pointer being freed was not allocated

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.