From 9545b0ec1fe1f9efeef5ed66d91838796a30f70b Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Date: Mon, 26 Nov 2018 09:50:53 +0100 Subject: [PATCH] Fix incorrect 1-to-1 relationship --- manager/migrations/0006_auto_20181126_0849.py | 19 +++++++++++++++++++ manager/models.py | 2 +- manager/templates/base.html | 10 +++++++--- manager/templates/manager/index.html | 9 ++++++++- 4 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 manager/migrations/0006_auto_20181126_0849.py diff --git a/manager/migrations/0006_auto_20181126_0849.py b/manager/migrations/0006_auto_20181126_0849.py new file mode 100644 index 0000000..3f73d92 --- /dev/null +++ b/manager/migrations/0006_auto_20181126_0849.py @@ -0,0 +1,19 @@ +# Generated by Django 2.1.3 on 2018-11-26 08:49 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('manager', '0005_device_lasttime'), + ] + + operations = [ + migrations.AlterField( + model_name='device', + name='network', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='manager.Network'), + ), + ] diff --git a/manager/models.py b/manager/models.py index a1f1d6a..a383707 100644 --- a/manager/models.py +++ b/manager/models.py @@ -24,7 +24,7 @@ class Device(models.Model): serial = models.CharField("Device Serial Number", max_length=12, unique=True) name = models.CharField("Common Name", max_length=100, blank=True, null=True) organization = models.ForeignKey(Organization, on_delete=models.CASCADE) - network = models.OneToOneField(Network, on_delete=models.SET_NULL, blank=True, null=True) + network = models.ForeignKey(Network, on_delete=models.SET_NULL, blank=True, null=True) curip = models.CharField("Current IP Address", max_length=15, blank=True, null=True) lasttime = models.DateTimeField("Last Received Heartbeat", blank=True, null=True) secret = models.CharField("Secret", default=getRandom, max_length=128) diff --git a/manager/templates/base.html b/manager/templates/base.html index b9eb5f1..caa7176 100644 --- a/manager/templates/base.html +++ b/manager/templates/base.html @@ -12,6 +12,13 @@ + + + + + + @@ -53,9 +60,6 @@ - - - diff --git a/manager/templates/manager/index.html b/manager/templates/manager/index.html index 6687c80..fc8a7d5 100644 --- a/manager/templates/manager/index.html +++ b/manager/templates/manager/index.html @@ -6,7 +6,7 @@

User: {{ user.firstname }} {{ user.lastname }} ({{ user.username }})

- +
@@ -32,4 +32,11 @@
Device ID
+ + + {% endblock %}