librelist archives

« back to archive

Admin extension module

Admin extension module

From:
Andy Wilson
Date:
2011-06-17 @ 22:46
Hi everybody.

I've been working on extension module that provides a simple admin
interface. The code can be found at:
http://github.com/wilsaj/<http://github.com/wilsaj/flask-admin/>
flask-admin/ <http://github.com/wilsaj/flask-admin/>

There is still some work to be done but I would really appreciate any
thoughts/feedback on API and design before an initial release. Right now it
is specifically tied to SQLAlchemy declarative models (either through
Flask-SQLAlchemy or using SQLAlchemy directly), and I intend to accommodate
other datastores in the future.


Also, the name Flask-Admin is tentative. Some googling shows a few other
projects of the same name with similar aims, but none of these seem to have
much activity. If anyone feels strongly about the name please let me know.


Thanks!
-andy

Re: [flask] Admin extension module

From:
Alex
Date:
2011-06-18 @ 02:21
Hi Andy,
I use flask-sqlalchemy to cooperate with flask-admin. The query is
successful while insert a new record failed.
The error message is :

   - File
   
"/usr/lib/python2.7/site-packages/Flask_Admin-0.1-py2.7.egg/flaskext/admin/__init__.py",
   line *141*, in wrapper

   return f(*args, **kwds)

   - File
   
"/usr/lib/python2.7/site-packages/Flask_Admin-0.1-py2.7.egg/flaskext/admin/__init__.py",
   line *255*, in add

   model_instance = model()


TypeError: __init__() takes exactly 5 arguments (1 given)


My model is at http://pastebin.com/fvFb6T7r

2011/6/18 Andy Wilson <wilson.andrew.j@gmail.com>

>
> Hi everybody.
>
> I've been working on extension module that provides a simple admin
> interface. The code can be found at: 
http://github.com/wilsaj/<http://github.com/wilsaj/flask-admin/>
> flask-admin/ <http://github.com/wilsaj/flask-admin/>
>
> There is still some work to be done but I would really appreciate any
> thoughts/feedback on API and design before an initial release. Right now it
> is specifically tied to SQLAlchemy declarative models (either through
> Flask-SQLAlchemy or using SQLAlchemy directly), and I intend to accommodate
> other datastores in the future.
>
>
> Also, the name Flask-Admin is tentative. Some googling shows a few other
> projects of the same name with similar aims, but none of these seem to have
> much activity. If anyone feels strongly about the name please let me know.
>
>
> Thanks!
> -andy
>

Re: [flask] Admin extension module

From:
Alex
Date:
2011-06-18 @ 02:59
Hi Andy,
This problem is solved after i add default parameters to __init__.
But i come to another problem.
Some columns should be caculated automatically.So i want them to
hide when i insert a new record or edit the records.
How can i do it?
Thanks for the great work.


2011/6/18 Alex <gfreezy@gmail.com>

> Hi Andy,
> I use flask-sqlalchemy to cooperate with flask-admin. The query is
> successful while insert a new record failed.
> The error message is :
>
>    - File
>    
"/usr/lib/python2.7/site-packages/Flask_Admin-0.1-py2.7.egg/flaskext/admin/__init__.py",
>    line *141*, in wrapper
>
>    return f(*args, **kwds)
>
>    - File
>    
"/usr/lib/python2.7/site-packages/Flask_Admin-0.1-py2.7.egg/flaskext/admin/__init__.py",
>    line *255*, in add
>
>    model_instance = model()
>
>
> TypeError: __init__() takes exactly 5 arguments (1 given)
>
>
> My model is at http://pastebin.com/fvFb6T7r
>
>
> 2011/6/18 Andy Wilson <wilson.andrew.j@gmail.com>
>
>>
>> Hi everybody.
>>
>> I've been working on extension module that provides a simple admin
>> interface. The code can be found at: 
http://github.com/wilsaj/<http://github.com/wilsaj/flask-admin/>
>> flask-admin/ <http://github.com/wilsaj/flask-admin/>
>>
>> There is still some work to be done but I would really appreciate any
>> thoughts/feedback on API and design before an initial release. Right now it
>> is specifically tied to SQLAlchemy declarative models (either through
>> Flask-SQLAlchemy or using SQLAlchemy directly), and I intend to accommodate
>> other datastores in the future.
>>
>>
>> Also, the name Flask-Admin is tentative. Some googling shows a few other
>> projects of the same name with similar aims, but none of these seem to have
>> much activity. If anyone feels strongly about the name please let me know.
>>
>>
>> Thanks!
>> -andy
>>
>
>

Re: [flask] Admin extension module

From:
Andy Wilson
Date:
2011-06-18 @ 17:53
Hi Alex.

Thanks so much for testing things out.


On Fri, Jun 17, 2011 at 9:59 PM, Alex <gfreezy@gmail.com> wrote:

> This problem is solved after i add default parameters to __init__.
>

Good catch, I've added a note about __init__ in the docs about this.



> But i come to another problem.
> Some columns should be caculated automatically.So i want them to
> hide when i insert a new record or edit the records.
> How can i do it?



You can create a form that only has the columns that you want to show up
when you add or edit a new record, and use the model_forms argument to
associate your fprm with the model. Check out the example here:

https://github.com/wilsaj/flask-admin/blob/master/example/declarative/custom_form.py