Thank you! Just checked it, looks really what i mean.
Will check this library more deep. First comment from developers site http://codysoyland.com/2009/sep/6/introduction-surlex/ >> This is pretty cool. You should build this as a drop-in into django! :-) Write clean regular expressions i think is little bit hard for some part of django users, because regexp is not simple for some developers. If allow users use url predefined patterns out of the box users will appreciate it i think. -- Alexandr Shurigin From: Bleier Sean [email protected] Reply: [email protected] [email protected] Date: 29 мая 2014 г. at 0:01:43 To: [email protected] [email protected] Subject: Re: Make url patterns group kwargs more simple You might want to check out Surlex[1], written by Cody Soyland. It basically does what you want. [1] http://codysoyland.com/projects/surlex/documentation/ On Wed, May 28, 2014 at 8:54 AM, Alexandr Shurigin <[email protected]> wrote: Hi all. What do you think about adding some extra default and more simpler syntax for url patterns? Now patterns looks little bit difficult, especially if you have long urls with 2-3 params. For example take a look into url. url(r'^(?P<slug_genre>[^/]+)/(?P<slug>[^/]+)/news/(?P<slug_item>[^/]+)$', views.GameNewsItem.as_view(), name="view_news_view") This is ‘good seo url’ for big project. This url have game genre, game slug name, /news/ and news slug name. For example this matches path /arcade/pacman/news/new-update-2014/ This is pretty cool when site have such urls and support all url subpaths, user can simple remove some path in url and go other pages of site catalog structure. In presented example i wanted to show you this url entry shard to read (but not so difficult to write) when you supporting your project. When you have about 20-30 same style urls in one file, this makes your urls file unreadable :) Maybe allow user enter url masks in simpler way by adding some magic? For django is not problem make url regexps from string with ‘meta tags’ and process it way like it work now. But i think user will be really happy to enter simpler (and shorter!) urls. I mean we allow user only describe his urls simpler. For example in ruby on rails user can enter urls like get 'products/:id/purchase' => 'catalog#purchase', as: :purchase Where :id is just shortcut for regexp pattern group. I think we (or me, no difference) can do same way. We can do it 2 ways: 1. hardcode some usually used tags (for example id, day, year, slug, any other) and words built from them (for example we understand that :id and :product_id have the same path type ([0-9]+)). 2. Make library for registering such tags like template tag library and add rules from #1 to it. Allowing way for users to extend library tags with their own. Using this way, we can get very simple and fancy urls. For example my game news url will look like: url(r’^:slug_genre/:slug/news/:slug_item$', views.GameNewsItem.as_view(), name="view_news_view") This will make urls very short, fast-readable and writable. Also we can skip in pattern masks ?P, for example from url pattern (<slug_genre>[^/]+) we can simple compile (?P<slug_genre>[^/]+) I think a lot of users will appreciate this feature. What you think? Django urls are not simple right now for users and looks little ugly, because 99% users reuse standard types of masks (id like - [0-9]+, slug like - [a-z0-9]+, year [0-9]{4}, month [0-9]{2}, day [0-9]{2}). But of course user can combine url shortcuts with their custom regexps. -- Alexandr Shurigin -- You received this message because you are subscribed to the Google Groups "Django developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/etPan.5386069d.57e4ccaf.406%40MacBook-Pro-dude.local. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Django developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAKFtT_0KEgdyusp%3DhSn0z361zp%3DQvsy0f3-AOgi0UncveNNdsQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Django developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/etPan.53861a3b.3dc240fb.406%40MacBook-Pro-dude.local. For more options, visit https://groups.google.com/d/optout.
