from __future__ import unicode_literals
from django.db import models
from django.contrib import admin
from django.contrib import *
from tinymce import models as tinymce_models
from PIL import Image
from django.contrib.auth.models import User
import time
from datetime import date
# Create your models here.
ESTADO_VISIBLE = [1,2]
class ManejadorPost(models.Manager):
def get_query_set(self):
default_queryset = super(ManejadorPost, self).get_query_set()
return default_queryset.filter(status__in=ESTADO_VISIBLE)
class Categorias(models.Model):
nombre = models.CharField(max_length=50)
slug = models.SlugField(max_length=50, unique=True, default='slug')
descripcion = models.TextField()
creada_en = date.today()
actualizada_al = date.today()
class Meta:
db_table = 'categorias'
verbose_name_plural = 'Categorias'
def __unicode__(self):
return self.nombre
class BlogPost(models.Model):
ESTADOS=((1,"Publicado"), (2, 'Archivado'), (3,'Nesecita editarse'), (4,'Nesecita aprobacion'))
status = models.IntegerField(choices=ESTADOS,default=4)
objetos_panel = models.Manager()
objects = ManejadorPost()
title=models.CharField(max_length=150)
author = models.ForeignKey(User)
time = date.today()
categorias_post = models.ManyToManyField(Categorias)
body = tinymce_models.HTMLField()
imagen = models.ImageField(upload_to = "photos")
class Meta:
db_table = 'entradas'
verbose_name_plural = 'Posts'
def __unicode__(self):
return self.title
def __unicode__(self):
return self.body
Hi.
I am learning Django, but, I have major problems because I don´t know much about python/Django.
Here this problem:
problem one : the databases backend does not accept 0 as a ' valueError: The databases backend does not accept 0 as value for AutoField.
problem two: TypeError: int() argument must be a string or a number, not 'datetime.datetime'
Here my models.py
from __future__ import unicode_literalsfrom django.db import modelsfrom django.contrib import adminfrom django.contrib import *from tinymce import models as tinymce_modelsfrom PIL import Imagefrom django.contrib.auth.models import UserESTADO_VISIBLE = [1,2]class ManejadorPost(models.Manager):def get_query_set(self):default_queryset = super(ManejadorPost, self).get_query_set()return default_queryset.filter(status__in=ESTADO_VISIBLE)class Categorias(models.Model):nombre = models.CharField(max_length=50)slug = models.SlugField(max_length=50, unique=True, default='slug')descripcion = models.TextField()creada_en = models.DateTimeField(auto_now_add=True)actualizada_al = models.DateTimeField(auto_now=True)class Meta:db_table = 'categorias'verbose_name_plural = 'Categorias'def __unicode__(self):return self.nombreclass BlogPost(models.Model):ESTADOS=((1,"Publicado"), (2, 'Archivado'), (3,'Nesecita editarse'), (4,'Nesecita aprobacion'))status = models.IntegerField(choices=ESTADOS,default=4)objetos_panel = models.Manager()objects = ManejadorPost()title=models.CharField(max_length=150)author = models.ForeignKey(User)time = models.DateTimeField(auto_now=True)categorias_post = models.ManyToManyField(Categorias)body = tinymce_models.HTMLField()imagen = models.ImageField(upload_to = "photos")class Meta:db_table = 'entradas'verbose_name_plural = 'Posts'def __unicode__(self):return self.titledef __unicode__(self):return self.body
I hope you will join me.
Thanks....
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c4825eb7-ab86-4835-88a3-d24ed14495a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment