Well, at this point it is up to you to determine the absolute url of each object. Since we don't know what fields your model has, and what views are supposed to serve it, we can't say for sure what the url should be.

In general, all objects inheriting from Displayable will have a slug field, which is ideal for generating urls. In that case, get_absolute_url() can return reverse("your_url_name", kwargs={"slug": self.slug}).

Of course, for this to work you'll need to create the view that serves the object and register it under a named urlpattern.


On 2017-10-13 5:18 PM, Tom Tanner wrote:
OK, I've gotten more done after watching your video and going over the Django tutorials covering `admin.py`. My `admin.py` looks like this now. I renamed the classes...:

|
from __future__ import unicode_literals

from copy import deepcopy

from django.contrib import admin
from django.utils.translation import ugettext_lazy as _

from .models import ProjectLinkPage, ProjectCategory

# Register your models here.

admin.site.register(ProjectLinkPage)
admin.site.register(ProjectCategory)
|

So now "Project links" appears in the admin page lefthand side. When I add a new project link, then try to view it on site, I get an error saying:
|
NotImplementedError: The model ProjectLinkPage does not have get_absolute_url defined

|

I will add a `get_absolute_url()` method to my `ProjectLinkPage` class. But here's the thing. I want this Projects Page to have links to different, customized pages. One of the links on the Projects Page could go to an HTML file that has an interactive map on it. Looking at `get_absolute_url()` in Mezzanine's BlogPost class, I'm unsure how I'd edit ProjectLinksPage's `get_absolute_url()` to do what I want. Any tips? Examples of other custom-made `get_absolute_url()` methods? Or maybe I'm looking at this all wrong?


On Wednesday, October 11, 2017 at 9:15:13 PM UTC-4, Eduardo Rivas wrote:

    Also (and I know I've posted this a ton lately, but I think it's
    relevant) here's a talk describing the general steps I follow when
    building apps for Mezzanine:
    https://www.youtube.com/watch?v=yVAmMXES2EU
    <https://www.youtube.com/watch?v=yVAmMXES2EU>

    It touches on how to uses Mezzanine's models, admin, and template
    utilities.


    On 2017-10-11 7:08 PM, Eduardo Rivas wrote:

    Hi Tom.

    You need to register your model in the admin. You can use
    mezzanine.blog.admin as an example:
    https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/blog/admin.py
    
<https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/blog/admin.py>.

    This admin configuration is a bit complex, so I recommend you
    become familiar with Django's admin in general before diving into
    it. Have you completed the official Django tutorial? It should
    introduce you to all these concepts:
    https://docs.djangoproject.com/en/1.11/intro/tutorial01/
    <https://docs.djangoproject.com/en/1.11/intro/tutorial01/>


    On 2017-10-11 7:02 PM, Tom Tanner wrote:

    Hey all,

    When I go to the Admin section of my site, I see the "Blog
    posts" under "Content" on the left. I want to make a new
    "Content" section called "Projects." It would be similar to a
    page of blog posts. But I'm not sure how to start doing this.

    Here's what my app's `models.py` looks like.

    |
    from__future__ importunicode_literals


    fromdjango.db importmodels
    fromdjango.core.urlresolvers importreverse
    fromdjango.utils.translation importugettext_lazy as_


    frommezzanine.conf importsettings
    frommezzanine.core.fields importFileField
    frommezzanine.core.models importDisplayable,Ownable,RichText,Slugged
    frommezzanine.generic.fields importCommentsField,RatingField
    frommezzanine.utils.models importAdminThumbMixin,upload_to


    # Create your models here.


    classProjectsPage(Displayable):
    '''
     A page representing the format of the page that
     has links to standalone, project projects
     '''


     categories =models.ManyToManyField("ProjectCategory",
     verbose_name=_("Categories"),
     blank=True,related_name="projectposts")
     allow_comments =models.BooleanField(verbose_name=_("Allow
    comments"),
    default=True)
     comments =CommentsField(verbose_name=_("Comments"))
     featured_image =FileField(verbose_name=_("Featured Image"),
     upload_to=upload_to("project.ProjectPost.featured_image","project"),
     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"


    classMeta:
       verbose_name=_("Project link")
       verbose_name_plural=_("Project links")
       ordering=("-publish_date",)




    classProjectCategory(Slugged):
    '''
     A category for grouping project links into a series
     '''


    classMeta:
       verbose_name=_("Project Category")
       verbose_name_plural=_("Project Categories")
       ordering=("title",)
    |
    I basically copied a section of `mezzanine/blog/models.py`.

    But "Projects" won't show up in my Admin menu. What am I doing
    wrong?
-- 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]
    <javascript:>.
    For more options, visit https://groups.google.com/d/optout
    <https://groups.google.com/d/optout>.


--
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] <mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.

--
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.

Reply via email to