Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem inheriting get_absolute_url in an child model
    primarykey
    data
    text
    <p>I have the following sets of models (abbreviated for clarity):</p> <p><strong>First set:</strong></p> <pre><code>class Web(Link): ideas = models.ManyToManyField(Idea, blank=True, null=True) precedents = models.ManyToManyField(Precedent, blank=True, null=True) categories = GenericRelation(CategoryItem) @permalink def get_absolute_url(self): return ('resources-link-detail', [str(self.slug)]) </code></pre> <p>which is a child of:</p> <pre><code>class Link(models.Model): title = models.CharField(max_length=250) description = models.TextField(blank=True) website = models.URLField(unique=True) slug = models.SlugField(unique_for_date='pub_date') ... @permalink def get_absolute_url(self): return ('link-detail', [str(self.slug)]) </code></pre> <p><strong>Second set</strong></p> <pre><code>class ResourceOrganization(Organization): ideas = models.ManyToManyField(Idea, blank=True, null=True) precedents = models.ManyToManyField(Precedent, blank=True, null=True) categories = GenericRelation(CategoryItem) @permalink def get_absolute_url(self): return ('resources-org-detail', [str(self.slug)]) </code></pre> <p>which is a child of:</p> <pre><code>class Organization(Contact): name = models.CharField(max_length=100) org_type = models.PositiveSmallIntegerField(choices=ORG_CHOICES) ... @permalink def get_absolute_url(self): return ('org-detail', [str(self.slug)]) </code></pre> <p>which is a child of:</p> <pre><code>class Contact(models.Model): description = models.TextField(blank=True, null=True) address_line1 = models.CharField(max_length=250, blank=True) address_line2 = models.CharField(max_length=250, blank=True) slug = models.SlugField(unique=True) ... class Meta: abstract = True </code></pre> <p>The "ResourceOrganization" model is properly overiding the get_absolute_url method and is adding the "categories" generic relation.</p> <p>The "Web" model is not.</p> <p>I'm at a loss to figure out why. Would appreciate any insight.</p> <p>P.S. I'm realizing that there may have been better ways to implement this functionality, but I'm stuck with it for the moment until I can refactor and would like to get it working.</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload