Skip to content

Commit

Permalink
Merge pull request #2546 from johannaengland/related-names-6
Browse files Browse the repository at this point in the history
Add related names to django models (macwatch)
  • Loading branch information
johannaengland committed Feb 22, 2023
2 parents 3b40ba2 + 7973473 commit ec18ec9
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions python/nav/web/macwatch/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ class MacWatch(models.Model):
# TODO: Create MACAddressField in Django
mac = models.CharField(db_column='mac', max_length=17, unique=True)
userid = models.ForeignKey(
Account, on_delete=models.CASCADE, db_column='userid', null=False
Account,
on_delete=models.CASCADE,
db_column='userid',
null=False,
related_name="mac_watches",
)
description = VarcharField(db_column='description', null=True)
created = models.DateTimeField(db_column='created', auto_now_add=True)
Expand Down Expand Up @@ -75,9 +79,19 @@ class MacWatchMatch(models.Model):

id = models.AutoField(db_column='id', primary_key=True)
macwatch = models.ForeignKey(
MacWatch, on_delete=models.CASCADE, db_column='macwatch', null=False
MacWatch,
on_delete=models.CASCADE,
db_column='macwatch',
null=False,
related_name="mac_watch_matches",
)
cam = models.ForeignKey(
Cam,
on_delete=models.CASCADE,
db_column='cam',
null=False,
related_name="mac_watch_matches",
)
cam = models.ForeignKey(Cam, on_delete=models.CASCADE, db_column='cam', null=False)
posted = models.DateTimeField(db_column='posted', auto_now_add=True)

class Meta(object):
Expand Down

0 comments on commit ec18ec9

Please sign in to comment.