Sunday, April 3, 2011

Re: unicode and database oddity

Yeesh.
Good call.

Talk about embarrassed. I totally missed that.
Thanks for the editing eye!


On Apr 3, 11:46 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Sun, Apr 3, 2011 at 11:33 PM, xiao_haozi <matthew.ma...@gmail.com> wrote:
> > from shortener.models import url
> > url = u'http://t04u.be/'
>
> In the 1st line you are importing a model (?) named url.
>
> In the 2nd you are discarding that url you just imported and rebinding the
> name url to a unicode string. You no longer have any reference to what you
> imported from shortener.models.
>
> Any attempt to use the name url as though it were the thing you imported is
> now going to give odd results (like the TypeError you reported).
>
> Don't name your variables the same as your models/classes. If you followed
> the CapWords convention for Python class names (and lowercase convention for
> variables) this would be less likely to happen.
>
> Karen
> --http://tracey.org/kmt/

--
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