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
并希望在用户填写模型后重定向到具有该格式的URL
localhost/FirstName-Lastname
What would I need to write in the urls.py file?
我需要在urls.py文件中写什么?
1 个解决方案
#1
1
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
你可以在这里看到文档
#1
1
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
你可以在这里看到文档