django为crud操作实现可手持的电子表格。

django-funky-sheets的Python项目详细描述


django为crud操作实现可手持的电子表格。

现场演示

Demo

安装

安装django-funky-sheets

$ pip install django-funky-sheets

funky_sheets添加到已安装的应用程序:

# settings.py

INSTALLED_APPS = [
    ...
    'funky_sheets',
    ...
]

快速启动

网址

定义创建和更新视图的URL。

# urls.pyfromdjango.urlsimportpathfrom.importviewsurlpatterns=[path('',views.index,name='index'),path('create/',views.CreateMovieView.as_view(),name='create'),path('update/',views.UpdateMovieView.as_view(),name='update')]

视图

定义从HotView继承的创建和更新视图,并基于选定的模型字段呈现可手持的电子表格。

# views.pyfromdjango.formsimportCheckboxSelectMultiple,CheckboxInput,DateInputfromdjango.urlsimportreverse_lazyfromfunky_sheets.formsetsimportHotViewfrom.modelsimportMovieclassCreateMovieView(HotView):# Define model to be used by the viewmodel=Movie# Define templatetemplate_name='examples/create.html'# Define prefix for the formset which is constructed from Handsontable spreadsheet on submissionprefix='table'# Define success URLsuccess_url=reverse_lazy('update')# Define fields to be included as columns into the Handsontable spreadsheetfields=('id','title','director','release_date','parents_guide','imdb_rating','genre','imdb_link',)# Define extra formset factory kwargsfactory_kwargs={'widgets':{'release_date':DateInput(attrs={'type':'date'}),'genre':CheckboxSelectMultiple(),'parents_guide':CheckboxInput(),}}# Define Handsontable settings as defined in Handsontable docshot_settings={'contextMenu':'true','autoWrapRow':'true','rowHeaders':'true','contextMenu':'true','search':'true'}classUpdateMovieView(CreateMovieView):template_name='examples/update.html'# Define 'update' actionaction='update'# Define 'update' buttonbutton_text='Update'

模板

定义包含hot_template的模板,以便在其中呈现可手持的电子表格。

examples/create.html

...
{%includehot_template%}
...

examples/update.html

...
{%includehot_template%}
...

贡献

这是一个开源项目,任何贡献都是值得赞赏的。

许可证

这个项目是由麻省理工学院授权的。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java访问私有字段而不使用getter方法?   使用PowerMockito在JavaEWSAPI中模拟测试拉订阅   启动活动时未保存java首选项并清除变量   java如何在servlet中检索子域?斯普林有帮手吗   java使用Docker从命令行构建Android项目   java Android,ActionBar后退按钮(setDisplayHomeAsUpEnabled(true))重新创建父活动   java在重用FileOutputStream时应该关闭流吗?   java使用RESTAPI将文件上载到s3 bucket   Java SOAP Web服务应用程序中的mysql用户登录方法不工作   java使用多个数字计算百分比并转换为长   java Android SQLiteDatabase查询忽略空格   java如何在Javafx中比较两个字段文本   java错误:未设置java_HOME,在Eclipse安装后找不到   java在安卓中保存对象   java如何使用jaxws从返回List<Object>的服务中检索值   java Google OAuth2 JWT令牌验证异常   SpringMVC中的JavaUTF8编码问题,当从JSP表单发送POST请求中的越南语信件时   java从webview重定向到安卓应用程序   JUnit 5中多个扩展的java顺序