You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think I just need some advice on how to integrate media_tree with my models admin.
I just created a derived model from FileNode to be able to link several documents to differents models.
Then I added this my admin.py file to use only the fields I needed in the attached files Inline:
from media_tree.forms import FileForm
from media_tree.models import FileNode
class MyFileForm(FileForm):
class Meta:
fields = ['parent','file','title']
class AttachmentsInline(GenericTabularInline):
model = Attachment
form = MyFileForm
extra = 1
But when saving I have an error about the node_type column being NOT NULL so I have to do something about that.
I'm unable to override MyFileForm init method to set up a initial value like FileNode.FILE because the node_type field has the editable = False flag.
I ended overriding my model save() method:
def save(self, *args, **kwargs):
if not self.node_type:
self.node_type = FileNode.FILE
super(Attachment, self).save(*args, **kwargs)
What would have been the right way to do this ?
The text was updated successfully, but these errors were encountered:
I think I just need some advice on how to integrate media_tree with my models admin.
I just created a derived model from FileNode to be able to link several documents to differents models.
Then I added this my admin.py file to use only the fields I needed in the attached files Inline:
But when saving I have an error about the node_type column being NOT NULL so I have to do something about that.
I'm unable to override MyFileForm init method to set up a initial value like
FileNode.FILE
because thenode_type
field has theeditable = False
flag.I ended overriding my model save() method:
What would have been the right way to do this ?
The text was updated successfully, but these errors were encountered: