Following the Mezzanine blog as an example would be something like this
from mezzanine.conf import settings
# Trailing slahes for urlpatterns based on setup.
_slash = "/" if settings.APPEND_SLASH else ""
# Blog patterns.
urlpatterns = [
url("^(?P<slug>.*)%s$" % _slash, project_detail, name="project_detail"),
]
You can also skip that step and write the slash manually
urlpatterns = [
url("^(?P<slug>.*)/$", project_detail, name="project_detail"),
]
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.