Steps with explanations to set up a server using:
- virtualenv
- Django
- nginx
- uwsgi
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) |
# -*- 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 | |
# coding: utf-8 | |
#By turicas: https://gist.github.com/4288101 | |
import io | |
import unicodedata | |
from Tkinter import * | |
<?php | |
class JConfig { | |
/* Site Settings */ | |
public $offline = '0'; | |
public $offline_message = 'This site is down for maintenance.<br /> Please check back again soon.'; | |
public $sitename = ''; | |
public $editor = 'tinymce'; | |
public $list_limit = '10'; | |
public $legacy = '0'; | |
/* Debug Settings */ |
# API JSON | |
from django.http import HttpResponse | |
from django.utils import simplejson | |
from django.views.generic.detail import BaseDetailView | |
from django.views.generic.list import BaseListView | |
from django.db.models.query import QuerySet | |
class JSONResponseMixin(object): | |
def render_to_response(self, context): | |
return self.get_json_response(self.convert_context_to_json(context)) |
#-*-coding: utf-8 -*- | |
''' | |
This module represents the FriendsRecommender system for recommending | |
new friends based on friendship similarity and state similarity. | |
''' | |
__author__ = 'Marcel Caraciolo <[email protected]>' |
/* The code below should be included in a separate file using IE conditional comments | |
as it causes errors in IE8(+?) */ | |
/** | |
* DD_belatedPNG: Adds IE6 support: PNG images for CSS background-image and HTML <IMG/>. | |
* Author: Drew Diller | |
* Email: [email protected] | |
* URL: http://www.dillerdesign.com/experiment/DD_belatedPNG/ | |
* Version: 0.0.8a | |
* Licensed under the MIT License: http://dillerdesign.com/experiment/DD_belatedPNG/#license |
# forms.py | |
class UserProfileForm(forms.ModelForm): | |
class Meta: | |
model = UserProfile | |
exclude = ('user',) | |
class UserForm(UserCreationForm): | |
def __init__(self, *args, **kwargs): | |
super(UserForm, self).__init__(*args, **kwargs) |
from django.views.generic import ListView | |
from django.views.generic.edit import FormMixin | |
from django.db.models import Q | |
class SearchView(FormMixin, ListView): | |
template_name_suffix = '_search' | |
filter_operator = 'contains' | |
allow_or_operator = False | |
def get_filter_operator(self): |