Self hosted FLOSS fitness/workout, nutrition and weight tracker
Only set the domain in site url
Roland Geider13e1b4979164
diff --git a/wger/core/management/commands/set-site-url.py b/wger/core/management/commands/set-site-url.pyindex d47f7f876..3ee98c1d7 100644--- a/wger/core/management/commands/set-site-url.py+++ b/wger/core/management/commands/set-site-url.py@@ -1,7 +1,15 @@+# Standard Library+from urllib.parse import urlparse+# Djangofrom django.conf import settingsfrom django.contrib.sites.models import Site-from django.core.management.base import BaseCommand+from django.core.exceptions import ValidationError+from django.core.management.base import (+ BaseCommand,+ CommandError,+)+from django.core.validators import URLValidator"""@@ -10,13 +18,21 @@ Sets the site URLclass Command(BaseCommand):-help = 'Sets the site URL from settings.SITE_URL, this is used e.g. for password reset emails'def handle(self, *args, **options):+ if not settings.SITE_URL:+ return++ try:+ val = URLValidator()+ val(settings.SITE_URL)+ except ValidationError:+ raise CommandError('Please set a valid URL for SITE_URL')+ domain = urlparse(settings.SITE_URL).netlocsite = Site.objects.get_current()- site.domain = settings.SITE_URL+ site.domain = domainsite.name = settings.SITE_URLsite.save()- self.stdout.write(self.style.SUCCESS(f"Set site URL to {settings.SITE_URL}"))+ self.stdout.write(self.style.SUCCESS(f"Set site URL to {domain}"))