Q:

Django urls -> {n,m} type restriction and .format()

i' m trying to have a url pattern which contains a
\d{3}

type restriction, and a 
.format()

string substitution. Separated they' re working fine, but together doesn' t. The first 2 lines are working, but the problem is the 3rd line:
url(r'(?P<id>\d+)/(?P<phase>\w+)/(?P<required_start>\d{3})/$', 'sceduler.views.reserve_slot'),
url(r'(?P<id>\d+)/(?P<phase>{PHASE_STR})/(?P<required_start>\d+)/$'.format(PHASE_STR = PHASE_STR), 'sceduler.views.reserve_slot'),
url(r'(?<Pid>\d+)/(?P<phase>{PHASE_STR})/(?P<required_start>\d{3})/$'.format(PHASE_STR = PHASE_STR), 'sceduler.views.reserve_slot'),

.
Any idea how to overcome on this?
Thanks.

A:

replacing \d{3} with \d{{3}} should do the trick, but I'm not sure why you're formatting urls like that

