akaariai / django-reverse-unique Goto Github PK
View Code? Open in Web Editor NEWA ReverseUnique model field implementation for Django
License: BSD 3-Clause "New" or "Revised" License
A ReverseUnique model field implementation for Django
License: BSD 3-Clause "New" or "Revised" License
First of all, this project is a great idea. Thanks!
current_salary = models.ReverseUnique(
"EmployeeSalary",
filter=Q(valid_from__gte=datetime.now) &
(Q(valid_until__isnull=True) | Q(valid_until__lte=datetime.now))
)
aren't the valid_from
and valid_until
filters swapped so we can actually an employee's current salary?
current_salary = models.ReverseUnique(
"EmployeeSalary",
filter=Q(valid_from__lte=datetime.now) &
(Q(valid_until__isnull=True) | Q(valid_until__gte=datetime.now))
)
Should you be able to include a ReverseUnique field in prefetch_related? Something like Lang.objects.all().prefetch_related('articletranslation_set__article__active_translation')
. Currently this raises an error:
File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/query.py", line 96, in __iter__
self._fetch_all()
File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/query.py", line 856, in _fetch_all
self._prefetch_related_objects()
File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/query.py", line 517, in _prefetch_related_objects
prefetch_related_objects(self._result_cache, self._prefetch_related_lookups)
File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/query.py", line 1598, in prefetch_related_objects
obj_list, additional_prl = prefetch_one_level(obj_list, prefetcher, attr)
File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/query.py", line 1697, in prefetch_one_level
prefetcher.get_prefetch_queryset(instances)
File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/fields/related.py", line 277, in get_prefetch_queryset
qs = self.get_queryset(instance=instances[0]).filter(**query)
File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/query.py", line 590, in filter
return self._filter_or_exclude(False, *args, **kwargs)
File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/query.py", line 608, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1198, in add_q
clause = self._add_q(where_part, used_aliases)
File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1232, in _add_q
current_negated=current_negated)
File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1100, in build_filter
allow_explicit_fk=True)
File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1351, in setup_joins
names, opts, allow_many, allow_explicit_fk)
File "/srv/python-environments/eadfe1e8e3d19d09/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1274, in names_to_path
"Choices are: %s" % (name, ", ".join(available)))
FieldError: Cannot resolve keyword '+' into field. Choices are: abstract, article, body, id, lang, title
The only released version is not compatible with Django 1.9
I'd like to do three things:
CI-tests would be nice, too.
As said above I haven't done a package before, so if somebody has some experience of how to do the above mentioned things, I'm all ears.
Passing callable arguments to queryset is deprecated as of Django 1.9.
Filters such as Q(lang=get_language)
or Q(from_date__lte=date.today)
are no longer valid.
We should allow the filters
kwarg to be a callable
,
def get_active_translation_filters():
return Q(lang=get_language())
active_translation = ReverseUnique(
'ArticleTranslation', filters=get_active_translation_filters
)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.