add routing template field to peer model

This commit is contained in:
Eduardo Silva
2026-01-22 12:55:06 -03:00
parent ee4674d6fe
commit d378b62c49
2 changed files with 25 additions and 2 deletions

View File

@@ -0,0 +1,20 @@
# Generated by Django 5.2.9 on 2026-01-22 15:52
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('routing_templates', '0002_routingtemplate_enforce_route_policy'),
('wireguard', '0027_alter_wireguardinstance_peer_list_refresh_interval'),
]
operations = [
migrations.AddField(
model_name='peer',
name='routing_template',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='peers', to='routing_templates.routingtemplate'),
),
]

View File

@@ -1,7 +1,7 @@
from django.core.exceptions import ValidationError
from django.db import models
import uuid
from django.db import models
NETMASK_CHOICES = (
(8, '/8 (255.0.0.0)'),
(9, '/9 (255.128.0.0)'),
@@ -82,6 +82,9 @@ class Peer(models.Model):
persistent_keepalive = models.IntegerField(default=25)
wireguard_instance = models.ForeignKey(WireGuardInstance, on_delete=models.CASCADE)
sort_order = models.IntegerField(default=0)
routing_template = models.ForeignKey(
'routing_templates.RoutingTemplate', on_delete=models.SET_NULL, blank=True, null=True, related_name='peers'
)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)