Django Case Insensitive Field is used to make Django Model Field case insensitive - by default Django can't do this.
Project description
Django Case Insensitive Field
# install from pypi
pip install django_case_insensitive_field
Django Case Insensitive Field is used to make Django Model Field case insensitive - by default Django can't do this.
Let's assume you have a username field on your UserModel which ofcourse would require username to be unique accross the table but to Django abc is different from ABC because it is case sensitive (meaning: users can use the same username but with different case).
Look at the example below:
from django.db import models
class UserModel(models.Model):
username = models.CharField(max_length=16, unique=True)
user1 = UserModel(username='user1') # will go through
user2 = UserModel(username='User1') # will still go through
Using Django Case Insensitive Model
To make Django Model Field insensitive, you can use the code below:
# fields.py
from django_case_insensitive_field import CaseInsensitiveField
class LowerCharField(CaseInsensitiveMixin, 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)
# models.py
from .fields import LowerCharField
class UserModel(models.Model):
username = LowerCharField(max_length=16, unique=True)
user1 = UserModel(username='user1') # will go through
user2 = UserModel(username='User1') # will not go through
Dependencies
Holla! No dependecy. Lightweight!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_case_insensitive_field-1.0.3.tar.gz.
File metadata
- Download URL: django_case_insensitive_field-1.0.3.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6804b850038401c6ab2e4280b790f099130414336bb9534e537afa113b639341
|
|
| MD5 |
522ce232d4f62b55a86b150b9af114f6
|
|
| BLAKE2b-256 |
5d81773bdfcd170ffbc097a517a43b7ca9bad4e011cbeba2b5a70423a1af37d3
|
File details
Details for the file django_case_insensitive_field-1.0.3-py3-none-any.whl.
File metadata
- Download URL: django_case_insensitive_field-1.0.3-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10a27f0a360624102654cbfe2799210a886a62d8a850a9aeb74322960b310801
|
|
| MD5 |
56520a7e6d1890bb2c9680ce46dc016a
|
|
| BLAKE2b-256 |
bca41e21c832a1069e922062aa66d45829fa69c4ddb432dd3139c441a5de6c68
|