~ubuntu-branches/ubuntu/quantal/python-django/quantal

« back to all changes in this revision

Viewing changes to tests/regressiontests/model_forms_regress/models.py

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2009-07-29 11:26:28 UTC
  • mfrom: (1.1.8 upstream) (4.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20090729112628-pg09ino8sz0sj21t
Tags: 1.1-1
* New upstream release.
* Merge from experimental:
  - Ship FastCGI initscript and /etc/default file in python-django's examples
    directory (Closes: #538863)
  - Drop "05_10539-sphinx06-compatibility.diff"; it has been applied
    upstream.
  - Bump Standards-Version to 3.8.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import os
 
2
from django.db import models
 
3
 
 
4
class Person(models.Model):
 
5
    name = models.CharField(max_length=100)
 
6
 
 
7
class Triple(models.Model):
 
8
    left = models.IntegerField()
 
9
    middle = models.IntegerField()
 
10
    right = models.IntegerField()
 
11
 
 
12
    class Meta:
 
13
        unique_together = (('left', 'middle'), (u'middle', u'right'))
 
14
 
 
15
class FilePathModel(models.Model):
 
16
    path = models.FilePathField(path=os.path.dirname(__file__), match=".*\.py$", blank=True)
 
17
 
 
18
class Publication(models.Model):
 
19
    title = models.CharField(max_length=30)
 
20
    date_published = models.DateField()
 
21
 
 
22
    def __unicode__(self):
 
23
        return self.title
 
24
 
 
25
class Article(models.Model):
 
26
    headline = models.CharField(max_length=100)
 
27
    publications = models.ManyToManyField(Publication)
 
28
 
 
29
    def __unicode__(self):
 
30
        return self.headline
 
31
 
 
32
class CustomFileField(models.FileField):
 
33
    def save_form_data(self, instance, data):
 
34
        been_here = getattr(self, 'been_saved', False)
 
35
        assert not been_here, "save_form_data called more than once"
 
36
        setattr(self, 'been_saved', True)
 
37
 
 
38
class CustomFF(models.Model):
 
39
    f = CustomFileField(upload_to='unused', blank=True)