Browse Source

fix to new installs

Roberto Berto 5 years ago
parent
commit
09a1f988e1
2 changed files with 7 additions and 1 deletions
  1. 2 0
      vycenter/config/views.py
  2. 5 1
      vycenter/vyos.py

+ 2 - 0
vycenter/config/views.py

@@ -29,6 +29,8 @@ def instances(request):
     all_instances = vyos.instance_getall()
     hostname_default = vyos.get_hostname_prefered(request)
 
+    if hostname_default == None:
+        return redirect('config:instance-add')
 
     template = loader.get_template('config/instances.html')
     context = { 

+ 5 - 1
vycenter/vyos.py

@@ -50,7 +50,11 @@ def get_hostname_prefered(request):
         
 
     if hostname == None:
-        instance = Instance.objects.get(main=True)
+        try:
+            instance = Instance.objects.get(main=True)
+        except Instance.DoesNotExist:
+            return None
+
         hostname = instance.hostname
 
     return hostname