I am going to try to add better information for this issue, here we
go:

The model for the obituary looks like this:


class obit_entry(models.Model):
    first_name = models.CharField('First Name', max_length=100,
blank=False)
    middle_name = models.CharField('Middle Name', max_length=100,
blank=False)
    last_name = models.CharField('Last Name', max_length=100,
blank=False)
    nick_name = models.CharField('Nickname', max_length=100,
blank=True)
    city = models.CharField('City', max_length=100, blank=False)
    state = USStateField(blank=False)
    occupation = models.CharField('Occupation', blank=True,
max_length=100)
    date_of_birth = models.DateField(blank=False)
    date_of_death = models.DateField(blank=False)
    date_of_service = models.DateTimeField(blank=False)
    type_of_service = models.CharField('Type of service',
max_length=100, choices=Service_Type, blank=False)
    on_premises = models.BooleanField(blank=True)
    service_location = models.CharField('Location of service',
max_length=100, blank=True)
    service_address = models.CharField('Service Address',
max_length=100, blank=True)
    service_city = models.CharField('City of service', max_length=100,
blank=True)
    service_state = USStateField('State of service', blank=True)
    additional_info = models.TextField('Additional Information',
blank=True)
    organ_donor = models.BooleanField(blank=True)
    natural_causes = models.CharField('Died of Natural causes',
max_length=100, choices=Causes_Choices, blank=False)
    date_to_run = models.DateField('Date obit should run', blank=True,
null=True)
    date_created = models.DateTimeField(auto_now_add=True)
    date_update = models.DateTimeField(auto_now=True)
    created_by = models.ForeignKey(FullProfile,
related_name="createdBY", null=True, blank=True)

the model for the business profile (FullProfile) looks like this:


class FullProfile(User):
    bus_name = models.CharField('Full Business Name',
help_text='excluding type (e.g. Funeral Home, Crematorium)',
max_length=200, blank=True)
    bus_type = models.CharField('Business Type', help_text='(e.g.
Funeral Home, Crematorium, etc.)', max_length=200, blank=True)
    address_street = models.CharField('Street Number', max_length=200,
blank=True)
    address_city = models.CharField('City', max_length=200,
blank=True)
    address_zip = models.CharField('Zip Code', max_length=10,
blank=True)
    phone = PhoneNumberField('Phone Number', blank=True)
    contact = models.CharField('Contact Name', max_length=100,
blank=True)
    bus_type_2 = models.CharField('Business Type 2', help_text='(e.g.
Funeral Home, Crematorium, etc.)', max_length=200, blank=True)
    address_street_2 = models.CharField('Street Number',
max_length=200, blank=True)
    address_city_2 = models.CharField('City', max_length=200,
blank=True)
    address_zip_2 = models.CharField('Zip Code', max_length=10,
blank=True)
    completed = models.BooleanField()
    objects = UserManager()

There is an obituary form that is a model form of the obit model:

I would like to change the on_premises field to lookup of the two
business type fields in the FullProfile model so that the user can
select which business type they want to attach to the individual
obituary.

So if a business has bus_type = Funeral Home and bus_type_2 =
Crematorium, in the obituary form the user will have a drop down of
either "Funeral Home" or "Crematorium" to choose from.


On Jun 16, 2:39 pm, Nick <nickt...@gmail.com> wrote:
> OK, here's the deal. I'm working up an obituary site. There are 3
> models/tables and at one point I need to connect two in a way that is
> different than I have done up to this point. Here is the situation,
> any recommendations on how to accomplish this would be great:
>
> I have an obituary table. In that table there is a field that checks
> if a funeral service is on the premises (column name "on_premises" of
> the Funeral Home that is entering the information.
>
> If this BooleanField is checked then it returns the location
> information of the funeral home which is stored in a business_profile
> table. Not difficult, just check if the boolean returns a value and
> then populate the template
>
> That works out nicely except I have been given an extra criteria for
> this project. Some business have both a funeral home and a
> crematorium. Many of these situations require that we list the address
> of one or the other. Since the "on premises" is a BooleanField there
> is no way for someone to state what part of their business is
> responsible for the service.
>
> What I would like to do is make this option a drop down in the
> obituary form that basically gives the business the option of choosing
> which one of their locations is the one we want attached to this obit.
> Once this is chosen then I will pull the value into the templates.
>
> How do I relate these models? My first thought is to create two
> "business type" columns in the business profile table and then relate
> the "service_location" column to these columns in a drop down? Is that
> even possible?
>
> How do I retrieve the values from two different fields and then select
> from them in another model?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to