backend

Check if logged in user is the author of a post | Django | If-else doesn't work

Check if logged in user is the author of a post | Django | If-else doesn't work Question: I want to check if the logged in user is the author of a post in my Forum. I have written some code to figure that out: <div class="right-section-posts"> user: {{ user }} <!–Output: Admin–> author: {{ …

Total answers: 1

Django Crispy Form doesn't add or update database

Django Crispy Form doesn't add or update database Question: Hello, I am writing a small project about a car shop and this is the problem I came up with. I’m trying to add a new car and everything seems to work, but when I fill out the form and click submit, it just redirects me …

Total answers: 1

DRF pagination issue in APIView

DRF pagination issue in APIView Question: I want to implement LimitOffsetPagination in my APIView which was successful but the url is required to be appended with ?limit=<int>. Something like this: But I do not want to manually add that endpoint. So I tried creating a new pagination.py file: But now I am not getting the …

Total answers: 1

django.template.exceptions.TemplateSyntaxError: 'bootstrap_field' received some positional argument(s) after some keyword argument(s)

django.template.exceptions.TemplateSyntaxError: 'bootstrap_field' received some positional argument(s) after some keyword argument(s) Question: I was trying to modify my django sign_in template with bootstrap field along with some arguments but i was not able too. Exception: C:UsershpDesktopfastparcelcoretemplatessign_in.html, error at line 25 ‘bootstrap_field’ received some positional argument(s) after some keyword argument(s) {% bootstrap_field form.username show_lable=False placeholder ="Email" %}` …

Total answers: 1

How to create combobox with django model?

How to create combobox with django model? Question: i want to create something like a combo box with django model, but i don’t find any field type to do that. something like this: enter image description here Asked By: Bassam Nazemi || Source Answers: Simply you can do this in models.py: class Student(models.Model): select_gender = …

Total answers: 1

Django/python retrieving integer value from models.integerfield

Django/python retrieving integer value from models.integerfield Question: class Trainingvalue(models.Model): maximalvalue= models.PositiveIntegerField(null=True,blank=True) How can I retrieve integer from maximal value, in order to use in a views.py function like to create another variable to render it to context dictionary? def trainingplan(request, pk): training = Trainingvalue.objects.get(id=pk) sets1=[3,6] sets2=[3,6] sets3=[2,4] repsrange1=[18,30] repsrange2=[12,24] repsrange3=[10,20] u = Trainingvalue.objects.values(‘maximalvalue’).get(id=1) firstweek= [u*0.55, …

Total answers: 2

Making an authenticated user's form that can be edited in django

Making an authenticated user's form that can be edited in django Question: I am making a medical website, and I wanted to add a feature where the user could add their medical history in a description box. The website renders the main page only when the user has successfully signed in. So what I wanted …

Total answers: 1

Alternative to hardcoding urlpatterns in django

Alternative to hardcoding urlpatterns in django Question: I am making a django website in which the homepage shows links of domains… upon clicking on each domain, you links of respective topics and upon clicking each topic you get links of respective subtopics… The problem is that I want to extract the domains, topics, and subtopics …

Total answers: 2

How to download file using django as backend and nginx

How to download file using django as backend and nginx Question: I have a filefield in a document model from which i can upload files like this document=models.FileField(max_length=350 ,validators=[FileExtensionValidator(extensions)]) uploading is working good, now i want to implement download feature for the frontend, but only those files which are uploaded by the user. using url …

Total answers: 1