2016-10-10 77 views
2

所以我正在開發我的應用程序,並在模型中添加了slugfield。然後正常進行到makemigrations,並出現了大量紅色的錯誤。OperationalError:沒有這樣的表

Traceback (most recent call last): 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\db\backends\utils.py", line 64, in execute 
    return self.cursor.execute(sql, params) 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\db\backends\sqlite3\base.py", line 337, in execute 
    return Database.Cursor.execute(self, query, params) 
sqlite3.OperationalError: no such table: Reader_manga 

The above exception was the direct cause of the following exception: 

Traceback (most recent call last): 
    File "C:\Program Files (x86)\JetBrains\PyCharm 2016.2.3\helpers\pycharm\django_manage.py", line 41, in <module> 
    run_module(manage_file, None, '__main__', True) 
    File "C:\Users\Andreas\AppData\Local\Programs\Python\Python35-32\lib\runpy.py", line 182, in run_module 
    return _run_module_code(code, init_globals, run_name, mod_spec) 
    File "C:\Users\Andreas\AppData\Local\Programs\Python\Python35-32\lib\runpy.py", line 96, in _run_module_code 
    mod_name, mod_spec, pkg_name, script_name) 
    File "C:\Users\Andreas\AppData\Local\Programs\Python\Python35-32\lib\runpy.py", line 85, in _run_code 
    exec(code, run_globals) 
    File "D:/WindowsFolders/Documents/Python/ReaderProject\manage.py", line 10, in <module> 
    execute_from_command_line(sys.argv) 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line 
    utility.execute() 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\core\management\__init__.py", line 359, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\core\management\base.py", line 294, in run_from_argv 
    self.execute(*args, **cmd_options) 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\core\management\base.py", line 342, in execute 
    self.check() 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\core\management\base.py", line 374, in check 
    include_deployment_checks=include_deployment_checks, 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\core\management\base.py", line 361, in _run_checks 
    return checks.run_checks(**kwargs) 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks 
    new_errors = check(app_configs=app_configs) 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\core\checks\urls.py", line 14, in check_url_config 
    return check_resolver(resolver) 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\core\checks\urls.py", line 24, in check_resolver 
    for pattern in resolver.url_patterns: 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\utils\functional.py", line 35, in __get__ 
    res = instance.__dict__[self.name] = self.func(instance) 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\urls\resolvers.py", line 313, in url_patterns 
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\utils\functional.py", line 35, in __get__ 
    res = instance.__dict__[self.name] = self.func(instance) 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\urls\resolvers.py", line 306, in urlconf_module 
    return import_module(self.urlconf_name) 
    File "C:\Users\Andreas\AppData\Local\Programs\Python\Python35-32\lib\importlib\__init__.py", line 126, in import_module 
    return _bootstrap._gcd_import(name[level:], package, level) 
    File "<frozen importlib._bootstrap>", line 986, in _gcd_import 
    File "<frozen importlib._bootstrap>", line 969, in _find_and_load 
    File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked 
    File "<frozen importlib._bootstrap>", line 673, in _load_unlocked 
    File "<frozen importlib._bootstrap_external>", line 662, in exec_module 
    File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed 
    File "D:/WindowsFolders/Documents/Python/ReaderProject\ReaderProject\urls.py", line 25, in <module> 
    from Reader import views 
    File "D:/WindowsFolders/Documents/Python/ReaderProject\Reader\views.py", line 7, in <module> 
    from .forms import UploadForm 
    File "D:/WindowsFolders/Documents/Python/ReaderProject\Reader\forms.py", line 12, in <module> 
    class UploadForm(forms.Form): 
    File "D:/WindowsFolders/Documents/Python/ReaderProject\Reader\forms.py", line 15, in UploadForm 
    for manga in mangas: 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\db\models\query.py", line 256, in __iter__ 
    self._fetch_all() 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\db\models\query.py", line 1087, in _fetch_all 
    self._result_cache = list(self.iterator()) 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\db\models\query.py", line 54, in __iter__ 
    results = compiler.execute_sql() 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\db\models\sql\compiler.py", line 835, in execute_sql 
    cursor.execute(sql, params) 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\db\backends\utils.py", line 79, in execute 
    return super(CursorDebugWrapper, self).execute(sql, params) 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\db\backends\utils.py", line 64, in execute 
    return self.cursor.execute(sql, params) 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\db\utils.py", line 94, in __exit__ 
    six.reraise(dj_exc_type, dj_exc_value, traceback) 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\utils\six.py", line 685, in reraise 
    raise value.with_traceback(tb) 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\db\backends\utils.py", line 64, in execute 
    return self.cursor.execute(sql, params) 
    File "C:\Users\Andreas\ReaderProject\lib\site-packages\django\db\backends\sqlite3\base.py", line 337, in execute 
    return Database.Cursor.execute(self, query, params) 
