Advertisement
horozov86

project

Mar 13th, 2024
977
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. from django.contrib.auth.models import User
  2. from django.db import models
  3.  
  4.  
  5. class Place(models.Model):
  6.     RATING_CHOICES = [
  7.         (1, '1 Star'),
  8.         (2, '2 Stars'),
  9.         (3, '3 Stars'),
  10.         (4, '4 Stars'),
  11.         (5, '5 Stars'),
  12.     ]
  13.  
  14.     CATEGORY_CHOICES = [
  15.         ('Mountain', 'Mountain'),
  16.         ('Sea', 'Sea'),
  17.         ('Historical Site', 'Historical Site'),
  18.         ('City', 'City'),
  19.         ('Spa', 'Spa'),
  20.         ('Wine Tourism', 'Wine Tourism')
  21.  
  22.     ]
  23.     name = models.CharField(
  24.         max_length=200,
  25.         null=False,
  26.         blank=False,
  27.     )
  28.     description = models.TextField(
  29.         null=False,
  30.         blank=False,
  31.     )
  32.     location = models.CharField(
  33.         max_length=200,
  34.         null=False,
  35.         blank=False,
  36.     )
  37.     rating = models.IntegerField(
  38.         choices=RATING_CHOICES,
  39.         null=True,
  40.         blank=True,
  41.     )
  42.  
  43.     image = models.ImageField(
  44.         upload_to='photos/',
  45.         null=True,
  46.         blank=True,
  47.     )
  48.  
  49.     category = models.CharField(max_length=100, choices=CATEGORY_CHOICES, null=True, blank=True)
  50.  
  51.  
  52.     def __str__(self):
  53.         return self.name
  54.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement