On Wed, 27 Jun 2012 08:02:37 -0700, David Wagner <cptnwinky@gmail.com>
declaimed the following in gmane.comp.python.django.user:
>
> class NRA_Certs(models.Model):
> CRSO = models.BooleanField(blank=True, null=True, "Chief Range Safety
> Officer")
> HFS = models.BooleanField(blank=True, null=True, "Home Firearm Safety")
> MCR = models.BooleanField(blank=True, null=True, "Metallic Cartridge
> Reloading")
> PPH = models.BooleanField(blank=True, null=True, "Personal Protection
> in the Home")
> PPO = models.BooleanField(blank=True, null=True, "Personal Protection
> Outside the Home")
> PS = models.BooleanField(blank=True, null=True, "Pistol Shooting")
> RS = models.BooleanField(blank=True, null=True, "Rifle Shooting")
> SSR = models.BooleanField(blank=True, null=True, "Shotgun Shell
> Reloading")
> SS = models.BooleanField(blank=True, null=True, "Shotgun Shooting")
> RTBVDW = models.BooleanField(blank=True, null=True, "Refuse to be a
> Victim Workshop")
> RTBVO = models.BooleanField(blank=True, null=True, "Refuse to be a
> Victim Online")
> NMLRA_MP = models.BooleanField(blank=True, null=True, "NMLRA
> Muzzleloading Pistol Shooting")
> NMLRA_MR = models.BooleanField(blank=True, null=True, "NMLRA
> Muzzleloading Rifle Shooting")
> NMLRA_MS = models.BooleanField(blank=True, null=True, "NMLRA
> Muzzleloading Shotgun Shooting")
>
Ugh!...
I'm not familiar enough with Django's internal format so I'm using a
form of old relational theory notation: tablename(_key_, /foreignkey/,
other, fields...)
NRACertificate(_ID_, certificateName, other, type, specific,
attributes))
{I forget your individual model so a generic}
Person(_ID_, name, other, stuff)
Person_NRACertificate(_ID_, /personID/, /nracertificateID/,
dateCertified, dateExpires, other, certificate, specfic, data)
Django can build this intersection table automatically -- but it
would only have _ID_, /personID/, /nracertificateID/! I think, for your
information, you'd want to define your own "through" table to hold the
data specific to an instance of a certificate as held by a person.
Same with concealed carry permits IF you need a list on a, say, per
state basis.
Note though, that if the /lists/ don't carry any significant
information beyond the name of the item, you just need one-to-many
configurations. For example, if the only information you track for CCW
is: who (foreign key to Person), license number, issuing state (or other
government entity), date issued, date expires... then a one-to-many is
all you need. (Though you may find you need another one-to-many --
California's rare CCW includes a list of /which/ firearm(s) are
permitted [if you sell one gun and buy a different one, you have to beg
the government to update the CCW with the new gun's information]).
The NRACertificates table may also not be needed if all it provides
is a list of names to populate a dropdown selection box -- might speed
up processing by just hard-coding the list and saving the name directly
(replace the /nracerticateID/ in the intersect table with the actual
text of the certificate as selected from the dropdown selection.
Bigger note: You will NOT be using a multiple selection list... More
reasonable is an "add new certificate" button which brings up a form
from which to select one certificate (by name in dropdown), and fields
for the dates, and whatever else is common to certificates.
When displaying a person, the certificates would be (if I recall
Django terms) a "formset" (where the "form" is for a single
certificate's data).
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment