[Django]-Why can't django's reverse() match an email parameter?

2👍

The problem is not the @, it is the .. That’s because the default regex the DRF router uses for parameters is [^/.]+, which specifically excludes dots.

You should be able to override this by setting lookup_value_regex on the viewset:

class UserViewSet(ModelViewSet):
    lookup_field = 'email'
    lookup_value_regex = r'[^/]+'

Leave a comment