1👍
First question:
url(r'^doctor/(?P<name>\w+)/$', views.showDocProfileByName),
Second question:
def showDocProfileById(request, id):
doctor = Doctor.objects.get(id=id)
name = doctor.name.replace(' ', '-')
HttpResponseRedirect(reverse('project.views.showDocProfileByName', args=(name)))
👤torm
0👍
You could just allow the user to input either id or doctor name
url(r'^docprofile/(?P<identifier>(\d+|\w+))', views.showDocProfile, name='showDocProfile')
👤Greg
- [Answer]-Validate Django Choices with Accents in ModelForms
- [Answer]-Breaking form fields up separately django
Source:stackexchange.com