Note that there are some explanatory texts on larger screens.

plurals
  1. POdjango form error : Caught AttributeError while rendering: 'NoneType' object has no attribute 'label'
    primarykey
    data
    text
    <p>Model:</p> <pre><code>class AppUser(models.Model) : user = models.ForeignKey(User, unique=True) slug = models.SlugField(editable=False, blank=True) date_created = models.DateTimeField(editable=False, auto_now_add=True) last_updated = models.DateTimeField(editable=False, auto_now=True) hobbies = models.CharField(max_length=100, blank=True, null=True) education_level = models.CharField(max_length=100, blank=True, null=False) identifier = models.CharField(max_length=100, blank=True, null=True, unique=True) class Student(models.Model): appuser = models.ForeignKey(AppUser , unique=True) institution = models.ForeignKey(Institution , blank=True, null=False) course = models.CharField(max_length=100, blank=True, null=True) department = models.ForeignKey(Department, blank=True, null=True) institute_email = models.EmailField(blank=True, null=True) is_valid = models.BooleanField(default=False) </code></pre> <p>Forms:</p> <pre><code>class StudentForm(ModelForm): institute_id = forms.CharField() institution = forms.ModelChoiceField(queryset=Institution.objects.all()) course = forms.ChoiceField(choices=COURSE_CHOICES) education_level = forms.ChoiceField(choices=EDUCATION_LEVELS) class Meta: model = Student exclude = ('appuser','department', 'is_valid') </code></pre> <p>Views:</p> <pre><code>student_formset = inlineformset_factory(AppUser,Student,fields=('institution', \ 'course', 'institute_email', 'identifier', 'education_level'),form=StudentForm) if request.POST: student_form = student_formset(request.POST, instance=user) if student_form.is_valid(): </code></pre> <p>Template:</p> <pre><code>&lt;form method='post' action='#student'&gt; {{ student_form.management_form }} {% for form in student_form.forms %} &lt;p&gt;{{ form}}&lt;/p&gt; {% endfor %} &lt;/form&gt; </code></pre> <p>Error:</p> <pre><code>Caught AttributeError while rendering: 'NoneType' object has no attribute 'label' </code></pre> <p>Request Method: GET Request URL: <a href="http://127.0.0.1:8000/profiles/add_details/" rel="nofollow">http://127.0.0.1:8000/profiles/add_details/</a> Django Version: 1.2.4 Exception Type: TemplateSyntaxError Exception Value:<br> Caught AttributeError while rendering: 'NoneType' object has no attribute 'label' .....</p> <p>Template error .... Caught AttributeError while rendering: 'NoneType' object has no attribute 'label'</p> <p><strong>It shows problem in template code..</strong></p> <p><strong>If in template instead of rendering {{form}} we use {{form.as_p}} then it outputs nothing.</strong></p> <p>Any ideas on above issue??</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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