I can't save an object through my view. MultiValueDictKeyError at - python

I'm trying to save a object 'Animal' with the data from my form but im getting a error.
This is my view:
def addAnimal(request):
if request.user.id == None:
return render(request, "deny.html")
else:
if request.method == 'POST':
animal_name = request.POST['animal_name']
animal_type = request.POST['animal_type']
animal_age = request.POST['animal_age']
animal_port = request.POST['animal_port']
animal = Animal(animal_name=animal_name, animal_age=animal_type, animal_type=animal_age, animal_port=animal_port)
animal.save()
return render(request, "home.html", args)
This is the model im trying to save:
class Animal(models.Model):
animal_name = models.CharField(max_length=255)
animal_age = models.ManyToManyField(Age)
animal_type = models.ManyToManyField(Type)
animal_port = models.ManyToManyField(Port)
def __str__(self):
return self.animal_name
And this is my form:
<form method="post" class="form-signin" action="{% url 'addAnimal' %}">
{% csrf_token %}
<img class="mb-4" src="{% static 'images/logo_transparent.png' %}" alt="" width="300" height="300">
<h1 class="h3 mb-3 font-weight-normal text-white">Adicione o seu Animal de Estimação</h1>
<input type="text" id="animal_name" name="animal_name" class="form-control"
placeholder="Nome do Seu Animal de Estimação">
<select class="form-control" id="animal_type" name="ration_type">
<option value="Cão">Cão</option>
<option value="Gato">Gato</option>
</select>
<select class="form-control" id="animal_age" name="animal_age">
<option value="Junior">Junior</option>
<option value="Adulto">Adulto</option>
<option value="Senior">Senior</option>
</select>
<select class="form-control" id="animal_port" name="animal_port">
<option value="Pequeno">Pequeno</option>
<option value="Médio">Médio</option>
<option value="Grande">Grande</option>
</select>
<div> &nbsp</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Adicionar</button>
</form>
And a print if you nedd so:
Update
Im getting a new error:
TypeError at /addAnimal/
Direct assignment to the forward side of a many-to-many set is prohibited. Use animal_age.set() instead.
How can I solve it?

This is because of your POST request.
Try request.POST.get() instead. And/or when you're taking in attributes from POST, try typing for example request.POST['animal name', None] or request.POST.get('animal name', None) Where None can be replaced with any default value. It's a null checking issue I think.

Related

Django: Deleting multiple objects with a view that requires a object pk?

Hey I got this Code to remove my keys:
class AKeysRemove(DeleteView, ProgramContextMixin):
model = AKeys
template_name = 'administration/keys/remove.html'
def dispatch(self, request, *args, **kwargs):
return super(AKeysRemove, self).dispatch(request, *args, **kwargs)
def get_success_url(self):
return reverse('akeys_index', args=[self.get_program_id()])
def delete(self, request, *args, **kwargs):
# Get the query parameters from the request
is_active = request.GET.get('is_active')
category = request.GET.get('category')
# Build a Q object to filter AccessKeys by is_active and category
q_filter = Q()
if is_active is not None:
q_filter &= Q(is_active=is_active)
if category is not None:
q_filter &= Q(category=category)
# Check if there are any filters
has_filters = is_active is not None or category is not None
# Delete the AKeys that match the filter, or just the one AKey
if has_filters:
queryset = self.get_queryset().filter(q_filter)
deleted_count, _ = queryset.delete()
if deleted_count == 1:
messages.success(request, f"One AKey deleted.")
else:
messages.success(request, f"{deleted_count} AKeys deleted.")
else:
obj = self.get_object()
obj.delete()
messages.success(request, f"AKey {obj} deleted.")
return redirect(self.get_success_url())
My url looks like this:
re_path(r'^p/(?P<p_id>[0-9]+)/keys/(?P<pk>[0-9]+)/delete/?$', AKeysRemove.as_view(), name='akeys_delete'),
Deleting one Single Key works fine, but I build myself a filter to delete Keys from a certain category or if they're active or not (is_active)
<div class="row" style="margin-top: 10px">
<div class="col-md-12">
<form method="POST" action="{% url 'akeys_delete' p.id %}" id="delete-akeys-form">
<div class="form-group">
<label for="category-filter">Category:</label>
<select name="category" id="category-filter" class="form-control">
<option value="">All</option>
{% for category in acategories %}
<option value="{{ category.name }}">{{ category.name }}</option>
{% endfor %}
</select>
</div>
<div class="form-group">
<label for="active-filter">Status:</label>
<select name="is_active" id="active-filter" class="form-control">
<option value="">All</option>
<option value="true">Active</option>
<option value="false">Inactive</option>
</select>
</div>
<button type="submit" class="btn btn-default">Delete</button>
</form>
</div>
</div>
The problem now is that when I open my site I get the obvious error:
Reverse for 'akeys_delete' with arguments '(3,)' not found. 1 pattern(s) tried: ['admin/p/(?P<p_id>[0-9]+)/keys/(?P<pk>[0-9]+)/delete/?$']
Which I understand, since its missing the key.pk, I just can't really figure out how I could re-write my code to accept both single objects to delete and multiple?
I'm thankful for any help :)
I assume you want to support multiple functionality with same view. In that case, why not write two urls pointing to the same view, like this:
re_path(r'^p/(?P<p_id>[0-9]+)/keys/(?P<pk>[0-9]+)/delete/?$', AKeysRemove.as_view(), name='akeys_delete'),
re_path(r'^p/(?P<p_id>[0-9]+)/keys/delete/?$', AKeysRemove.as_view(), name='akeys_multi_delete'),
And update the url in template:
<form method="POST" action="{% url 'akeys_multi_delete' p.id %}" id="delete-akeys-form">

