I can post new jobs but can’t update them even in the admin panel.
here you see It’s showing in notification that the title changed but it didn’t. If I create new model It works fine though. I guess problem is in my code.
models.py
import random
from modules import files, options
from django.db import models
from ckeditor import fields
# Modules
import random
def customId():
return str(random.randint(10000000, 99999999))
# Jobs Model
class Job(models.Model):
jobid = models.SlugField(unique=True, editable=False, verbose_name="JobID")
title = models.CharField(max_length=250, verbose_name="Job Title")
country = models.CharField(max_length=250, verbose_name="Country", choices=options.COUNTRIES)
experience = models.CharField(verbose_name="Experience Range")
qualification = models.CharField(max_length=250, verbose_name="Qualification Level", choices=options.QUALIFICATION)
industry = models.CharField(max_length=250, verbose_name="Industry to Hire", choices=options.INDUSTRIES)
description = fields.RichTextField(max_length=10000, verbose_name="Job Description")
nationality = models.CharField(max_length=250, verbose_name="JobSeeker Nationality", choices=options.NATIONALITY)
posted = models.DateTimeField(auto_now_add=True, editable=False)
keywords = models.CharField(max_length=500, blank=True, default="Jobs, ")
def save(self):
if not self.jobid:
self.jobid = 'JB' + customId()
super(Job, self).save()
def __str__(self):
return f'{self.title} | ID: {self.jobid}'
class Meta:
verbose_name = "Vacancy"
verbose_name_plural = "Vacancies"
ordering = ('-posted',)
admin.py
from django.contrib import admin
from skcdash import models
class JobAdmin(admin.ModelAdmin):
model = models.Job
list_display = ['jobid', 'title', 'country']
admin.site.register(models.Job, JobAdmin)
Not Updating only in this model I tried creating a new temparary model and that was working fine.