Skip to content

Instantly share code, notes, and snippets.

View x-N0's full-sized avatar
🌊
Experimentation is the key to mastering.

Robinson Chaplain x-N0

🌊
Experimentation is the key to mastering.
View GitHub Profile
@x-N0
x-N0 / remove_custom_fk_uniqueconstraint_django_mysql.md
Created September 20, 2023 18:37 — forked from cb109/remove_custom_fk_uniqueconstraint_django_mysql.md
Fix: Cannot remove UniqueConstraint on ForeignKey with Django/MySQL

Django allows you to define custom UniqueConstraints to specify which combinations of values are allowed in a row, but removing these later can be problematic when some ForeignKey is involved, at least with MySQL it may throw a Cannot drop index '...': needed in a foreign key constraint at you.

The example below shows you how to resolve such a situation in 3 small individual migrations:

  • We start with an existing UniqueConstraint.
class MyModel(models.Model):
    other_model = models.ForeignKey("OtherModel", on_delete=models.CASCADE)
    name = models.CharField(Max_length=128)
@x-N0
x-N0 / README.md
Created November 7, 2022 21:57 — forked from BastinRobin/README.md
Django URL regex

Common Regular Expressions for Django URLs

A list of comman regular expressions for use in django url's regex.

Example Django URLs patterns:

urlpatterns = patterns('',
@x-N0
x-N0 / git-bash-in-webstorm.md
Created October 10, 2020 22:25 — forked from sadikaya/git-bash-in-webstorm.md
git bash inside Webstorm terminal

Go to File -> Settings -> Tools -> Terminal and change Shell path based on the the installed git version.

for 64bit:

"C:\Program Files\Git\bin\sh.exe" --login -i

for 32bit:

"C:\Program Files (x86)\Git\bin\sh.exe" --login -i