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 django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
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.

Reply via email to