Created
February 15, 2012 03:42
-
-
Save huogerac/1833005 to your computer and use it in GitHub Desktop.
Comandos da aula da academia de python do dia 14/fev
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
1) Ambiente: | |
i) Instalar virtualenv (que vem com pip) | |
# apt-get install virtualenv | |
ii) Instalar o django utilizando virtualenv | |
# virtualenv --no-site-packages django1.3 | |
# cd django1.3/bin | |
# . activate | |
# pip install django | |
# pip install sqlite | |
obs: o django pode ser instalado em outro local | |
2) Criando primeira aplicação django | |
i) criar um modulo | |
# django-admin.py startproject suporte | |
# chmod +x manage.py | |
# ./manage.py runserver | |
ii) habilitar a app admin | |
no settings.py: descomentar as linhas do sqlite e da app admin | |
no urls.py: descomentar as linhas de admin | |
# manage.py syncdb | |
ii) criando uma nova app dentro do modulo suporte | |
# manage.py startapp ticket | |
no settings.py: adicionar a app criada: 'suporte.ticket', | |
ii) criar uma classe de modelo, por exemplo Ocorrencia |
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 Ocorrencia(models.Model): | |
titulo = models.CharField(max_length=128) | |
descricao = models.TextField() | |
ativa = models.BooleanField(default=True) | |
email_usuario = models.EmailField() | |
def __unicode__(self): | |
return self.titulo | |
from django.contrib import admin | |
from django.db import models | |
admin.site.register(Ocorrencia) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment