#16406: Allow separate access to matches from urlpatterns and extra_context args
-------------------------------------+-------------------------------------
     Reporter:  Florian Apolloner    |                    Owner:  Alexandre
         Type:                       |  Prieto Pantoja
  Cleanup/optimization               |                   Status:  assigned
    Component:  Core (URLs)          |                  Version:  dev
     Severity:  Normal               |               Resolution:
     Keywords:  resolvers, reverse   |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Alexandre Prieto Pantoja):

 Hello,

 I'am trying to figure out the context of this ticket but I am rather stuck
 on the resolution until now.

 I reproduced the use case with the information in the ticket. My code is
 now the is the following:


 == views.py file:
 {{{
 #!python
 def homepage(request, *args, **kwargs):l
     links = []
     langs = settings.LANGUAGES
     match = resolve(request.path)

     for lang in langs:
         with translation.override(lang[0]):
             links.append(reverse(match.url_name, args=match.args,
 kwargs=match.kwargs))

     message = _('Welcome to our site!')

     return render(request, 'ticket_16406/homepage.html', {'message':
 message, 'links':links})
 }}}


 == url.py file:

 {{{
 #!python
 from django.conf.urls.i18n import i18n_patterns
 from django.contrib import admin
 from django.urls import path, re_path
 from django.utils.translation import gettext_lazy as _
 from ticket_16406 import views


 urlpatterns = [
     path(_('admin/'), admin.site.urls),
 ]
 urlpatterns += i18n_patterns(
     re_path(_(r'^home/(?P<slug>[\w-]+)/$'), views.homepage, {'extra':
 True}, name="homepage"),
 )

 }}}



 == template
 {{{

     {% for link in links %}
         <a href={{link}}>{{link}}</a>
     {% endfor %}
 }}}

 I have access to content in different languages in my template.

 I don't find the problem I have to tackle here.

 Could you give me  more information/details on  "why the patch no longer
 applies cleanly"?

 It would be a great help. Thanks!

-- 
Ticket URL: <https://code.djangoproject.com/ticket/16406#comment:11>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.088dc6c14f4d639fdf810dd8eb7b3fa4%40djangoproject.com.

Reply via email to