Coder Social home page Coder Social logo

Comments (4)

plaes avatar plaes commented on July 21, 2024

Code in the example should also allow passing the name and other args:

class UserView(ModelView):
    can_create = False
    def __init__(self, session, **kwargs):
        super(UserView, self).__init__(User, session, **kwargs)

from flask-admin.

mrjoes avatar mrjoes commented on July 21, 2024

Few questions:

  1. Thanks, see it.
  2. Any suggestions?
  3. You mean that naming convention should be consistent? MyView everywhere?

OK, I will use 'easy' instead. :-)

Thanks for tips.

from flask-admin.

plaes avatar plaes commented on July 21, 2024

Looks better now, though I would add these changes:

diff --git a/doc/quickstart.rst b/doc/quickstart.rst
index 53b3e71..ef33fd4 100644
--- a/doc/quickstart.rst
+++ b/doc/quickstart.rst
@@ -235,9 +235,9 @@ you can do something like this::
         # Override displayed fields
         list_columns = ('login', 'email')

-        def __init__(self, session):
+        def __init__(self, session, **kwargs):
             # You can pass name and other parameters if you want to
-            __super__(MyView, self).__init__(User, session)
+            super(MyView, self).__init__(User, session, **kwargs)

     admin = Admin(app)
     admin.add_view(MyView(db.session))

This makes sure that I could do admin.add_view(MyView(db.session, name='foo')). And what's __super__? ;)

from flask-admin.

mrjoes avatar mrjoes commented on July 21, 2024

Don't really like kwargs approach here, better to pass explicit parameters, but should work for this example. And yes, I have no idea what is super :-)

from flask-admin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.