Dear all,
I am making a small Django app for a bug tracking system to get my
head round this awesome framework. I am facing a problem wherein when
accepting input via a form generated by models. The classes are listed below
(not in its entirety).
[code]
class Report(models.Model):
#type = models.CharField(max_length=200)
REPORT_CHOICES = (
('BR: Bug Report', 'Bug Report'),
('UN: Unknown Problem', 'Unknown Problem'),
)
type = models.CharField(max_length=1, choices=REPORT_CHOICES)
submitter = models.CharField(max_length=200, default='Anonymous')
...
...
class Incident(models.Model):
report = models.ForeignKey(Report)
INCIDENT_CHOICES = (
('SF: Seg Fault', 'SegFault'),
('ML: Memory Leak', 'Memory Leak'),
('MC: Memory Corruption', 'Memory Corruption'),
)
type = models.CharField(max_length=1, choices=INCIDENT_CHOICES)
#description of the incident
description = models.CharField(max_length=20000)
...
...
[/code]
I have generated a form wherein a user can enter a report, and multiple
incidents related to the report. When I use the function to accept the
input, not actually processing anything I get "Select a valid choice. SF:
Seg Fault is not one of the available choices." .
The HTML page code looks like below:
[code]
<h2>Submit a report</h2>
{% if new_report_form %}
<ul>
<form action="/submit_new_report/" method="post">
{{ new_report_form.non_field_errors }}
<div class="reportType">
{{ new_report_form.type.errors }}
<label for="id_reporttype">Type of Report:</label>
{{ new_report_form.type }}
</div>
<div class="incidentType">
{{ new_incident_form.type.errors }}
<label for="id_incidenttype">Type of Incident:</label>
{{ new_incident_form.type }}
</div>
...
...
[/code]
The form.is_valid() call is basically saying that there's a problem with
validating the form input because the choice selected for the incident-type
is not valid. However, in the model description, the choices are clearly
valid and in the form I have different identifiers too. Can someone please
provide some advice as to why this might be happening.
Thanks in advance.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.