That default
argument must point to a callable, not a function call with arguments (which are only evaluated once when Django starts). You need to write your own wrapper function and refer to that instead. For example:
def my_secret():
return secrets.token_urlsafe(32)[:32] # Return only the first 32 characters.
#...
token=models.CharField(max_length=32, default=my_secret)
Refer to this answer: https://stackoverflow.com/a/12654998/4082726
Regarding the length: token_urlsafe
's argument is the number of bytes, not characters. According to the documentation this means roughly 1.3 characters per byte, so 32 * 1.3 = ~42.