0

I've been trying to create an edit option in the frontend for the users to be able to change different settings. At the moment I am bit stuck with the dropdown showing the options that are already saved in the database. I don't know what I'm missing, I hope you can help me out.

models.py

  STATUS_CHOICES = (
    ('4', 'Interview'),
    ('5', 'Rejected'),
    ('2', 'Following'),
    )
class StatusType(models.Model):
    status = models.CharField(max_length=90, choices=STATUS_CHOICES)

    def __str__(self):
        return self.status


class JobStatus(models.Model):
    job_application = models.ForeignKey(JobApplication, on_delete=models.CASCADE)

    def __str__(self):
        return self.status_type.status

index.html

{% with object.jobstatus_set.all|first as status %}
     <form action='' method="post">
       <select class="dropdown" type="dropdown" name='job_status'>
          <option value={{ status }}> {{status}} </option>
       </select>
     </form>
{% endwith %}

Right now it works if I login into the database and assign the value for the job, otherwise the dropdown menu is empty. What I want is to be able to see all the options when clicking on the select menu, so that the users set it to their own choice and then save it.

Thank you, any help is very much appreciated.

I am not using Django forms. I have tried several of the options given to other similar questions, using forms and not, and I always get the same result.

Lolita66
  • 3
  • 1
  • 5
  • Possible duplicate of [Django ChoiceField populated from database values](https://stackoverflow.com/questions/11936470/django-choicefield-populated-from-database-values) – ramganesh Apr 09 '18 at 11:30
  • It is not a duplicate from that one, as I pointed out, so that answer didn't work. Is anyone able to help, please? – Lolita66 Apr 21 '18 at 18:11

0 Answers0