python - Adding a new record in Django Admin gives persistent error -
i'm starting mess around django. created new project , new app. in app created model , activated admin. seemed work fine. wanted add couple new records database using admin. in first 3 tables went fine, in fourth 1 (called 'locations') error saying: 'tuple' object has no attribute 'encode'. full error here on pastebin: http://pastebin.com/wjzat6nn
the strange thing when go general admin page , want click table on got error, error (so without trying add anything).
my question: why happening? maybe there wrong models.py, pasted below message well.
all tips welcome!
from django.db import models # create models here. class countries(models.model): country = models.charfield(max_length=100) def __unicode__(self): return self.country class organisationtypes(models.model): organisationtype = models.charfield(max_length=100) def __unicode__(self): return self.organisationtype class organisations(models.model): organisationname = models.charfield(max_length=200) organisationtype = models.foreignkey(organisationtypes) countryoforigin = models.foreignkey(countries) def __unicode__(self): return self.organisationname class locations(models.model): organisation = models.foreignkey(organisations) countryoflocation = models.foreignkey(countries) telnr = models.charfield(max_length=15) address = models.charfield(max_length=100) def __unicode__(self): return self.organisation, self.countryoflocation, self.telnr, self.address
here:
def __unicode__(self): return self.organisation, self.countryoflocation, self.telnr, self.address
you're returning tuple. expects single string.
change this:
def __unicode__(self): return "%s - %s - %s - %s" % (self.organisation self.countryoflocation, self.telnr, self.address)
Comments
Post a Comment