I want to group all uploaded Resumes under the job they were applied

I want to tie job applications (resume and cover letter) to the specific job post the job seeker is applying
for.

I want all resumes and cover letters to be uploaded in a folder named after the specific job id so that the admin can download all applications under a specific job together

class Post(models.Model):
    category = models.ForeignKey(Category, on_delete=models.CASCADE)
    location = models.ForeignKey(Location, on_delete=models.CASCADE)
    type = models.ForeignKey(JobType, on_delete=models.CASCADE)
    title = models.CharField(max_length=255)
    content = RichTextField()
    slug = models.SlugField(max_length=255, unique=True)
    date_created = models.DateTimeField(default=timezone.now)
    apply_by_date = models.DateTimeField(default=timezone.now)
    updated_on = models.DateTimeField(auto_now=True)
    author = models.ForeignKey(User, default=0,
                               on_delete=models.CASCADE)
    active = models.BooleanField(
        default=False)

    class Meta:
        ordering = ['-date_created', 'author']

    def __str__(self):
        return self.title
class Application(models.Model):
    first_name = models.CharField(max_length=50)
    last_name = models.CharField(max_length=50)
    email = models.EmailField(max_length=55)
    phone = models.CharField(max_length=13, )
    cover_letter = models.FileField(
        upload_to='applications/uploads/')
    resume = models.FileField(upload_to='applications/uploads/')
    reference = models.CharField(
        max_length=255,
        choices=WAYS_TO_FIND_US,
        default=default_option)
    date_applied = models.DateTimeField(default=timezone.now)
    date_updated = models.DateTimeField(auto_now=True)

    def __str__(self):
        return f"{self.first_name} {self.last_name}"

Then you want to create a ForeignKey field in the Application model referring to the Post model.

See the docs for upload_to. Instead of a path, you can supply a callable that identifies the destination at runtime.

1 Like

Thank you so much for taking your time to reply. Let me give this a try