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, 2019 in Python by Anirudh
• 2,090 points
854 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, 2019 by Nymeria
• 3,560 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 aryya
• 7,460 points
862 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,560 points
1,403 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,560 points
954 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,560 points
2,219 views
–1 vote
1 answer
0 votes
1 answer

Need help checking the validity of an image file in Python

I went through the Python documentation and ...READ MORE

answered Jan 18, 2019 in Python by Nymeria
• 3,560 points
2,244 views
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, 2019 in Python by Nymeria
• 3,560 points
1,666 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP