Skip to content
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

Inner inline not making inline field row #82

Open
jerickbixly opened this issue Aug 22, 2017 · 1 comment
Open

Inner inline not making inline field row #82

jerickbixly opened this issue Aug 22, 2017 · 1 comment

Comments

@jerickbixly
Copy link

hi. i have the following model definition setup

class Product(AuthorStampedModel):
    name = models.CharField(max_length=100)
    summary = models.TextField(blank=True, default="")
    related_products = models.ManyToManyField(
        "self",
        related_name="related_to",
        blank=True,
        null=True
    )
    similar_products = models.ManyToManyField(
        "self",
        related_name="similar_to",
        blank=True,
        null=True
    )

    def __unicode__(self):
        return self.name

class Specification(models.Model):
    product = models.ForeignKey('Product', related_name='specs')
    title = models.CharField(max_length=100)

    def __unicode__(self):
        return '{0}: {1}'.format(self.product, self.title)


class SpecificationListContent(models.Model):
    specification = models.ForeignKey('Specification', related_name='list_content')
    content = models.CharField(max_length=255)

    def __unicode__(self):
        return str(self.specification)


class SpecificationGroupedContent(models.Model):
    specification = models.ForeignKey('Specification', related_name='group_content')
    field_unit = models.CharField(max_length=255)

    def __unicode__(self):
        return str(self.specification)


class SpecificationGroupedContentValue(models.Model):
    specification_grouped_content = models.ForeignKey(
        'SpecificationGroupedContent',
        related_name='group_content_value'
    )
    value = models.CharField(max_length=255)

    def __unicode__(self):
        return str(self.specification_grouped_content)

I set up the django admin like so

class SpecificationGroupedContentValueInline(NestedStackedInline):
    model = SpecificationGroupedContentValue
    extra = 1


class SpecsGroupedContentInline(NestedStackedInline):
    model = SpecificationGroupedContent
    inlines = [SpecificationGroupedContentValueInline]
    extra = 1


class SpecsContentInline(NestedStackedInline):
    model = SpecificationListContent
    extra = 1


class SpecsInline(NestedStackedInline):
    model = Specification
    inlines = [SpecsContentInline, SpecsGroupedContentInline]
    extra = 1


class ProductAdmin(AuthorStampedMixin, NestedModelAdmin):
    inlines = [
        SpecsInline
    ]
    list_display = ('name',)


admin.site.register(Product, ProductAdmin)

My goal was within the inline for Specs, there would be an inline entry for SpecificationListContent and the inline group for SpecificationGroupedContent. When the admin page renders, it looks like this

screenshot from 2017-08-22 14-10-23

So from the photo, for the Specification inline, i have two sections, a Specification List Contents inline and a Specification Grouped Contents. In Specification Grouped Contents, there's a field called "Field unit" and another inline for Specification Grouped Content Values which i could add additional values for. what happens is that for the Specification Grouped Content, when i try adding a new one, there's no "Value" entry form row present in the new Specification Grouped Content inline like the image below

screenshot from 2017-08-22 14-15-19

No rows are being added also when i try clicking the "Add another Specification Grouped Content Value" link to hopefully generate a row.

Is there something incorrect with my setup? I tried testing with just the SpecsGroupedContentInline present in the SpecsInline inline object but the result is still the same.

I'm using Django 1.7

Thanks

@jerickbixly
Copy link
Author

jerickbixly commented Sep 5, 2017

I noticed the same issue again after making a work around for this issue, details of which is found here

https://stackoverflow.com/questions/46034371/django-nested-inline-missing-fields-when-adding-new-inline-row

from what i could tell also, it seems the fields for the new lines are added but hidden due to the wrapping div having an empty-form class. There's also missing jquery commands for it unlike for the previous rows. It seems to only affect last models which are foreign keys of other models as well.

Also, it seems to affect only last models in inlines which are foreign keys of another model

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant