Skip to content

Instantly share code, notes, and snippets.

@jonathancg90
jonathancg90 / gist:7501893
Created November 16, 2013 16:04
Upload image
def upload_file(self, request):
form = FileUploadForm(request.POST, request.FILES)
if form.is_valid():
self.handle_uploaded_file(request.FILES['file'])
return True
def handle_uploaded_file(self, file):
destination = open(settings.MEDIA_ROOT + '/filename', 'wb+')
for chunk in file.chunks():
destination.write(chunk)
sudo apt-get install python-software-properties
sudo apt-add-repository ppa:chris lea/node.js
sudo apt-get update
sudo apt-get install nodejs
npm install socket.io
1) sudo apt-get install mongodb mongodb-clients mongodb-server
2) sudo service mongodb start
3) Consola mongo:
mongo
4) Salir
ctrl c
5) Añadir al inicio:
sudo update -rc.d mongodb defaults
6) entrar interfaz grafica
1)Paso 1:
sudo apt-get install python3-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev python-numpy libportmidi-dev ffmpeg libswscale-dev libavformat-dev libavcodec-dev checkinstall mercurial
2) Paso 2:
hg clone https://bitbucket.org/pygame/pygame
*Si no se puede clonar directamente descargarlo.
3) Paso 3:
find . -name '*.pyc' -delete
./manage.py migrate --delete-ghost-migrations
def get_form(self, form_class):
_form = super(ProductModelCreateView, self).get_form(form_class)
_form.fields["maximum_order"].initial = 0
_form.fields["maximum_order"].widget = HiddenInput()
===================================
Campo requerido en vista
$(function(){
console.log('hello');
var country = $('#id_country').change(setStates);
var state = $('#id_state').change(setCity);
//Saber que formulario estamos utilizando
if ($('#id_city').length){
var city = $('#id_city');
} else {
var city = $('#id_id');
-HOST
-------------------
1) sudo a2enmod rewrite
2) “/etc/hosts” ->editar (127.0.0.1 project.local)
3) sudo gedit /etc/apache2/sites-available/project-local.conf
<VirtualHost *:80>
ServerName project.local
DocumentRoot /var/www/project
</VirtualHost>
if ( event.which == 13) {
var value = $(this).val()
//value.replace(" ","W3Schools");
var category = $('#list-category').val()
var host = window.location.host;
url="http://"+host+"/search/#/0/"+category+"/0/0/0/0/"+value;
$(location).attr('href',url);
}