Steps with explanations to set up a server using:
- virtualenv
- Django
- nginx
- uwsgi
# coding: utf-8 | |
#By turicas: https://gist.github.com/4288101 | |
import io | |
import unicodedata | |
from Tkinter import * | |
# -*- coding: utf-8 -*- | |
import os | |
from django.core.mail import get_connection | |
from django.core.mail.message import EmailMessage | |
from django.conf import settings | |
from django.contrib.sites.models import Site | |
from django.template import Context, RequestContext | |
from django.template.loader import get_template | |
from django.core.exceptions import PermissionDenied | |
from django.contrib import admin | |
from crm.models import Customer | |
class ReadPermissionModelAdmin(admin.ModelAdmin): | |
def has_change_permission(self, request, obj=None): | |
if getattr(request, 'readonly', False): | |
return True | |
return super(ReadPermissionModelAdmin, self).has_change_permission(request, obj) |
<div class="control-group"> | |
<label class="control-label">Location</label> | |
<div class="controls"> | |
<input name="location" type="text" placeholder="City, State, Country" value=""> | |
<input name="location_city" type="hidden" value=""> | |
<input name="location_state" type="hidden" value=""> | |
<input name="location_country" type="hidden" value=""> | |
<input name="location_lat" type="hidden"> | |
<input name="location_lng" type="hidden"> | |
</div> |
WeasyPrint converts HTML including images to PDF, it's cross platform but Windows requires a decent amount of massaging to persuade it to work.
To install Pango and Cairo download the [all in one bundle][GTK] of the GTK+ stack and extract the archive to C:\GTK.
You'll need to add the GTK bin folder to your system path so the various
# coding: utf-8 | |
u""" | |
Redimensionamento proporcional de imagem, com base na altura, feito com um simples cálculo de proporção. | |
Ex: | |
+------+ 10 15 (altura desejada para a nova imagem) | |
| | -- x -- | |
| 10x5 | 5 x (largura proporcional a nova altura) | |
| | | |
+------+ (10 x x) = (5 x 15) | |
10x = 75 |
from django.template.defaultfilters import slugify | |
class AutoSlugMixin(object): | |
""" | |
Automatically set slug to slugified version of the name if left empty. | |
Use this as follows:: | |
class MyModel(AutoSlugMixin, models.Model): | |
def save(self): | |
super(MyModel, self).save() |
{% load core_utils %} | |
<ul id="tags" class="nav nav-tabs nav-stacked"> | |
{% for tag in tags %} | |
{% if tag_full_list|list_count:tag %} | |
<li> | |
<a href="{% url "post:posts-tagged-related" tag.slug %}"> | |
{{ tag.name }} <span class="label label-info">{{ tag_full_list|list_count:tag }}</span> | |
</a> | |
</li> |