I think I'm starting to get it.
My `urls.py` includes this...
urlpatterns += [
...
url("^(?P<slug>.*)%s$" % _slash, project_detail, name="project_detail"),
]
But when I run `python manage.py runserver`, I get this error:
`url("^(?P<slug>.*)%s$" % _slash, project_detail, name="project_detail"),
NameError: name '_slash' is not defined`. I guess this means I need to
define _slash in my `urls.py`? Or can I pull the definition from
`mezzanine.blog.urls.py`?
On Monday, October 23, 2017 at 3:33:08 AM UTC-4, Rainell Dilou Gómez wrote:
>
> Sorry, I wrote that the third parameter passed to the get_absolute_url
> method in the example is a list, instead it is a dictionary. And, about
> _slash in the urlpattern, if you have taken a look at urls.py in the
> Mezzanine blog application, you will see that _slash is set before
> urlpatterns.
>
> Il giorno domenica 22 ottobre 2017 00:36:31 UTC+2, Tom Tanner ha scritto:
>>
>>
>> Hey all,
>>
>> I've started a new Mezzanine site. I'm trying to make a page where I can
>> post elements from the Admin menu. Kind of l like the Blog section.
>>
>> Here's what my custom class looks like in my app's `models.py`.
>>
>>
>> class ProjectLinkPage(Displayable):
>> '''
>> A page representing the format of the page that
>> has links to standalone, projectlink projectlinks
>> '''
>> categories = models.ManyToManyField("ProjectCategory",
>> verbose_name=_("Categories"),
>> blank=True, related_name="projectlinkposts")
>> # allow_comments = models.BooleanField(verbose_name=_("Allow comments"),
>> # default=False)
>> # comments = CommentsField(verbose_name=_("Comments"))
>> # featured_image = FileField(verbose_name=_("Featured Image"),
>> # upload_to=upload_to("projectlink.ProjectPost.featured_image",
>> "projectlink"),
>> # format="Image", max_length=255, null=True, blank=True)
>> # related_posts = models.ManyToManyField("self",
>> # verbose_name=_("Related posts"), blank=True)
>> # admin_thumb_field = "featured_image"
>>
>>
>> class Meta:
>> verbose_name=_("Project link")
>> verbose_name_plural=_("Project links")
>> ordering=("-publish_date",)
>>
>>
>> def get_absolute_url(self):
>> return self.slug
>>
>> When I open the Admin section, I see "Project links" on the left-side
>> menu. I click it, then click "Add Project Link." I fill out the form and
>> click "save." I then click "View on site." My browser tries to open "
>> http://127.0.0.1:8000/admin/r/32/2/," but I get a browser error: "This
>> page isn't working. 127.0.0.1 sent an invalid response." My terminal looks
>> like this when I clicked "View on site":
>>
>> [21/Oct/2017 22:35:39] "GET /admin/r/32/2/ HTTP/1.1" 302 0
>> [21/Oct/2017 22:35:39] "GET /admin/r/32/2/ HTTP/1.1" 302 0
>>
>> I figure I must be defining `get_absolute_url()` wrong. What must I fix
>> so that 'View on site" leads to the right address?
>>
>
--
You received this message because you are subscribed to the Google Groups
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.