-
Notifications
You must be signed in to change notification settings - Fork 705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inline sortable error when model features only FKs #232
Comments
Please provide a code example of your models and admin classes. |
I'm able to reproduce this issue with the following simple app (models taken almost directly from the Django docs). # models.py
from django.db import models
class Person(models.Model):
name = models.CharField(max_length=128)
def __str__(self):
return self.name
class Group(models.Model):
name = models.CharField(max_length=128)
members = models.ManyToManyField(Person, through='Membership')
def __str__(self):
return self.name
class Membership(models.Model):
person = models.ForeignKey(Person)
group = models.ForeignKey(Group)
sort_order = models.PositiveIntegerField()
# admin.py
from django.contrib import admin
from suit.admin import SortableTabularInline
from .models import Person, Group, Membership
class PersonAdmin(admin.ModelAdmin):
pass
class MembershipInline(SortableTabularInline):
model = Membership
sortable = 'sort_order'
class GroupAdmin(admin.ModelAdmin):
inlines = [MembershipInline]
admin.site.register(Person, PersonAdmin)
admin.site.register(Group, GroupAdmin) To reproduce, get the admin running and do the following:
You should see "This field is required." errors in the "Sort order" column. After looking at #216, I tried the following and it seems to fix the problem but I'm not sure I understand what the implications of the change are.
Let me know if there's anything else I can do to help reproduce or fix the issue. Thanks! |
Please try latest develop branch and confirm problem is fixed?
|
Fixed! Thank you! |
I think there's an issue with the sortable JS. I have an inlined model which features only the parent FK, an FK to another model and the sortable order field. The final JS sort before submit is corrupting the order values. It only happens when the model has just these fields - I got round it by adding an extra, non FK field which I simply hide with CSS. I did try to amend the JS but I couldn't quite crack where it was going awry. Hoped you might be able to shed some light. Thanks v much for Suit BTW, it's awesome :-)
The text was updated successfully, but these errors were encountered: