Can someone please explain how you can write a url pattern and view that allows optional parameters? I've done this successfully, but I always break the url template tag.
Here's what I have currently:
Pattern
(r'^so/(?P<required>d+)/?(?P<optional>(.*))/?$', 'myapp.so')
View
def so(request, required, optional):
If I use the url template tag in this example providing both arguments, it works just fine; however, if I omit the optional argument, I get a reversing error.
How can I accomplish this?
Thanks,
Pete
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…