How i get the value from a dictionary if the key from all keys are the same?

I wanna from a dictionary all values but i have for each value the same key. It is possible that i can get the values in a separately empty list? dic = QuesModel.objects.values("ans").distinct() print(dic) # i get: """<QuerySet [{‘ans’: ‘antwort1’}, {‘ans’: ‘answer2’}, {‘ans’: ‘besitzt als Modelle elemente verschiedene Ereignistypen.’}, {‘ans’: ‘als Nachrichten und Datenobjekte e… Read More How i get the value from a dictionary if the key from all keys are the same?

Django queryset to list of ids with integer values

I need to retrieve IDs from multiple queries and add them into a list. products = Product.objects.filter(category="Apple").values_list("product_id", flat=True) reviewed = Reviews.objects.filter(category="Apple").values_list("product_id", flat=True) selected_ids = [10,20,30] Then I tried all_products = selected_ids + products + reviewed This raised error as list cannot be added to queryset. so, I tried, all_product_ids = selected_ids + list(products) + list(reviewed)… Read More Django queryset to list of ids with integer values

__init__() got multiple values for argument 'user'

I have a form, model and view and trying to show ModelChoiceField with filters I wrote an init in my forms.py but when im trying to submit my form on html page i got an error: "__init__() got multiple values for argument ‘user’ " forms.py class WorkLogForm(forms.ModelForm): worklog_date = forms.DateField(label=’Дата’, widget=forms.DateInput( attrs={‘class’: ‘form-control’, ‘placeholder’: ‘Введите… Read More __init__() got multiple values for argument 'user'

How to call a function in django view.py

I need to call the function get_context_data in my VacanciesView. Code views.py: def VacanciesView(request): navigate_results = Navigate.objects.all() context_vac = { ‘navigate_results’: navigate_results} get_context_data(self, **kwargs) return render(request, ‘main/vacancies.html’, context_vac) def get_context_data(self, **kwargs): context = super(VacanciesView, self).get_context_data(**kwargs) context[‘vacancies’] = sorted(get_vacancies(), key=lambda item: item["published_at"][:10]) return context I try to do it by get_context_data(self, **kwargs), but it takes: name… Read More How to call a function in django view.py

Use HTML-template from other app, in same project (Django)

I have a project wich contains two apps User and Accounting. Since all of their HTML-templates should extend from the same base.html template, I made a third app called Shared, and my accounting/base.html and user/base.html would then extend from shared/base.html like {% extends "shared/base.html" %} {% block content %} <div>Hello world</div> {% endblock content %}… Read More Use HTML-template from other app, in same project (Django)