Currently, I'm working from the demos in the book and the site.

Here is what I have currently.

forms.py:

from django import newforms as forms
from django.newforms import form_for_model
from models import PlanMember

TITLES = (
    ('Miss','Miss'),
    ('Mrs.','Mrs.'),
    ('Ms.','Ms.'),
    ('Mr.','Mr.'),
    ('Dr.','Dr.'),
    ('Prof.','Prof.'),
    ('Rev.','Rev.'),
)

ApplicationForm = form_for_model(PlanMember)

---

views.py:

# Create your views here.
from django.db.models import Q
from django.shortcuts import render_to_response
#from models import PlanMember
from forms import ApplicationForm

#def index():
#    return render_to_responce('index.html')

def application(request):
    if request.method == 'POST':
        form = ApplicationForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/add_publisher/thanks/')
    else:
        form = ApplicationForm()
    return render_to_response('application.html', {'form': form})

---

models.py:

from django.db import models

class TitleChoices(models.Model):
    name = models.CharField(maxlength=5)

    def __str__(self):
        return self.name

    class Admin:
        pass

# Create your models here.
class PlanMember(models.Model):
    title = models.ForeignKey(TitleChoices)
    f_name = models.CharField(maxlength=30)
    l_name = models.CharField(maxlength=40)
    b_date = models.DateField()
    relation = models.CharField(maxlength=40)
    sin = models.CharField(maxlength=15)
    h_phone = models.PhoneNumberField()
    c_phone = models.PhoneNumberField()
    b_phone = models.PhoneNumberField()
    b_p_ext = models.CharField(maxlength=8)
    address = models.CharField(maxlength=80)
    city = models.CharField(maxlength=40)
    prov = models.CharField(maxlength=2)
    postal = models.CharField(maxlength=7)
    email = models.EmailField()
    work = models.CharField(maxlength=80)
    job = models.CharField(maxlength=40)

# Joint applicant
    j_title = models.CharField(maxlength=7)
    j_f_name = models.CharField(maxlength=30)
    j_l_name = models.CharField(maxlength=40)
    j_b_date = models.DateField()
    j_relation = models.CharField(maxlength=40)
    j_sin = models.CharField(maxlength=15)
    j_email = models.EmailField()
    j_work = models.CharField(maxlength=80)
    j_job = models.CharField(maxlength=40)

# Parrent info
    p_title = models.CharField(maxlength=7)
    p_f_name = models.CharField(maxlength=30)
    P_l_name = models.CharField(maxlength=40)
    p_h_phone = models.PhoneNumberField()
    p_c_phone = models.PhoneNumberField()
    p_b_phone = models.PhoneNumberField()
    p_b_p_ext = models.CharField(maxlength=8)
    p_address = models.CharField(maxlength=80)
    p_city = models.CharField(maxlength=40)
    p_prov = models.CharField(maxlength=2)
    p_postal = models.CharField(maxlength=7)

# MemberProfile:
    children = models.PositiveSmallIntegerField()
    inv_knoledge = models.PositiveSmallIntegerField()
    risk_tol = models.PositiveSmallIntegerField()
    total_income = models.PositiveSmallIntegerField()
    networth = models.PositiveSmallIntegerField()
    borrowed = models.BooleanField()
    add_info = models.CharField(maxlength=80)

    def __str__(self):
        return '%s %s %s' % (self.title, self.f_name, self.l_name)

    class Admin:
        pass
 ---

Joint applicant, Parrent and MemberProfile were originally individual
tables. But in trying to make it DRY, and get all the fields I wanted
on the same form, I joined them together. They really all need to be
stored at the same time anyway.

I've temporarily changed all but the first 'title' back from a foreign
key to a charfield just to get it to render at all.

Lance
On May 21, 7:41 pm, "Adam Gomaa" <[EMAIL PROTECTED]> wrote:
> Lance, it's also not clear to me what exactly you need. Are you using
> ModelForm? If not, what do you mean by the 'auto generated' form? I
> think I have a rough idea what you're looking for, but a few more details
> would go a long way.
>
> Adam
>
> On Wed, May 21, 2008 at 3:30 PM, Lance F. Squire <[EMAIL PROTECTED]> wrote:
>
>
>
> > I'm trying to make a Form where 3 people need to be inputed. All three
> > need to have a Title.(EG. Mr. Mrs. etc.)
>
> > I tried making the Title fields in the database be a key to a table of
> > title selections. The sql generation had no trouble with that, but the
> > Form generator doesn't like it at all...
>
> > I had them as character fields, but couldn't figure out how to get
> > them to become select/choice fields after the form was auto generated
> > from the table, before the view...
>
> > I'm new to Django. Played with Rails some, but mostly work in Perl/
> > Postgres
>
> > Also looked at having the people in separate tables, but it didn't
> > seem practical either from a filling in data point or a rendering/
> > parching the form point.
>
> > Thanks for any help and/or pointers.
> > Lance
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to