WebFaction
Community site: login faq

Hi all, I have a simple model that uses two ManyToMany fields with a CheckboxSelectMultiple widget:

class Language(models.Model):
    name = models.CharField(max_length=100, choices=LANGUAGE_CHOICES)
    ietf = models.CharField(max_length=20, choices=IETF_CHOICES)

    def __unicode__(self):
        return self.name

class Teacher(models.Model):
    name = models.CharField(max_length=200)
    languages_taught = models.ManyToManyField(Language, related_name='languages_taught')
    languages_spoken = models.ManyToManyField(Language, related_name='languages_spoken')
    post_date = models.DateField(auto_now_add=True)
    modified_date = models.DateField(auto_now=True)
    user = models.ForeignKey(User, unique=True)

    def __unicode__(self):
        return self.name

class TeacherForm(ModelForm):
    languages_taught = ModelMultipleChoiceField(widget=CheckboxSelectMultiple(), required=True, queryset=Language.objects.all())
    languages_spoken = ModelMultipleChoiceField(widget=CheckboxSelectMultiple(), required=True, queryset=Language.objects.all())
    class Meta:
        model = Teacher
        exclude = ('user',)

The checkboxes delightfully appear in my dev box but don't show up on the WebFaction hosted account. There is no form widget whatsoever.

Dev box generated HTML:

<table> 
    <tr><th><label for="id_name">Name:</label></th><td><input id="id_name" type="text" name="name" value="Admin" maxlength="200" /></td></tr> 
    <tr><th><label for="id_phone">Phone:</label></th><td><input id="id_phone" type="text" name="phone" value="6175054312" maxlength="20" /></td></tr> 
    <tr><th><label for="id_email">Email:</label></th><td><input id="id_email" type="text" name="email" value="szu.han.chang@gmail.com" maxlength="75" /></td></tr> 
    <tr><th><label for="id_rate">Rate:</label></th><td><input type="text" name="rate" value="200" id="id_rate" /></td></tr> 
    <tr><th><label for="id_bio">Bio:</label></th><td><textarea id="id_bio" rows="10" cols="40" name="bio">This is the legendary Admin user who is a great English teacher. He also speaks Mandarin Chinese.</textarea></td></tr> 
    <tr><th><label for="id_languages_taught_0">Languages taught:</label></th><td><ul> 
    <li><label for="id_languages_taught_0"><input checked="checked" type="checkbox" name="languages_taught" value="1" id="id_languages_taught_0" /> English</label></li> 
    <li><label for="id_languages_taught_1"><input type="checkbox" name="languages_taught" value="2" id="id_languages_taught_1" /> Simplified Chinese</label></li> 
    <li><label for="id_languages_taught_2"><input type="checkbox" name="languages_taught" value="3" id="id_languages_taught_2" /> Traditional Chinese</label></li> 
    </ul></td></tr> 
    <tr><th><label for="id_languages_spoken_0">Languages spoken:</label></th><td><ul> 
    <li><label for="id_languages_spoken_0"><input checked="checked" type="checkbox" name="languages_spoken" value="1" id="id_languages_spoken_0" /> English</label></li> 
    <li><label for="id_languages_spoken_1"><input checked="checked" type="checkbox" name="languages_spoken" value="2" id="id_languages_spoken_1" /> Simplified Chinese</label></li> 
    <li><label for="id_languages_spoken_2"><input checked="checked" type="checkbox" name="languages_spoken" value="3" id="id_languages_spoken_2" /> Traditional Chinese</label></li> 
</ul></td></tr> 
</table>

Webfaction generated HTML:

<table> 
    <tr><th><label for="id_name">Name:</label></th><td><input id="id_name" type="text" name="name" maxlength="200" /></td></tr> 
    <tr><th><label for="id_phone">Phone:</label></th><td><input id="id_phone" type="text" name="phone" maxlength="20" /></td></tr> 
    <tr><th><label for="id_email">Email:</label></th><td><input id="id_email" type="text" name="email" maxlength="75" /></td></tr> 
    <tr><th><label for="id_rate">Rate:</label></th><td><input type="text" name="rate" id="id_rate" /></td></tr> 
    <tr><th><label for="id_bio">Bio:</label></th><td><textarea id="id_bio" rows="10" cols="40" name="bio"></textarea></td></tr> 
    <tr><th><label for="id_languages_taught_0">Languages taught:</label></th><td><ul> 
    </ul></td></tr> 
    <tr><th><label for="id_languages_spoken_0">Languages spoken:</label></th><td><ul> 
    </ul></td></tr> 
</table>

The link is here: http://languagemarket.shanghaiforexpats.com/teachers/add/ (Sorry for the hassle, registration required.)

I am using Python 2.6 on my dev box and 2.7 on WebFaction but that's the only difference. Any ideas as to why this might be happening?

asked 13 May '11, 09:31

hanchang
111
accept rate: 0%

Did you restart the Apache server on our side after updating your code?

There is no special reason for widget=CheckboxSelectMultiple() not to take effect on our side. My only guess is that your new code is not properly loaded. You might want to test the form output via "manage.py shell" as well.

(13 May '11, 09:41) tie

Haha, I'm retarded...

When I deployed, I didn't include any fixtures to insert any Language objects into the production database. Adding Language objects using the Django admin panel fixed the problem. Hope this helps someone else!

permanent link

answered 13 May '11, 10:00

hanchang
111
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×337
×9

question asked: 13 May '11, 09:31

question was seen: 8,427 times

last updated: 13 May '11, 10:00

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM