Fix queryset assigment, should always be of MetadataType not DocumentTypeMetadataType, errors out on Postgres.
This commit is contained in:
@@ -101,7 +101,11 @@ class AddMetadataForm(forms.Form):
|
||||
def __init__(self, *args, **kwargs):
|
||||
document_type = kwargs.pop('document_type')
|
||||
super(AddMetadataForm, self).__init__(*args, **kwargs)
|
||||
self.fields['metadata_type'].queryset = document_type.metadata.all()
|
||||
self.fields['metadata_type'].queryset = MetadataType.objects.filter(
|
||||
pk__in=document_type.metadata.values_list(
|
||||
'metadata_type', flat=True
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class MetadataTypeForm(forms.ModelForm):
|
||||
|
||||
@@ -243,7 +243,7 @@ def metadata_add(request, document_id=None, document_id_list=None):
|
||||
try:
|
||||
document_metadata, created = DocumentMetadata.objects.get_or_create(
|
||||
document=document,
|
||||
metadata_type=metadata_type.metadata_type,
|
||||
metadata_type=metadata_type,
|
||||
defaults={'value': ''}
|
||||
)
|
||||
except Exception as exception:
|
||||
|
||||
Reference in New Issue
Block a user