Is there a way to customize the field name (not just label) while creating 
a ModelForm?

Eg. for the model:

class Book(models.Model):
    title = models.CharField(max_length=256, db_index=True)
    author = models.CharField(max_length=512, db_index=True)
    published = models.DateTimeField(db_index=True)


the ModelForm can be:


class BookForm(forms.ModelForm):

    fields = ('title', 'author')


Is there a way I can expose 'title' as 'book_name'? As in, the form HTML should 
have:


<tr><th><label for="id_book_name">book_name:</label></th><td><input 
id="id_book_name" type="text" name="book_name" maxlength="256" /></td></tr>

<tr><th><label for="id_author">Author:</label></th><td><input id="id_author" 
type="text" name="author" maxlength="512" /></td></tr>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/aUOMVI85ftoJ.
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?hl=en.

Reply via email to