Thanks for your reply.
The model.py contains,
class SignUp(models.Model):
email = models.EmailField()
full_name = models.CharField(max_length = 120, blank = True, null =
True)
timestamp = models.DateTimeField(auto_now_add = True, auto_now = False)
updated = models.DateTimeField(auto_now_add = False, auto_now = True)
def __unicode__(self): #__str__ for python3
return self.email
I had to add the updated field,
updated = models.DateTimeField(auto_now_add = False, auto_now = True)
Running make migrations,
[pi@Huawei-HG658c-instalacion src]$ python manage.py makemigrations
/home/pi/src/djangoTest/urls.py:20: RemovedInDjango110Warning: Support for
string view arguments to url() is deprecated and will be removed in Django
1.10 (got news.views.home). Pass the callable instead.
url(r'^$', 'news.views.home', name='home'),
No changes detected
Then running migrations
[pi@Huawei-HG658c-instalacion src]$ python manage.py migrate
/home/pi/src/djangoTest/urls.py:20: RemovedInDjango110Warning: Support for
string view arguments to url() is deprecated and will be removed in Django
1.10 (got news.views.home). Pass the callable instead.
url(r'^$', 'news.views.home', name='home'),
Operations to perform:
Apply all migrations: admin, news, contenttypes, auth, sessions
Running migrations:
Rendering model states... DONE
Applying news.0002_signup_updated...Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py"
, line 353, in execute_from_command_line
utility.execute()
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py"
, line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.7/site-packages/django/core/management/base.py",
line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/lib/python2.7/site-packages/django/core/management/base.py",
line 399, in execute
output = self.handle(*args, **options)
File
"/usr/lib/python2.7/site-packages/django/core/management/commands/migrate.py"
, line 200, in handle
executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
File "/usr/lib/python2.7/site-packages/django/db/migrations/executor.py",
line 92, in migrate
self._migrate_all_forwards(plan, full_plan, fake=fake, fake_initial=
fake_initial)
File "/usr/lib/python2.7/site-packages/django/db/migrations/executor.py",
line 121, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=
fake_initial)
File "/usr/lib/python2.7/site-packages/django/db/migrations/executor.py",
line 198, in apply_migration
state = migration.apply(state, schema_editor)
File "/usr/lib/python2.7/site-packages/django/db/migrations/migration.py",
line 123, in apply
operation.database_forwards(self.app_label, schema_editor, old_state,
project_state)
File
"/usr/lib/python2.7/site-packages/django/db/migrations/operations/fields.py"
, line 62, in database_forwards
field,
File
"/usr/lib/python2.7/site-packages/django/db/backends/sqlite3/schema.py",
line 221, in add_field
self._remake_table(model, create_fields=[field])
File
"/usr/lib/python2.7/site-packages/django/db/backends/sqlite3/schema.py",
line 103, in _remake_table
self.effective_default(field)
File "/usr/lib/python2.7/site-packages/django/db/backends/base/schema.py",
line 210, in effective_default
default = field.get_db_prep_save(default, self.connection)
File
"/usr/lib/python2.7/site-packages/django/db/models/fields/__init__.py",
line 728, in get_db_prep_save
prepared=False)
File
"/usr/lib/python2.7/site-packages/django/db/models/fields/__init__.py",
line 1461, in get_db_prep_value
value = self.get_prep_value(value)
File
"/usr/lib/python2.7/site-packages/django/db/models/fields/__init__.py",
line 1440, in get_prep_value
value = super(DateTimeField, self).get_prep_value(value)
File
"/usr/lib/python2.7/site-packages/django/db/models/fields/__init__.py",
line 1296, in get_prep_value
return self.to_python(value)
File
"/usr/lib/python2.7/site-packages/django/db/models/fields/__init__.py",
line 1399, in to_python
parsed = parse_datetime(value)
File "/usr/lib/python2.7/site-packages/django/utils/dateparse.py", line 93
, in parse_datetime
match = datetime_re.match(value)
TypeError: expected string or buffer
Thanks,
On Wednesday, 27 January 2016 19:21:16 UTC, ofeyofey wrote:
>
> Hi,
> I forgot to add a field to a model and wish to add it now.
> I added the line to models.py but makemigrations and migrate aren't
> working now.
> Is this possible in Django or do i need to go directly tp the sqlite DB
> and do it using SQL?
> Thanks
> Currently following this tutorial
> https://www.youtube.com/watch?v=g0tvJsUAx7g
>
--
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 [email protected].
To post to this group, send email to [email protected].
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/695bb1fe-2a6d-49e8-899f-d9bc43abfab8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.