create migration for snippets models

This commit is contained in:
ergz 2022-07-24 10:14:13 -07:00
parent 33992fc25f
commit 18b241ed3b
2 changed files with 40 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@ -4,8 +4,17 @@ from pygments.lexers import get_all_lexers
from pygments.styles import get_all_styles
LEXERS = [item for item in get_all_lexers() if item[1]]
LANG_CHOICES = sorted([(item[1][0], item[1]) for item in LEXERS])
LANG_CHOICES = sorted([(item[1][0], item[0]) for item in LEXERS])
STYLE_CHOICES = sorted([(item, item) for item in get_all_styles()])
class Snippet(models.Model):
created = models.DateTimeField(auto_now=True)
created_at = models.DateTimeField(auto_now=True)
title = models.CharField(max_length=100, blank=True, default="")
code = models.TextField()
line_numbers = models.BooleanField(default=False)
language = models.CharField(choices=LANG_CHOICES, default="python", max_length=100)
style = models.CharField(choices=STYLE_CHOICES, default="friendly", max_length=100)
class Meta:
ordering = ["created_at"]