Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.db import models
- from django.contrib.auth.models import User
- class Category(models.Model):
- name = models.CharField(max_length=100)
- description = models.TextField(blank=True)
- def __str__(self):
- return self.name
- class Place(models.Model):
- name = models.CharField(max_length=200)
- description = models.TextField()
- location = models.CharField(max_length=200)
- category = models.ForeignKey(Category, on_delete=models.CASCADE)
- rating = models.FloatField(default=0) # You can adjust this field to represent ratings
- def __str__(self):
- return self.name
- class Photo(models.Model):
- place = models.ForeignKey(Place, related_name='photos', on_delete=models.CASCADE)
- image = models.ImageField(upload_to='photos/')
- description = models.TextField(blank=True)
- uploaded_at = models.DateTimeField(auto_now_add=True)
- user = models.ForeignKey(User, on_delete=models.CASCADE)
- def __str__(self):
- return f"Photo of {self.place.name}"
- class Review(models.Model):
- place = models.ForeignKey(Place, related_name='reviews', on_delete=models.CASCADE)
- user = models.ForeignKey(User, on_delete=models.CASCADE)
- text = models.TextField()
- rating = models.IntegerField() # You can adjust this field to represent ratings
- created_at = models.DateTimeField(auto_now_add=True)
- def __str__(self):
- return f"Review of {self.place.name} by {self.user.username}"
- class UserProfile(models.Model):
- user = models.OneToOneField(User, on_delete=models.CASCADE)
- bio = models.TextField(blank=True)
- profile_picture = models.ImageField(upload_to='profile_pictures/', blank=True)
- def __str__(self):
- return self.user.username
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement