Fix incorrect 1-to-1 relationship

This commit is contained in:
Kumi 2018-11-26 09:50:53 +01:00
parent 669132b282
commit 9545b0ec1f
4 changed files with 35 additions and 5 deletions

View file

@ -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'),
),
]

View file

@ -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)

View file

@ -12,6 +12,13 @@
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
<!-- link href="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.12/css/dataTables.bootstrap4.min.css" rel="stylesheet"/ --!>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.bundle.min.js"></script>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.12/js/jquery.dataTables.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.13/js/dataTables.bootstrap4.min.js"></script> -->
</head>
@ -53,9 +60,6 @@
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.bundle.min.js"></script>
</body>
</html>

View file

@ -6,7 +6,7 @@
<p><b>User:</b> {{ user.firstname }} {{ user.lastname }} ({{ user.username }})</p>
<div class="table-responsive">
<table id="table" class="table">
<table id="table" name="table" class="table">
<thead>
<tr>
<th>Device ID</th>
@ -32,4 +32,11 @@
</table>
</div>
<script>
/* $(document).ready(function() {
$('#table').DataTable();
}); */
</script>
{% endblock %}