-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for Django redirects in the project
Implemented `Redirect` model handling in admin, registered it, and added a sample fixture. Updated settings to include `django.contrib.redirects` in `INSTALLED_APPS` and middleware. Added documentation for resolving migration-related issues.
- Loading branch information
1 parent
43e2d59
commit 7535cbc
Showing
5 changed files
with
96 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Resolving `django.db.migrations.exceptions.InconsistentMigrationHistory` Error | ||
|
||
If you encounter the error | ||
`django.db.migrations.exceptions.InconsistentMigrationHistory: Migration socialaccount.0001_initial is applied before its dependency sites.0001_initial on database 'default'.` | ||
while migrating, follow these steps to resolve it: | ||
|
||
--- | ||
|
||
## Steps to Resolve | ||
|
||
### 1. Comment Out Apps and Middleware | ||
|
||
Open the **settings file** (`common.py`) and temporarily comment out the following configurations: | ||
|
||
In the `INSTALLED_APPS` section, comment out: | ||
|
||
```python | ||
'django.contrib.sites', | ||
'django.contrib.redirects', | ||
``` | ||
|
||
In the `MIDDLEWARE` section, comment out: | ||
|
||
```python | ||
'django.contrib.redirects.middleware.RedirectFallbackMiddleware', | ||
``` | ||
|
||
After updating the settings, save the file. | ||
|
||
--- | ||
|
||
### 2. Roll Back the Problematic Migrations | ||
|
||
Run the following Django command in your terminal to roll back the `socialaccount` app's migrations to the start (zero): | ||
|
||
```bash | ||
python manage.py migrate socialaccount zero | ||
``` | ||
|
||
This will unapply all migrations related to the `socialaccount` app. | ||
|
||
--- | ||
|
||
### 3. Restore Settings | ||
|
||
After rolling back the migrations, revert the changes you made in `common.py`: | ||
|
||
1. Uncomment `'django.contrib.sites'` and `'django.contrib.redirects'` in the `INSTALLED_APPS` section. | ||
2. Uncomment `'django.contrib.redirects.middleware.RedirectFallbackMiddleware'` in the `MIDDLEWARE` section. | ||
|
||
Save the file. | ||
|
||
--- | ||
|
||
### 4. Reapply Migrations | ||
|
||
Re-run the migrations step-by-step: | ||
|
||
```bash | ||
python manage.py migrate | ||
``` | ||
|
||
This will reapply all migrations in the correct order, resolving the inconsistent migration history. | ||
|
||
--- | ||
|
||
### Summary of Commands | ||
|
||
Here’s a quick list of the commands you’ll need: | ||
|
||
```bash | ||
# Step 2: Roll back socialaccount migrations | ||
python manage.py migrate socialaccount zero | ||
|
||
# Step 4: Reapply migrations | ||
python manage.py migrate | ||
``` |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters