Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.db import models
- from users.models import Agent, Customer
- # Create your models here.
- class Property(models.Model):
- id = models.BigAutoField(primary_key=True, null=False)
- agent = models.ForeignKey(
- Agent, on_delete=models.CASCADE, verbose_name="Agente", blank=True
- )
- region = models.CharField(max_length=99, verbose_name="Regione", null=False)
- province = models.CharField(max_length=99, verbose_name="Provincia", null=False)
- city = models.CharField(max_length=99, verbose_name="Città", null=False)
- zip_code = models.IntegerField(verbose_name="C.A.P.", null=False)
- address1 = models.CharField(max_length=99, verbose_name="Indirizzo", null=False)
- address2 = models.CharField(max_length=99, verbose_name="Scala, Piano", blank=True)
- property_type = models.CharField(
- max_length=20,
- verbose_name="Tipologia",
- choices=[
- ("HOUSE", "Casa"),
- ("APARTMENT", "Appartamento"),
- ("LAND", "Terreno"),
- ("FARM", "Masseria"),
- ],
- )
- price = models.DecimalField(
- decimal_places=2, max_digits=19, verbose_name="Prezzo di Vendita", null=False
- )
- construction_year = models.IntegerField(
- verbose_name="Anno di costruzione", null=True, blank=True
- )
- total_plans = models.IntegerField(verbose_name="Piani Totali", null=True)
- mq = models.DecimalField(
- decimal_places=2, max_digits=99, verbose_name="mq totali", null=True, default=0
- )
- locals_number = models.DecimalField(
- decimal_places=2, max_digits=99, verbose_name="Locali", null=True
- )
- bedrooms_number = models.IntegerField(verbose_name="Camere da letto", null=True)
- bathrooms_number = models.DecimalField(
- decimal_places=2, max_digits=99, verbose_name="Bagni", null=True
- )
- garden = models.BooleanField(default=False, verbose_name="Giardino", null=False)
- garden_mq = models.DecimalField(
- decimal_places=2,
- max_digits=99,
- verbose_name="mq giardino",
- null=True,
- blank=True,
- default=0,
- )
- box = models.BooleanField(default=False, verbose_name="Garage", null=False)
- box_mq = models.DecimalField(
- decimal_places=2, max_digits=99, verbose_name="mq garage", null=True, default=0
- )
- title = models.CharField(
- max_length=99, blank=False, verbose_name="Titolo", null=False
- )
- description = models.TextField(max_length=99, verbose_name="Descrizione")
- cover = models.ImageField(
- upload_to="cover/upload", verbose_name="Copertina", blank=True
- )
- images = models.ImageField(
- upload_to="gallery/upload", verbose_name="Galleria", blank=True
- )
- created_at = models.DateField(auto_now_add=True)
- favourites = models.ManyToManyField(Customer, default=None, blank=True, verbose_name="Preferito")
- class Meta:
- verbose_name = "Immobile"
- verbose_name_plural = "Immobili"
- def __str__(self):
- return self.title
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement