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

List columns, rename columns, etc. #2

Closed
Auha opened this issue Mar 23, 2012 · 2 comments
Closed

List columns, rename columns, etc. #2

Auha opened this issue Mar 23, 2012 · 2 comments

Comments

@Auha
Copy link

Auha commented Mar 23, 2012

Going through the examples and trying to use some of my apps into it. I was wondering if we could actually make list_columns, rename_columns, etc. more into options instead of customization?

For example, I want to be able to use the normal sqlalchemy interface, but according to the documentation I would need to create a custom interface in order to utilize the list_columns functionality. I would not be able to use the sqlalchemy interface.

As a workaround I made it so that I could pass those customization when I first create the View. Would this be the best way to do it? Or should we come up with some sort of API to do such a thing?

@mrjoes
Copy link
Member

mrjoes commented Mar 23, 2012

Probably I don't understand question right...

Administrative interface is built on top of python classes. If you inherit from existing class, you're inheriting its functionality. So, for example, if you create something like this:

class MyAdmin(ModelAdmin):
    list_columns = ('test', 'foo')

it will be still sqlalchemy adminstrative class. Its just sqlalchemy admin implementation knows that it should look for list_columns in self and work accoridingly.

As for passing customization parameters through the constructor, do something like this::

class MyView(ModelView):
    def __init__(self, model, session, name=None, category=None, list_columns=None, rename_columns=None, ...)
        self.list_columns = list_columns
        self.rename_columns = rename_columns

        super(MyView, self).__init__(model, session, name, category)

And then just use your class::

admin.add_view(MyView(User, db.session, list_columns=('test','foo'))

@Auha
Copy link
Author

Auha commented Mar 24, 2012

Hmmm I think I asked a bad question. For some strange reason my brain was thinking that you coudl only inherit from the BaseModelView class.

@Auha Auha closed this as completed Mar 24, 2012
mrjoes pushed a commit that referenced this issue Dec 26, 2013
mrjoes pushed a commit that referenced this issue Mar 12, 2015
pawl pushed a commit to pawl/flask-admin that referenced this issue Sep 1, 2015
Add tests for csv export and fix python 3 unicode issues
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