mirror of
				https://github.com/django/django.git
				synced 2025-10-31 01:25:32 +00:00 
			
		
		
		
	Introduced a distinct implementation depending on the type of the date field (DateField or DateTimeField), and applied appropriate conversions is the latter case, when time zone support is enabled.
		
			
				
	
	
		
			48 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| from django.db import models
 | |
| 
 | |
| 
 | |
| class Artist(models.Model):
 | |
|     name = models.CharField(max_length=100)
 | |
| 
 | |
|     class Meta:
 | |
|         ordering = ['name']
 | |
|         verbose_name = 'professional artist'
 | |
|         verbose_name_plural = 'professional artists'
 | |
| 
 | |
|     def __unicode__(self):
 | |
|         return self.name
 | |
| 
 | |
|     @models.permalink
 | |
|     def get_absolute_url(self):
 | |
|         return ('artist_detail', (), {'pk': self.id})
 | |
| 
 | |
| class Author(models.Model):
 | |
|     name = models.CharField(max_length=100)
 | |
|     slug = models.SlugField()
 | |
| 
 | |
|     class Meta:
 | |
|         ordering = ['name']
 | |
| 
 | |
|     def __unicode__(self):
 | |
|         return self.name
 | |
| 
 | |
| class Book(models.Model):
 | |
|     name = models.CharField(max_length=300)
 | |
|     slug = models.SlugField()
 | |
|     pages = models.IntegerField()
 | |
|     authors = models.ManyToManyField(Author)
 | |
|     pubdate = models.DateField()
 | |
| 
 | |
|     class Meta:
 | |
|         ordering = ['-pubdate']
 | |
| 
 | |
|     def __unicode__(self):
 | |
|         return self.name
 | |
| 
 | |
| class Page(models.Model):
 | |
|     content = models.TextField()
 | |
|     template = models.CharField(max_length=300)
 | |
| 
 | |
| class BookSigning(models.Model):
 | |
|     event_date = models.DateTimeField()
 |