Hello,

I've been exploring django and so far it has been a great experience. I made a little test app with generic classes based on this documentation. This all works perfectly and I dove in deeper using the as_p() function.

After that I tried to remove the auto generated id's in the labels etc. using auto_id=false (documentation). I don't seem to get this to work however.

My understanding is that I should change the code like so:

class AuthorUpdate(UpdateView): auto_id = False model = Author

This does not work for me unfortunately and I can't seem to find any more information about it. Can anyone point me in the right direction please?

Cheers

asked 25 Apr '13, 05:24

deganderson's gravatar image

deganderson
462
accept rate: 100%

edited 25 Apr '13, 05:25


Thank you but the idea was to let django create the forms for me using the generic classes. I found the ModelFormMixin class in the django source though and saw an override there for get_form_kwargs. I did the same in my own class like so:

class AuthorUpdate(UpdateView): model = Author def get_form_kwargs(self): kwargs = super(AuthorUpdate, self).get_form_kwargs() kwargs.update({'auto_id': False}) return kwargs

link

answered 26 Apr '13, 02:47

deganderson's gravatar image

deganderson
462
accept rate: 100%

what you need to do is create your own form with auto_id false parameter

then

give this form to your updateView with

form_class = YourFormClassName

parameter

link

answered 25 Apr '13, 08:11

DjangoForum's gravatar image

DjangoForum ♦♦
6317
accept rate: 8%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×3
×1
×1

Asked: 25 Apr '13, 05:24

Seen: 719 times

Last updated: 26 Apr '13, 02:47

powered by OSQA