Coverage for apps / core / models.py: 100%

14 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-01-11 00:40 +0000

1from django.db import models 

2 

3 

4class AppSettings(models.Model): 

5 """Singleton model for application-wide settings.""" 

6 

7 openrouter_api_key = models.CharField(max_length=500, blank=True) 

8 default_ai_model = models.CharField( 

9 max_length=100, default='anthropic/claude-3.5-haiku' 

10 ) 

11 

12 class Meta: 

13 verbose_name = 'App Settings' 

14 verbose_name_plural = 'App Settings' 

15 

16 def save(self, *args, **kwargs): 

17 self.pk = 1 # Enforce singleton 

18 super().save(*args, **kwargs) 

19 

20 @classmethod 

21 def get(cls): 

22 """Get or create the singleton instance.""" 

23 obj, _ = cls.objects.get_or_create(pk=1) 

24 return obj 

← Back to Dashboard