User modifying field in Django

I’m sort of new to Django and am currently struggling with a certain aspect of it. In my project I want all Users to have access to certain Job s added by the admin and appear on the Front end. However, each Job has a field called userStatus that the user should be able to edit. This field however should not change for any other users. Currently, I have created a model out of userStatus and created a Foreign Key field to link to a Job and also it was my Django interview questions. Then userStatus has a User Foreign Key Field.

class Job(models.Model):
    name = models.CharField(max_length=200, help_text='Enter the Spring/Internship')
    course = models.ForeignKey('Course', on_delete=models.RESTRICT,null=True)
    company = models.ForeignKey('Company', on_delete=models.RESTRICT,default='N/A')
    deadline = models.DateField(null=True, blank=True)
    userStatus = models.ForeignKey('userStatus', on_delete=models.RESTRICT, null=True, blank=True)

class userStatus(models.Model):
    user = models.ForeignKey(User, on_delete=models.RESTRICT)

    USER_STATUS = (
        ('n', 'Not Applied'),
        ('a', 'Applied'),
        ('i', 'Got Interview'),
        ('o', 'Got Offer'),
        ('r', 'Rejected'),
    )

    stage = models.CharField(
        primary_key=True,
        max_length=1,
        choices=USER_STATUS,
        blank=False,
        default='c',
        help_text='What is the current stage of the process',
    )

The User should not be able to edit any field except for the userStatus that should only belong to them. The tuple USER_STATUS should be the only options for that model and every Job should have access to these 5 options. In context: One job might be called “Internship at Google”, one user may have “Got Interview” to this Job but another user has “Not applied”. This Second user may apply and wants to change their status to “Applied”. If they do, it should not affect the first user’s “Got Interview” status.

I feel as though my approach is completely wrong so please let me know how and what my approach should be.

There are two separate and distinct parts to this.

  • The data model
  • Access permissions

While each affects the other - they’re not truly independent, one does not “drive” or “direct” the other.

Looking at the data model first. It looks like you’re using the standard Django User model. (If not, that’s ok - it doesn’t affect the rest of my response.) You have a Job model.
Each User can be associated with many Job, and each Job can have many User associated with it. This is a classic many-to-many relationship.

Additionally, you have this extra piece of data for the status of a User-Job relation.

So, the standard implementation of this is a ManyToMany with a through model containing the status field.

Once you’ve got this built, then you can manage access by controlling who can change the status field in your through table.