I'm a newbie to python/Django and getting a value error and no http response error. Also when added with return statement, form is not updating [duplicate]

This question already has answers here:
The view didn't return an HttpResponse object. It returned None instead
(7 answers)
Closed last month.
ValueError at /update_department/14
The view management.views.update_department didn't return an HttpResponse object. It returned None instead.Also when added with return statement data is not updating.
Request information
USER
admin
GET
No GET data
POST
Variable Value
csrfmiddlewaretoken
'XLqZBPhMKImvlfgWsNLeN1Ei8nz5u1HJ15IvAQV4JNwVMeG31rhDOD1q9PJuwXmz'
department_code
'15'
department_name_e
'Finance'
department_name_l
'Finance'
parent_code
''
submit
''
These are the details.I don't know why is there error here while all the posted data is right.also the form is not updating.
Models:
class Departments(models.Model):
department_code = models.CharField(db_column='Department_Code', primary_key= True, max_length=20, db_collation='SQL_Latin1_General_CP1_CI_AS') # Field name made lowercase.
department_name_e = models.CharField(db_column='Department_Name_E', max_length=50, db_collation='SQL_Latin1_General_CP1_CI_AS') # Field name made lowercase.
department_name_l = models.CharField(db_column='Department_Name_L', max_length=50, db_collation='SQL_Latin1_General_CP1_CI_AS') # Field name made lowercase.
parent_code = models.CharField(db_column='Parent_Code', max_length=20, db_collation='SQL_Latin1_General_CP1_CI_AS') # Field name made lowercase.
is_active = models.BooleanField(db_column='Is_Active') # Field name made lowercase.
created_by = models.IntegerField(db_column='Created_By') # Field name made lowercase.
created_date = models.DateTimeField(db_column='Created_date') # Field name made lowercase.
modified_by = models.IntegerField(db_column='Modified_By') # Field name made lowercase.
modified_date = models.DateTimeField(db_column='Modified_date') # Field name made lowercase.
class Meta:
db_table = 'Departments'
unique_together = (('department_code'),)
def __str__(self):
return str("self.department_name_e") or ''
View:
#login_required
def update_department(request, department_code):
dep_up = Departments.objects.get(department_code=department_code)
if request.method == "POST":
form = DepartmentsForm(request.POST, instance = dep_up)
if form.is_valid():
department_code = form.cleaned_data['department_code']
department_name_e = form.cleaned_data['department_name_e']
department_name_l = form.cleaned_data['department_name_l']
parent_code = form.cleaned_data['parent_code']
obj = form.save(commit = False)
obj.is_active = True
obj.created_by = request.user.id
obj.created_date = datetime.today()
obj.modified_by = request.user.id
obj.modified_date = datetime.today()
obj.save()
return HttpResponseRedirect('department_list')
forms:
class DepartmentsForm(forms.ModelForm):
class Meta:
model = Departments
fields = ['department_code','department_name_e','department_name_l','parent_code']
HTML:
{% extends 'base.html' %}
{% block title %}Update Company{% endblock title %}
{% block body %}
<div style="margin-left:22%" class=" top-marg">
<h2 ><strong>Company:</strong></h2><br><br>
<form class="" action="{%url 'update_company' comp_up.company_code %}" method="post">
{% csrf_token %}
<div style="margin-left:20%;margin-right:20%" class="form-floating ">
<input type="text" value="{{comp_up.company_code}}" class="form-control" id="company_code" name="company_code" placeholder="Company Code" required>
<label style="margin-left:15px" for="company_code">Company Code</label>
</div>
<br>
<div style="margin-left:20%;margin-right:20%" class="form-floating ">
<input type="text" value="{{comp_up.company_name_e}}" class="form-control" id = "company_name_e" name="company_name_e" placeholder="Enter Company" required>
<label style="margin-left:15px" for="company_name_e">Company Name English</label>
</div>
<br>
<div style="margin-left:20%;margin-right:20%" class="form-floating ">
<input type="text" value="{{comp_up.company_name_l}}" class="form-control" id = "company_name_l" name="company_name_l" placeholder="Enter Company" required>
<label style="margin-left:15px" for="company_name_e">Company Name Local</label>
</div>
<br>
<div style="margin-left:20%;margin-right:20%" class="form-floating ">
<input type="tel" value="{{comp_up.tel}}" class="form-control" id = "tel" name="tel" placeholder="Telephone Number" required>
<label style="margin-left:15px" for="tel">Telephone Number</label>
</div>
<br>
<div style="margin-left:20%;margin-right:20%" class="form-floating ">
<input type="tel" value="{{comp_up.fax}}" class="form-control" id = "fax" name="fax" placeholder="Enter Fax"required>
<label style="margin-left:15px" for="fax"> Fax Number</label>
</div>
<br>
<div style="margin-left:20%;margin-right:20%" class="form-floating ">
<textarea name="address" class="form-control" rows="4" cols="100" placeholder="Address" required>{{comp_up.address}}</textarea>
<label style="margin-left:15px" for="address">Address</label>
</div>
<br>
<div style="margin-left:20%;margin-right:20%" class="form-floating ">
<select class="form-control" name="country_id" required>
<option value="{{comp_up.country_id.id}}" >{{comp_up.country_id.country_name_e}}</option>
{% for con in country %}
<option value="{{con.id}}" >{{con.country_name_e}}</option>
{% endfor %}
</select>
</div>
<br>
<label style = "margin-left:21%; " for="logo">Logo</label>
<div class="form-floating" >
<input value="{{comp_up.}}" style = "margin-left:21%;" accept="image/*" type="file" name="logo" onchange="loadFile(event)" required> <br>
<img style = "margin-left:21%;" id="output" >
<script>
var loadFile = function(event) {
var output = document.getElementById('output');
output.src = URL.createObjectURL(event.target.files[0]);
output.onload = function() {
URL.revokeObjectURL(output.src) // free memory
}
};
</script>
</div>
<br><br>
<center>
<button type="submit" class="btn btn-success" name="submit">Update</button>
<button type="button" class="btn btn-primary" onclick="window.location.href = '{%url 'company_list'%}'" name="cancel">Cancel</button>
</center>
</form>
</div>
{% endblock body %}
You have provided HttpReponse only for POST and valid form. You should give the standard response (with empty form) for fresh entries or posting with errors. Like this:
#login_required
def update_department(request, department_code):
dep_up = Departments.objects.get(department_code=department_code)
if request.method == "POST":
form = DepartmentsForm(request.POST, instance = dep_up)
if form.is_valid():
...
return HttpResponseRedirect('department_list')
form = DepartmentsForm()
return render(request, 'template.html', context={'form': form})

2023 Everybody! We made it. I want to update my form, but my details are not pulling through to the form

I want to Update/Edit my details on my form. I want to pull the existing details from the database and have them populate on the form, without having the user start from the beginning.
Views.py
def Client_Update(request, Client_id):
ClientUpdate = TestModel.objects.get(pk=Client_id)
ClientUpdates = TestForm(request.POST or None, instance=ClientUpdate)
if request.method == 'POST':
if ClientUpdates.is_valid():
ClientUpdates.save()
return redirect('/Client_Details')
return render(request, 'GymApp/ClientUpdate.html',
{'ClientUpdate':ClientUpdate,
'ClientUpdates':ClientUpdates})
urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.Home, name='Home'),
path('ClientList/', views.Client_list, name='Client_list'),
path('ClientDetails/<int:Client_id>', views.Client_Details, name='Client_Details'),
path('ClientUpdate/<int:Client_id>', views.Client_Update, name='Client_Update'),
path('ClientDelete/<int:Client_id>', views.Client_Delete, name='Client_Delete'),
path('DownloadingCSV/', views.DownloadingCSV, name='DownloadingCSV'),
path('Search/', views.Search, name='Search'),
]
HTML Page
{% extends 'GymApp/Layout.html' %}
{% block content %}
<h1>Updating status</h1>
<form action="" method="POST">
{% csrf_token %}
<div class="mb-3">
<input type="text" class="form-control"
name="Name" placeholder="Client's Name"><br>
<input type="text" class="form-control"
name="Surname"placeholder="Client's Surname"><br>
<select name="Gender" class="form-control">
<option selected disabled>
Open this select menu
</option>
<option value="Male">Male</option><br>
<option value="Female">Female</option>
</select>
</div>
<div class="mb-3">
<input type="text" class="form-control" name="Weight" id="Weight" placeholder="Client's Weight"><br><br>
<input type="text" class="form-control" name="Height" id="Height" placeholder="Client's Height"><br><br>
<button type="button" onclick="calculation()">Calculation update</button>
<br>
</div>
<br>
<div class="mb-3">
<input type="text" class="form-control" name="Outcome" id="Outcome" placeholder="BMI Outcome"><br>
<select name="Activity_log" class="form-control"><br>
<option selected disabled>Open this select menu</option>
<option value="Not Active">Not Active</option><br>
<option value="Active">Active</option>
</select>
<br>
<button type="submit">Finalising update!</button>
</div>
</form>
<script>
function calculation(){
W = document.getElementById('Weight').value;
H = document.getElementById('Height').value;
O = W * H;
document.getElementById('Outcome').value = O;
}
</script>
{% endblock %}
And the outcome when i press the Update button is the following:
As you can the form is empty
How to i pull the existing details on my form? Please help.
from django.db import models
# Create your models here.
class TestModel(models.Model):
Name = models.CharField(max_length=30, blank=True)
Surname = models.CharField(max_length=30, blank=True)
Weight = models.CharField(max_length=30, blank=True)
Height = models.CharField(max_length=30,blank=True)
Gender = models.CharField(max_length=6, blank=True, null=True)
Outcome = models.CharField(max_length=30,blank=True)
Activity = models.CharField(max_length=30, blank=True)
def __str__(self):
return self.Name
And this is my updated HTML
<form action="" method="POST">
{% csrf_token %}
<div class="mb-3">
<input type="text" class="form-control" name="Name" value={{Name}}><br>
<input type="text" class="form-control" name="Surname" value={{Surname}}><br>
<select name="Gender" class="form-control">
<option selected disabled>
Open this select menu
</option>
<option value="Male" value={{Gender}}>Male</option><br>
<option value="Female" value={{Gender}}>Female</option>
</select>
</div>
<div class="mb-3">
<input type="text" class="form-control" id="Weight" value={{Weight}} ><br><br>
<input type="text" class="form-control" id="Height" value={{Height}} ><br><br>
<button type="button" onclick="calculation()">Calculation update</button>
<br>
</div>
<br>
<div class="mb-3">
<input type="text" class="form-control" name="Outcome" id="Outcome" placeholder="BMI Outcome"><br>
<select name="Activity_log" class="form-control"><br>
<option selected disabled>Open this select menu</option>
<option value="Not Active">Not Active</option><br>
<option value="Active">Active</option>
</select>
<br>
<button type="submit">Finalising update!</button>
</div>
</form>
All my views.py
from django.shortcuts import render, redirect
from . models import TestModel
from . forms import TestForm
from django.http import HttpResponse
import csv
# Create your views here.
def Search(request):
if request.method == "POST":
Searching = request.POST['Searching']
Results_query = TestModel.objects.filter(Name__contains=Searching)
{'Searching':Searching,
'Results_query':Results_query}
return render(request, 'GymApp/Searching.html',
{'Searching':Searching,
'Results_query':Results_query})
def DownloadingCSV(request):
response = HttpResponse(content_type='text/csv')
response['content-disposition'] = 'attachment; filename=Client_list.csv'
writer = csv.writer(response)
Downloading_all = TestModel.objects.all()
writer.writerow(['Name','Surname',
'Weight','Height',
'Outcome','Gender',
'Activity'])
for download in Downloading_all:
writer.writerow([download.Name,
download.Surname,
download.Weight,
download.Height,
download.Outcome,
download.Gender,
download.Activity])
return response
def Client_Delete(request, Client_id):
ClientUpdate = TestModel.objects.get(pk=Client_id)
ClientUpdate.delete()
return redirect('Home')
def Client_Update(request, Client_id):
ClientUpdate = TestModel.objects.get(pk=Client_id)
ClientUpdates = TestForm(request.POST or None, instance=ClientUpdate)
if request.method == 'POST':
if ClientUpdates.is_valid():
ClientUpdates.save()
return redirect('/Client_Details')
return render(request, 'GymApp/ClientUpdate.html',
{'ClientUpdate':ClientUpdate,
'ClientUpdates':ClientUpdates})
def Client_list(request):
Clients = TestModel.objects.all()
return render(request, 'GymApp/ClientList.html',
{'Clients':Clients})
def Client_Details(request, Client_id):
ClientDetails = TestModel.objects.get(pk=Client_id)
return render(request, 'GymApp/ClientDetails.html',
{'ClientDetails':ClientDetails})
def Home(request):
Forms = TestForm
if request.method == 'POST':
Forms = TestForm(request.POST or None)
if Forms.is_valid():
Forms.save()
return redirect('Client_list')
return render(request, 'GymApp/Home.html',{})
### You have not given value
<input type="text" class="form-control"
name="Name" value={{ClientUpdates.Name}} placeholder="Client's Name"><br>
###{{Name}} --> your model field name

How to display Selected option value Selected in option tag in Django Template File?

I want to keep user selected option active from the long SELECT OPTION dropdown list what they choose from SELECT OPTION. active mean display selected value. Like by default in select options it shows Spanish To English(first one) but if user selects French To English I want to keep selected this one
This is my HTML form in template file.
<form action="" method="post">
{% csrf_token %}
<div class="d-flex form-inputs">
<select class="form-select" aria-label=".form-select-lg" name="lang_txt">
<option value="span_to_eng">Spanish To English</option>
<option value="eng_to_span">English To Spanish</option>
<option value="french_to_eng">French To English</option>
</select>
<input name="txt" class="form-control p-3" type="text" placeholder="Search...">
<img src="/static/assets/image/search.png" alt="">
</div>
</form>
This is views function
def lang_convert_view(request):
if request.method == "POST" and 'txt' in request.POST:
txt = request.POST.get('txt')
selected_lang = request.POST.get('lang_txt')
data = custom_function_name(txt)
context = {'data': data}
else:
context = {}
return render(request, 'index.html', context)
Views:
def lang_convert_view(request):
if request.method == "POST" and 'txt' in request.POST:
txt = request.POST.get('txt')
selected_lang = request.POST.get('lang_txt')
data = custom_function_name(txt)
context = {'data': data}
else:
data = Model.objects.get(id='your query')
context = {'data': data}
return render(request, 'index.html', context)
Template:
<form action="" method="post">
{% csrf_token %}
<div class="d-flex form-inputs">
<select class="form-select" aria-label=".form-select-lg" name="lang_txt">
<option value="span_to_eng" {% if data.selected_lang == 'span_to_eng' %}selected{% endif %}>Spanish To English</option>
<option value="eng_to_span" {% if data.selected_lang == 'eng_to_span' %}selected{% endif %}>English To Spanish</option>
<option value="french_to_eng" {% if data.selected_lang == 'french_to_eng' %}selected{% endif %}>French To English</option>
</select>
<input name="txt" class="form-control p-3" type="text" placeholder="Search...">
<img src="/static/assets/image/search.png" alt="">
</div>
</form>

