<daniel.marquez0112@gmail.com> wrote:
> Wow, I should've caught that. Thanks guys. However, since I needed a
> string, what I did was add "default=x" to the integer field as
> follows:
>
> class Phone(models.Model):
> phonenumber = models.IntegerField(default=10)
> pub_date = models.DateTimeField('date published')
> def __unicode__(self):
> return self.phonenumber
>
> and it worked.
>
That is still not returning unicode from the unicode method. When you
return a non unicode object, you should do something like this:
def __unicode__(self):
return unicode(self.phonenumber)
Also, as Shawn said, you should use a CharField for your phone number
field. If you are collecting phone numbers for a specific country,
there are localized form fields for certain countries to ensure users
enter the data in the correct format - nothing worse than 'sdffdhj'
being allowed as a phone number!
Cheers
Tom
--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment