core/models.py (56 lines of code) (raw):
# Copyright 2022 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from django.db import models
from django.contrib.auth import get_user_model
import uuid
from datetime import datetime
User = get_user_model()
# Create your models here.
class Profile(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
id_user = models.IntegerField()
bio = models.TextField(blank=True)
profileimg = models.ImageField(upload_to='profile_images', default='blank-profile-picture.png')
location = models.CharField(max_length=100, blank=True)
def __str__(self):
return self.user.username
class ProfileGCP(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
id_user = models.IntegerField()
bio = models.TextField(blank=True)
profileimg = models.TextField(default='media/blank-profile-picture.png')
location = models.CharField(max_length=100, blank=True)
def __str__(self):
return self.user.username
class Post(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4)
user = models.CharField(max_length=100)
image = models.ImageField(upload_to='post_images')
caption = models.TextField()
created_at = models.DateTimeField(default=datetime.now)
no_of_likes = models.IntegerField(default=0)
def __str__(self):
return self.user + " " + str(self.image)
class PostGCP(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4)
user = models.CharField(max_length=100)
image = models.TextField()
caption = models.TextField()
created_at = models.DateTimeField(default=datetime.now)
no_of_likes = models.IntegerField(default=0)
def __str__(self):
return self.user + " " + str(self.image)
class LikePost(models.Model):
post_id = models.CharField(max_length=500)
username = models.CharField(max_length=100)
def __str__(self):
return self.username
class FollowersCount(models.Model):
follower = models.CharField(max_length=100)
user = models.CharField(max_length=100)
def __str__(self):
return self.user
class Comment(models.Model):
post_id = models.CharField(max_length=500)
username = models.CharField(max_length=100)
comment = models.TextField()
created_at = models.DateTimeField(default=datetime.now)
def __str__(self):
return self.username