I want to create a many-to-many relationship where one person can be in many clubs and one club can have many persons. I added the models.py and
many-to-many
models.py
You can simply pass None to 'request' key in context in situations where you just need the relative URL, e.g; testing a serializer in command line.
None
'request'
context
serializer = YourModelSerializer(modelInstance_or_obj, context={'request': None})