Ok, I've done it this way and it worked fine.
urlpatterns = [
url(r'^ingredients/', include("apps.ingredients.urls")),
]
urlpatterns += i18n_patterns(
# Change the admin prefix here to use an alternate URL for the
# admin interface, which would be marginally more secure.
url("^admin/", include(admin.site.urls)),
)
Il giorno sabato 9 settembre 2017 21:52:36 UTC+2, Rainell Dilou Gómez ha
scritto:
>
> I created a view for my model, with the corresponding urls and template
> files. Then, in the admin panel, I have created a Rich text page,
> specifying the same URL (ingredients) defined in urlpatterns. Mezzanine
> ignores the view, displays the template but does not pass the context.
> Please help, how can I solve that?
>
> *models.py*
> from django.db import models
> from mezzanine.pages.models import Page
> from django.utils.translation import ugettext_lazy as _
>
> class Ingredient(Page):
> name = models.CharField(max_length=60)
> information = models.TextField(null=True, blank=True, verbose_name=_(
> "Description"))
>
> *views.py*
>
> from django.shortcuts import render
> from .models import Ingredient
>
> def ingredients(request):
> ingredients = Ingredient.objects.all().order_by('name')
> return render(request, 'pages/ingredients.html', {'ingredients':
> ingredient
>
>
>
> *urls.py*
> from django.conf.urls import url
> from .views import ingredients
>
> urlpatterns = [
> url("^$", ingredients, name="ingredients"),
> ]
>
> *NOTE: *I have also tested with TemplateResponse and it also did not work:
> from django.template.response import TemplateResponse
> from .models import Ingredient
>
> def ingredients(request):
> ingredients = Ingredient.objects.all().order_by('name')
> templates = ["pages/ingredients.html"]
> return TemplateResponse(request, templates, {'ingredients':ingredients
> })
>
>
>
--
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.