Skip to content

Instantly share code, notes, and snippets.

View goinnn's full-sized avatar
🏠
Working remotely

Pablo Martín goinnn

🏠
Working remotely
View GitHub Profile
import re
from django.core.management.base import BaseCommand
from django.template import base, defaulttags
from django.template.loader import get_template
from django.template.base import TextNode
# Monkey patching
render_tags = ('block ', 'endblock ', 'extends ', 'include ')
BLOCK_TAG_START = []
@goinnn
goinnn / gist:5530987
Last active December 17, 2015 01:49 — forked from armonge/gist:2830057
import urlparse
import re
from django import forms
from django.db import models
from django.utils.translation import ugettext_lazy as _
def validate_youtube_url(value):
'''El patron lo saque de http://stackoverflow.com/questions/2964678/jquery-youtube-url-validation-with-regex'''
@goinnn
goinnn / form_process.py
Created October 26, 2012 11:10
Example the edit and add views to the form process
def content_add(request, template_name='content/content_add.html', extra_context=None):
extra_context = extra_context or {}
extra_context['submit'] = 'Add'
return content_edit(request, template_name=template_name, extra_context=extra_context)
def content_edit(request, content_id=None, template_name='content/content_edit.html', extra_context=None):
data = instance = None
extra_context = extra_context or {}
if request.method == 'POST':