Skip to content

URLField serializer is not playing nice with "built in" test server address http://testserver #9705

Discussion options

You must be logged in to vote
  • if I got it right such validation stems from DJANGO itself, so should it be checked/fixed there?

It does. I was able to reproduce the problem with a simpler test case:

from django.core.validators import URLValidator

def test_url_validator():
    validator = URLValidator()
    assert validator("http://testserver/path") is None  # fails
  • any way to workaround?

Change the base URL to something with a TLD? I usually have a constant in my settings to be able to switch it between test/dev/staging/prod. Django has the standard MEDIA_URL for media file, you can make up your own to fit your use case. This testserver doesn't come from DRF either, it's vanilla Django too.

Not much specific t…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@browniebroke
Comment options

@yarikoptic
Comment options

Comment options

You must be logged in to vote
1 reply
@yarikoptic
Comment options

Answer selected by browniebroke
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #9704 on May 21, 2025 07:26.