-
Notifications
You must be signed in to change notification settings - Fork 103
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
Unable to delete inline when it has the same formset prefix as another inline in the same admin #60
Comments
Could you post the code for your models and admin so that I can try to reproduce the bug? (Or at least as much code as is needed to see the bug). What version of Django are you using? With or without grappelli? |
#admin.py
class Aa(Bar):
class Meta:
proxy=True
class Bb(Bar):
class Meta:
proxy=True
class AaModelForm(ModelForm):
class Meta:
model = Bar
exclude = []
class BbModelForm(ModelForm):
class Meta:
model = Bar
exclude = []
class AaAdminInline(nested_admin.NestedStackedInline):
model = Aa
form = AaModelForm
extra = 1
class BbAdminInline(nested_admin.NestedStackedInline):
model = Bb
form = BbModelForm
extra = 1
class FooAdmin(nested_admin.NestedModelAdmin):
inlines = [AaAdminInline, BbAdminInline]
admin.site.register(Foo, FooAdmin) #models.py
class Foo(models.Model):
foo_field1 = models.CharField(max_length=10,blank=True, null=True)
foo_field2 = models.CharField(max_length=10,blank=True, null=True)
class Bar(models.Model):
foo = models.ForeignKey(Foo, related_name='bar_foo')
bar_field1 = models.CharField(max_length=10,blank=True, null=True)
bar_field2 = models.CharField(max_length=10,blank=True, null=True) This should be enough to reproduce it. No grappell. Django 1.10 I'm using custom get_queryset on the inlines so they are not just the same objects repeated. It works fine on standard Django admin or when I remove the related_name |
Thanks for the report! It turns out that the proxy models are somewhat incidental to the underlying issue: the same bug surfaces if you have two inline classes on an admin that point to the same model. The problem occurs when multiple inline admin formsets on a parent model share the same prefix, which is why you are seeing it when you specify a I'm a bit surprised no one has ever encountered this issue before, but it should be enough to tweak the regular expressions that parse the form prefixes. I'll take a look. |
This was fixed in the 3.0.11 release of django-nested-admin. Let me know if you have any more issues. |
Hi, Since the 3.0.11 release, I now have this problem, whereas I didn't have it before. I also have a new problem where dragging a nested form to change the order is now broken (I'm not using grappeli). I am not using proxy models at all. Also, nothing in the browser logs for the checkboxes, but for dragging to change order I get a "t is undefined". |
@grigi Could it be that your browser is loading cached versions of the nested admin static files? That's my best guess. If that is the case, I recommend setting If that is not the issue, set |
Nope, tested that the browser was running non cached versions. I'll try the NESTED_ADMIN_DEBUG = True option for the dragging. (although there was no exception at all in the js for the delete checkbox issue. |
I'm still having similar issue reported on #26 when using related_name AND proxy model on admin to use the same model more than once. The moment I use a related_name, no matter what value I use, the checkbox to delete can't be checked anymore
The text was updated successfully, but these errors were encountered: