django-templates

Phython getting issue with urls path

Phython getting issue with urls path Question: I’m learning pyhton django, and I created a file nosotros.html inside of templates/paginas: and on views.py my I have: from django.shortcuts import render from django.http import HttpResponse # Create your views here. def inicio(request): return HttpResponse("<h1> Bienvenido </h1>") def nosotros(request): return render(request, "paginas/nosotros.html") def libros(request): return render(request, "libros/index.html") …

Total answers: 1

Django Template how to get the value of a model through the OneToOneField

Django Template how to get the value of a model through the OneToOneField Question: In my Django App i have Two Models and the User model from django.contrib.auth.models from django.contrib.auth.models import User class Room(models.Model): host = models.ForeignKey(User, on_delete=models.CASCADE, null=True) topic = models.ForeignKey(Topic, on_delete=models.SET_NULL, null=True) name = models.CharField(max_length=200) description = models.TextField(null = True, blank = True) …

Total answers: 2

Select 3 random items and exclude the one already selected

Select 3 random items and exclude the one already selected Question: I’m trying to display three random drinks in my template, selected from a database of drinks. I currently have the random selection working but also noticed theres a chance of a drink showing up twice. How do I prevent this from happening? Is there …

Total answers: 2

Django QuerySet Not returning all data

Django QuerySet Not returning all data Question: I am trying to return all the data in queryset which is saved in my model. But when I try to print it only returns the title nothing else. Bellow are the screenshots attached for refrence. Please assist Code: enter image description here and here is the data …

Total answers: 1

admin panel in Django creating for to change Product media and text from webpage

admin panel in Django creating for to change Product media and text from webpage Question: I have created a website in Django that contains product details and captions. Now, I want to create a dynamic admin panel that performs the following tasks without using code (because the client has no idea about coding): Add or …

Total answers: 2

Better alternative for passing complex object from template to views.py on POST call

Better alternative for passing complex object from template to views.py on POST call Question: In views.py on GET call, I create a random list of questions (its a complex object, list of dictionaries) and I send that list to the template (HTML) file using return render(request, ‘some_page.html’, args). I show one question at a time …

Total answers: 1

Django Not Found: /media/ , GET /media/ HTTP/1.1" 404 2679

Django Not Found: /media/ , GET /media/ HTTP/1.1" 404 2679 Question: I am currently building a project which i have to use media. Since i have used media before i copy pasted everyting from my other project and altough the original is working my current project is not. I can upload and select fotos thru …

Total answers: 2

How to hash stored passwords in mysql using pbkdf2_sha256 using Django

How to hash stored passwords in mysql using pbkdf2_sha256 using Django Question: I have list of user passwords stored as plain text. I think I need a script to run over the stored passwords and hash them. I’m new to Django and not sure where to start or how. I created login and creating accounts …

Total answers: 1

rtsp stream with django

rtsp stream with django Question: I’m trying to put a url based on my views.py but it returns the error: Reverse for ‘transmition’ not found. ‘transmition’ is not a valid view function or pattern name. project urls.py: from django.contrib import admin from django.urls import path, include from django.conf.urls.static import static from django.conf import settings from …

Total answers: 1