Tuesday, June 18, 2013

Re: Model Error

Hi Legg,
 
In your TextFile class, the name of your  __unicode__ method is wrong. You wrote def __unicde__(self): instead of def __unicode__(self):.
I think that's the issue.
Regards, 
 
Ange Bouablé
06 16 86 92 01
 
 
"Là où la volonté est grande, les difficultés diminuent"
"Le succès c'est d'aller d'échec en échec sans perdre son enthousiasme"


2013/6/19 Nigel Legg <nigel.legg@gmail.com>
I have been working through the tutorial, "Writing your first Django app, part 1", at https://docs.djangoproject.com/en/1.5/intro/tutorial01/. I have the following model code:

from django.db import models
import datetime
from django.utils import timezone

class TextFile(models.Model):
    tfile = models.CharField(max_length = 50)
    filetype = models.CharField(max_length = 50)
    up_date = models.DateTimeField('date_uploaded')

    def __unicde__(self):
        return self.tfile

    def was_uploaded_recently(self):
        return self.up_date>= timezone.now() - datetme.timedelta(days=1)

class Bitext_upd(models.Model):
    tFile = models.ForeignKey(TextFile)
    bitext_file = models.CharField(max_length = 50)
    Bit_up_date = models.DateTimeField('date_analysed')

    def __unicode__(self):
        return self.bitext_file

However in the shell I am still getting:
>>> from apilink.models import TextFile
>>> TextFile.object.all()
[<TextFile: TextFile object>, <TextFile: TextFile object>]

... when there are two files added. 
In the admin interface, I have a list of two "TextFile objects" (see image), if I edit them I can see the details.

I am a bit lost as to where the error is, can anyone help?
Many thanks.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate