Hello,
I've already talked about it in the IRC channel, but I'm posting here to
make sure...
I have a model Client like so:
class Client(models.Model):
name = models.CharField(maxlength=30, core=True)
contact_name = models.CharField(maxlength=30, blank=True)
contact_email = models.EmailField(blank=True)
So I'd like to add a new client. Isn't it possible to use the
autogeneration of the admin for my app ?
Instead of writing a template declaring *every* field of the Client
model, wouldn't it be possible to autogenerate the form from the
existing model ?
If I never add a new entry in my model, let's say:
city = models.CharField(maxlength=30, core=True)
when I reload my "add_client" (or "edit_client") page, it would
automaticly display the form including the new "city" field without
having to touch my template code.
I'm about to go into a "for" loop inside the form.data dictionnary to
generate every field. But as it already took me some time to use
organize the "fields" variable like I wanted for the "Admin" class, I
was telling myself there *MUST* be someway to reuse the admin code for
autogenerating forms in my own application.
I have looked into this page:
http://www.djangoproject.com/documentation/forms/
But it explains I have to write every field into my template.
Any idea ?
Regards,
--
Alexandre CONRAD - TLV
Research & Development
tel : +33 1 30 80 55 05
fax : +33 1 30 80 55 06
6, rue de la plaine
78860 - SAINT NOM LA BRETECHE
FRANCE
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---