Need help with Django URL string parameter pattern in Python

0 votes

Hi all, 

I am aware that the Django URL pattern consists of the following number of parameters:

url(r'^polls/(?P<poll_id>\d+)/$', 'polls.views.detail')

My question is pretty simple - What would be the right way of using the code if the poll_id, in this case, turns to be NaN but an actual character string with certain data in it?

How can I go about this? All help appreciated!

Jan 28 in Python by Anirudh
• 2,070 points
46 views

1 answer to this question.

0 votes

Good question. The solution to this short problem is small as well.

It all comes down to what characters you plan to use in your particular program. After referring to the official documentation you can make use of \w

This basically gives you an underscore or even an alphanumeric character that you can make use of to serve the purpose

Hope this helped!

answered Jan 28 by Nymeria
• 3,520 points

Related Questions In Python

0 votes
1 answer

Need help with Tkinter window formatting using Python

Tkininter comes with the columnspan argument to span the labels ...READ MORE

answered Sep 7, 2018 in Python by ariaholic
• 7,340 points
48 views
0 votes
1 answer

How should I write tests for Forms in Django with Python?

from django.tests import TestCase class MyTests(TestCase): ...READ MORE

answered Nov 20, 2018 in Python by Nymeria
• 3,520 points
41 views
+1 vote
1 answer

Need some help with Python memory leaks

As far as best practices, keep an ...READ MORE

answered Nov 26, 2018 in Python by Nymeria
• 3,520 points
33 views
0 votes
1 answer

How to parse date/time string with timezone abbreviated name in Python?

The parse() function in dateutil can't handle ...READ MORE

answered Nov 27, 2018 in Python by Nymeria
• 3,520 points
225 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Need help with making use of Pluck in Python

Hi, good question. Easy solution to be ...READ MORE

answered Jan 24 in Python by Nymeria
• 3,520 points
125 views