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

Field name override #141

Open
mjanv opened this issue Aug 25, 2015 · 1 comment
Open

Field name override #141

mjanv opened this issue Aug 25, 2015 · 1 comment

Comments

@mjanv
Copy link

mjanv commented Aug 25, 2015

Hello,

For the purpose of my website, I use Flask-SuperAdmin. I found there is a feature missing (if i'm correct, but i didn't find it after reviewing the code...), so I implemented it. I think it's useful to be able to change the field names which appears in the header of the list.html and are often not good enough for a proper administration section display (not the good language, too obscur,...). Have a way to be able to change it will be great.

The only change I made are these three lines in flask_superadmin/model/base.py

83    field_name_dict = {}
    [...]
206    def field_name(self, field):
207        return prettify(self.field_name_dict.get(label,label))

Therefore, we just have to define a field_name_dict into a Model View to do the job. For example,

class UserModel(BaseModel):
    list_display = ('username','email',)
    field_name_dict =  { 'username' : 'Pseudo' , 'email' : 'Courriel' }

capture d ecran 2015-08-25 a 16 59 59

If it seems to be a good feature to add, I can propose a merge request.

@darker0n
Copy link

darker0n commented Jun 2, 2016

Good idea +1

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

2 participants