| Name | zippzom |
|---|---|
| Email Address | n/a |
| Posts | 2 |
-
- 2010-07-01 13:59:40
- Checkbox Help
- Board » Django » Templates
-
I'm trying to put in a checkbox in a website, but I can't get it to work. I put in this HTML code in the template:
<td><label for="id_membership">Commitee:</label> <input type="checkbox" name="membership?" id="membership" /> </td> <td><input type="submit" value="Submit" /></td>
and threw this code in the place where of the rest of the code for that page was being done:
membership = forms.BooleanField(required=False, label="Membership") if membership: u.membership = True
and because the rest of the data about the people was being stored in the default user thing that Django provides, i tried to write this "add-on for it"
class ReaderAddOn(models.Model): membership = models.BooleanField() user = models.ForeignKey(User, unique=True)
I'm sure the code i posted isn't helpful, so i'm more just looking for how to do it, not so much why my code isn't working. Thanks!
-
- 2010-06-27 10:16:36
- Tutorial problems
- Board » Django » Models
-
So, i'm working through the tutorial, but i'm having a problem with
the unicode method that you put in the model in the part 1 writing your own apps. I've copied
the code to the letter (I think), but it still only returns <Poll:Poll object>
instead <Poll: Whats Up?>. Any ideas why this could be happening?
Here is my code:
from django.db import models import datetime class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') def _unicode_(self): return self.question def was_published_today (self): return self.pub_date.date() == datetime.date.today() class Choice(models.Model): poll = models.ForeignKey(Poll) choice = models.CharField(max_length=200) votes = models.IntegerField() def _unicode_(self): return self.choice
and here is what happens


