[pyar] [Django] problema al modificar y agregar un campo fecha un Model

Ricardo Daniel Quiroga l2radamanthys en gmail.com
Dom Ago 28 12:58:25 ART 2016


si ahi quedo el problema porque renombre el campo y sigue tratando enviar
el cambio, vere de eliminar la carpeta migration y forzar de nuevo



2016-08-28 12:55 GMT-03:00 Ricardo Daniel Quiroga <l2radamanthys en gmail.com>:

> disculpa copie un traceback anterior, en realidad renombre el campo
> expire_date a vencimiento por no tener un desastre en spanglish
>
>
> 2016-08-28 12:50 GMT-03:00 Francisco J Capdevila <fjcapdevila en gmail.com>:
>
>> Me parece que Fernando te cantó la justa.
>>
>> Otro posible problema sería que tu nuevo campo se llame "expire_date"
>> en lugar de "vencimiento" y que tu modelo se llame "Catamaran" en
>> lugar de "Negocio". En ese caso, estás intentando agregar un nuevo
>> campo que no puede ser Null (por defecto Django define los fields como
>> null=False), pero ya existen registros en dicha tabla, entonces se
>> queja por que no puede pner en Null el nuevo campo para los registros
>> ya existentes en la tabla y tampoco sabe que valor poner por defecto.
>> Deberías ver si podes definir ese campo como null=True o bien
>> explicarle a Django como calcular un "expire_date" para los registros
>> que ya existen para el modelo "Catamaran"
>>
>> Saludos y suerte con eso!
>> Francisco J. Capdevila
>>
>>
>> 2016-08-28 12:34 GMT-03:00 Fernando Riquelme <
>> fernandoriquelme55 en gmail.com>:
>> > El problema podría estar en el campo expire_date, de alguna de tus
>> tablas
>> > (creo que Main_catamaran puede tener ese campo)
>> >
>> > 2016-08-28 2:47 GMT-03:00 Ricardo Daniel Quiroga <
>> l2radamanthys en gmail.com>:
>> >>
>> >> Hola
>> >> actualmente estoy modificando un Modelo en django especificamente
>> >>
>> >> class Negocio(models.Model):
>> >>     nombre = models.CharField(max_length=100)
>> >>     telefono = models.CharField(max_length=20, blank=True, default='')
>> >>     telefono_alt = models.CharField(max_length=20, blank=True,
>> default='')
>> >>     facebook = models.CharField(max_length=100,
>> >> default='https://facebook.com')
>> >>     email = models.CharField(max_length=100, blank=True, default='')
>> >>     lat = models.FloatField(default=0.0)
>> >>     lng = models.FloatField(default=0.0)
>> >>     inproved = models.BooleanField(default=False)
>> >>     vencimiento = models.DateField(auto_now=True)
>> >>     active = models.BooleanField(default=True, editable=False)
>> >>
>> >> agregue el campo vencimiento
>> >>      vencimiento = models.DateField(auto_now=True)
>> >>
>> >> pero cuando corro python manage.py migrate (despues de haber corrido
>> >> makemigrations) me devuelve el siguiente error,
>> >>
>> >>
>> >>
>> >> (env3c) D:\Workspace\Python\SPOServer\SPOServer>python manage.py
>> >> makemigrations
>> >> Migrations for 'Main':
>> >>   Main\migrations\0010_auto_20160828_0238.py:
>> >>     - Alter field expire_date on catamaran
>> >>
>> >> (env3c) D:\Workspace\Python\SPOServer\SPOServer>python manage.py
>> migrate
>> >> Operations to perform:
>> >>   Apply all migrations: Main, admin, auth, contenttypes, sessions
>> >> Running migrations:
>> >>   Rendering model states... DONE
>> >>   Applying Main.0005_auto_20160828_0233...Traceback (most recent call
>> >> last):
>> >>   File
>> >> "D:\Workspace\virtualenv\env3c\lib\site-packages\django\db\
>> backends\utils
>> >> .py", line 64, in execute
>> >>     return self.cursor.execute(sql, params)
>> >>   File
>> >> "D:\Workspace\virtualenv\env3c\lib\site-packages\django\db\
>> backends\sqlit
>> >> e3\base.py", line 337, in execute
>> >>     return Database.Cursor.execute(self, query, params)
>> >> sqlite3.IntegrityError: NOT NULL constraint failed:
>> >> Main_catamaran.expire_date
>> >>
>> >> The above exception was the direct cause of the following exception:
>> >>
>> >> Traceback (most recent call last):
>> >>   File "manage.py", line 22, in <module>
>> >>     execute_from_command_line(sys.argv)
>> >>   File
>> >> "D:\Workspace\virtualenv\env3c\lib\site-packages\django\
>> core\management\_
>> >> _init__.py", line 367, in execute_from_command_line
>> >>     utility.execute()
>> >>   File
>> >> "D:\Workspace\virtualenv\env3c\lib\site-packages\django\
>> core\management\_
>> >> _init__.py", line 359, in execute
>> >>     self.fetch_command(subcommand).run_from_argv(self.argv)
>> >>   File
>> >> "D:\Workspace\virtualenv\env3c\lib\site-packages\django\
>> core\management\b
>> >> ase.py", line 305, in run_from_argv
>> >>     self.execute(*args, **cmd_options)
>> >>   File
>> >> "D:\Workspace\virtualenv\env3c\lib\site-packages\django\
>> core\management\b
>> >> ase.py", line 356, in execute
>> >>     output = self.handle(*args, **options)
>> >>   File
>> >> "D:\Workspace\virtualenv\env3c\lib\site-packages\django\
>> core\management\c
>> >> ommands\migrate.py", line 202, in handle
>> >>     targets, plan, fake=fake, fake_initial=fake_initial
>> >>   File
>> >> "D:\Workspace\virtualenv\env3c\lib\site-packages\django\db\
>> migrations\exe
>> >> cutor.py", line 97, in migrate
>> >>     state = self._migrate_all_forwards(plan, full_plan, fake=fake,
>> >> fake_initial=
>> >> fake_initial)
>> >>   File
>> >> "D:\Workspace\virtualenv\env3c\lib\site-packages\django\db\
>> migrations\exe
>> >> cutor.py", line 132, in _migrate_all_forwards
>> >>     state = self.apply_migration(state, migration, fake=fake,
>> >> fake_initial=fake_
>> >> initial)
>> >>   File
>> >> "D:\Workspace\virtualenv\env3c\lib\site-packages\django\db\
>> migrations\exe
>> >> cutor.py", line 237, in apply_migration
>> >>     state = migration.apply(state, schema_editor)
>> >>   File
>> >> "D:\Workspace\virtualenv\env3c\lib\site-packages\django\db\
>> migrations\mig
>> >> ration.py", line 129, in apply
>> >>     operation.database_forwards(self.app_label, schema_editor,
>> old_state,
>> >> projec
>> >> t_state)
>> >>   File
>> >> "D:\Workspace\virtualenv\env3c\lib\site-packages\django\db\
>> migrations\ope
>> >> rations\fields.py", line 84, in database_forwards
>> >>     field,
>> >>   File
>> >> "D:\Workspace\virtualenv\env3c\lib\site-packages\django\db\
>> backends\sqlit
>> >> e3\schema.py", line 231, in add_field
>> >>     self._remake_table(model, create_fields=[field])
>> >>   File
>> >> "D:\Workspace\virtualenv\env3c\lib\site-packages\django\db\
>> backends\sqlit
>> >> e3\schema.py", line 199, in _remake_table
>> >>     self.quote_name(model._meta.db_table),
>> >>   File
>> >> "D:\Workspace\virtualenv\env3c\lib\site-packages\django\db\
>> backends\base\
>> >> schema.py", line 112, in execute
>> >>     cursor.execute(sql, params)
>> >>   File
>> >> "D:\Workspace\virtualenv\env3c\lib\site-packages\django\db\
>> backends\utils
>> >> .py", line 79, in execute
>> >>     return super(CursorDebugWrapper, self).execute(sql, params)
>> >>   File
>> >> "D:\Workspace\virtualenv\env3c\lib\site-packages\django\db\
>> backends\utils
>> >> .py", line 64, in execute
>> >>     return self.cursor.execute(sql, params)
>> >>   File
>> >> "D:\Workspace\virtualenv\env3c\lib\site-packages\django\db\utils.py",
>> lin
>> >> e 94, in __exit__
>> >>     six.reraise(dj_exc_type, dj_exc_value, traceback)
>> >>   File
>> >> "D:\Workspace\virtualenv\env3c\lib\site-packages\django\utils\six.py",
>> li
>> >> ne 685, in reraise
>> >>     raise value.with_traceback(tb)
>> >>   File
>> >> "D:\Workspace\virtualenv\env3c\lib\site-packages\django\db\
>> backends\utils
>> >> .py", line 64, in execute
>> >>     return self.cursor.execute(sql, params)
>> >>   File
>> >> "D:\Workspace\virtualenv\env3c\lib\site-packages\django\db\
>> backends\sqlit
>> >> e3\base.py", line 337, in execute
>> >>     return Database.Cursor.execute(self, query, params)
>> >> django.db.utils.IntegrityError: NOT NULL constraint failed:
>> >> Main_catamaran.expir
>> >> e_date
>> >>
>> >> (env3c) D:\Workspace\Python\SPOServer\SPOServer>
>> >>
>> >> alguna manera de agregar esto por django o tendre que hacerlo a mano en
>> >> SQLite
>> >> Estoy usando Django 1.10 y Python 3.5.2 32bit sobre Windows por si
>> sirve
>> >> de algo
>> >>
>> >> gracias
>> >>
>> >>
>> >>
>> >> --
>> >>
>> >> Ricardo Daniel Quiroga
>> >>
>> >>
>> >> _______________________________________________
>> >> pyar mailing list pyar en python.org.ar
>> >> http://listas.python.org.ar/listinfo/pyar
>> >>
>> >> PyAr - Python Argentina - Sitio web: http://www.python.org.ar/
>> >>
>> >> La lista de PyAr esta Hosteada en USLA - Usuarios de Software Libre de
>> >> Argentina - http://www.usla.org.ar
>> >
>> >
>> >
>> > _______________________________________________
>> > pyar mailing list pyar en python.org.ar
>> > http://listas.python.org.ar/listinfo/pyar
>> >
>> > PyAr - Python Argentina - Sitio web: http://www.python.org.ar/
>> >
>> > La lista de PyAr esta Hosteada en USLA - Usuarios de Software Libre de
>> > Argentina - http://www.usla.org.ar
>> _______________________________________________
>> pyar mailing list pyar en python.org.ar
>> http://listas.python.org.ar/listinfo/pyar
>>
>> PyAr - Python Argentina - Sitio web: http://www.python.org.ar/
>>
>> La lista de PyAr esta Hosteada en USLA - Usuarios de Software Libre de
>> Argentina - http://www.usla.org.ar
>>
>
>
>
> --
>
> Ricardo Daniel Quiroga
>
>


-- 

Ricardo Daniel Quiroga
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://listas.python.org.ar/pipermail/pyar/attachments/20160828/24549d43/attachment.html>


Más información sobre la lista de distribución pyar