Last active
July 9, 2021 21:00
-
-
Save godfather68/dbfcfe09bb1b326e137a003ca3445a9c to your computer and use it in GitHub Desktop.
models.py for rental service API.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class House(models.Model): | |
"""House object""" | |
STATUS_CHOICES = ( | |
('review', 'Review'), | |
('published', 'Published') | |
) | |
title = models.CharField(max_length=255) | |
price = models.DecimalField(max_digits=5, decimal_places=2) | |
description = models.TextField(blank=True) | |
publish = models.DateTimeField(default=timezone.now) | |
status = models.CharField(max_length=10, choices=STATUS_CHOICES, default='review') | |
location = models.ForeignKey('District', on_delete=models.CASCADE) | |
options = models.ForeignKey('Options', on_delete=models.CASCADE) | |
furnished = models.BooleanField(default=False) | |
published = PublishedManager() # Custom manager for filtering | |
link = models.CharField(max_length=255, blank=True) | |
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) | |
class Meta: | |
ordering = ('-publish',) | |
def __str__(self): | |
return self.title |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment