Model:
class Subject(models.Model):
name = models.CharField(max_length=50)
places = models.IntegerField()
class Temp(models.Model):
subject_r = models.ForeignKey(Subject)
Now in my views I want to do simple thing:
If Subject id exists in Temp table, field places (which is integer) need to be decremented by 1, else, it should stay as it is, and then I want to display the correct places variable in my template. Note that i don’t want to save new value in a database, i just want it to be displayed correctly in a template.
Since it’s for display only, I would actually set an arbitrary new attribute so that it’s clear you’re not trying to modify the database.