Skip to content

Instantly share code, notes, and snippets.

@denisorehovsky
denisorehovsky / fields.py
Created April 1, 2018 09:17
AutoSlugField
from django.db import models
from slugify import slugify
class AutoSlugField(models.CharField):
def __init__(self, populate_from, *args, always_update=False,
to_lower=False, max_length=50, **kwargs):
self.populate_from = populate_from
self.always_update = always_update
@denisorehovsky
denisorehovsky / prism-showdown.js
Last active September 28, 2016 07:19
Markdown and syntax highlighting
/*
jquery.min.js, showdown.min.js, prism.js and prism.css must be loaded
The container that will hold markdown should be have the class
'content-markdown'.
Place code in between:
1. $$name_of_language$$ code_goes_here $$end$$ (inline-code)
2. $name_of_language$ code_goes_here $end$ (block-code)
E.g.
@denisorehovsky
denisorehovsky / template.html
Created August 16, 2016 10:44
Create list and get random number in Django template
{{ rand|add:'123456'|make_list|random }}