Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango ModelForm not displayed in template
    text
    copied!<p>I've got a few ModelForms at the bottom of my models.py file. Some of the modelforms are working (i.e. they are displayed in the template correctly).</p> <p>These are 2 of the several that work:</p> <pre><code>class Account_Balance_Form(ModelForm): class Meta: model = Account_Balance fields = ('date','balance') class Asset_Form(ModelForm): class Meta: model = Asset exclude = ('account','id') </code></pre> <p>Others don't work though. Even using the same view (passing the different ModelForm) to the same template. These are 2 that don't work:</p> <pre><code>class Allocation_Form(ModelForm): class Meta: model = Allocation class Deduction_Form(ModelForm): class Meta: model = Deduction </code></pre> <p>Not really sure what I'm doing wrong... I've tried to run syncdb, but that didn't help. Also, it looks like the form objects are being created fine:</p> <pre><code>allocation_form &lt;forecast.models.Allocation_Form object at 0x90f15ac&gt; </code></pre> <p>They're just not being displayed...Any thoughts?</p> <p>===================</p> <p>FYI, sample view that works:</p> <pre><code>def view_allocation(request): form = Asset_Form() return render_to_response('alloc.html', {'form': form}) </code></pre> <p>Doesn't Work:</p> <pre><code>def view_allocation(request): form = Allocation_Form() return render_to_response('alloc.html', {'form': form}) </code></pre> <p>Sample Template:</p> <pre><code>&lt;html&gt; &lt;body&gt; {{ form.as_p }} &lt;/body&gt; &lt;/html&gt; </code></pre> <hr> <p>as requested:</p> <pre><code>class Allocation(models.Model): user = models.ForeignKey(User) name = models.CharField(max_length=40) account = models.ForeignKey(Account) amount = models.DecimalField(max_digits=20,decimal_places=2) percent = models.DecimalField(max_digits=10,decimal_places=10) allocation_group = models.IntegerField(max_length=11) def __unicode__(self): return self.name class Deduction(models.Model): iei = models.ForeignKey(Inc_Exp_Item, null=True, blank=True) name = models.CharField(max_length=40) amount = models.DecimalField(max_digits=20,decimal_places=2) percent = models.DecimalField(max_digits=10,decimal_places=10) before_tax = models.BooleanField() credit_debit = models.CharField(max_length=6, choices=(('Debit','Income'), ('Credit','Expense'),)) tax_category = models.ForeignKey(Tax_Category) account = models.ForeignKey(Account) active = models.BooleanField() deduct_taxes = models.BooleanField() </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload