2017-01-16 3 views
0

Ich habe Probleme, meine Django 1.10 App auf Heroku zu bekommen. Wenn ich diese Seite zu Heroku schieben, erhalte ich die Anwendungsfehler:Django Heroku Postgres collectstatic --noinput

ProgrammingError at /homelibrary/ 
relation "catalog_book" does not exist 
LINE 1: SELECT COUNT(*) AS "__count" FROM "catalog_book" 

Seit ich die Standard-Sqlite3 Datenbank Postgres geändert, es war nicht lokal ausgeführt und ich bekomme Fehler jedes Mal, wenn ich wandern. Ich habe versucht:

python3 manage.py makemigrations 
python3 manage.py makemigrations catalog 
python3 manage.py syncdb 
python3 manage.py migrate catalog --fake 
python3 manage.py migrate --fake 

ich diesen Fehler jedes Mal: ​​

Traceback (most recent call last): 
File "manage.py", line 22, in <module> 
execute_from_command_line(sys.argv) 
File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 367, in execute_from_command_line 
utility.execute() 
File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 359, in execute 
self.fetch_command(subcommand).run_from_argv(self.argv) 
File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 294, in run_from_argv 
self.execute(*args, **cmd_options) 
File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 345, in execute 
output = self.handle(*args, **options) 
File "/usr/local/lib/python3.5/dist-packages/django/core/management/commands/makemigrations.py", line 95, in handle 
loader = MigrationLoader(None, ignore_no_migrations=True) 
File "/usr/local/lib/python3.5/dist-packages/django/db/migrations/loader.py", line 52, in __init__ 
self.build_graph() 
File "/usr/local/lib/python3.5/dist-packages/django/db/migrations/loader.py", line 268, in build_graph 
raise exc 
File "/usr/local/lib/python3.5/dist-packages/django/db/migrations/loader.py", line 238, in build_graph 
self.graph.validate_consistency() 
File "/usr/local/lib/python3.5/dist-packages/django/db/migrations/graph.py", line 261, in validate_consistency 
[n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)] 
File "/usr/local/lib/python3.5/dist-packages/django/db/migrations/graph.py", line 261, in <listcomp> 
[n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)] 
File "/usr/local/lib/python3.5/dist-packages/django/db/migrations/graph.py", line 104, in raise_error 
raise NodeNotFoundError(self.error_message, self.key, origin=self.origin) 
django.db.migrations.exceptions.NodeNotFoundError: Migration catalog.0004_auto_20170107_2239 dependencies reference nonexistent parent node ('homelibrary', '0003_book_sub_title') 

Manchmal habe ich Variationen in der letzten Zeile, wie

django.db.migrations.exceptions.NodeNotFoundError: Migration catalog.0003_book_sub_title dependencies reference nonexistent parent node ('homelibrary', '0002_auto_20170107_2158') 

und

django.db.migrations.exceptions.NodeNotFoundError: Migration catalog.0006_auto_20170107_2320 dependencies reference nonexistent parent node ('homelibrary', '0005_auto_20170107_2300') 

Hat jemand irgendwelche Vorschläge, was ist g? falsch?

UPDATE:

ich mit allen Migration Dateien gelöscht:

find . -path "*/migrations/*.py" -not -name "__init__.py" -delete 
find . -path "*/migrations/*.pyc" -delete 

Jetzt bin ich nicht in der Lage zu Heroku Master schieben und eine Fehlermeldung erhalten, dass/tmp/build_e7c89faecaf0e6bc9724a9a2be271ba4/static existiert nicht :

python manage.py collectstatic --noinput 

remote:  Traceback (most recent call last): 
remote:   File "manage.py", line 22, in <module> 
remote:   execute_from_command_line(sys.argv) 
remote:   File "/app/.heroku/python/lib/python3.5/site- packages/django/core/management/__init__.py", line 367, in execute_from_command_line 
remote:   utility.execute() 
remote:   File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/__init__.py", line 359, in execute 
remote:   self.fetch_command(subcommand).run_from_argv(self.argv) 
remote:   File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/base.py", line 294, in run_from_argv 
remote:   self.execute(*args, **cmd_options) 
remote:   File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/base.py", line 345, in execute 
remote:   output = self.handle(*args, **options) 
remote:   File "/app/.heroku/python/lib/python3.5/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 193, in handle 
remote:   collected = self.collect() 
remote:   File "/app/.heroku/python/lib/python3.5/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 115, in collect 
remote:   for path, storage in finder.list(self.ignore_patterns): 
remote:   File "/app/.heroku/python/lib/python3.5/site-packages/django/contrib/staticfiles/finders.py", line 112, in list 
remote:   for path in utils.get_files(storage, ignore_patterns): 
remote:   File "/app/.heroku/python/lib/python3.5/site-packages/django/contrib/staticfiles/utils.py", line 28, in get_files 
remote:   directories, files = storage.listdir(location) 
remote:   File "/app/.heroku/python/lib/python3.5/site-packages/django/core/files/storage.py", line 399, in listdir 
remote:   for entry in os.listdir(path): 
remote:  FileNotFoundError: [Errno 2] No such file or directory: '/tmp/build_e7c89faecaf0e6bc9724a9a2be271ba4/static' 

Projektstruktur

