~ubuntu-branches/debian/sid/python-django/sid

« back to all changes in this revision

Viewing changes to tests/basic/models.py

  • Committer: Package Import Robot
  • Author(s): Luke Faraone
  • Date: 2013-11-07 15:33:49 UTC
  • mfrom: (1.3.12)
  • Revision ID: package-import@ubuntu.com-20131107153349-e31sc149l2szs3jb
Tags: 1.6-1
* New upstream version. Closes: #557474, #724637.
* python-django now also suggests the installation of ipython,
  bpython, python-django-doc, and libgdal1.
  Closes: #636511, #686333, #704203
* Set package maintainer to Debian Python Modules Team.
* Bump standards version to 3.9.5, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# coding: utf-8
 
2
"""
 
3
1. Bare-bones model
 
4
 
 
5
This is a basic model with only two non-primary-key fields.
 
6
"""
 
7
from django.db import models
 
8
from django.utils.encoding import python_2_unicode_compatible
 
9
 
 
10
 
 
11
@python_2_unicode_compatible
 
12
class Article(models.Model):
 
13
    headline = models.CharField(max_length=100, default='Default headline')
 
14
    pub_date = models.DateTimeField()
 
15
 
 
16
    class Meta:
 
17
        ordering = ('pub_date','headline')
 
18
 
 
19
    def __str__(self):
 
20
        return self.headline
 
21
 
 
22
class ArticleSelectOnSave(Article):
 
23
    class Meta:
 
24
        proxy = True
 
25
        select_on_save = True
 
26
 
 
27
@python_2_unicode_compatible
 
28
class SelfRef(models.Model):
 
29
    selfref = models.ForeignKey('self', null=True, blank=True,
 
30
                                related_name='+')
 
31
 
 
32
    def __str__(self):
 
33
        return SelfRef.objects.get(selfref=self).pk