django-templates

Django TemplateDoesNotExist error – wrong path to templates folder

Django TemplateDoesNotExist error – wrong path to templates folder Question: I am currently watching the Django lecture from CS50W and was coding along with Brian just fine. But now I keep getting the same error no matter what I do. I want to render the simple HTML5 page with Django and even though I have …

Total answers: 1

custom message if there isnt any record to show in django-template

custom message if there isnt any record to show in django-template Question: Hello there im trying to show a custom message like "Doesnt exists" if there isnt really any record to show and ignore having None in the template for empty records Template : <div class="col-md-6 col-sm-12 col-xs-12 form-group pull-right "> <label style="color : blue;" …

Total answers: 2

Override a template of a Django package

Override a template of a Django package Question: How can I override a change_list.html template of a Django package e.g Django import export, in an existing Django app. E.g I want to override this package template, this is what I did in my project. path to the file of my app : app/templates/import_export/change_list.html Below is …

Total answers: 1

I can't loop trough a dictionnary in my Django Template

I can't loop trough a dictionnary in my Django Template Question: I’m trying to loop trough a dictionnary to create a simple table with the keys in a column and the values in the other. So in my view I create the dictionnary vegetables_dict. I loop trhough the "items" of a "cartitem". If the item …

Total answers: 3

AttributeError at /addtowatchlist/5: 'QuerySet' object has no attribute 'listings'

AttributeError at /addtowatchlist/5: 'QuerySet' object has no attribute 'listings' Question: Within my app, I’m allowing any given user to add an auction listing to their watch list, but no matter what I have tried, it does not seem to work and I keep getting the error in the title. I am simply trying to access …

Total answers: 2

Django templates error; Reverse for 'search' not found. 'search' is not a valid view function or pattern name

Django templates error; Reverse for 'search' not found. 'search' is not a valid view function or pattern name Question: my layout: {% load static %} <!DOCTYPE html> <html lang="en"> <head> <title>{% block title %}{% endblock %}</title> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> <link href="{% static ‘encyclopedia/styles.css’ %}" rel="stylesheet"> </head> <body> <div class="row"> <div class="sidebar col-lg-2 col-md-3"> …

Total answers: 1

Show date & time from database in html input field

Show date & time from database in html input field Question: I wanted to show dates from my database in my HTML input field. For example id one has "2023-01-13 17:30:00", but when I display it on my input field it just show "Jan." I wanted it to display exactly as "2023-01-13 17:30:00". You might …

Total answers: 1

Django queryset related field lookup with filtering the last object

Django queryset related field lookup with filtering the last object Question: I am building a Price comparing django app, i came across this scenario where i need to filter the Last price for each seller in a related field lookup. Seller model : class Seller(models.Model): name = models.CharField(max_length=250, null=True) Part model : class Part(models.Model): name …

Total answers: 2

Django. Access list index in child for loop

Django. Access list index in child for loop Question: How can I change the accessed index of an inner for loop list based on a counter from the outer loop? In normal python I would do something like parent_list = [‘One’,’Two’,’Three’] child_list = [‘A’,’B’,’C’] for idx, item in enumerate(parent_list): for child_item in child_list[idx]: print(str(idx), item, …

Total answers: 2