Skip to content

Commit 9c36c2d

Browse files
author
Mark Gibbs
committed
First steps towards an app model
1 parent e44daad commit 9c36c2d

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

django_plotly_dash/admin.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
from django.contrib import admin
22

3-
from .models import DashApp, DashAppAdmin
3+
from .models import (DashApp, DashAppAdmin,
4+
StatelessApp, StatelessAppAdmin,
5+
)
46

57
admin.site.register(DashApp, DashAppAdmin)
8+
admin.site.register(StatelessApp, StatelessAppAdmin)
69

django_plotly_dash/models.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,25 @@
77

88
import json
99

10+
class StatelessApp(models.Model):
11+
'''
12+
A stateless Dash app. An instance of this model represents a dash app witout any specific state
13+
'''
14+
app_name = models.CharField(max_length=100, blank=False, null=False, unique=True)
15+
slug = models.SlugField(max_length=110, unique=True, blank=True)
16+
17+
def __str__(self):
18+
return self.app_name
19+
20+
def save(self, *args, **kwargs):
21+
if not self.slug or len(self.slug) < 2:
22+
self.slug = slugify(self.app_name)
23+
return super(StatelessApp, self).save(*args,**kwargs)
24+
25+
class StatelessAppAdmin(admin.ModelAdmin):
26+
list_display = ['app_name','slug',]
27+
list_filter = ['app_name','slug',]
28+
1029
class DashApp(models.Model):
1130
'''
1231
An instance of this model represents a dash application and its internal state

0 commit comments

Comments
 (0)