mirror of
				https://github.com/django/django.git
				synced 2025-11-04 05:35:37 +00:00 
			
		
		
		
	git-svn-id: http://code.djangoproject.com/svn/django/trunk@15650 bcc190cf-cafb-0310-a4f2-bffc1f526a37
		
			
				
	
	
		
			55 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			55 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
"""
 | 
						|
Tests of ModelAdmin validation logic.
 | 
						|
"""
 | 
						|
 | 
						|
from django.db import models
 | 
						|
 | 
						|
 | 
						|
class Album(models.Model):
 | 
						|
    title = models.CharField(max_length=150)
 | 
						|
 | 
						|
 | 
						|
class Song(models.Model):
 | 
						|
    title = models.CharField(max_length=150)
 | 
						|
    album = models.ForeignKey(Album)
 | 
						|
    original_release = models.DateField(editable=False)
 | 
						|
 | 
						|
    class Meta:
 | 
						|
        ordering = ('title',)
 | 
						|
 | 
						|
    def __unicode__(self):
 | 
						|
        return self.title
 | 
						|
 | 
						|
    def readonly_method_on_model(self):
 | 
						|
        # does nothing
 | 
						|
        pass
 | 
						|
 | 
						|
 | 
						|
class TwoAlbumFKAndAnE(models.Model):
 | 
						|
    album1 = models.ForeignKey(Album, related_name="album1_set")
 | 
						|
    album2 = models.ForeignKey(Album, related_name="album2_set")
 | 
						|
    e = models.CharField(max_length=1)
 | 
						|
 | 
						|
 | 
						|
class Author(models.Model):
 | 
						|
    name = models.CharField(max_length=100)
 | 
						|
 | 
						|
 | 
						|
class Book(models.Model):
 | 
						|
    name = models.CharField(max_length=100)
 | 
						|
    subtitle = models.CharField(max_length=100)
 | 
						|
    price = models.FloatField()
 | 
						|
    authors = models.ManyToManyField(Author, through='AuthorsBooks')
 | 
						|
 | 
						|
 | 
						|
class AuthorsBooks(models.Model):
 | 
						|
    author = models.ForeignKey(Author)
 | 
						|
    book = models.ForeignKey(Book)
 | 
						|
 | 
						|
 | 
						|
class State(models.Model):
 | 
						|
    name = models.CharField(max_length=15)
 | 
						|
 | 
						|
 | 
						|
class City(models.Model):
 | 
						|
    state = models.ForeignKey(State)
 |