Reputation: 8917
I'm trying to write an app that, among other things, will generate a list of dogs that are available for adoption.
At the moment when I try to generate that list I get the following error:
Reverse for 'dog' with arguments '()' and keyword arguments '{'dog_id': 3, 'name': 'Rex'}' not found. 1 pattern(s) tried: ['ForeverHomes/Dog/(?P<dog_id>\\d+)/(P?<name>[A-Za-z ]+)']
Which is being raise when Django tries to get the absolute url via:
def get_absolute_url(self):
return reverse('ForeverHomes:dog',
kwargs={"dog_id": self.dog_id,
"name": self.name},
current_app="ForeverHomes")
The pattern that it's trying to match is the correct pattern, but what I don't understand is how my Dog
object is ever meant to match to a regular expression. My Dog
objects all have a dog_id
and a name
, if that matters.
Upvotes: 0
Views: 372
Reputation: 599460
I don't know what you mean by "how my Dog object is ever meant to match to a regular expression".
Your problem is simply that you have a malformed regex: the ?
and the P
are the wrong way round in the name
group.
Upvotes: 1