Click here to Skip to main content
15,671,597 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My form is receiving data when I put values in it but it is not displaying it in HTML.
user = models.OneToOneField(User, on_delete = models.CASCADE)
  image = models.ImageField(default = 'default.jpg', upload_to = 'profile_images')
  ethnicity = models.CharField(choices= ETHINIC_CHOICES, default=BLACK, max_length= 200 )
  email_confirmed =  models.BooleanField(default=False)
  date_birth = models.DateField(blank=True, null=True)
  sex = models.CharField(choices=SEX_CHOICES, default= OTHER, max_length= 200)
  marital_status = models.CharField(choices= MARITAL_STATUS, default= SINGLE, max_length= 200)
  addressLine1 = models.CharField(null = True, max_length= 200)
  addressLine2 = models.CharField(null= True, max_length= 200)
  suburb = models.CharField(blank=True, null=True, max_length= 200)
  city = models.CharField(blank=True, null=True,max_length= 200)
  province = models.CharField(choices=PROVINCE_CHOICES, default=GAUTENG, max_length= 200)
  phoneNumber = models.CharField(blank=True, null=True, max_length= 200)
  slug = models.SlugField(max_length=300, unique=True, blank=True, null=True)
  date_created = models.DateTimeField(
  last_updated = models.DateTimeField(blank=True, null=True)
  cover_letter = models.FileField(blank=True, upload_to='resumes')
  cv = models.FileField(blank=True, null=True, upload_to='resumes')

  def _str_(self):
      return '{} {} {}'.format(self.first_name,self.user.last_name, self.uniqueId)

  def get_absolute_url(self):
      return reverse('resume-detail', kwargs ={'slug' : self.slug})

  def save(self, *args, **kwargs):

      if self.slug is None:
          self.slug = slugify('{} {} {}'.format(self.user.first_name, self.user.last_name, self.uniqueId))

      if self.image == 'default.jpg':
          self.image = random.choice(self.IMAGES) #randomely choose between IMAGES folder images and assign it here

      super(Resume, self).save(*args, **kwargs)
image = forms.ImageField(required=False, widget=forms.FileInput(attrs={'class': 'form-control'})) 
    ethnicity = forms.ChoiceField(choices = ETHINIC_CHOICES, widget=forms.Select(attrs={'class': 'nice-select rounded'}))
    date_birth = forms.DateField(required=True, widget=forms.DateInput(attrs={'class': 'form-control', 'placeholder': 'Enter a date: '}))
    marital_status = forms.ChoiceField(choices = MARITAL_STATUS, widget=forms.Select(attrs={'class': 'nice-select rounded'}))
    addressLine1 = forms.CharField(required=True, widget=forms.TextInput(attrs={'class': 'form-control resume', 'placeholder': 'Enter Address Line 1'}))
    addressLine2 = forms.CharField(required=True, widget=forms.TextInput(attrs={'class': 'form-control resume', 'placeholder': 'Enter Address Line 2'}))
    suburb = forms.CharField(required=True, widget=forms.TextInput(attrs={'class': 'form-control resume', 'placeholder': 'Enter Suburb'}))
    city = forms.CharField(required=True, widget=forms.TextInput(attrs={'class': 'form-control resume', 'placeholder': 'Enter City'}))
    province = forms.ChoiceField(choices = PROVINCE_CHOICES, widget=forms.Select(attrs={'class': 'nice-select rounded'}))
    phoneNumber = forms.CharField(required=True, widget=forms.TextInput(attrs={'class': 'form-control resume', 'placeholder': 'Enter Phone Number'}))
    cover_letter = forms.FileField(required=False, widget=forms.FileInput(attrs={'class': 'form-control'}))
    cv = forms.FileField(required=False, widget=forms.FileInput(attrs={'class': 'form-control'}))
    class Meta:
        model = Resume
        fields = [

<form class="p-4 border rounded" submit = 'POST' enctype="multipart/form-data" >
            {% csrf_token %}
            {{ form.non_field_errors }}
            <!-- DEBUG -->
                      {% for field in form %}
                          {% if field.errors %}{{ field.html_name }}: {{ field.errors }}{% endif %}
                      {% endfor %}
 <div class="form-group app-label">

                      <label class="text-muted" >Profile Image</label>
                      {{ form.image }}
                   <div class="col-md-12"

                    <div class="form-group app-label">

                      <label class="text-muted" >Ethnicity</label>
                      {{ form.ethnicity }}
                   <label class="text-muted" >Date birth</label>
                   {{ form.date_birth }}
                <label class="text-muted" >marital_status</label>
                {{ form.marital_status}}
                <label class="text-muted" >addressLine1</label>
                {{ form.addressLine1}}
                <label class="text-muted" >addressLine2</label>
                {{ form.addressLine2}}
                <label class="text-muted" >suburb</label>
                {{ form.suburb}}
                <label class="text-muted" >city</label>
                <label class="text-muted" >province</label>
                {{ form.province}}
                <label class="text-muted" >cover_letter</label>
                {{ form.phoneNumber}}
                <label class="text-muted" >cover_letter</label>
                {{ form.cover_letter}}
                <label class="text-muted" >cv</label>
<div class="row form-group">
                  <div class="col-md-12">
                    <input type="submit" value="create-resume" class="btn px-4 btn-primary text-white">

I am not sure what I am doing wrong.

What I have tried:

I tried debugging it but I am not receiving any error. I am also logged in during this so I am getting user info too.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900