-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Substitute Category model #34
Comments
Yeah, It can be done without many problems. However, you have to consider that you will need to modify the default templates and the entries filters in routes.py |
Thanks for your prompt reply!
Best, |
@route(r'^category/(?P<category>[-\w]+)/$')
def entries_by_category(self, request, category, *args, **kwargs):
self.search_type = _('category')
self.search_term = category
self.entries = self.get_entries().filter(entry_categories__category__slug=category)
return Page.serve(self, request, *args, **kwargs)
class CategoryEntryPage(models.Model):
category = models.ForeignKey(Category, related_name="+", verbose_name=_('Category')) |
Thank you very much Marc! Fabio |
Yeah, why not? I have to study this feature and implement it in the cleaner way. |
Great! I stay tuned then :-) |
Hi Marc, I made the following patches and anything seems to work:
CategoryModel = import_model(getattr(settings, 'PUPUT_CATEGORY_MODEL', CategoryDefault))
@register_snippet
class Category(CategoryModel):
objects = CategoryManager()
class Meta:
proxy = True
if hasattr(Category, 'parent'):
categories = Category.objects.with_uses(blog_page).filter(parent=None)
else:
categories = Category.objects.with_uses(blog_page).all() Do you have any kind of suggestions? Fabio |
👍
Nice approach, but I think it will be better a pattern like
👍 |
Thanks Mark! |
@fab10m any news regarding this issue? |
Hi, @marctc I've no news. I'm stiill in the same situation of 5 months ago. Allora works fine, so I decided not to touch anything :-) |
Hi,
is there anyway substitute the puput category model with a custom one?
I'm trying to install puput over an existing django project. All has gone very well, but my project already has his own category model that can't be substitute.
Best,
Fabio
The text was updated successfully, but these errors were encountered: