Im looking for a solution for DRF where I would get query like this:
..../?sort=foo&order=asc/desc
I was able to change order param to "sort" but I dont know how to add explicitly "&order=asc" except current solution which uses "-" before column.
thank you in advance.
Related
I need to find the cities (municipality) in a circle around a point, the only way I found to do that is to search for "city-hall" (800-8100-0163). I use with curl from php to retrieve the json result.
https://browse.search.hereapi.com/v1/browse?at={$coords}&in=circle:{$coords};r={$raggio}&lang=it&categories=800-8100-0163&limit=100&apiKey=<apiKey>
but some cities are missing in the result even if there's a city-hall in there so I think it's the wrong way to do that.
So my question is: is there a better way to achieve what I need?
It seems your request should be other.
If you search in Places Category System then should be parameter cat=800-8100-0163 and parameter (category system) should be cs=pds
Then request will look like: https://places.ls.hereapi.com/places/v1/browse?in=42.2722%2C13.3917%3Br%3D180718&cat=800-8100-0163&size=100&cs=pds&Accept-Language=it-It%2Cit%3Bq%3D0.9%2Cru-RU%3Bq%3D0.8%2Cru%3Bq%3D0.7%2Cde-DE%3Bq%3D0.6%2Cde%3Bq%3D0.5&app_id=WvHj2YKdvDQaKq1ZWCwL&app_code=W-ENnB-UBLqwG7sEhqyLMQ
i have an api(web service) in django like this:
http://127.0.0.1:9000/api/back_office/appointments/days/?branch=1
that in swagger i want to input query parameter named branch but don't work this(all of my Apis have same problem!!).
before, i use older version of swagger and for enter query parameters use like --param_name syntax, but now in django-rest-swagger==2.1.1 don't work this syntax.
can anyone help me?
Perhaps i should use get_customizations in OpenAPIRenderer class?
Thanks in advance.
For adding query parameters to swagger please, go through this post
I'm trying to order_by a query but i cannot seem to accomplish it, any help would be appreciated
users = User.objects.filter(Q(groups__name=group)).distinct()
This is the starting query i have tried many ways to make this work with the order_by method. But cant seem to get it working i am trying to order the query by the first_name in descending order.
.order_by('-first_name'.desc())
Something like this?
I get an error 'str' object has no attribute 'desc'
I have tried to look this up but cant see it being produced in the context that i am using it so i cant relate to the answers
-- Edit --
i have had some progress, Names are changing places but i cant seem to match a pattern, So i am thinking that (Q(groups__name=group)) could be the cause of it but i have no idea what this actually does, Can anyone explain this to me? thanks
use
.order_by('-first_name')
instead of
.order_by('-first_name'.desc())
- stands for descending already. otherwise you are trying to call a method on a string instead of QuerySet object
I have three class in my ontology
class babyAge (6+, 8+, 12+)
class taste (asam, manis, asin)
class food (recipe name)
i want to querying data food for babyAge (6+) and have taste (asam)
i use this code in my java program (i dont know if there are other code more simple than this one, if you know please tell me too) :
SELECT ?babyAge ?taste ?food
WHERE { ?babyAge mpasi:hasResep ?food.
?food mpasi:hasRasa ?taste.
FILTER regex(str(?babyAge),"6+").
FILTER regex (str(?taste),"asam")}
and i get my data. but when i execute that code in protege, i dont get anything. Can someone help me?
It's difficult to tell without seeing the ontology.
My first move would be to ensure mpasi is bound to the same value in the ontology and in your query - it might be a case of mismatched IRIs.
You might also want to try without filters and see if anything is returned.
I am almost done with my first production-ready django-project. I got one big problem left:
I got an article-search-view that renders a list of found articles. Pagination is working just fine for the resultlist. When I click on the article-title the object-detail-page opens. What I want: previous- and next-result-links on the object-detail-page.
I tried several approaches to similar problems but didn't find a working solution. If I try to use a paginator with only one article (for the object-detail-page) I need to know that paginator-index in the resultlist. But how?
Even the .get_next(previous)_by_foo-Method is not really usable in this scenario AFAICT. Or am I missing something obvious here? Thanks for any help in advance!
Paginator from django works with lists. A way of searching indexes in lists it's like that:
['aaa', 'bbb', 'ccc'].index('bbb') # result: 1
or so like this:
model = object()
[object(), object(), model].index(model) # result: 2
Hope that gives you a hint on how you find paginator-index on your list.
If you want to get a link, at object-details-page, to next item from search-result, you must get next item from the search-result. To get a next item you need to perform the same search query which was executed in search-page and apply some extra filters to get only the next item from that list. But here you have a problem: you only have object-id in object-details page, you don't have the search-term. Without search-term you won't be able to create the search-query. That means you need to get search-term somehow. How do you get that search-term? You need to pass it from the search-result-page somehow. You can save the search-term in session/cookie, or, maybe better: you can pass it via a GET parameter to object-details page. Now when you search-term in object-display page, you can perform a search-query, and from that query you can select the next and the previous objects.
I think now you should be able to implement that. If not you could show some of your code of object-details view, maybe someone will write some code for you.
you could use this
next »
« previous