You can use path or re_path
 path for normal urls
 re_path for urls containing regular expressions

urlpatterns = [

path('index' , views.index , name='index)

re_path('index/[a-z]*w/' , views.another_index , name='anotherIndex')



On Sat, 9 Nov 2019, 12:47 am Mdlr, <rockyourc...@hotmail.fr> wrote:

> I try to compile an old code in Django 1.4 Many things are deprecated. I
> manage to change some of them but I don't knwo how to go futher on the
> urls.py
>
> here is the old code
>
>
> *from django.conf.urls.defaults import *
> from django.conf import settings
>
> dynurls = patterns('minesweepr.views',
>     (r'^api/minesweeper_solve/$', 'api_solve'),
> )
>
> staticurls = patterns('minesweepr.views',
>     (r'^player/$', 'template_static'),
>     (r'^query/$', 'template_static'),
> )
>
> urlpatterns = patterns('',
>     ('^%s' % settings.BASE_URL, include(dynurls)),
>     ('^%s' % settings.BASE_STATIC_URL, include(staticurls)),
> )*
>
>
>
> I know django.conf.urls.defaults is deprecated and I tried to change the
> code like this
>
>
>
> *from django.conf.urls import url, include
> from django.conf import settings
>
> dynurls = ['minesweepr.views',
>     (r'^api/minesweeper_solve/$', 'api_solve'),
> ]
>
> staticurls = ['minesweepr.views',
>     (r'^player/$', 'template_static'),
>     (r'^query/$', 'template_static'),
> ]
>
> urlpatterns = ['',
>     ('^%s' % settings.BASE_URL, include(dynurls)),
>     ('^%s' % settings.BASE_STATIC_URL, include(staticurls)),
> **]*
>
> But it is not sufficient
> It is said my url patterns are invalid.
> Anybody has an idea ?
> Thank you
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f5ff4194-ae39-4020-ab80-9373ea19d15a%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/f5ff4194-ae39-4020-ab80-9373ea19d15a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHV4E-dopUZETcCid6%2BzzEB_NU6BRNi%2BN98hP2xjR03U22%2BsJg%40mail.gmail.com.

Reply via email to