Let's suppose I have this model
class Example(models.Model):
FirstName = models.CharField(max_length=100)
LastName = models.CharField(max_length=100)
And wanted that after the user fills the model to redirect to an url with the format
localhost/FirstName-Lastname
What would I need to write in the urls.py file?
You will need an url like this:
url(r'^(?P<first_name>\w+)-(?P<last_name>\w+)/$', views.your_view),
You can see docs here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.