2020-07-19 00:13:49 +02:00
|
|
|
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()
|
2020-07-27 20:34:18 +02:00
|
|
|
|
|
|
|
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)])
|