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,050 points
24 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,500 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,320 points
31 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,500 points
16 views
0 votes
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,500 points
15 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,500 points
99 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,500 points
44 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.