22 lines
		
	
	
		
			656 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			656 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from django.db import models
 | |
| 
 | |
| # Create your models here.
 | |
| 
 | |
| class Place (models.Model):
 | |
|     name = models.CharField(max_length=50)
 | |
|     location = models.CharField(max_length=50)
 | |
|     latitude = models.FloatField()
 | |
|     longitude = models.FloatField()
 | |
|     description = models.TextField()
 | |
| 
 | |
|     def __str__(self):
 | |
|         return self.name
 | |
| 
 | |
| class PlaceImage (models.Model):
 | |
|     filename = models.ImageField(upload_to='places/%Y/%m/', max_length=50)
 | |
|     place = models.ForeignKey(Place, on_delete=models.CASCADE, related_name='images')
 | |
|     description = models.TextField(blank=True)
 | |
| 
 | |
|     def __str__(self):
 | |
|         return ' '.join([self.place.name, str(self.pk)])
 |