Skip to content
Advertisement

Tag: django-queryset

Django – Retrieve all manytomany field objects related to a specific model

I have my models reviews and news, both having a manytomany relation with Category model. Now I want to get all the categories associated with only one of these two models. For example, to get all categories associated with News model, I tried querying database with News.categories.all() but got AttributeError: ‘ManyToManyDescriptor’ object has no attribute ‘objects’. News Model: Reviews Model:

Splitting dictionary objects

I am building a Blog App and I made a queryset which is showing blog date and likes of every day since blog date, But it is showing in dictionary and i am trying to show both instances differently in table like. Blog Date Likes 20 Sep. 6 Likes 21 Sep. 2 Likes 22 Sep. 4 Likes But it is

django custom Func for specific SQL function

I’m currently performing a raw query in my database because i use the MySQL function instr. I would like to translate is into a django Func class.I’ve spend several days reading the docs, Django custom for complex Func (sql function) and Annotate SQL Function to Django ORM Queryset `FUNC` / `AGGREGATE` but i still fail to write succesfully my custom

Django-queryset join without foreignkey

model.py What I want is to get id_noga where dzienrok=1234. I know that dziens should be but it isn’t and I can’t change that. Normally I would use something like but I don’t know how to join and filter those tables without foreignkey. Answer It’s possible to join two tables by performing a raw sql query. But for this case

Advertisement