This code is a sample for a question on Stackoverflow about making multisite user models with Django 1.7.
Add these lines to your settings file:
AUTH_USER_MODEL='s1.Member'
SITE_ID = 1
AUTHENTICATION_BACKENDS = ( 'MyApp.MyModule.MyModelBackend',)
var fs = require('fs'), | |
url = require('url'); | |
module.exports = function (rootDir, indexFile) { | |
indexFile = indexFile || "index.html"; | |
return function(req, res, next){ | |
var path = url.parse(req.url).pathname; | |
fs.readFile('./' + rootDir + path, function(err, buf){ |
var fs = require('fs'); | |
module.exports = function (urlRoot, pathRoot) { | |
pathRoot = pathRoot.replace(urlRoot, ''); | |
return function(req, res, next){ | |
if (req.url.indexOf(urlRoot) === 0) { | |
// Ignore querystrings | |
url = req.url.split('?')[0]; |
var date1 = new Date(2010, 6, 17); | |
var date2 = new Date(2013, 12, 18); | |
var diff = new Date(date2.getTime() - date1.getTime()); | |
// diff is: Thu Jul 05 1973 04:00:00 GMT+0300 (EEST) | |
console.log(diff.getUTCFullYear() - 1970); // Gives difference as year | |
// 3 | |
console.log(diff.getUTCMonth()); // Gives month count of difference | |
// 6 |
/** | |
* @ngdoc directive | |
* @name ng.directive:translate | |
* | |
* @element ANY | |
* | |
* @description | |
* | |
* Angular icin ceviri directive'i | |
* |
/** | |
* 0 User must enter a digit (0 to 9). | |
* 9 User can enter a digit (0 to 9). | |
* # User can enter a digit, space, plus or minus sign. If skipped, enters a blank space. | |
* L User must enter a letter. | |
* ? User can enter a letter. | |
* A User must enter a letter or a digit. | |
* a User can enter a letter or a digit. | |
* & User must enter either a character or a space. | |
* C User can enter characters or spaces. |
/** | |
* @ngdoc directive | |
* @name safe.directive:checkboxAll | |
* | |
* @element input | |
* | |
* @description | |
* | |
* Bir listedeki tüm elemanları seçen bir checkbox kutusu yapmak için pratik bir directive. | |
* |
/** | |
* @ngdoc directive | |
* @name safe.directive:incomplete-confirmation | |
* | |
* @element ANY | |
* | |
* @description | |
* | |
* `name` attribute'u olan bütün form elementlerinde çalışarak | |
* üzerinde değişiklik yapılmış ancak kaydedilmemiş bir form olduğunda |
def get_score(word1, word2): | |
shared_chars = [char for char in word1.lower() if char in word2.lower()] | |
return len(shared_chars) | |
# Usage | |
get_score('murat', 'burak') | |
# > 3 |
This code is a sample for a question on Stackoverflow about making multisite user models with Django 1.7.
Add these lines to your settings file:
AUTH_USER_MODEL='s1.Member'
SITE_ID = 1
AUTHENTICATION_BACKENDS = ( 'MyApp.MyModule.MyModelBackend',)
from django.http import HttpResponse, JsonResponse, HttpResponseForbidden, HttpResponseNotAllowed, HttpResponseNotFound | |
from django.forms.models import model_to_dict | |
from django.db.models import Model | |
from django.db.models.query import QuerySet | |
from functools import wraps | |
from django.utils.decorators import available_attrs | |
from django.core import serializers | |
class PermissionError(Exception): | |
pass |