Answer the question
In order to leave comments, you need to log in
How to store mp3 files in django?
I drink the application. The idea is "Photos are accompanied by a voice description." i.e. when the user creates an entity called "story" - he uploads a photo and description (in mp3).
So the essence of the "History from Paul" consists of a general title + a photo with an audio description (there can be many such bundles of photos + description).
Here are the models I created:
from django.db import models
# Create your models here.
class Account(models.Model):
login = models.CharField(primary_key=True, max_length=30)
password = models.CharField(max_length=30)
def __unicode__(self):
return self.login
class Story(models.Model):
login = models.ForeignKey(Account) # добавляем поле логин из таблицы Account
story_id = models.CharField(unique=True, max_length=30)
story_color = models.CharField(max_length=16, default=0)
head = models.CharField(max_length=100)
main_mp3 = models.CharField(max_length=300)
def __unicode__(self):
return self.story_id
class Story_Segment(models.Model):
story_id = models.ForeignKey(Story)
voice = models.CharField(max_length=300)
photo = models.CharField(max_length=300)
def __unicode__(self):
return self.story_id
Answer the question
In order to leave comments, you need to log in
#class Account(models.Model)
from django.contrib.auth.models import AbstractUser
class Account(AbstractUser):
#class Story_Segment
class StorySegment(models.Model):
story = models.ForeignKey(Story)
voice = models.FileField(upload_to='uploads/')
photo = models.FileField(upload_to='uploads/')
#story_id = models.CharField(unique=True, max_length=30)
story = models.ForeignKey(Story)
#def __unicode__
def __str__
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question