(Full description and list of commands at - https://npmjs.org/doc/index.html)
Make sure to export your local $PATH and prepand relative ./node_modules/.bin/:
| from django.contrib.auth.backends import ModelBackend | |
| from django.contrib.auth.models import User | |
| class EmailBackend(ModelBackend): | |
| def authenticate(self, **credentials): | |
| if 'username' in credentials: | |
| return super(EmailBackend, self).authenticate(**credentials) | |
| try: |
| import re | |
| from django import forms | |
| from django.contrib.auth.models import User | |
| from django.contrib.auth.forms import UserCreationForm | |
| class UniqueUserEmailField(forms.EmailField): | |
| """ | |
| An EmailField which only is valid if no User has that email. | |
| """ | |
| def validate(self, value): |
| /** | |
| * SocketManager - Singleton to manage multi-channel socket 'routing', need a way to merge with socket.io so client sessions aren't stored twice in memory, | |
| * | |
| * Requires Socket.IO-node and Socket.IO client libraries. | |
| * | |
| * Usage: | |
| * in your main app.js file (or whereever you create the server) | |
| * | |
| * var io = require('socket.io'), | |
| * sm = require('socketmanager'); |
| @rem Do not use "echo off" to not affect any child calls. | |
| @setlocal | |
| @rem Get the abolute path to the parent directory, which is assumed to be the | |
| @rem Git installation root. | |
| @for /F "delims=" %%I in ("%~dp0..") do @set git_install_root=%%~fI | |
| @set PATH=%git_install_root%\bin;%git_install_root%\mingw\bin;%PATH% | |
| @if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH% | |
| @if not exist "%HOME%" @set HOME=%USERPROFILE% |
| { | |
| "draw_white_space": "all", | |
| "font": "monospace", | |
| "font_size": 11, | |
| "translate_tabs_to_spaces": true, | |
| "vintage_start_in_command_mode": true, | |
| "vintage_ctrl_keys": true, | |
| "color_scheme": "Packages/Color Scheme - Default/Pastels on Dark.tmTheme" | |
| } |
| from django.views.generic import CreateView | |
| from library.forms import BookForm | |
| class CreateBook(CreateView): | |
| template_name = 'create_form.html' | |
| success_url = '/books/' | |
| form_class = BookForm |
| # simple form usage in view | |
| def my_view(request, template_name='home.html'): | |
| # sticks in a POST or renders an empty form | |
| form = MyForm(request.POST or None) | |
| if form.is_valid(): | |
| do_something() | |
| return redirect('/') | |
| return render_to_response(template_name, {'form':form}) | |
| # form with files |
| from django.forms import EmailField | |
| from django.utils.translation import ugettext_lazy as _ | |
| from django.contrib.auth.models import User | |
| from django.contrib.auth.forms import UserCreationForm | |
| class UserCreationForm(UserCreationForm): | |
| email = EmailField(label=_("Email address"), required=True, |
| # -*- coding: utf-8 -*- | |
| from django import template | |
| register = template.Library() | |
| @register.inclusion_tag('template.html', takes_context = True) | |
| def tag(context): | |
| pass |
(Full description and list of commands at - https://npmjs.org/doc/index.html)
Make sure to export your local $PATH and prepand relative ./node_modules/.bin/: