$('.form-input-text').blur(function() {
$(this).parent().toggleClass('active');
});
from django import template
from django.utils.safestring import mark_safe
register = template.Library()
class RenderNode(template.Node):
def __init__(self, content):
self.content = content
def render(self, context):
try:
self.content = template.resolve_variable(self.content, context)
return template.Template(self.content).render(template.Context(context, autoescape=False))
except template.TemplateSyntaxError as e:
return mark_safe("<strong>Template error: There is an error one of this page's template tags: <code>%s</code></small>" % e.message)
@register.tag(name='render')
def render_django(parser, token):
content = token.split_contents()[-1]
return RenderNode(content)
render_django.is_safe = True
{% render flatpage.content %}
class Category(mptt.models.MPTTModel):
parent = mptt.models.TreeForeignKey('self', null=True, blank=True, related_name='children')
title = models.CharField(max_length=50)
def save(self, *args, **kwargs):
if parent.level == 3:
raise ValueError(u'Достигнута максимальная вложенность!')
super(Category, self).save(*args, **kwargs)
jQuery(document).ready(function() {
var id = jQuery("div.vc_tta-panel.vc_active").attr("id");
jQuery(".page-numbers").each(function() {
var href = jQuery(this).attr('href');
if(href && href.indexOf('#') != -1)
href = href.substring(0, href.indexOf('#'));
jQuery(this).attr('href', href + '#' + id);
});
});
def getError(user):
local_gettext = gettext.translation('myapplication', languages=[user.get_lang()])
_ = local_gettext.ugettext
return _('Error')
var form = document.getElementById('some-form');
var button = document.getElementById('submit-button');
var inputs = form.getElementsByTagName('input');
button.addEventListener('click', function(e) {
for(var i=0; i < inputs.length; i++) {
var input = inputs[i];
if(!input.value)
e.preventDefault();
}
});
lambda x, (y, z): x | (z << y)
заменить на lambda x, yz: x | (yz[1] << yz[0])
. Распаковка картежей в параметрах была убрана из python 3 в соответствии с PEP 3113. import requests
from xml.etree import ElementTree as ET
response = requests.get('http://site.com/api/', stream=True)
tree = ET.fromstring(response.content)
for currency in tree.findall('currency'):
title = currency.find('title_alias').text
print(title)
rates = currency.find('rates')
print('\tBuy: ' + rates.find('buy_rate').text)
print('\tSell: ' + rates.find('sell_rate').text)