Y
Y
yuki2021-05-04 15:40:17
Django
yuki, 2021-05-04 15:40:17

How to link resume to User model 1 to 1?

I ran into a problem that I can not link a user account to his resume. There is a User model (the usual one that comes from Django) and a ResumesModel model

class ResumesModel(models.Model):
    client_id = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True)
    work_experience = models.IntegerField(verbose_name="Опыт работы")
    specialization = models.TextField(verbose_name="Специальность")
    desired_salary = models.IntegerField(verbose_name="Желаемая зарплата", blank=True)
    hard_skills = models.TextField(verbose_name="Ключевые навыки")
    about_you = models.TextField(verbose_name="О себе")
    native_language = models.TextField(verbose_name="Родной язык")
    foreign_language = models.TextField(verbose_name="Иностранный язык")

    def __str__(self):
        return str(self.client_id)

In general, the idea itself seems wrong to me, because the process should be automated in terms of capturing the current user, and I need to select an entity from the list (which is complete nonsense). Please tell me how to do better or how to at least fix the error: ValueError at /work/resumes/create. Cannot assign "1": "ResumesModel.client_id" must be a "User" instance.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question