mirror of
https://github.com/Django-LiveView/demo-alarms
synced 2026-01-08 06:23:32 +01:00
Real-time alert system using Django LiveView with WebSocket support. Features include: - Real-time alert creation, viewing, and deletion - Broadcast notifications to all connected users - SQLite database - Stimulus.js integration for interactive UI - Modal dialogs for alert details - Alert form with validation Fixed Stimulus controller scope issue by placing data-controller on html element.
20 lines
483 B
Python
20 lines
483 B
Python
from django.db import models
|
|
|
|
|
|
class Alert(models.Model):
|
|
ALERT_TYPES = [
|
|
('INFO', 'Info'),
|
|
('WARNING', 'Warning'),
|
|
('CRITICAL', 'Critical'),
|
|
]
|
|
|
|
type = models.CharField(max_length=10, choices=ALERT_TYPES)
|
|
description = models.TextField(blank=True, default='')
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
|
|
class Meta:
|
|
ordering = ['-created_at']
|
|
|
|
def __str__(self):
|
|
return f"{self.type} - {self.created_at}"
|