Changeset 5386
- Timestamp:
- 05/30/07 23:25:40 (1 year ago)
- Files:
-
- django/branches/unicode/docs/db-api.txt (modified) (3 diffs)
- django/branches/unicode/docs/forms.txt (modified) (1 diff)
- django/branches/unicode/docs/model-api.txt (modified) (3 diffs)
- django/branches/unicode/docs/newforms.txt (modified) (1 diff)
- django/branches/unicode/docs/overview.txt (modified) (2 diffs)
- django/branches/unicode/docs/tutorial01.txt (modified) (2 diffs)
- django/branches/unicode/tests/modeltests/basic/models.py (modified) (1 diff)
- django/branches/unicode/tests/modeltests/choices/models.py (modified) (1 diff)
- django/branches/unicode/tests/modeltests/custom_columns/models.py (modified) (2 diffs)
- django/branches/unicode/tests/modeltests/custom_managers/models.py (modified) (3 diffs)
- django/branches/unicode/tests/modeltests/custom_methods/models.py (modified) (1 diff)
- django/branches/unicode/tests/modeltests/custom_pk/models.py (modified) (2 diffs)
- django/branches/unicode/tests/modeltests/field_defaults/models.py (modified) (1 diff)
- django/branches/unicode/tests/modeltests/fixtures/models.py (modified) (1 diff)
- django/branches/unicode/tests/modeltests/generic_relations/models.py (modified) (4 diffs)
- django/branches/unicode/tests/modeltests/get_latest/models.py (modified) (2 diffs)
- django/branches/unicode/tests/modeltests/get_object_or_404/models.py (modified) (2 diffs)
- django/branches/unicode/tests/modeltests/get_or_create/models.py (modified) (1 diff)
- django/branches/unicode/tests/modeltests/lookup/models.py (modified) (1 diff)
- django/branches/unicode/tests/modeltests/m2m_and_m2o/models.py (modified) (1 diff)
- django/branches/unicode/tests/modeltests/m2m_intermediary/models.py (modified) (3 diffs)
- django/branches/unicode/tests/modeltests/m2m_multiple/models.py (modified) (2 diffs)
- django/branches/unicode/tests/modeltests/m2m_recursive/models.py (modified) (1 diff)
- django/branches/unicode/tests/modeltests/m2o_recursive2/models.py (modified) (1 diff)
- django/branches/unicode/tests/modeltests/m2o_recursive/models.py (modified) (1 diff)
- django/branches/unicode/tests/modeltests/manipulators/models.py (modified) (2 diffs)
- django/branches/unicode/tests/modeltests/many_to_many/models.py (modified) (2 diffs)
- django/branches/unicode/tests/modeltests/many_to_one/models.py (modified) (2 diffs)
- django/branches/unicode/tests/modeltests/many_to_one_null/models.py (modified) (2 diffs)
- django/branches/unicode/tests/modeltests/model_forms/models.py (modified) (4 diffs)
- django/branches/unicode/tests/modeltests/model_inheritance/models.py (modified) (2 diffs)
- django/branches/unicode/tests/modeltests/one_to_one/models.py (modified) (3 diffs)
- django/branches/unicode/tests/modeltests/ordering/models.py (modified) (1 diff)
- django/branches/unicode/tests/modeltests/or_lookups/models.py (modified) (1 diff)
- django/branches/unicode/tests/modeltests/pagination/models.py (modified) (1 diff)
- django/branches/unicode/tests/modeltests/reserved_names/models.py (modified) (1 diff)
- django/branches/unicode/tests/modeltests/reverse_lookup/models.py (modified) (3 diffs)
- django/branches/unicode/tests/modeltests/save_delete_hooks/models.py (modified) (1 diff)
- django/branches/unicode/tests/modeltests/select_related/models.py (modified) (8 diffs)
- django/branches/unicode/tests/modeltests/serializers/models.py (modified) (4 diffs)
- django/branches/unicode/tests/modeltests/str/models.py (modified) (2 diffs)
- django/branches/unicode/tests/modeltests/transactions/models.py (modified) (1 diff)
- django/branches/unicode/tests/modeltests/validation/models.py (modified) (1 diff)
- django/branches/unicode/tests/regressiontests/fixtures_regress/models.py (modified) (1 diff)
- django/branches/unicode/tests/regressiontests/null_queries/models.py (modified) (2 diffs)
- django/branches/unicode/tests/regressiontests/one_to_one_regress/models.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/unicode/docs/db-api.txt
r5381 r5386 16 16 tagline = models.TextField() 17 17 18 def __ str__(self):18 def __unicode__(self): 19 19 return self.name 20 20 … … 23 23 email = models.URLField() 24 24 25 def __ str__(self):25 def __unicode__(self): 26 26 return self.name 27 27 … … 33 33 authors = models.ManyToManyField(Author) 34 34 35 def __ str__(self):35 def __unicode__(self): 36 36 return self.headline 37 37 django/branches/unicode/docs/forms.txt
r5310 r5386 48 48 pass 49 49 50 def __ str__(self):50 def __unicode__(self): 51 51 return self.name 52 52 django/branches/unicode/docs/model-api.txt
r5381 r5386 1340 1340 1341 1341 1342 * The ``__str__()`` method is just as valid in ``list_display`` as any 1343 other model method, so it's perfectly OK to do this:: 1344 1345 list_display = ('__str__', 'some_other_field') 1342 * The ``__str__()`` and ``__unicode__()`` methods are just as valid in 1343 ``list_display`` as any other model method, so it's perfectly OK to do 1344 this:: 1345 1346 list_display = ('__unicode__', 'some_other_field') 1346 1347 1347 1348 * Usually, elements of ``list_display`` that aren't actual database fields … … 1749 1750 1750 1751 ``__str__()`` is a Python "magic method" that defines what should be returned 1751 if you call ``str()`` on the object. Django uses ``str(obj)`` in a number of 1752 places, most notably as the value displayed to render an object in the Django 1753 admin site and as the value inserted into a template when it displays an 1754 object. Thus, you should always return a nice, human-readable string for the 1755 object's ``__str__``. Although this isn't required, it's strongly encouraged. 1752 if you call ``str()`` on the object. Django uses ``str(obj)`` (or the related 1753 function, ``unicode(obj)`` -- see below) in a number of places, most notably 1754 as the value displayed to render an object in the Django admin site and as the 1755 value inserted into a template when it displays an object. Thus, you should 1756 always return a nice, human-readable string for the object's ``__str__``. 1757 Although this isn't required, it's strongly encouraged (see the description of 1758 ``__unicode__``, below, before putting ``_str__`` methods everywhere). 1756 1759 1757 1760 For example:: … … 1762 1765 1763 1766 def __str__(self): 1764 return '%s %s' % (self.first_name, self.last_name) 1767 # Note use of django.utils.encoding.smart_str() here because 1768 # first_name and last_name will be unicode strings. 1769 return smart_str('%s %s' % (self.first_name, self.last_name)) 1770 1771 ``__unicode__`` 1772 --------------- 1773 1774 The ``__unicode__()`` method is called whenever you call ``unicode()`` on an 1775 object. Since Django's database backends will return Unicode strings in your 1776 model's attributes, you would normally want to write a ``__unicode__()`` 1777 method for your model. The example in the previous section could be written 1778 more simply as:: 1779 1780 class Person(models.Model): 1781 first_name = models.CharField(maxlength=50) 1782 last_name = models.CharField(maxlength=50) 1783 1784 def __unicode__(self): 1785 return u'%s %s' % (self.first_name, self.last_name) 1786 1787 If you define a ``__unicode__()`` method on your model and not a ``__str__()`` 1788 method, Django will automatically provide you with a ``__str__()`` that calls 1789 ``__unicode()__`` and then converts the result correctly to a UTF-8 encoded 1790 string object. This is recommended development practice: define only 1791 ``__unicode__()`` and let Django take care of the conversion to string objects 1792 when required. 1765 1793 1766 1794 ``get_absolute_url`` django/branches/unicode/docs/newforms.txt
r5381 r5386 1334 1334 birth_date = models.DateField(blank=True, null=True) 1335 1335 1336 def __ str__(self):1336 def __unicode__(self): 1337 1337 return self.name 1338 1338 django/branches/unicode/docs/overview.txt
r5054 r5386 28 28 full_name = models.CharField(maxlength=70) 29 29 30 def __ str__(self):30 def __unicode__(self): 31 31 return self.full_name 32 32 … … 37 37 reporter = models.ForeignKey(Reporter) 38 38 39 def __ str__(self):39 def __unicode__(self): 40 40 return self.headline 41 41 django/branches/unicode/docs/tutorial01.txt
r5081 r5386 475 475 Wait a minute. ``<Poll: Poll object>`` is, utterly, an unhelpful 476 476 representation of this object. Let's fix that by editing the polls model (in 477 the ``polls/models.py`` file) and adding a ``__ str__()`` method to both477 the ``polls/models.py`` file) and adding a ``__unicode__()`` method to both 478 478 ``Poll`` and ``Choice``:: 479 479 480 480 class Poll(models.Model): 481 481 # ... 482 def __ str__(self):482 def __unicode__(self): 483 483 return self.question 484 484 485 485 class Choice(models.Model): 486 486 # ... 487 def __ str__(self):487 def __unicode__(self): 488 488 return self.choice 489 489 490 It's important to add ``__str__()`` methods to your models, not only for your 491 own sanity when dealing with the interactive prompt, but also because objects' 492 representations are used throughout Django's automatically-generated admin. 490 It's important to add ``__unicode__()`` methods to your models, not only for 491 your own sanity when dealing with the interactive prompt, but also because 492 objects' representations are used throughout Django's automatically-generated 493 admin. 494 495 .. admonition:: Why ``__unicode__`` and not ``__str__``? 496 497 If you are wondering why we add a ``__unicode__()`` method, rather than a 498 simple ``__str__()`` method, it is because Django models will contain 499 unicode strings by default. The values returned from the database, for 500 example, are all unicode strings. In most cases, your code should be 501 prepared to handle non-ASCII characters and this is a litle fiddly in 502 ``__str__()`` methods, since you have to worry about which encoding to 503 use, amongst other things. If you create a ``__unicode__()`` method, 504 Django will provide a ``__str__()`` method that calls your 505 ``__unicode__()`` and then converts the result to UTF-8 strings when 506 required. So ``unicode(p)`` will return a unicode string and ``str(p)`` 507 will return a normal string, with the characters encoded as UTF-8 when 508 necessary.. 493 509 494 510 Note these are normal Python methods. Let's add a custom method, just for … … 510 526 >>> from mysite.polls.models import Poll, Choice 511 527 512 # Make sure our __ str__() addition worked.528 # Make sure our __unicode__() addition worked. 513 529 >>> Poll.objects.all() 514 530 [<Poll: What's up?>] django/branches/unicode/tests/modeltests/basic/models.py
r5372 r5386 15 15 ordering = ('pub_date','headline') 16 16 17 def __ str__(self):17 def __unicode__(self): 18 18 return self.headline 19 19 django/branches/unicode/tests/modeltests/choices/models.py
r5320 r5386 21 21 gender = models.CharField(maxlength=1, choices=GENDER_CHOICES) 22 22 23 def __ str__(self):23 def __unicode__(self): 24 24 return self.name 25 25 django/branches/unicode/tests/modeltests/custom_columns/models.py
r5185 r5386 22 22 last_name = models.CharField(maxlength=30, db_column='last') 23 23 24 def __ str__(self):25 return '%s %s' % (self.first_name, self.last_name)24 def __unicode__(self): 25 return u'%s %s' % (self.first_name, self.last_name) 26 26 27 27 class Meta: … … 33 33 authors = models.ManyToManyField(Author, db_table='my_m2m_table') 34 34 35 def __ str__(self):35 def __unicode__(self): 36 36 return self.headline 37 37 django/branches/unicode/tests/modeltests/custom_managers/models.py
r3661 r5386 24 24 objects = PersonManager() 25 25 26 def __ str__(self):27 return "%s %s" % (self.first_name, self.last_name)26 def __unicode__(self): 27 return u"%s %s" % (self.first_name, self.last_name) 28 28 29 29 # An example of a custom manager that sets get_query_set(). … … 40 40 authors = models.ManyToManyField(Person, related_name='books') 41 41 42 def __ str__(self):42 def __unicode__(self): 43 43 return self.title 44 44 … … 56 56 fast_cars = FastCarManager() 57 57 58 def __ str__(self):58 def __unicode__(self): 59 59 return self.name 60 60 django/branches/unicode/tests/modeltests/custom_methods/models.py
r3661 r5386 12 12 pub_date = models.DateField() 13 13 14 def __ str__(self):14 def __unicode__(self): 15 15 return self.headline 16 16 django/branches/unicode/tests/modeltests/custom_pk/models.py
r4971 r5386 16 16 ordering = ('last_name', 'first_name') 17 17 18 def __ str__(self):19 return "%s %s" % (self.first_name, self.last_name)18 def __unicode__(self): 19 return u"%s %s" % (self.first_name, self.last_name) 20 20 21 21 class Business(models.Model): … … 25 25 verbose_name_plural = 'businesses' 26 26 27 def __ str__(self):27 def __unicode__(self): 28 28 return self.name 29 29 django/branches/unicode/tests/modeltests/field_defaults/models.py
r4796 r5386 17 17 pub_date = models.DateTimeField(default=datetime.now) 18 18 19 def __ str__(self):19 def __unicode__(self): 20 20 return self.headline 21 21 django/branches/unicode/tests/modeltests/fixtures/models.py
r4971 r5386 15 15 pub_date = models.DateTimeField() 16 16 17 def __ str__(self):17 def __unicode__(self): 18 18 return self.headline 19 19 django/branches/unicode/tests/modeltests/generic_relations/models.py
r5185 r5386 25 25 ordering = ["tag"] 26 26 27 def __ str__(self):27 def __unicode__(self): 28 28 return self.tag 29 29 … … 34 34 tags = generic.GenericRelation(TaggedItem) 35 35 36 def __ str__(self):36 def __unicode__(self): 37 37 return self.common_name 38 38 … … 43 43 tags = generic.GenericRelation(TaggedItem) 44 44 45 def __ str__(self):45 def __unicode__(self): 46 46 return self.name 47 47 … … 52 52 # note the lack of an explicit GenericRelation here... 53 53 54 def __ str__(self):54 def __unicode__(self): 55 55 return self.name 56 56 django/branches/unicode/tests/modeltests/get_latest/models.py
r3683 r5386 18 18 get_latest_by = 'pub_date' 19 19 20 def __ str__(self):20 def __unicode__(self): 21 21 return self.headline 22 22 … … 27 27 # Note that this model doesn't have "get_latest_by" set. 28 28 29 def __ str__(self):29 def __unicode__(self): 30 30 return self.name 31 31 django/branches/unicode/tests/modeltests/get_object_or_404/models.py
r4796 r5386 18 18 name = models.CharField(maxlength=50) 19 19 20 def __ str__(self):20 def __unicode__(self): 21 21 return self.name 22 22 … … 31 31 by_a_sir = ArticleManager() 32 32 33 def __ str__(self):33 def __unicode__(self): 34 34 return self.title 35 35 django/branches/unicode/tests/modeltests/get_or_create/models.py
r4796 r5386 13 13 birthday = models.DateField() 14 14 15 def __ str__(self):16 return '%s %s' % (self.first_name, self.last_name)15 def __unicode__(self): 16 return u'%s %s' % (self.first_name, self.last_name) 17 17 18 18 __test__ = {'API_TESTS':""" django/branches/unicode/tests/modeltests/lookup/models.py
r5185 r5386 13 13 ordering = ('-pub_date', 'headline') 14 14 15 def __ str__(self):15 def __unicode__(self): 16 16 return self.headline 17 17 django/branches/unicode/tests/modeltests/m2m_and_m2o/models.py
r4796 r5386 15 15 client = models.ForeignKey(User, related_name='test_issue_client') 16 16 17 def __ str__(self):18 return str(self.num)17 def __unicode__(self): 18 return unicode(self.num) 19 19 20 20 class Meta: django/branches/unicode/tests/modeltests/m2m_intermediary/models.py
r3661 r5386 17 17 last_name = models.CharField(maxlength=30) 18 18 19 def __ str__(self):20 return "%s %s" % (self.first_name, self.last_name)19 def __unicode__(self): 20 return u"%s %s" % (self.first_name, self.last_name) 21 21 22 22 class Article(models.Model): … … 24 24 pub_date = models.DateField() 25 25 26 def __ str__(self):26 def __unicode__(self): 27 27 return self.headline 28 28 … … 32 32 position = models.CharField(maxlength=100) 33 33 34 def __ str__(self):35 return '%s (%s)' % (self.reporter, self.position)34 def __unicode__(self): 35 return u'%s (%s)' % (self.reporter, self.position) 36 36 37 37 __test__ = {'API_TESTS':""" django/branches/unicode/tests/modeltests/m2m_multiple/models.py
r3661 r5386 15 15 ordering = ('name',) 16 16 17 def __ str__(self):17 def __unicode__(self): 18 18 return self.name 19 19 … … 26 26 ordering = ('pub_date',) 27 27 28 def __ str__(self):28 def __unicode__(self): 29 29 return self.headline 30 30 django/branches/unicode/tests/modeltests/m2m_recursive/models.py
r4796 r5386 20 20 idols = models.ManyToManyField('self', symmetrical=False, related_name='stalkers') 21 21 22 def __ str__(self):22 def __unicode__(self): 23 23 return self.name 24 24 django/branches/unicode/tests/modeltests/m2o_recursive2/models.py
r3661 r5386 15 15 father = models.ForeignKey('self', null=True, related_name='fathers_child_set') 16 16 17 def __ str__(self):17 def __unicode__(self): 18 18 return self.full_name 19 19 django/branches/unicode/tests/modeltests/m2o_recursive/models.py
r3661 r5386 17 17 parent = models.ForeignKey('self', null=True, related_name='child_set') 18 18 19 def __ str__(self):19 def __unicode__(self): 20 20 return self.name 21 21 django/branches/unicode/tests/modeltests/manipulators/models.py
r5082 r5386 11 11 last_name = models.CharField(maxlength=30) 12 12 13 def __ str__(self):14 return "%s %s" % (self.first_name, self.last_name)13 def __unicode__(self): 14 return u"%s %s" % (self.first_name, self.last_name) 15 15 16 16 class Album(models.Model): … … 19 19 release_date = models.DateField(blank=True, null=True) 20 20 21 def __ str__(self):21 def __unicode__(self): 22 22 return self.name 23 23 django/branches/unicode/tests/modeltests/many_to_many/models.py
r4448 r5386 13 13 title = models.CharField(maxlength=30) 14 14 15 def __ str__(self):15 def __unicode__(self): 16 16 return self.title 17 17 … … 23 23 publications = models.ManyToManyField(Publication) 24 24 25 def __ str__(self):25 def __unicode__(self): 26 26 return self.headline 27 27 django/branches/unicode/tests/modeltests/many_to_one/models.py
r5243 r5386 12 12 email = models.EmailField() 13 13 14 def __ str__(self):15 return "%s %s" % (self.first_name, self.last_name)14 def __unicode__(self): 15 return u"%s %s" % (self.first_name, self.last_name) 16 16 17 17 class Article(models.Model): … … 20 20 reporter = models.ForeignKey(Reporter) 21 21 22 def __ str__(self):22 def __unicode__(self): 23 23 return self.headline 24 24 django/branches/unicode/tests/modeltests/many_to_one_null/models.py
r3661 r5386 11 11 name = models.CharField(maxlength=30) 12 12 13 def __ str__(self):13 def __unicode__(self): 14 14 return self.name 15 15 … … 21 21 ordering = ('headline',) 22 22 23 def __ str__(self):23 def __unicode__(self): 24 24 return self.headline 25 25 django/branches/unicode/tests/modeltests/model_forms/models.py
r5241 r5386 35 35 url = models.CharField('The URL', maxlength=40) 36 36 37 def __ str__(self):37 def __unicode__(self): 38 38 return self.name 39 39 … … 41 41 name = models.CharField(maxlength=50, help_text='Use both first and last names.') 42 42 43 def __ str__(self):43 def __unicode__(self): 44 44 return self.name 45 45 … … 59 59 return super(Article, self).save() 60 60 61 def __ str__(self):61 def __unicode__(self): 62 62 return self.headline 63 63 … … 66 66 description = models.CharField(maxlength=20) 67 67 68 def __ str__(self):68 def __unicode__(self): 69 69 return self.phone 70 70 django/branches/unicode/tests/modeltests/model_inheritance/models.py
r3661 r5386 11 11 address = models.CharField(maxlength=80) 12 12 13 def __ str__(self):14 return "%s the place" % self.name13 def __unicode__(self): 14 return u"%s the place" % self.name 15 15 16 16 class Restaurant(Place): … … 18 18 serves_pizza = models.BooleanField() 19 19 20 def __ str__(self):21 return "%s the restaurant" % self.name20 def __unicode__(self): 21 return u"%s the restaurant" % self.name 22 22 23 23 class ItalianRestaurant(Restaurant): 24 24 serves_gnocchi = models.BooleanField() 25 25 26 def __ str__(self):27 return "%s the italian restaurant" % self.name26 def __unicode__(self): 27 return u"%s the italian restaurant" % self.name 28 28 29 29 __test__ = {'API_TESTS':""" django/branches/unicode/tests/modeltests/one_to_one/models.py
r3846 r5386 13 13 address = models.CharField(maxlength=80) 14 14 15 def __ str__(self):16 return "%s the place" % self.name15 def __unicode__(self): 16 return u"%s the place" % self.name 17 17 18 18 class Restaurant(models.Model): … … 21 21 serves_pizza = models.BooleanField() 22 22 23 def __ str__(self):24 return "%s the restaurant" % self.place.name23 def __unicode__(self): 24 return u"%s the restaurant" % self.place.name 25 25 26 26 class Waiter(models.Model): … … 28 28 name = models.CharField(maxlength=50) 29 29 30 def __ str__(self):31 return "%s the waiter at %s" % (self.name, self.restaurant)30 def __unicode__(self): 31 return u"%s the waiter at %s" % (self.name, self.restaurant) 32 32 33 33 class ManualPrimaryKey(models.Model): django/branches/unicode/tests/modeltests/ordering/models.py
r3661 r5386 22 22 ordering = ('-pub_date', 'headline') 23 23 24 def __ str__(self):24 def __unicode__(self): 25 25 return self.headline 26 26 django/branches/unicode/tests/modeltests/or_lookups/models.py
r4971 r5386 21 21 ordering = ('pub_date',) 22 22 23 def __ str__(self):23 def __unicode__(self): 24 24 return self.headline 25 25 django/branches/unicode/tests/modeltests/pagination/models.py
r4796 r5386 13 13 pub_date = models.DateTimeField() 14 14 15 def __ str__(self):15 def __unicode__(self): 16 16 return self.headline 17 17 django/branches/unicode/tests/modeltests/reserved_names/models.py
r3661 r5386 22 22 db_table = 'select' 23 23 24 def __ str__(self):24 def __unicode__(self): 25 25 return self.when 26 26 django/branches/unicode/tests/modeltests/reverse_lookup/models.py
r5185 r5386 10 10 name = models.CharField(maxlength=200) 11 11 12 def __ str__(self):12 def __unicode__(self): 13 13 return self.name 14 14 … … 17 17 creator = models.ForeignKey(User) 18 18 19 def __ str__(self):19 def __unicode__(self): 20 20 return self.question 21 21 … … 25 25 related_poll = models.ForeignKey(Poll, related_name="related_choice") 26 26 27 def __ str(self):27 def __unicode__(self): 28 28 return self.name 29 29 django/branches/unicode/tests/modeltests/save_delete_hooks/models.py
r3661 r5386 12 12 last_name = models.CharField(maxlength=20) 13 13 14 def __ str__(self):15 return "%s %s" % (self.first_name, self.last_name)14 def __unicode__(self): 15 return u"%s %s" % (self.first_name, self.last_name) 16 16 17 17 def save(self): django/branches/unicode/tests/modeltests/select_related/models.py
r4797 r5386 14 14 class Domain(models.Model): 15 15 name = models.CharField(maxlength=50) 16 def __ str__(self):16 def __unicode__(self): 17 17 return self.name 18 18 … … 20 20 name = models.CharField(maxlength=50) 21 21 domain = models.ForeignKey(Domain) 22 def __ str__(self):22 def __unicode__(self): 23 23 return self.name 24 24 … … 26 26 name = models.CharField(maxlength=50) 27 27 kingdom = models.ForeignKey(Kingdom) 28 def __ str__(self):28 def __unicode__(self): 29 29 return self.name 30 30 … … 32 32 name = models.CharField(maxlength=50) 33 33 phylum = models.ForeignKey(Phylum) 34 def __ str__(self):34 def __unicode__(self): 35 35 return self.name 36 36 … … 38 38 name = models.CharField(maxlength=50) 39 39 klass = models.ForeignKey(Klass) 40 def __ str__(self):40 def __unicode__(self): 41 41 return self.name 42 42 … … 44 44 name = models.CharField(maxlength=50) 45 45 or
