Can anyone help me with this issues. Help is very much appreciated. Thanks.
Here is my program
template.html
<tbody>
{% for condition in conditioner %}
{{ condition.owner }}
{% with "#CCE6FF" as bgcolor %}
<tr>
<td style="height: 30">{{ condition.NEW_DATE }}</td>
<td>
<select class="SMOKER select_input" name="condition">
<option value="{{condition.SMOKER.01}}" >Never</option>
<option value="{{condition.SMOKER.02}}" >Ex-Smoker</option>
</select>
<td><input type="text" name="condition" id="condition{{ forloop.counter }}" value="{{ condition.WEIGHT }}" /></td>
<td><input type="text" name="condition" id="condition{{ forloop.counter }}" value="{{ condition.HEIGHT }}" /></td>
<td><input type="text" name="condition" id="condition{{ forloop.counter }}" value="{{ condition.BP }}" /></td>
</tr>
----more program---
models.py
class Condition(models.Model):
owner = models.ForeignKey(Afdeling)
CPR = models.ForeignKey(Patient)
NEW_DATE = models.DateField(null = True, blank = True)
smoker = (("01" , 'Never'),
("02" , 'Ex-Smoker'),
SMOKER = models.CharField(max_length = 2, choices = smoker, null = True, blank = True)
WEIGHT = models.DecimalField(max_digits = 5, decimal_places = 1, null = True, blank = True)
HEIGHT = models.DecimalField(max_digits = 5, decimal_places = 1, null = True, blank = True)
BP = models.SmallIntegerField(max_length = 3, null = True, blank = True)
----more models.py---

It shows the table and selected option but it’s not showing the correct data.
In my database 19 okt should be Ex-Smoker but here it shown Never to all of the column.
The html for the table are:
<select class="SMOKER select_input" name="condition">
<option value="2" >Never</option>
<option value >Ex-Smoker</option>
</select>
I hope my explanation is understandable and if anyone need more clarification I will try my best to explain. I really need help on this. Thank you very much.
I admit that I don’t fully understand, for example what you’re trying to do with
{{condition.SMOKER.01}}, it looks like you would rather want to do{{ condition.smoker.0.0 }}and{{ condition.smoker.1.0 }}which would respectively output01and02, like in pythoncondition.smoker[0][0]andcondition.smoker[0][1].Anyway, about this:
It is simply because you never set a option with
selected="selected". Maybe it should look like this:Hope this helps. But as I said, it is hard to understand what you are trying to do and the fact that you have deliberately broken common standards doesn’t help: using caps for property names and lower case for pseudo-constants is the opposite of what we use to do – and what you can see in django documentation which would look like:
So maybe you’re just confused by your own makings ?