django-templates

For loop with range in django template

For loop with range in django template Question: How can I make a for loop with range function in django template? I want to search in three lists by using this structure. I tried this and it didn’t work: {% for i in range(number) %} {{ my_list.i }} {% endfor %} Asked By: mhn || …

Total answers: 1

Issue with passing arguments to button onClick js function with Django template

Issue with passing arguments to button onClick js function with Django template Question: I am using django template as standalone. When using it, the Django template rendering is escaping single-quotes (adding to ‘) for the arguments of onClick function call. <button id="order" onclick="myFunction(‘{{ val }}’)"> {{ val }} </button> when rendered in python with with …

Total answers: 2

Django 'QuerySet' object has no attribute 'startswith'

Django 'QuerySet' object has no attribute 'startswith' Question: I’m new to Django and I created function to allow admin to create users accounts. I used a password generator + make_password() function to hash the password. Now it’s sending the plain password to users email and storing it in the database hashed, I used check_password() to …

Total answers: 2

using if else condition with for loop in Django

using if else condition with for loop in Django Question: I fairly new to Django, I have a list of usecase model shown in a a table, and a usecase progress model that includes a foreign key of the usecase. Initially a new usecase doesn’t have a progress yet, so in my template I’m trying …

Total answers: 1

How to show and keep the last record in Django

How to show and keep the last record in Django Question: I’m new to Django I hope I’m making sense. I have two models: Usecase and Usecase_progress. I’m creating a page where I can see a list of all the use cases with their information + the usecase progress for each use case gets recorded. …

Total answers: 1

Chain-Model Getting all objects for template

Chain-Model Getting all objects for template Question: models.py class Sirket(models.Model): isim = models.CharField(max_length=20) def __str__(self): return f"{self.isim}" class Proje(models.Model): ad = models.CharField(max_length=20) total = models.DecimalField(max_digits=20,decimal_places=0) kalan = models.DecimalField(max_digits=20,decimal_places=0) tarih = models.DateField() firma = models.ForeignKey(Sirket, on_delete=models.CASCADE) def __str__(self): return f"{self.ad}" class Santiye(models.Model): isim = models.CharField(max_length=20) kasa = models.DecimalField(max_digits=20, decimal_places=0, default=0) araclar = models.ManyToManyField(Arac) baglanti = models.ForeignKey(Proje, …

Total answers: 2

Django form is not displaying all fields

Django form is not displaying all fields Question: I have a problem, i need to create form like scheme, i have my models and created forms.py.When i add my forms into the HTML, i have only 2 of all fields in my forms.What it can be? This is my models.py class Post(models.Model): full_name = models.CharField(max_length=60, …

Total answers: 3

How to properly create recursive comments in templates django?

How to properly create recursive comments in templates django? Question: I want to create a tree like comment section in my site, but I can’t handle to work it as expected. I just ended up with a mess there, but it seems to me that model works perfectly.. Maybe I am wrong, but I assume …

Total answers: 1

rant_category() got an unexpected keyword argument 'slug'

rant_category() got an unexpected keyword argument 'slug' Question: Running into an rant_category() got an unexpected keyword argument ‘slug’ on my django project. Basically, I just need to get the slug of the #category in my app to show it in the url. Here’s my code: views.py class RantListView(ListView): model = Rant context_object_name = "rants" template_name …

Total answers: 3