diff options
| author | Tom Christie | 2011-01-04 17:42:23 +0000 |
|---|---|---|
| committer | Tom Christie | 2011-01-04 17:42:23 +0000 |
| commit | f144b769fedd421f3ec24dfd3a4f10c681192337 (patch) | |
| tree | a3ebc0fe0cdd38aad6e3a40f04d62b49fbee51d5 /src/testapp/models.py | |
| parent | 48c7171aa05cd69ab8d9cd6f3a8eed52f18792a4 (diff) | |
| download | django-rest-framework-f144b769fedd421f3ec24dfd3a4f10c681192337.tar.bz2 | |
Lots of good form validation and default actions
Diffstat (limited to 'src/testapp/models.py')
| -rw-r--r-- | src/testapp/models.py | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/testapp/models.py b/src/testapp/models.py index 71a83623..75304c9c 100644 --- a/src/testapp/models.py +++ b/src/testapp/models.py @@ -1,3 +1,31 @@ from django.db import models +import uuid -# Create your models here. +def uuid_str(): + return str(uuid.uuid1()) + +class ExampleModel(models.Model): + num = models.IntegerField(default=2, choices=((1,'one'), (2, 'two'))) + hidden_num = models.IntegerField(verbose_name='Something', help_text='HELP') + text = models.TextField(blank=False) + another = models.CharField(max_length=10) + + +class ExampleContainer(models.Model): + """Container. Has a key, a name, and some internal data, and contains a set of items.""" + key = models.CharField(primary_key=True, default=uuid_str, max_length=36, editable=False) + name = models.CharField(max_length=256) + internal = models.IntegerField(default=0) + + @models.permalink + def get_absolute_url(self): + return ('testapp.views.ContainerInstance', [self.key]) + + +class ExampleItem(models.Model): + """Item. Belongs to a container and has an index number and a note. + Items are uniquely identified by their container and index number.""" + container = models.ForeignKey(ExampleContainer, related_name='items') + index = models.IntegerField() + note = models.CharField(max_length=1024) + unique_together = (container, index)
\ No newline at end of file |
