theatlantic / django-nested-admin

Django admin classes that allow for nested inlines
http://django-nested-admin.readthedocs.org/
Other
690 stars 97 forks source link

CompositeKey issue - django-viewflow compatibility #218

Open McQueTX opened 2 years ago

McQueTX commented 2 years ago

I unfortunately have to deal with legacy tables that are linking tables without a pk. The package django-viewflow==2.0.0a2 allows us to create a virtual field that is a composite of the 2 foreign keys in the linking table. i.e. id='{"tbl1_kf": 123, "tbl2_fk": 456}'

There are 2 compatibility issues I am having: 1) The formsets.py get_queryset qs.filter(pk__in) was breaking pmysql. I was able to work around using json.loads() to split the key when the model uses the virtual field. 2) The tbl2_fk is the only field that is editable in the form as it is not the foreign key to the inline's parent. If anything inside the formset is clicked the tbl2_fk select goes blank. Submiting the form throws a validation error saying tbl2_fk is required even though a value is selected before submitting.

I am assuming the second issue is in the js since the tbl2_fk field value never makes it back to my app. If you have any ideas on where I should look in the js file to try to fix the issue that would be greatly appreciated!