""" from __future__ import division import random from datetime import date, datetime, time from string import hexdigits from django import forms from django.core.validators import validate_ipv4_address, validate_ipv6_address, validate_ipv46_address from django.utils import formats from django_any import xunit from django_any.functions import ExtensionMethod, split_model_kwargs, valid_choices any_form = ExtensionMethod() any_form_field = ExtensionMethod() @any_form.register_default def any_form_default(form_cls, **kwargs): """ Returns tuple with form data and files """ form_data = {} form_files = {} form_fields, fields_args = split_model_kwargs(kwargs) for name, field in form_cls.base_fields.items(): if name in form_fields:
from django.db import models, IntegrityError from django.db.models import Q from django.db.models.fields.files import FieldFile from django.contrib.webdesign.lorem_ipsum import paragraphs from django.core.validators import validate_ipv4_address try: from django.core.validators import validate_ipv6_address, validate_ipv46_address except ImportError: validate_ipv6_address = None validate_ipv46_address = None from django_any import xunit from django_any.functions import valid_choices, split_model_kwargs, ExtensionMethod any_field = ExtensionMethod() any_model = ExtensionMethod(by_instance=True) @any_field.decorator def any_field_blank(function): """ Sometimes return None if field could be blank """ def wrapper(field, **kwargs): if kwargs.get('isnull', False): return None if field.blank and random.random < 0.1: return None return function(field, **kwargs) return wrapper