WhisperMaPhone/main/models.py

20 lines
660 B
Python

import os
import uuid
from django.db import models
class Thought(models.Model):
text = models.CharField(max_length=140)
extended_text = models.TextField(blank=True)
uuid = models.UUIDField(default=uuid.uuid4, editable=False)
posted = models.DateTimeField(auto_now_add=True)
timezone_offset = models.IntegerField() # The number of minutes behind UTC we were when this was posted
media = models.FileField(upload_to="", blank=True) # A single image, video, or sound clip per post
def get_media_type(self):
if not self.media:
return ""
else:
return os.path.splitext(self.media.path)[1][1:]