When I migrate the database, I meet some errors, and errors are following:
-- Operations to perform:
Synchronize unmigrated apps: staticfiles, messages
Apply all migrations: admin, contenttypes, api, auth, sessions
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
Rendering model states... DONE
Applying api.0004_auto_20151119_1545...Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 346, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 394, in run_from_argv
self.execute(*args, **cmd_options)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 445, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.7/site-packages/django/core/management/commands/migrate.py", line 222, in handle
executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
File "/Library/Python/2.7/site-packages/django/db/migrations/executor.py", line 110, in migrate
self.apply_migration(states[migration], migration, fake=fake, fake_initial=fake_initial)
File "/Library/Python/2.7/site-packages/django/db/migrations/executor.py", line 148, in apply_migration
state = migration.apply(state, schema_editor)
File "/Library/Python/2.7/site-packages/django/db/migrations/migration.py", line 115, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/Library/Python/2.7/site-packages/django/db/migrations/operations/fields.py", line 62, in database_forwards
field,
File "/Library/Python/2.7/site-packages/django/db/backends/sqlite3/schema.py", line 179, in add_field
self._remake_table(model, create_fields=[field])
File "/Library/Python/2.7/site-packages/django/db/backends/sqlite3/schema.py", line 77, in _remake_table
self.effective_default(field)
File "/Library/Python/2.7/site-packages/django/db/backends/base/schema.py", line 211, in effective_default
default = field.get_db_prep_save(default, self.connection)
File "/Library/Python/2.7/site-packages/django/db/models/fields/__init__.py", line 710, in get_db_prep_save
prepared=False)
File "/Library/Python/2.7/site-packages/django/db/models/fields/__init__.py", line 1322, in get_db_prep_value
value = self.get_prep_value(value)
File "/Library/Python/2.7/site-packages/django/db/models/fields/__init__.py", line 1317, in get_prep_value
return self.to_python(value)
File "/Library/Python/2.7/site-packages/django/db/models/fields/__init__.py", line 1274, in to_python
parsed = parse_date(value)
File "/Library/Python/2.7/site-packages/django/utils/dateparse.py", line 60, in parse_date
match = date_re.match(value)
TypeError: expected string or bufferand the source code of models.py is following:
from django.db import models
from django.core.exceptions import ValidationError
from django.utils.dateformat import format
from django.contrib.auth.models import AbstractUser
from datetime import date
import datetime
from django.conf import settings
from django.db.models import Sum
from django.utils import timezone
from django.utils.dateformat import format
# Create your models here.
#Users, Contacts, Events
class User(models.Model):
phonenum = models.CharField(max_length=20)
username = models.CharField(max_length=20)
def get_usr_info(self):
data = {} # dictionary
data['phonenum'] = self.phonenum
data['name'] = self.username
return data
class Contacts(models.Model):
user = models.ForeignKey(User)
class UpdateEvents(models.Model):
user = models.ForeignKey(User)
events = models.CharField(max_length=50)
latitude = models.CharField(max_length=10)
longitude = models.CharField(max_length=10)
city = models.CharField(max_length=10)
arriveDate = models.DateTimeField(blank=True, null=True)
leaveDate = models.DateTimeField(blank=True, null=True)
#arriveDate = models.CharField(max_length=15, default="")
#leaveDate = models.CharField(max_length=15, default="")
def get_events_info(self):
data = {}
data['phonenum'] = self.user.phonenum
data['name'] = self.user.username
data['events'] = self.events
data['latitude'] = self.latitude
data['longitude'] = self.longitude
data['city'] = self.city
data['arriveDate'] = format(self.arriveDate, "U")
data['leaveDate'] = format(self.leaveDate, "U")
return data
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/945a393a-00c4-4894-96c3-3acff692115c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment