django-forms

Django form not saving inputs- refreshes upon submission

两盒软妹~` 提交于 2020-01-06 06:04:27
问题 I am trying to create a website with two dropdown menus: Department and Course Number. The data for the dropdown menus comes from the "courses" table of my SQL database. Right now my website initializes properly and shows the correct options in the dropdown menus. However, when the user selects an option within the dropdown menus and submits their choices, the website reloads as a blank slate so their selections are not being saved or processed. The error lies somewhere in the CourseForm form

why does password reset works with unregistered email in django?

半世苍凉 提交于 2020-01-06 04:20:11
问题 I have a couple of questions regarding how the password reset works in Django. How can I do testing on password reset testing during development phase? The password reset sends email to unregistered email addresses successfully (as appears on screen). I thought it should display "no such registered email address is found" instead of displaying "password reset successful". Here is the form used for password reset. I am confused from the form action. It submits to itself which is http://127.0.0

why does password reset works with unregistered email in django?

独自空忆成欢 提交于 2020-01-06 04:20:06
问题 I have a couple of questions regarding how the password reset works in Django. How can I do testing on password reset testing during development phase? The password reset sends email to unregistered email addresses successfully (as appears on screen). I thought it should display "no such registered email address is found" instead of displaying "password reset successful". Here is the form used for password reset. I am confused from the form action. It submits to itself which is http://127.0.0

Passing information between web pages in Django

蓝咒 提交于 2020-01-06 04:15:47
问题 I have an Image Gallery System where I'm building a feature to edit the attributes of an uploaded image. @login_required def edit(request): if request.method == 'POST': ZSN = request.POST['ZSN'] ZSN = 'images/' + ZSN + '.' image = Images.objects.filter(file__startswith=ZSN) if image: return HttpResponseRedirect('/home/photo-edit', {'image':image}) else: return HttpResponse("Invalid ZSN.") else: return render(request, 'cms/edit.html') This is my edit method in views.py . Notice that I am

how to increase the range of years to show up in Django templates?

不羁岁月 提交于 2020-01-06 04:12:07
问题 In the signUp form I am creating, I am pre-populating the date-of-birth field to "yesterday". But the scroll down menu for year is limited to 9 years. how can I increase the number of years to show up. It must not be limited. I have attached the image. you can see that there is an option to choose only among those nine years. Any ideas how to fix this? signups/forms.py: from django import forms from signups.models import SignUp import datetime from django.forms.extras.widgets import

Creating a drop-down menu of Member IDs

為{幸葍}努か 提交于 2020-01-05 23:56:18
问题 I have a model Member that includes a specification called member_id. class Member(models.Model): member_id = models.SlugField(max_length=10) name = models.CharField(max_length=200) gender = models.CharField(max_length=1, choices=GENDER_CHOICES) mobile = models.SlugField(max_length=20) def __str__(self): return self.name I want to create a drop-down menu of stored member ID's for the user to choose from in select_member.html . Right now, I have this in forms.py : (pretty sure it's wrong)

Django, passing information when modifying queryset for ModelForm

十年热恋 提交于 2020-01-05 12:28:07
问题 Database: Document has many Sections, Sections has many Comments On each document page, there is a comment form that lets you pick the section (using a ModelChoiceField). The problem is that the ModelChoiceField will contain ALL sections for all documents. So to limit them I do this: class CommentForm(ModelForm): def __init__(self, *args, **kwargs): super(CommentForm, self).__init__(*args, **kwargs) if self.instance: logger.debug(self.instance.document_id) # Prints "None" self.fields['section

update django choice field with database results

人走茶凉 提交于 2020-01-05 12:15:27
问题 I am developing an application using django where the UI needs to be updated when user interacts with it. For instance I have a Drop down field where the user selects a drink and submits it then based on that a dropdown with the places that drink is available, price and quantity at each place needs to be displayed. The user will then further submit the form for second process. From my understanding the Forms in django are pre-defined and I am not able to think of a way using which I could

How can you manually render a form field with its initial value set?

大城市里の小女人 提交于 2020-01-05 05:54:34
问题 I'm trying to render a form's fields manually so that my designer colleagues could manipulate the input elements within the HTML instead of struggling in Python source. ie. Instead of declaring form fields like this... {{ form.first_name }} .. I actually do ... <label for="id_first_name">Your name:</label> <input type="text" value="{{ form.first_name.somehow_get_initial_value_here }}" name="first_name" id="id_first_name" class="blabla" maxlength="30" > {% if form.first_name.errors %}<span>***

How to add a custom field in django model form?

末鹿安然 提交于 2020-01-05 05:29:48
问题 I'm trying to add a readonly field in a form. The model Folder is registered in admin site. The FolderAdminForm defines the custom field statistics . There isn't statistcs field in the Folder model, I just want to put some readonly data on the form. This data is defined in the template. But I get a error whenever the user doesn't have edit permission. If the user only have the view permission,this error is raised: AttributeError: Unable to lookup 'statistics' on Folder or FolderAdmin Here is