To reverse all migrations for an app, you can run:
python manage.py migrate my_app zero
4篇 django related articles
To reverse all migrations for an app, you can run:
python manage.py migrate my_app zero
I want to recreate the migrations, so I deleted files under migrations folder, and drop the database. And try this python manage.py makemigrations, it reponse No changes detected.
Create the database again, and clear files and folders under migrations, then try the following:
python manage.py makemigrations --empty appnamepython manage.py makemigrationspython manage.py migrateIt works!
mysql server was installed by brew install mysql
ERROR: Failed building wheel for mysqlclient
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
Exception: Wrong MySQL configuration: maybe https://bugs.mysql.com/bug.php?id=86971 ?
In the Django's tutorial, I created an app name front, and its urls.py definition like this:
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('front/', include('front.urls')),
path('admin/', admin.site.urls),
]
So, if the app's url in web browser is http://127.0.0.1:8000/front/
In fact, most website the home page won't have subdirectory. So, the solutions is here:
from django.contrib import admin
from django.urls import path, include, re_path
urlpatterns = [
re_path(r'^', include('front.urls')),
path('front/', include('front.urls')),
path('admin/', admin.site.urls),
]
Now, you can visit the app root url in the home page. http://127.0.0.1:8000/