This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from subprocess import Popen, PIPE | |
from os import environ | |
def source(script, update=True, clean=True): | |
""" | |
Source variables from a shell script | |
import them in the environment (if update==True) | |
and report only the script variables (if clean==True) | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
#Copyright (C) 2013 Seán Hayes | |
import my_project.settings as dj_settings | |
from fabric.api import local, run, sudo, env, prompt, settings, cd, parallel, execute | |
from fabric.contrib.files import exists | |
from fabric.decorators import hosts, roles, runs_once | |
import json | |
import logging | |
import os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class M1(models.Model): | |
title = models.CharField(max_length=100) | |
img1 = models.ImageField(upload_to="static/") | |
def __unicode__(self): | |
return self.title |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |