1๐
โ
Try changing your view variable name to team_numbers and replacing your team-stats.html snippet with the following:
<form method="post" action="">
<select name="teams">
{% for team_number in team_numbers %}
<option value="{{ team_number }}">Team Num: {{ team_number }}</option>
{% endfor %}
</select>
</form>
Then update your view to:
class TeamStatsView(View):
def get(self, request, *args, **kwargs):
return render(request, 'team-stats.html',
{'team_numbers':Team.objects.values('team_number')})
๐คNick S.
1๐
You can use choices=NUMBERS
NUMBERS = (
('1','1'),
('2','2'),
('3','3'),
('4','4')
)
class Team(models.Model):
team_number = models.IntegerField(choices=NUMBERS )
team_notes = models.CharField(max_length=150)
event_id = models.ForeignKey(
'Event', on_delete=models.CASCADE, unique=False)
def __unicode__(self):
return str(self.team_number)
class Meta:
db_table = 'teams'
app_label = 'frcstats'
๐คerajuan
- [Answered ]-How to set environment variable using Django and Python?
- [Answered ]-How to specify authentication info to memcache with django?
0๐
Your view variable is called team_number
.
Try to change TeamStatsView
into team_number
:
<form method="post" action="">
{% csrf_token %} {{ team_number }}
<input type="submit" value="Submit" />
</form>
๐คilse2005
- [Answered ]-Django template โ Create a cron job to wish an happy birthday
- [Answered ]-What's this after aggregation in django?
- [Answered ]-Django-allauth and custom Signup form
- [Answered ]-RemovedInDjango110Warning: The context_instance argument of render_to_string is deprecated
Source:stackexchange.com