I was trying to find an answer for this question in documentation but I unfortunately did not succeed.
In documentation it states that if I want to group my objects and Count them I should use the following:
MyObject.objects.values('field_to_group_by').annotate(Count('field_to_count'))
However it doesn't work. But when I add simple order_by it does:
MyObject.objects.values('field_to_group_by').annotate(Count('field_to_count')).order_by()
Any idea why is that? They didn't mention that in documentation.
Related
I am working on integrating Elastic Search in my existing Django REST application. I am using the django-dsl-drf module provided in the link below:
https://django-elasticsearch-dsl-drf.readthedocs.io/
In their documentation 'exclude' query param is provided. But the query only when we provide the full field value.
search-url?exclude=<field-value
For eg: If I have a value 'Stackoverflow' in field 'name'. I'll have to provide query param a
?name__exclude=Stackoverflow to exclude records having 'Stackoverflow' as name in the result. I would like to implement a search in such a way that when I provide 'over', I need to exclude these records, similar to ?name__exclude=over
I checked the above tutorial, but I couldn't find it. Is there any work around so that I can exclude records, fields containing terms instead of providing full field value, which is also case-insensitive.
Thanks a lot.
Using the contains functional filter, you can target documents that have their name field value containing the characters over anywhere in their terms:
?name__contains=over
However, as far as I know, there is no way to negate that filter in django-dsl-drf. You can create an issue requesting that feature, though, because odds are high that you're not the only who needs that, since it's a pretty common way of searching.
I want to add names to my constraints so that it's easier to read the .lp / .gams files.
EDIT: Sorry if I hadn't mentioned, but I want to do this when a constraint list is initialized and constraints are added to it. Pyomo documentation has it only for normal constraints.
I was using PuLP before and was able to just add a string in the end of a constraint. Not sure how to do it with Pyomo. Documentation does not show it anywhere.
This question was answered on the Pyomo forum: https://groups.google.com/forum/?nomobile=true#!topic/pyomo-forum/5DgnivI1JRY
I'm trying to fetch all operations related my google Cloud Functions. I need to give a filter parameter for this, but it is unclear to me what this filter should actually be.
The filter is described as "standard list filter", but I couldn't find what this was referring to. From the documentation it was impossible for me to discern what the correct parameters could be.
EDIT:
So far I've tried getting it to work in the "try this API" that's in the documentation.
I've tried filters like
/operations/*
.*
*
and names such as
/v1/name/operations
/name/operations
*
The problem I'm having is that I just have no clue what a valid filter could look like, and as far as I can see it's not in the documentation other than "standard list filter".
The documentation now contains some explanations:
The supported formats of filter are:
To query for specific function:
project:*,location:*,function:*
To query for all of the latest operations for a project:
project:*,latest:true
The drag method in Raphael has three parameters : onmove, onstart , onend.
Most examples in books show examples in that order , like this
drag(onmove, instart, onend)
and then declare them in any order.
Some examples show the parameters in a different order like:
drag(onstart, onmove, onend)
I have't been able to make it work this 2nd way but there are too many examples in books and the web for me to dismiss as just wrong. But is it wrong?
The docs here say...
Element.drag(onmove, onstart, onend, [mcontext], [scontext], [econtext])
And looking in the code here it supports this.
I'm not sure where you've seen the 2nd form you mention, but it looks wrong, and not sure why 'any order' for parameters would make sense. Maybe if you post a link to those examples, it may give further context. But for your own code, I would follow the docs, and then if that doesn't work, post an example jsfiddle or similar of your code for people to look at.
I'm trying to use the Yummly API. I've noticed that some of their developers have answered other questions here, so I'm hoping to catch their eye. I used the documentation at the yummly developer site https://developer.yummly.com/documentation#IDs.
Specifically here is my get request:
<http://api.yummly.com/v1/api/recipe/Avocado-cream-pasta-sauce-recipe-306039>
Which returns this:
Please include X-Yummly-App-ID and X-Yummly-App-Key
Seems like this is a sensible thing, except that I don't see anywhere in the documentation for the single recipe call where I'm supposed to insert that info. Any one out there know how to properly format this?
or include them as URL parameters:
_app_id=app-id&_app_key=app-key
https://developer.yummly.com/documentation#IDs
Try this:
http://api.yummly.com/v1/api/recipe/Avocado-cream-pasta-sauce-recipe-306039?_app_id=ID&_app_key=KEY
You need to take the URL you mentioned in the question and add your authentication parameters to it. So it becomes:
http://api.yummly.com/v1/api/recipe/Avocado-cream-pasta-sauce-recipe-306039?_app_id=ID&_app_key=KEY
Instead of ID and KEY insert the application id and key from your account on developer.yummly.com