I have a list of values which is not going to change.
Example:
modeofpayment : Cash, Cheque, OnlineTransfer, ATM Deposit
Is there a way without creating a database-table, I can use these values.
from django.db import models
# Create your models here.
class MasterCategory(models.Model):
masterid = models.AutoField(primary_key=True)
name = models.CharField(max_length=25, null=False)
@property
def __str__(self):
return self.name
class PaymentMode(models.Model):
modeid = models.AutoField(primary_key=True)
name = models.CharField(max_length=10, null=False)
@property
def __str__(self):
return self.name
class Daily(models.Model):
transid = models.AutoField(primary_key=True)
transdate = models.DateField()
transdetails = models.CharField(max_length=25)
transcategory = models.ForeignKey(MasterCategory, on_delete=models.CASCADE)
transmode = models.ForeignKey(PaymentMode, on_delete=models.CASCADE)
transsubdetails = models.CharField(max_length=100, null=True)
transamount = models.FloatField()
def __str__(self):
return "%s %s %s %s %s %s %s" % (self.transid, self.transdate, self.transdetails, self.transcategory, self.transmode, self.transsubdetails, self.transamount)
Above is my current model ( database )
Instead of creating a table “PaymentMode”, is there a way I can use the values as I have mentioned above.