Is unquestionably a url problem, I have made a test, where I include my 
application folder inside mezzanine, as a mezzanine app, at the same level 
of blog, gallery, etc.. Then I have added my application urls file to the 
*mezzanine/urls.py* urlpattern

urlpatterns = [
    # url(r'^ingredients/', include("mezzanine.ingredients.urls")),
]

it has worked!!
Then I wonder why it does not work when my application is inside the folder 
of my project "*my_project_folder/apps/ingredients*" and the file urls.py 
of the app is included in the project urls.py urlpattern

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)),
    url(r'^ingredients/', include("apps.ingredients.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 mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to