thanks - I've tried it both ways and with __str__ get the error

__str__ returned non-string (type NoneType).

the top-level error dump is

Request Method:         GET
Request URL:    http://localhost:8000/admin/papers_admin/paper/35/
Exception Type:         TypeError
Exception Value:        __str__ returned non-string (type NoneType)
Exception Location:     C:\Python25\lib\site-packages\django\db\models
\fields\__init__.py in get_choices, line 302

all the models where I apply

__str__ are of the form

class LuPaperContentRegion(models.Model):
    paper_content_region = models.CharField(maxlength=150)

    def __str__(self):
        return self.paper_content_region

    class Meta:
        db_table='lu_paper_content_region'

Now, I am a little confused as to the general set-up for attaching a
list to the FK model as

    Country = models.ForeignKey(LuCountry)

since this would be a link to the LuCountry table by the ID and my
expectation is this might display the ID in the linked table, not a
string so perhaps this may be the source of the problem -- but that is
just a guess.

Thanks for your response - hopefully there is a simple thing I am not
getting.

On Apr 13, 8:35 pm, Michael <[EMAIL PROTECTED]> wrote:
> Try changing __unicode__ to __str__. The unicode merge was after .96 and
> therefore it isn't looking for __unicode__ to define the name of the field.
>
> Hope that helps,
>
> Michael
>
> On Sun, Apr 13, 2008 at 9:28 PM, steve skelton <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > sorry I forgot to specify - am using 0.96.1 (django) and MySQL 5.0.51a
> > (server) and 5.1.11 (client) and my local install is on Vista laptop
> > with Apache and PHP also installed.
>
> > On Apr 13, 8:24 pm, steve skelton <[EMAIL PROTECTED]> wrote:
> > > Trying to get admin on my system to load values based on related
> > > tables on db.  I have set the FK on the papers table to tie with the
> > > PK of each look-up table and set models like so:
>
> > > class LuPaperContentEra(models.Model):
> > >    paper_content_era = models.CharField(blank=True, maxlength=150)
>
> > >    def __unicode__(self):
> > >        return self.paper_content_era
>
> > >    class Meta:
> > >        db_table='lu_paper_content_era'
>
> > > The main table, which should contain drop-downs for things like the
> > > model/table above, has things like:
>
> > > class Paper(models.Model):
> > >    ... many fields defined
> > >    PaperContent_Era = models.ForeignKey(LuPaperContentEra)
> > >    ... more fields defined
>
> > >    class Meta:
> > >        db_table='papers_admin'
>
> > >    class Admin:
> > >        list_display=('id','FirstName','LastName','Institution')
> > >        search_fields=['LastName']
>
> > > However, Admin displays the drop-down as
>
> > > LuPaperContactEra object, NOT the actual human-readable value list.
>
> > > I feel I am probably close to getting this to work but can't seem to
> > > find the right direction in which to be "nudged".
>
> > > Thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to