jueves, 21 de noviembre de 2013

Activar admin en django

Agregamos en el modelo la clase admin

from django.db import models


class Poll(models.Model):
    question = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')

class Choice(models.Model):
    poll = models.ForeignKey(Poll)
    choice_text = models.CharField(max_length=200)
    votes = models.IntegerField(default=0)
class Admin:
pass


Sincronizamos  la base de datos

$ python manage.py syncdb

(simast)cesar@developerWEB:~/simast/simast$ python manage.py syncdb
Creating tables ...
Creating table django_admin_log
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table django_content_type
Creating table django_session

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use 'cesar'): cesar
Email address: cesar.morones1@gmail.com
Password: 
Password (again): 
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)

Nos genera el usuario y ejecutamos el server

$python manage.py runserver

y accesamos a

http://127.0.0.1:8000/admin/





No hay comentarios.:

Publicar un comentario