Skip to content

Instantly share code, notes, and snippets.

View Vibhu-Agarwal's full-sized avatar
🐍
Having fun with projies

Vibhu Agarwal Vibhu-Agarwal

🐍
Having fun with projies
View GitHub Profile
# Model dependent image size validation
# forms.py
from django import forms
from .models import *
from django.core.files.images import get_image_dimensions
class ValidateImageForm(forms.ModelForm):
class Meta:
@Vibhu-Agarwal
Vibhu-Agarwal / Django_unsignedBigint.py
Created May 30, 2019 08:58 — forked from pinfort/Django_unsignedBigint.py
Django database fields for using unsigned bigint column
from django.db import models
class PositiveBigIntergerRelDbTypeMixin(models.PositiveIntegerRelDbTypeMixin):
def rel_db_type(self, connection):
if connection.features.related_fields_match_type:
return self.db_type(connection)
else:
return models.BigIntegerField().db_type(connection=connection)
class PositiveBigIntegerField(PositiveBigIntegerRelDbTypeMixin, models.BigIntegerField):