Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suit ignores formfield_overrides #117

Closed
dasloss opened this issue Jun 8, 2013 · 4 comments
Closed

Suit ignores formfield_overrides #117

dasloss opened this issue Jun 8, 2013 · 4 comments

Comments

@dasloss
Copy link

dasloss commented Jun 8, 2013

I have formfield_overrides set to make textinputs and text areas wider for charfields and textfields respectively. Suit appears to ignore or override this making it difficult to widen text inputs and textareas for easier editing. What is the recommended way to do this with Suit?

@darklow
Copy link
Owner

darklow commented Jun 8, 2013

I don't think Suit has something to do with it, since DS is mostly just a html/css/js skin.
Also default length of input and textarea is defined by Twitter Bootstrap.
Recommended way is using ModelForm and adding class="span6" for specific field widget.
See here an example: http://django-suit.readthedocs.org/en/develop/widgets.html

@dasloss
Copy link
Author

dasloss commented Jun 8, 2013

I remove suit from installed apps and the formfield_overrides for the admin works fine (so it must have something to do with Suit).

So then that means for every separate admin.ModelAdmin I have to define out the whole form? Can you give a specific example of how to do this roughly in the following way:

class MyModelForm(ModelForm):
.... get text areas/inputs to be wider ...

class MyModelAdmin(ModelAdmin):
use MyModelForm (pseudocode)

class Admin1(MyModelAdmin):
class specific things

class Admin2(MyModelAdmin):
class specific things

etc... because it seems the widget way would require creating custom forms for every admin?

@darklow
Copy link
Owner

darklow commented Jun 13, 2013

Sorry for delay. Summer vacation time :)

I just tested and formfield_overrides works fine for me.

Since you didn't show exact code, i guess you tried wrong method for "widening" inputs.
You must use CSS classes to do that, because using html size property is less powerful than twitter bootstrap css styles.

Here is how to do it using formfield_overrides:

class CountryAdmin(ModelAdmin):
    formfield_overrides = {
        models.CharField: {'widget': TextInput(attrs={'class':'span12'})},
    }

You can use span1 or span2 until span12 size. Or also you can add your own css class or use style attribute too.

Let me know if it works.
Also checkout out #58 if you would like to change default width for whole admin.

@gamesbook
Copy link

Thanks! Working now...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants