Horje
how to make django model field case insensitive Code Example
how to make django model field case insensitive
pip install django_case_insensitive_field
Source: github.com
how to make django model field case insensitive

from django.db.models import CharField

from django_case_insensitive_field import CaseInsensitiveFieldMixin


class CaseInsensitiveCharField(CaseInsensitiveFieldMixin, CharField):
    """[summary]
    Makes django CharField case insensitive \n
    Extends both the `CaseInsensitiveMixin` and  CharField \n
    Then you can import 
    """

    def __init__(self, *args, **kwargs):

        super(CaseInsensitiveMixin, self).__init__(*args, **kwargs) 
        

from .fields import CaseInsensitiveCharField


class UserModel(models.Model):

    username = CaseInsensitiveCharField(max_length=16, unique=True)

user1 = UserModel(username='user1')

user1.save()  # will go through


user2 = UserModel(username='User1') 

user2.save() # will not go through




Shell

Related
nuxt install Code Example nuxt install Code Example
install r packages in anaconda Code Example install r packages in anaconda Code Example
remove unused images docker manually version 1.12.6 Code Example remove unused images docker manually version 1.12.6 Code Example
scp folder recursive Code Example scp folder recursive Code Example
Install PIP ArchLinux Code Example Install PIP ArchLinux Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
16