在django中为后端用户添加默认内容

时间:2014-02-25 08:42:12

标签: python django django-models django-admin

我的网络服务保存文件,用户可以操作然后查看。 我使用电子邮件地址自动创建新用户。

我面临的困难是,如何为每个用户设置一些默认内容?我不能只链接到相同的文件,因为用户可以操作这些文件,因此所有其他用户的文件也将被更改。

我的模特:

class Contentfile(models.Model):
    content = ContentTypeRestrictedFileField(upload_to='uploads/', content_types=['video/mp4', 'application/pdf', 'image/gif', 'image/jpeg', 'image/png'],max_upload_size=104857600,blank=True, null=True, help_text='Upload a file to add it to the content the app displayes')
    created_at = models.DateTimeField(auto_now_add=True, editable=False)
    updated_at = models.DateTimeField(auto_now=True, editable=False)
    title = models.CharField(max_length=255, unique=True)
    file_type = models.CharField(max_length=5)
    published = models.BooleanField(default=True)
    file_owner = models.ForeignKey(User, related_name='Contentfiles')
    orderValue = models.IntegerField("presentation order")

0 个答案:

没有答案