On Wednesday, December 4, 2013 5:27:39 AM UTC-8, Tom Evans wrote: > > On Wed, Dec 4, 2013 at 7:20 AM, Hussain Nagri > <nagr...@gmail.com<javascript:>> > wrote: > > Hello, > > I am new to Django and trying to learn myself. > > My question is that when we create models in model.py then after each > class > > we define a '__unicode__'. Is it necessary that we define this method ? > It > > gets called every time I try to fetch any data from that model. what if > I > > don’t want it to run every time I try to fetch data ? > > As Tom says, your model instances have to be represented on-screen *somehow*, so Python is going to run *something* to calculate what that representation should be. You should define it so you get the representation you want rather than going with the defaults - you're not going to save measurably on performance by skipping the _unicode_ definition.
./s -- 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+unsubscr...@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. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/abc53592-8444-4762-a223-e522b623e1eb%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.