django.db.utils.OperationalError: no such table: Reader_manga 

我試圖刪除我添加但沒有用的字段。我已經做了幾乎所有在stackoverflow上建議的東西。

我也忘了將項目添加到github,現在也沒有原始數據庫文件。

模型,似乎是給錯誤:

class Manga(models.Model): 
    COMPLETED = 'COMP' 
    ONGOING = 'ONG' 
    STATUS_CHOICES = (
     (COMPLETED, 'Completed'), 
     (ONGOING, 'Ongoing'), 
    ) 
    JAPANESE_MANGA = 'JM' 
    KOREAN_MANGA = 'KM' 
    CHINESE_MANGA = 'CM' 
    UNKNOWN_MANGA = 'UM' 
    TYPE_CHOICES = (
     (JAPANESE_MANGA, 'Japanese Manga'), 
     (KOREAN_MANGA, 'Korean Manhwa'), 
     (CHINESE_MANGA, 'Chinese Manhua'), 
     (UNKNOWN_MANGA, 'Unknown'), 
    ) 
    authors = models.ManyToManyField(Author) 
    genres = models.ManyToManyField(Genre) 
    name = models.CharField(max_length=255, default="") 
    image = models.ImageField(upload_to=upload_manga_cover) 
    summary = models.TextField(max_length=1000) 
    rating = models.IntegerField(default=0) 
    views = models.IntegerField(default=0) 
    rank = models.IntegerField(default=0) 
    alt_names = models.TextField(max_length=400, default="") 
    type = models.CharField(
     max_length=255, 
     choices=TYPE_CHOICES, 
     default=UNKNOWN_MANGA 
    ) 
    status = models.CharField(
     max_length=255, 
     choices=STATUS_CHOICES, 
     default=ONGOING, 
    ) 
    released = models.DateField() 
    date_added = models.DateTimeField(auto_now_add=True) 
    date_modified = models.DateTimeField(auto_now=True) 
    slug = models.SlugField(unique=True) 

    def __str__(self): 
     return self.name 

告訴我些什麼,你需要知道的能夠幫助,我會添加它。

+0

你應該把你的模型置疑,不要把導致不同網站的鏈接。 –

+0

「我也忘了將項目添加到github中,現在也沒有原始數據庫文件。」所以這聽起來像你正在運行在空表上進行遷移。是這樣嗎? – e4c5

+0

@ e4c5是的,數據庫裏面沒有任何東西(用Pycharm的數據庫系統檢查)我應該可能剛剛離開了一切,而不是嘗試我在stackoverflow上找到的解決方案。 –

回答

0

因此,要解決這個問題最快的辦法是把剛纔複製的一切在進入一個新的項目(很可能只是刪除選定的零部件並重新添加它們)

然後,只需再製作該應用程式,複製的設置和模型結束。然後makemigrations然後migrate。然後,我可以簡單地複製視圖,網址和其他所有內容。

出了什麼問題?也許發生了一些遷移事件,並且再次從頭開始遷移有助於解決問題。

0

運行 'manage.py makemigrations' 作出新的遷移,並然後重新運行'manage.py migrate'以應用它們。

這是我在嘗試運行遷移時給出的提示。我做了上述事情,它爲我工作。

相關問題