I am creating hardware database webapp in django and I have a question for how to setup my models.py to ensure I get the data entered into the mysql db that I have setup.
from django.db import models
from django.utils import timezone
# Create your models here.
class Hardwareid(models.Model):
hardwareid_text = models.CharField(max_length=200)
pub_date = models.DateField(default=timezone.now)
def __unicode__(self):
return self.hardwareid_text
class Barcodeid1(models.Model):
barcode1 = models.ForeignKey(Hardwareid)
Barcodeid1_text = models.CharField(max_length=50)
def __unicode__(self):
return self.Barcodeid1_text
class Barcodeid2(models.Model):
barcode2 = models.ForeignKey(Hardwareid)
Barcodeid2_text = models.CharField(max_length=50)
def __unicode__(self):
return self.Barcodeid2_text
My question is do I have this setup properly? The end result I would like to have is to have a "master" Hardwareid name of an item in my sql db that has multiple barcodeids associated with each master hardwareid.
Is this the correct way to do it?