Mezzanine profiles

82 views
Skip to first unread message

oneloop

unread,
Feb 5, 2014, 12:08:43 PM2/5/14
to mezzani...@googlegroups.com

I want to add a completely custom profile page. How do I do this?

The off-the-shelf option that Mezzanine gives us is to, as far as I can tell, create a Link page to /users/. That gives you the default profile.

I know very little about Mezzanine, so at the moment the best I could do would be to

a) in models.py create a ProfilePage subclass off Page with no Fields.

b) take the accounts_profile.html template, copy it to myapp/templates/page/accounts_profile.html, and make the necessary modifications

c) create the necessary page_processor to add context.

This solution looks extremely ugly to me, especially step a). Alright, at least I will have to write a page_processor to add the context (step b), and I will also have to write the template itself (step c), but seing as how apparently Mezzanine already knows how to draw pages for Profiles without the necessity for a ProfilePage, is it possible to avoid step a)?

EDIT:

Maybe I can simply define a django-type view and urls and add it to the Content as a Link page. Is that acceptable?

Josh Cartmell

unread,
Feb 5, 2014, 1:37:59 PM2/5/14
to mezzani...@googlegroups.com
Hey oneloop, Mezzanine's profiles don't use Pages at all.

They just use a normal Django view (https://bitbucket.org/stephenmcd/mezzanine/src/9b7a34c72bb3ec8ba6fa11d576b5d786c6d5b1f3/mezzanine/accounts/views.py?at=default#cl-100) that renders a template.  You can override that template to customize the look of profile pages.  You could also override the view to customize the functionality and render any template you want.  Is this what you had in mind?


--
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 mezzanine-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

oneloop

unread,
Feb 7, 2014, 7:45:56 AM2/7/14
to mezzani...@googlegroups.com
Yes, that is exactly what I had in mind!

But, how do I override a view (because I want to add custom context)? I know how to override a template, but a view?

Josh Cartmell

unread,
Feb 7, 2014, 12:19:36 PM2/7/14
to mezzani...@googlegroups.com
For a view, especially a simple one like the profile view, I would create a url in your own project that will match requests that Mezzanine's profile url would otherwise match.  Put it in your own project's urls before the mezzanine urls are included that way it will be matched and Mezzanine's will never be touched.  Then you can point it at any view you like.

Pseudo code:

url.py

      '/acounts/[username]/' - > your_custom_view # before Mezzanine's urls so that it is found first
      '^' -> Mezzanine urls
 

João Aparício

unread,
Feb 9, 2014, 12:24:05 PM2/9/14
to mezzani...@googlegroups.com
Ahhh I understand. Good trick. Yes, that's what I was looking for. Thanks a lot Josh :-)


--
You received this message because you are subscribed to a topic in the Google Groups "Mezzanine Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mezzanine-users/d6Te48S6aUg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mezzanine-use...@googlegroups.com.

Josh Cartmell

unread,
Feb 10, 2014, 12:51:27 PM2/10/14
to mezzani...@googlegroups.com
No problem, glad you got it ;)
Reply all
Reply to author
Forward
0 new messages