django-templates

ValueError: not enough values to unpack (expected 2, got 1)

↘锁芯ラ 提交于 2020-01-25 21:31:27
问题 the following is my code views.py from django.shortcuts import render from .forms import MedicineForm from .models import Medicine def index(request): all_medicine = Medicine.objects.order_by('id') return render(request, 'medicine/index.html', {'all_medicine': all_medicine}) def add(request): if request.method == 'POST': form = MedicineForm(request.POST) if form.is_valid(): new = Medicine() new.name = form.cleaned_data['药品名称'] new.price = form.cleaned_data['药品价格'] new.number = form.cleaned

Project not finding my reusable app's admin template override

假如想象 提交于 2020-01-25 12:33:12
问题 I have a reusable app with a directory structure like this: myapp/ myapp/ views.py models.py ...etc templates/ myapp/ template1.html ...etc admin/ index.html test/ ...testing stuff setup.py ...etc I'm overriding the index.html admin template so that I can add some additional links in {% block userlinks %} that will appear in a project's navigation when it uses my app. However, when using my app inside a project, the admin homepage still uses Django's own index.html file. The project itself

django-social-auth app not working under virtualenv

最后都变了- 提交于 2020-01-25 12:12:45
问题 I shifted my django project to a virtualenv. I installed django-social-auth library using pip. I copied the same files that were working outside virtualenv to the new environment, but I am getting a Caught NoReverseMatch while rendering: Reverse for 'begin' with arguments '(u'facebook',)' and keyword arguments '{}' not found. I am able to import social_auth library in the django shell and social_auth is included in INSTALLED_APPS and its urls are present in the urls.py file. What mistake can

django-social-auth app not working under virtualenv

回眸只為那壹抹淺笑 提交于 2020-01-25 12:12:24
问题 I shifted my django project to a virtualenv. I installed django-social-auth library using pip. I copied the same files that were working outside virtualenv to the new environment, but I am getting a Caught NoReverseMatch while rendering: Reverse for 'begin' with arguments '(u'facebook',)' and keyword arguments '{}' not found. I am able to import social_auth library in the django shell and social_auth is included in INSTALLED_APPS and its urls are present in the urls.py file. What mistake can

Django check if form choice is empty

假装没事ソ 提交于 2020-01-25 10:43:05
问题 In a template how is it possible to check if a ModelChoiceField is empty ? This is my form: class BatchForm(forms.ModelForm): def __init__(self, user=None, *args, **kwargs): super(BatchForm, self).__init__(*args, **kwargs) this_templates = Template.objects.for_user(user) self.fields["templates"] = forms.ModelChoiceField(queryset=this_templates, required=False, empty_label=None) Then in my views I want to not show the drop down if the queryset is empty something like this... {% if not form

django pagination with multiple lists

别说谁变了你拦得住时间么 提交于 2020-01-25 10:10:10
问题 I am using Django pagination.There are 2 scenarios When user lands on this page the result set returns pre-filtered results so I don't necessarily need to paginate the results. When user turns off filters,I need to show all results( this is when I need to paginate,10000 s of records) Those records come to view in form of different lists And I send the result as a zipped format. I am not able to paginate through more than 1 list/result set. 回答1: All you need is to give Paginator a list of

django pagination with multiple lists

◇◆丶佛笑我妖孽 提交于 2020-01-25 10:08:19
问题 I am using Django pagination.There are 2 scenarios When user lands on this page the result set returns pre-filtered results so I don't necessarily need to paginate the results. When user turns off filters,I need to show all results( this is when I need to paginate,10000 s of records) Those records come to view in form of different lists And I send the result as a zipped format. I am not able to paginate through more than 1 list/result set. 回答1: All you need is to give Paginator a list of

django pagination with multiple lists

穿精又带淫゛_ 提交于 2020-01-25 10:08:14
问题 I am using Django pagination.There are 2 scenarios When user lands on this page the result set returns pre-filtered results so I don't necessarily need to paginate the results. When user turns off filters,I need to show all results( this is when I need to paginate,10000 s of records) Those records come to view in form of different lists And I send the result as a zipped format. I am not able to paginate through more than 1 list/result set. 回答1: All you need is to give Paginator a list of

Pass multiple checkbox selections in a template to a form

吃可爱长大的小学妹 提交于 2020-01-25 10:06:55
问题 I'm new to Django and i'm still learning the ropes. I have the following template, that allows the user to select multiple check boxes. Now I'd like for those options to be passed to a new url path after the user pushes a button. If i'm going about this the wrong way let me know and give a suggestion. <div class="container"> <div class="row"> <div class="col"> <h3>Financial</h3> <ul> {% for app in fingrouplist %} <li><input type="checkbox" name="request_reports" value ="{{app.report_id}}" > {

Pass multiple checkbox selections in a template to a form

别等时光非礼了梦想. 提交于 2020-01-25 10:05:05
问题 I'm new to Django and i'm still learning the ropes. I have the following template, that allows the user to select multiple check boxes. Now I'd like for those options to be passed to a new url path after the user pushes a button. If i'm going about this the wrong way let me know and give a suggestion. <div class="container"> <div class="row"> <div class="col"> <h3>Financial</h3> <ul> {% for app in fingrouplist %} <li><input type="checkbox" name="request_reports" value ="{{app.report_id}}" > {