Skip to content

Instantly share code, notes, and snippets.

####CREATE SUPERUSER ON DJANGO from django.contrib.auth.models import User

user = User.objects.create_superuser('john', '[email protected]', 'johnpassword')

``

###ORM COMMANDS DJANGO

python manage.py shell

from app.models import Class

###SITENAME/DOMAIN NAME ON DJANGO

from django.contrib.sites.models import Site

site = Site()

###CUZTOMIZE ADMIN FORM

class PollAdmin(admin.ModelAdmin):

fields = ['pub_date', 'question']

###DJANGO RELATIVE PATH

import os

PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

# vi: set ft=ruby :
Vagrant::Config.run do |config|
config.vm.box = "quantal"
config.vm.box_url = "http://static.aldoborrero.com/vagrant/quantal64.box"
config.vm.forward_port 8000, 8000
config.vm.network :hostonly, "33.33.00.10"
config.vm.provision :chef_solo do |chef|
chef.recipe_url = "https://dl.dropbox.com/u/4311762/cookbooks.tar.gz"

sudo apt-get install python-dev python-pip

wget --random-wait -r -p -e robots=off -U mozilla http://www.ejemplo.com

###DJANGO ANNOYING

pip install django-annoying

FIXTURES

JSON Parser

FIXTURE_DIRS = (
   '/path/to/myapp/fixtures/',
)

python manage.py dumpdata --format=json myapp > /path/to/myapp/fixtures/initial_data.json