---homelibrary 
    ---catalog 
     ---migrations 
     ---static 
     ---css 
     ---images 
      favicon.ico 
     ---templates 
     __init__.py 
     admin.py 
     apps.py 
     forms.py 
     models.py 
     tests.py 
     urls.py 
     views.py 
    ---homelibrary 
     __init__.py 
     settings.py 
     urls.py 
     wsgi.py 
    ---templates (for generic, cross-site forms) 
    ---venv 
    .gitignore.txt 
    db.sqlite3 
    LICENSE 
    manage.py 
    Procfile 
    README.md 
    requirements.txt 
    runtime.txt 

Katalog/models.py

from django.db import models 
from django.contrib.auth.models import User 

class Genre(models.Model): 
""" 
Model representing a book genre (e.g. Science Fiction, Non Fiction). 
""" 
name = models.CharField(max_length=200, help_text="Enter a book genre (e.g. Science Fiction, French Poetry etc.)") 

def __str__(self): 
    """ 
    String for representing the Model object (in Admin site etc.) 
    """ 
    return self.name 


class Language(models.Model): 
""" 
Model representing a Language (e.g. English, French, Japanese, etc.) 
""" 
name = models.CharField(max_length=200, 
         help_text="Enter a the book's natural language (e.g. English, French, Japanese etc.)") 

def __str__(self): 
    """ 
    String for representing the Model object (in Admin site etc.) 
    """ 
    return self.name 


from django.urls import reverse # Used to generate URLs by reversing the URL patterns 


class Book(models.Model): 
""" 
Model representing a book (but not a specific copy of a book). 
""" 
title = models.CharField(max_length=200) 
sub_title = models.CharField(max_length=300, null=True, blank=True) 
author = models.ForeignKey('Author', on_delete=models.SET_NULL, null=True) 
# Foreign Key used because book can only have one author, but authors can have multiple books 
# Author as a string rather than object because it hasn't been declared yet in the file. 
summary = models.TextField(max_length=1000, help_text="Enter a brief description of the book") 
isbn = models.CharField('ISBN', max_length=13, null=True, blank=True, 
         help_text='10-13 Character <a href="https://www.isbn-international.org/content/what-isbn">ISBN number</a>') 
genre = models.ManyToManyField(Genre, help_text="Select a genre for this book") 
language = models.ForeignKey('Language', on_delete=models.SET_NULL, null=True) 

# ManyToManyField used because genre can contain many books. Books can cover many genres. 
# Genre class has already been defined so we can specify the object above. 

def __str__(self): 
    """ 
    String for representing the Model object. 
    """ 
    return self.title 

def get_absolute_url(self): 
    """ 
    Returns the url to access a particular book instance. 
    """ 
    return reverse('book-detail', args=[str(self.id)]) 

def display_genre(self): 
     """ 
     Creates a string for the Genre. This is required to display genre in Admin. 
     """ 
     return ', '.join([genre.name for genre in self.genre.all()[:3]]) 

display_genre.short_description = 'Genre' 


import uuid # Required for unique book instances 
from datetime import date 


class BookInstance(models.Model): 
""" 
Model representing a specific copy of a book (i.e. that can be borrowed from the library). 
""" 
id = models.UUIDField(primary_key=True, default=uuid.uuid4, 
         help_text="Unique ID for this particular book across whole library") 
book = models.ForeignKey('Book', on_delete=models.SET_NULL, null=True) 
imprint = models.CharField(max_length=200, null=True, blank=True) 
due_back = models.DateField(null=True, blank=True) 
borrower = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True) 

@property 
def is_overdue(self): 
    if date.today() > self.due_back: 
     return True 
    return False 

LOAN_STATUS = (
    ('d', 'Maintenance'), 
    ('o', 'On loan'), 
    ('a', 'Available'), 
    ('r', 'Reserved'), 
) 

status = models.CharField(max_length=1, choices=LOAN_STATUS, blank=True, default='a', help_text='Book availability') 

class Meta: 
    ordering = ["due_back"] 
    permissions = (("can_mark_returned", "Set book as returned"),) 

def __str__(self): 
    """ 
    String for representing the Model object 
    """ 
    return '%s (%s)' % (self.id, self.book.title) 


class Author(models.Model): 
""" 
Model representing an author. 
""" 
first_name = models.CharField(max_length=100) 
last_name = models.CharField(max_length=100) 
date_of_birth = models.DateField(null=True, blank=True) 

def get_absolute_url(self): 
    """ 
    Returns the url to access a particular author instance. 
    """ 
    return reverse('author-detail', args=[str(self.id)]) 

def __str__(self): 
    """ 
    String for representing the Model object. 
    """ 
    return '%s, %s' % (self.last_name, self.first_name) 
+1

gut, wenn Sie --fake verwenden, werden die Tabellen nicht erstellt! – e4c5

+0

Ja, das ist mir klar, aber ich habe es ausprobiert, indem ich hier noch eine Frage und Antwort gelesen habe. – cssidy

+0

Haben Sie versucht zu laufen: 'heroku run python manage.py migrieren' –

Antwort

0

Versuchen Sie, jede Migration einschließlich Abhängigkeiten separat ausgeführt werden.

python manage.py migrate auth 
python manage.py migrate sites 
python manage.py migrate <your-app> 

Ich konnte einige Probleme wie diese umgehen.

+0

Ich habe versucht, dies zu tun, aber ich bekomme den gleichen Fehler, wie ich ursprünglich gepostet habe. – cssidy

Verwandte Themen