Skip to content
Advertisement

Tag: django

Django foreign key JWT auth

In my project I have the Post and Category Model and full working JWT Authentication. I want to create a view, that creates a new Post object, in which author will be assigned to Token owner that I pass in authorization (Bearer Token ) postman.image.example. I dont know how to do it please help. Sorry for my english. Serializer Answer

Add time in django Models.py

I tried subtracting two times in models.py but I got error. Here is my model That I have been working. and BusCompanyRoute have journey length. Now I tried adding these times in using @property decorator in following way but end up getting following error warning as: Class ‘time’ does not define ‘__add__’, so the ‘+’ operator cannot be used on

Django group by Choice Field and COUNT Zeros

Consider the following django model: Now, I’d like to group all Ratings by the number of ratings per category like this: which returns a QuerySets like this: Is there a way to include all not-rated dimensions? To achieve an output like: Answer First we will create a dictionary with counts for all dimensions initialised to 0. Next we will query

Setting href to dynamic view name

Trying to pass urls.py view names dynamically to template and then creating hyperlink to each view. How can href be adjusted to handle it. Answer I do not know what stg.addLink returns but to make it work you need to change from to BUT AGAIN it may not work. It depents what stg.editLink returns

Paginator not displaying page numbers Django

I’m trying to use the paginator inbuild Django module so that the user can pass the pages. The problem is that I’ve configured everything as it should, but the pages numbers are not displaying. The place where it should have the numbers is entirely blank. Why can that due to? Home Shop Shop views.py: Any help i would really appreciate

Multiple models in Django form

I have the following models: I’d like to create a front-end form which allows a user to review a coach, including a rating for some pre-populated categories. In my head, the form would look something like: I’ve seen Django Formsets in the documentation but these appear to exist for creating multiple forms from the same model as a single form?

maximum recursion depth exceeded when using Django redirects

I’m experiencing this error where when I try to redirect a user to a webpage using Django, it showed me this error maximum recursion depth exceeded views.py app’s urls.py Project’s urls.py Did I do something wrong? Did I not add something in settings.py? I’m new to Django Answer When you create the function “redirect”, you ovewrites the built-in function “redirect”

Advertisement