I’m trying to do a form query on a field and the goal is to get all the kids enrolled in all the teachers classes in this drop down menu. The query I have right now is getting all the classes a teacher is enrolled in . However how do I retrieve the kids within those classes. I attached a
Tag: django-views
Add styling to django Password reset forms
I want to add styling to django’s default password reset form such as classes and placeholders I have the following in my urls.py in the templates Answer yes of course you can overwrite django forms.
How can I remove the upper array list from the list of dictionaries?
I’ve a list of dictionaries and want to get rid of the external list array. Take into consideration the array below, My serializer looks like, and the view definition is, Answer You can use the index of list to refer to the inner dictionary and omit the outer bracket. The below is the output of a[0]:
Django ajax: in call does not make any changes
So I made this ajax view for my user model I extends my user model with an Integerfield of notification, but when I call the ajax it does not give +1 to my notification model, does anybody know what is going on? my urls.py and my ajax call my user profile model Answer So, change url: Then, change the view
How to fix TemplatesDoesNotExist error even after BASE_DIR has been Joined with templates in settings.py?
Image 1- Error I notice Exception Value: registration/login.html , I don’t even have that in the templates, instead, i have sign-in.html, I have no idea why it mentioned login.html. Please see my templates folder below as image 3-Templates. I’m trying to fix the above error. My project path looks like Image 2- project path Image 3- Templates The image 2
How to stop having anonymous user in django
So I have a django project and there is one view(home view) which displays the posts of the followed users and that requires a user to be authenticated, if there is no user loged in, then the code returns a ‘AnonimousUser’ is not iterable error and I will like my code to redirect the anonymous user to the login page
Django items = order.orderitem_set.all() returning empty value for quantity
When I try and put the {{ item.product.quantity }} in it returns an empty value. The quantity value is filled in in the database. I can’t seem t pinpoint the problem. I have tried printing the quantity value but got the same results. cart.html views.py models.py If I do print(items) the result would be: Answer So quantity is a field
NoReverseMatch at /v2/search/SARS_CoV_2/GID1716
I am developing a django application in which I am trying to send a value of the variable to the backend on click of a button through javascript. javascript code: urls.py views.py when I execute this code i am getting following error: what am I doing wrong? how can I solve this issue. I am still at learning stage of
TypeError ‘Purchase’ object has no attribute ‘__getitem__’ [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question views.py def vendor(request,pk): current_shop = get_current_shop(request) instance =get_object_or_404(Vendor.objects.filter(pk=pk,shop=current_shop,is_deleted=False)) Answer purchases is a normal QuerySet that yields model instances when iterated over. All your other queries
Template file not found Django
I am trying to make a home page of a new website via Django. My app name is ‘blog’, home page is home.html I still receive the error template does not exist when I go to http://127.0.0.1:8000/blog/home/ I made sure I added ‘blog’ to my templates in settings.py and that I added the folder templates in the main directory as