Hallo,
Ich habe es auf meinem Windows-PC installiert, aber ich habe diesen Fehler:
python manage.py migrate
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line
utility.execute()
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 347, in execute
django.setup()
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\registry.py", line 112, in populate
app_config.import_models()
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\allan\Documents\progetti\bootcamp\bootcamp\activities\models.py", line 14, in <module>
class Activity(models.Model):
File "C:\Users\allan\Documents\progetti\bootcamp\bootcamp\activities\models.py", line 26, in Activity
user = models.ForeignKey(User)
TypeError: __init__() missing 1 required positional argument: 'on_delete'
Ich möchte mit einer Funktion helfen, wenn ich Zeit verloren habe.
Dieser Fehler tritt auf, wenn django==2.0 ist. Bootcamp ist derzeit nicht mit dieser Version von Django kompatibel. Bitte entfernen Sie es und installieren Sie eine frühere Version, django==1.11.x funktioniert korrekt.
Guten Morgen @sebastian-code ,
Ich habe den Django heruntergestuft, aber jetzt habe ich diesen Fehler:
Traceback (most recent call last):
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 213, in ensure_connection
self.connect()
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 189, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\sqlite3\base.py", line 198, in get_new_connection
conn = Database.connect(**conn_params)
sqlite3.OperationalError: unable to open database file
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line
utility.execute()
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", line 330, in execute
output = self.handle(*args, **options)
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\migrate.py", line 83, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\executor.py", line 20, in __init__
self.loader = MigrationLoader(self.connection)
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\loader.py", line 52, in __init__
self.build_graph()
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\loader.py", line 209, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\recorder.py", line 65, in applied_migrations
self.ensure_schema()
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\recorder.py", line 52, in ensure_schema
if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 254, in cursor
return self._cursor()
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 229, in _cursor
self.ensure_connection()
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 213, in ensure_connection
self.connect()
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 213, in ensure_connection
self.connect()
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 189, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\sqlite3\base.py", line 198, in get_new_connection
conn = Database.connect(**conn_params)
django.db.utils.OperationalError: unable to open database file
Hallo @Allan-Nava, es scheint, dass Sie Probleme mit Ihrer Datenbank haben und der Server keine Verbindung mit dem Datenvolumen herstellen kann. Wie machen Sie diesen Teil?
Hallo @sebastian-code, ist meine erste Django-App mit meinem persönlichen PC-Fenster. Was soll ich machen?
Es hängt davon ab, wie Sie mit Datenbanken arbeiten. Persönlich verwende ich Docker, aber Sie könnten eine lokale Instanz von PostgreSQL verwenden, vielleicht einen vernetzten DB-Server oder eine Art VM mounten. Es gibt auch die einfachere Option als die lokale Verwendung von SQLite.
Ich möchte versuchen, SQLite Locally zu verwenden
Definieren Sie dazu die Variable DATABASE_URL
in Ihrer Datei .env
mit einer richtig formatierten SQLite-Datenbankadresse im URL-Format. Ein Beispiel finden Sie in der Datei env.example
.
Ich verwende die .env mit der gleichen conf:
# PostgreSQL conf
# POSTGRES_PASSWORD=mysecretpass
# POSTGRES_USER=my_super_user
# POSTGRES_DB=bootcamp
# DATABASE_URL=postgresql://my_super_user:[email protected]:5432/bootcamp
# Main environmental variables
DEBUG=True
SECRET_KEY=s3cr3t_key
ALLOWED_HOSTS=*
# URL to have SQLite example and to pass TravisCI
DATABASE_URL=sqlite:////bootcamp/db.sqlite3
# URL for Redis
# REDIS_URL=redis://redis_ip_address:port
Ich habe den gleichen Fehler:
C:\Users\allan\Documents\progetti\bootcamp>python manage.py migrate
Traceback (most recent call last):
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 213, in ensure_connection
self.connect()
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 189, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\sqlite3\base.py", line 198, in get_new_connection
conn = Database.connect(**conn_params)
sqlite3.OperationalError: unable to open database file
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line
utility.execute()
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", line 330, in execute
output = self.handle(*args, **options)
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\migrate.py", line 83, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\executor.py", line 20, in __init__
self.loader = MigrationLoader(self.connection)
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\loader.py", line 52, in __init__
self.build_graph()
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\loader.py", line 209, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\recorder.py", line 65, in applied_migrations
self.ensure_schema()
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\migrations\recorder.py", line 52, in ensure_schema
if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 254, in cursor
return self._cursor()
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 229, in _cursor
self.ensure_connection()
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 213, in ensure_connection
self.connect()
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 213, in ensure_connection
self.connect()
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\base\base.py", line 189, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\allan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\backends\sqlite3\base.py", line 198, in get_new_connection
conn = Database.connect(**conn_params)
django.db.utils.OperationalError: unable to open database file
Das liegt daran, dass die Adresse falsch ist. Für SQLite benötigt Django den physischen Speicherort für die SQLite-Datei auf Ihrer Festplatte, ausgedrückt im URI-Format.
@sebastian-code Danke, es funktioniert!
Wie verwenden Sie django 1.11 mit diesem Befehl pip install -U -r requirements/local.txt
Ich habe gelöst danke!
2018-01-12 11:17 GMT+01:00 jackengine [email protected] :
Wie verwenden Sie django 1.11 mit diesem Befehl pip install -U -r
anforderungen/local.txt—
Sie erhalten dies, weil Sie den Status Öffnen/Schließen geändert haben.
Antworten Sie direkt auf diese E-Mail und zeigen Sie sie auf GitHub an
https://github.com/vitorfs/bootcamp/issues/138#issuecomment-357199201 ,
oder den Thread stumm schalten
https://github.com/notifications/unsubscribe-auth/AVdMg5tftf9BMLRv8opKHg_ngou7E-Zpks5tJzE2gaJpZM4RHiIY
.
@sebastian-code Ich habe Django 2.x im Pip-Cache. Nun, wie kann ich pip zwingen, django 1.9 zu verwenden, während ich diesen Befehl ausführe pip install -U -r requirements/local.txt
Hallo @jackengine Der einfachste Weg ist, den Befehl auszuführen und nach der Installation das Paket manuell zu löschen und dann django erneut zu installieren, aber die gewünschte Version anzugeben. Mein Rat wäre, nicht mit Django v1.9 zu gehen, ist zu alt, ich würde vorschlagen, Django 1.11 zu verwenden, das LTS ist.