Django form post doesn't contain any values

Issue I have a simple unbound form: class TeamMemberMapForm(forms.Form): remote_id = forms.CharField(widget=forms.HiddenInput()) project = forms.ModelChoiceField(queryset=Project.objects.none()) Initial values are populated in the get_context_data: form.fields[‘remote_id’].value = remote_id form.fields[‘remote_id’].initial = remote_id form.fields[‘remote_id’].disabled = True form.fields[‘project’].queryset = Project.objects.\ filter(owned_by_company=self.request.user.owned_by_company, active=True) On the frontend, I

Continue reading

From API to Django template to show different data while iterating

Issue ***This is view function*** def home_view(request): url = "https://random-recipes.p.rapidapi.com/ai-quotes/50" headers = { "X-RapidAPI-Key": "`enter code here`", "X-RapidAPI-Host": "random-recipes.p.rapidapi.com" } response = requests.request("GET", url, headers=headers).json() res = response context = {‘res’ : change_recipe(), ‘iterator’:range(0,11)} return render(request,’home.html’, context=context) This is django

Continue reading

Django manipulate / modify date in template

Issue Is it possible to make an input that changes the date.today for the whole template ? my template {% for Ansicht in Ansicht.lehrertabelle_set.all %} <tbody> <tr> <th scope="row"></th> <td>{{Ansicht.Pflichtstunden_normal}}</td> <td>{{Ansicht.Status_normal}}</td> {% if Ansicht.Prognose_FK %} <td>{{Ansicht.Prognose_FK.Status}}</td> <td>{{Ansicht.Prognose_FK.Stunden}}</td> {% else %}

Continue reading

Django template includes + extends

Issue This is my Directory Tree. base.html: {% load static %} <!DOCTYPE html> <html lang="en"> {% include ‘weapons/head/head.html’ %} {% include ‘weapons/body/body.html’ %} </html> body.html: {% load static %} <body> {% block content %}{% endblock content %} </body> home.html: {%

Continue reading

Django TemplateDoesNotExist?

Issue My local machine is running Python 2.5 and Nginx on Ubuntu 8.10, with Django builded from latest development trunk. For every URL I request, it throws: TemplateDoesNotExist at /appname/path appname/template_name.html Django tried loading these templates, in this order: *

Continue reading

How to configure a button in Django Admin Change Form to Download PDF File

Issue I have an order field in my models class Order(models.Model): # … order_number = models.CharField(max_length=20,blank=True, null=True) first_name = models.CharField(max_length=50,blank=True, null=True) last_name = models.CharField(max_length=50,blank=True, null=True) def full_name(self): return f'{self.first_name} {self.last_name}’ def full_address(self): return f'{self.address_line_1} {self.address_line_2}’ def __str__(self): return self.order_number based

Continue reading

Django test for 404 erroring because Client expects 200?

Issue I am trying to test my 404 page to ensure certain elements are present on it. My test looks like this: class TestApp404PageIncludesLink(TestCase): def setUp(self): superuser = UserFactory(is_superuser=True, is_staff=True) self.client.force_login(superuser) def test_superuser_can_see_link(self): response = self.client.get("404") self.assertTrue(response.status_code == 404) self.assertContains(response,

Continue reading

Listview must return only the courses that student have puchased in django

Issue My models User class User(AbstractUser): is_student = models.BooleanField(default=False) …. purchased = models.ManyToManyField(Course, blank=True) Course class Course(models.Model): title = models.CharField(max_length=1000) ….. price = models.FloatField() My Views class StudentPurchasedcourse(ListView): model = Course template_name = ‘tutspack/purchasedcourse.html’ context_object_name = ‘course’ def get_queryset(self): queruset

Continue reading

Could not parse the remainder

Issue i want to compare num and {{buildSummary_list.number}}, but why it is not work? And i got an error Could not parse the remainder: ‘{{buildSummary_list.number}}’ from ‘{{buildSummary_list.number}}'”… {% for num in buildSummary_list.paginator.page_range %} {% ifequal num {{buildSummary_list.number}} %} <b>{{num}}</b> {%

Continue reading

Django Templates avoid loop

Issue I am working on a project and jhave a slight confusion. The Djago Template index.html has following code: <div class="carousel-item active"> {% for i in products|slice:"0:"%} <div class="col-xs-3 col-sm-3 col-md-3"> <div class="card" style="width: 17rem;"> <div class="card-body"> {% for img

Continue reading

How to sort a queryset by its Q objects order?

Issue I’ve a simple searching form and view: # forms.py class SearchForm(forms.Form): q = forms.CharField(label=’Search’, max_length=1024, required=False) # views.py def search(request): search_form = forms.SearchForm() q = ” if request.method == ‘GET’: search_form = forms.SearchForm(request.GET) if search_form.is_valid(): q = search_form.cleaned_data[‘q’] products

Continue reading

django-filter looking for templates only in venv

Issue Tried to make custom widget for RangeFilter. Every time django raises TemplateDoesNotExist Template-loader postmortem Django tried loading these templates, in this order: Using engine django: django.template.loaders.filesystem.Loader: C:\Users\Alexander\PycharmProjects\Search\venv\lib\site-packages\django\forms\templates\MyRangeWidget.html (Source does not exist) django.template.loaders.app_directories.Loader: C:\Users\Alexander\PycharmProjects\Search\venv\lib\site-packages\django_filters\templates\MyRangeWidget.html (Source does not exist) django.template.loaders.app_directories.Loader: C:\Users\Alexander\PycharmProjects\Search\venv\lib\site-packages\django\contrib\admin\templates\MyRangeWidget.html

Continue reading