I've been trying to make a form that will get customer information:

First Name           Last Name    MI
(etc)

and have been running into issues I can't seem to resolve without doing it 
the hard way. I was just wondering if there was an easier method?

Using generic views and edit views, the items in my model won't layout the 
way I want them to, so I manually made one.

    1. When I manually made my html form, none of the labels for my input 
boxes show up. I though it would use a default "verbose_name", then I added 
a verbose_name, still didn't change.
            - I added labels to my form, no change.
    2. Even though MI is set to maxlength=1 in the model, every text box is 
the same size.

In the admin site you can use the "tabularinlines" and "fieldsets" to group 
and lay things out. Is there any method to achieving the same thing apart 
from the admin page? Or do I manually have to add labels to every "{{ }}" 
on my .html template? Thanks!


models.py

class Customer(models.Model):

    first_name = models.CharField(max_length=20)
    last_name = models.CharField(max_length=30)
    middle_initial = models.CharField(max_length=1, null=True, blank=True)

forms.py

class CustomerForm(ModelForm):
    class Meta:
        model = Customer
        fields = ('full_name', 'first_name', 'last_name', 'middle_initial')
    labels = {
            'first_name': _('First Name'),
            'last_name': _('Last Name'),
            'middle_initial': _('MI'),
       }

customer_form_view.html

{% extends "base_template.html" %}

{% block center %}
<form action="" method="GET">
    {% csrf_token %}
    <div>{{ form.first_name }} {{ form.last_name }} {{ form.middle_initial 
}}</div>
    <div><input type="submit" value="Save" /></div>
</form>
{% endblock %}

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f6bddcb7-ec8e-40ca-8138-07e4317785ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to