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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:15:58+00:00 2026-05-25T23:15:58+00:00

Trying to create a Django app based off the tutorial but using a different

  • 0

Trying to create a Django app based off the tutorial but using a different model.(First time using Djanago)

I’m at the part where you alter the Admin panel to add 3 items with a dependent foreign key.

I know the problem originates from the

class EventAdmin(admin.ModelAdmin):

on line 10 of admin.py but I’m not sure how the fields should be arranged to make it work.

The admin panel works untill I try to create an event with 3 choices. Then I get the following error… coercing to Unicode: need string or buffer, Location found

Code is as follows…

models.py

from django.db import models

class Location(models.Model):
    icon = models.CharField(max_length=200)
    location = models.CharField(max_length=200)

    def __unicode__(self):
        return self.location

class Event(models.Model):
    location = models.ForeignKey(Location)
    info = models.CharField(max_length=200)

    def __unicode__(self):
        return self.location

class Choice(models.Model):
    event = models.ForeignKey(Event)
    choice = models.CharField(max_length=200)
    link = models.CharField(max_length=200)

    def __unicode__(self):
        return self.choice

admin.py

from map.models import Location
from map.models import Event
from map.models import Choice
from django.contrib import admin

class ChoiceInline(admin.StackedInline):
    model = Choice
    extra = 4

class EventAdmin(admin.ModelAdmin):
    fieldsets = [
             (None,               {'fields': ['location', 'info']}),
             ]
    inlines = [ChoiceInline]

admin.site.register(Event, EventAdmin)
admin.site.register(Location)
  • 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-25T23:15:58+00:00Added an answer on May 25, 2026 at 11:15 pm

    The .__unicode__() method is expected to return a unicode object.

    Your Event.__unicode__() however returns self.location which is a Location instance. Either have it cast self.location to unicode or explicitly reference a field in the Location object.

    def __unicode__(self):
        return u'%s' % (self.location, )
    
    def __unicode__(self):
        return self.location.location
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create an event using Facebooks api. (From a django app)
I'm working on my first Django app and trying to create the models for
I'm trying to create an app using Django on webfaction. I basically was messing
I'm trying to create site using Django framework. I looked on tutorial on Django
Am trying to create a registration form by extending django-registration app and using Django
I'm trying to create a Django model that handles the following: An Item can
Trying to create my first iPhone app that would play back audio. When I
Trying to create several layers of folders at once C:\pie\applepie\recipies\ without using several different
I'm trying create a box in my Django app that displays text (and possibly
i am trying to create a signup form for my django app. for 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.