Help me! Error in Django. Migrate mysql, datetime and more.

306 views
Skip to first unread message

Ricardo Felipe Ríos Higueras

unread,
Mar 28, 2016, 12:01:05 PM3/28/16
to Django users
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_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


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 = 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.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 = 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.title

def __unicode__(self):
return self.body


I hope you will join me. 
Thanks....
models.py

James Schneider

unread,
Mar 28, 2016, 1:15:47 PM3/28/16
to django...@googlegroups.com

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'


When or where do you get these errors? The models themselves look correct. Do you have code that runs that generates these errors?

Can you please post the entire traceback that you are receiving for both errors?

-James
Reply all
Reply to author
Forward
0 new messages