Python 向django中的后端用户添加默认内容

Python 向django中的后端用户添加默认内容,python,django,django-models,django-admin,Python,Django,Django Models,Django Admin,我的web服务保存文件,用户可以对其进行操作并查看。 我使用电子邮件地址自动创建新用户 我面临的困难是,如何为每个用户设置一些默认内容?我不能仅仅链接到相同的文件,因为用户有能力操作这些文件,所以其他用户的所有文件也会被更改 我的模型: class Contentfile(models.Model): content = ContentTypeRestrictedFileField(upload_to='uploads/', content_types=['video/mp4', 'ap

我的web服务保存文件,用户可以对其进行操作并查看。 我使用电子邮件地址自动创建新用户

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

我的模型:

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")

您的用户可以操纵实际的文件,还是只操纵他们的
Contentfile
元数据?我使用s3来存储文件。当用户“删除”或“编辑”文件时,它实际上是实际文件。我会添加一个
Contentfile.is_template
boolean字段,将默认内容设置为
True
,然后创建实际文件的完整副本,并在第一次操作尝试时清除
is_template
标志,但您的问题对于堆栈溢出来说实在太宽泛了。看看。有趣的阅读,我想我要做的是取消编辑文件的选项,只保留删除选项。我的post delete signal listener目前负责从s3服务器中删除文件,只有在is_模板为false时才这样做。