Re: models.py question for setting up multiple sql entries for 1 master sql entry

2014-11-24 Thread François Schiettecatte
Hi

You should consider having a single Barcodeid table and have a one-to-many 
relationship between the Hardwareid and Barcodeid.

François
 
> On Nov 24, 2014, at 1:43 AM, Bovine Devine  wrote:
> 
> Hello,
> 
> 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.
> 
> I have my models.py setup this way:
> 
> 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?
>   
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/47abd291-f46c-4d9b-b535-bd1ed0a7c6da%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/19DACD41-B8C6-4499-B5E4-A214709A573A%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


models.py question for setting up multiple sql entries for 1 master sql entry

2014-11-23 Thread Bovine Devine
Hello,

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.

I have my models.py setup this way:

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?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/47abd291-f46c-4d9b-b535-bd1ed0a7c6da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.