Project

General

Profile

Statistics
| Branch: | Revision:

root / env / lib / python2.7 / site-packages / south / tests / brokenapp / models.py @ d1a4905f

History | View | Annotate | Download (1.59 KB)

1
# -*- coding: UTF-8 -*-
2

    
3
from django.db import models
4
from django.contrib.auth.models import User as UserAlias
5

    
6
def default_func():
7
    return "yays"
8

    
9
# An empty case.
10
class Other1(models.Model): pass
11

    
12
# Nastiness.
13
class HorribleModel(models.Model):
14
    "A model to test the edge cases of model parsing"
15
    
16
    ZERO, ONE = range(2)
17
    
18
    # First, some nice fields
19
    name = models.CharField(max_length=255)
20
    short_name = models.CharField(max_length=50)
21
    slug = models.SlugField(unique=True)
22
    
23
    # A ForeignKey, to a model above, and then below
24
    o1 = models.ForeignKey(Other1)
25
    o2 = models.ForeignKey('Other2')
26
    
27
    # Now to something outside
28
    user = models.ForeignKey(UserAlias, related_name="horribles")
29
    
30
    # Unicode!
31
    code = models.CharField(max_length=25, default="↑↑↓↓←→←→BA")
32
    
33
    # Odd defaults!
34
    class_attr = models.IntegerField(default=ZERO)
35
    func = models.CharField(max_length=25, default=default_func)
36
    
37
    # Time to get nasty. Define a non-field choices, and use it
38
    choices = [('hello', '1'), ('world', '2')]
39
    choiced = models.CharField(max_length=20, choices=choices)
40
    
41
    class Meta:
42
        db_table = "my_fave"
43
        verbose_name = "Dr. Strangelove," + \
44
                     """or how I learned to stop worrying
45
and love the bomb"""
46
    
47
    # Now spread over multiple lines
48
    multiline = \
49
              models.TextField(
50
        )
51
    
52
# Special case.
53
class Other2(models.Model):
54
    # Try loading a field without a newline after it (inspect hates this)
55
    close_but_no_cigar = models.PositiveIntegerField(primary_key=True)