GAE Python self.request.get_all not returning selected value

I am trying to get a value out of a SELECT tag.
My HTML is
<div class="form-group">
<label for="acadYear">Academic Year:</label>
<select id="acadYear" name"acadYear">
<option value="2017-18">This Academic Year</option>
<option value="2018-19">Next Academic Year</option>
</select>
</div>
My python code to get this value is
acadYear=self.request.get('acadYear')
This doesn't return anything. When I try
acadYear=self.request.get_all('acadYear')
throws an error
BadValueError: Expected string, got []
What's happening? Any clues?
MORE DETAILS
The Entity
from google.appengine.ext import ndb
class Allocation(ndb.Model):
acadYear = ndb.StringProperty()
branch = ndb.StringProperty()
semester = ndb.StringProperty()
subjectCode = ndb.StringProperty()
subjectName = ndb.StringProperty()
facultyId = ndb.StringProperty()
facultyName = ndb.StringProperty()
choiceNumber = ndb.StringProperty()
status = ndb.StringProperty()
createdOn = ndb.DateTimeProperty(auto_now_add=True)
#classmethod
def faculty_query(cls, parent_key):
return cls.query(ancestor=parent_key).order(-cls.createdOn)
HTML Code to Receive Data
<form action="" method="post">
<legend>Mention Your New Preferences Here</legend>
<div class="form-group">
<label for="acadYear">Academic Year:</label>
<select id="acadYear" name="acadYear">
<option value="2017-18">This Academic Year</option>
<option value="2018-19">Next Academic Year</option>
</select>
</div>
<div class="form-group">
<label for="branch">Branch:</label>
<input type="text" id="branch" name"branch" value="CSE or ISE or MCA">
</div>
<div class="form-group">
<label for="semester">Semester:</label>
<input type="text" id="semester" name="semester" value="From 1 to 8"/>
</div>
<div class="form-group">
<label for="choiceNumber">Choice#:</label>
<input type="text" id="choiceNumber" name="choiceNumber" value="1,2,3"/>
</div>
<div class="form-group">
<label for="subjectCode">Subject Code:</label>
<input type="text" id="subjectCode" name="subjectCode" value="Example: 10CS43"/>
</div>
<div class="form-group">
<label for="subjectName">Subject Name:</label>
<input type="text" id="subjectName" name="subjectName" value="Example: Design and Analysis of Algorithms"/>
</div>
<div class="form-group">
<button type="submit">Save Preference</button>
</div>
</form>
Python Handler
MainHandler Class
class MainHandler(webapp2.RequestHandler):
def _render_template(self, template_name, context=None):
if context is None:
context = {}
# Get the logged in user
user = users.get_current_user()
ancestor_key = ndb.Key("User", user.nickname())
qry = Allocation.faculty_query(ancestor_key)
context['allocs'] = qry.fetch()
template = jinja_env.get_template(template_name)
return template.render(context)
#ndb.transactional
def _create_alloc(self, user):
alloc = Allocation(parent=ndb.Key("User", user.nickname()),
acadYear=self.request.get_all('acadYear'),
branch=self.request.get('branch'),
semester=self.request.get('semester'),
subjectCode=self.request.get('subjectCode'),
subjectName=self.request.get('subjectName'),
facultyId=user.user_id(),
facultyName=user.nickname(),
choiceNumber=self.request.get('choiceNumber'),
status='Requested')
alloc.put()
def get(self):
user = users.get_current_user()
if user is not None:
logout_url = users.create_logout_url(self.request.uri)
template_context = {
'user': user.nickname(),
'logout_url': logout_url,
}
self.response.out.write(
self._render_template('main.html', template_context))
else:
login_url = users.create_login_url(self.request.uri)
self.redirect(login_url)
def post(self):
user = users.get_current_user()
if user is None:
self.error(401)
self._create_alloc(user)
logout_url = users.create_logout_url(self.request.uri)
template_context = {
'user': user.nickname(),
'logout_url': logout_url,
}
self.response.out.write(
self._render_template('main.html', template_context))
acadYear=self.request.get_all('acadYear') returns a list - apparently in Unicode - which need to become string for putting into data store.
I have tried the following
(1) Use an intermediate variable = does not work.
(2) Encoding to UTF-8 - can't because the list does not have an encode method.
(3) I don't know which element would be chosen [0] or [1]. Hence I can't try
acadYear=self.request.get_all('acadYear')[0].encode('UTF-8').
Such a simple thing - but - why it had to be so complex!
Any help is appreciated. I am losing face before kids.
You have a typo in this line:
<select id="acadYear" name"acadYear">
You need to add an "=" after "name". Because of this typo, your browser is not sending the data for the select field.

Categories

Resources