Changes between Version 41 and Version 42 of NewbieMistakes


Ignore:
Timestamp:
09/07/11 12:10:58 (4 years ago)
Author:
jordanreiter
Comment:

As I understand it, you're supposed to use __unicode__ not __str__ for models.

Legend:

Unmodified
Added
Removed
Modified
  • NewbieMistakes

    v41 v42  
    5252==== Probable cause ====
    5353
    54 You may have forgotten to create a {{{__str__()}}} function for your model. Django calls {{{__str__()}}} to find out how to display objects in the admin interface. An alternate cause is the string you return from {{{__str__()}}} includes brackets (an therefore looks like an html tag), and is cleaned up by the {{{strip_tags}}} template filter, resulting in blank entries.
    55 
    56 ==== Solution ====
    57 
    58 Add a correct {{{__str__()}}} function (without brackets in the output) to all your models. Make it a habit so it becomes automatic.
     54You may have forgotten to create a {{{__unicode__()}}} function for your model. Django calls {{{__unicode__()}}} to find out how to display objects in the admin interface. An alternate cause is the string you return from {{{__unicode__()}}} includes brackets (an therefore looks like an html tag), and is cleaned up by the {{{strip_tags}}} template filter, resulting in blank entries.
     55
     56==== Solution ====
     57
     58Add a correct {{{__unicode__()}}} function (without brackets in the output) to all your models. Make it a habit so it becomes automatic.
    5959
    6060== Integer & NULLS ==
     
    352352MyRandNum = models.CharField(max_length=4, default=lambda:random.randint(1000,9999))
    353353}}}
    354 
Back to Top