2014-12-05 74 views
1

我有这个错误的一些麻烦.. 我试过一个manage.py刷新,但是当我syncdb获得一个新的superadmin帐户它只是说这个错误 我已经尝试了很多,但没有工作:(帮助!我Django 1.7数据库错误

Operations to perform: 
    Synchronize unmigrated apps: debug_toolbar 
    Apply all migrations: admin, home, contenttypes, auth, sessions 
Synchronizing apps without migrations: 
    Creating tables... 
    Installing custom SQL... 
    Installing indexes... 
Running migrations: 
    Applying home.0008_auto_20141204_1209...Traceback (most recent call last): 
    File "manage.py", line 14, in <module> 
    execute_from_command_line(sys.argv) 
    File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line 
    utility.execute() 
    File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 377, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 288, in run_from_argv 
    self.execute(*args, **options.__dict__) 
    File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 338, in execute 
    output = self.handle(*args, **options) 
    File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 160, in handle 
    executor.migrate(targets, plan, fake=options.get("fake", False)) 
    File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 63, in migrate 
    self.apply_migration(migration, fake=fake) 
    File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 97, in apply_migration 
    migration.apply(project_state, schema_editor) 
    File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/migration.py", line 107, in apply 
    operation.database_forwards(self.app_label, schema_editor, project_state, new_state) 
    File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/operations/fields.py", line 84, in database_forwards 
    schema_editor.remove_field(from_model, from_model._meta.get_field_by_name(self.name)[0]) 
    File "/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/schema.py", line 185, in remove_field 
    self._remake_table(model, delete_fields=[field]) 
    File "/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/schema.py", line 135, in _remake_table 
    self.quote_name(model._meta.db_table), 
    File "/usr/local/lib/python2.7/dist-packages/django/db/backends/schema.py", line 99, in execute 
    cursor.execute(sql, params) 
    File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 81, in execute 
    return super(CursorDebugWrapper, self).execute(sql, params) 
    File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 65, in execute 
    return self.cursor.execute(sql, params) 
    File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 94, in __exit__ 
    six.reraise(dj_exc_type, dj_exc_value, traceback) 
    File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 65, in execute 
    return self.cursor.execute(sql, params) 
    File "/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.py", line 485, in execute 
    return Database.Cursor.execute(self, query, params) 
django.db.utils.OperationalError: near ")": syntax error 

这是我的模型:

from django.db import models 
from django.contrib import admin 
from urlparse import urlparse 
from django.contrib.auth.models import User 
from django.db import migrations 
from django.utils import timezone 
import datetime 




class Topic(models.Model): 
    user = models.ForeignKey(User) 
    postit = models.TextField(max_length=300) 
    comment = models.TextField(max_length=300) 
    createdat = models.DateTimeField(default=timezone.now) 

    '''createdat = models.DateTimeField(auto_now_add=True) 
    updatedat = models.DateTimeField(auto_now=True) 
    def created(self): 
     return self.createdat 

    ''' 

    def updated(self): 
     return self.updatedat 

    def timer(self): 
     return self.createdat 


    def who(self): 
     return self.user 

    def __str__(self):    # __unicode__ on Python 2 
     return self.postit 


class Group(models.Model): 
    name = models.CharField(max_length=100) 
    members = models.ManyToManyField(User) 
    Topics = models.ManyToManyField(Topic) 

    def __str__(self):    # __unicode__ on Python 2 
     return self.name 


# Create your models here. 

class texting(models.Model): 
    text = models.TextField() 

class Chatting(models.Model): 

    moderator = models.ForeignKey(User) 
    title = models.CharField(max_length=200) 


    ''' 
    created_at = models.DateTimeField(auto_now_add=True) 
    updated_at = models.DateTimeField(auto_now=True) 




    self hyper link? 
    @property 
    def domain(self): 
     return urlparse(self.url).netloc 

''' 
+0

似乎是您的迁移文件'home.0008_auto_20141204_1209 ...' – Anentropic 2014-12-05 11:22:06

+0

语法错误为什么你用'syncdb'与Django 1.7? – rnevius 2014-12-05 11:24:00

+0

我真的不明白新的移民事情。我是django的新手。只是想学习和实验 – nokker 2014-12-05 15:34:34

回答

-2

惠,

尝试以下步骤 - :

1)删除所有以前的迁移文件。

2)然后运行该------------------------>蟒manage.py迁移

3)然后运行--- ------------------------> python manage.py migrate。

希望这将是helpfull.If任何其他问题请评论

感谢

+0

会尝试,但我不知道如何删除迁移文件 – nokker 2014-12-05 15:34:51

+0

好吧,我删除了所有文件,似乎再次工作!谢谢。 – nokker 2014-12-05 15:46:51

+0

快乐 - 总是乐于帮助:-) – 2014-12-05 17:10:02