在Wagtail和Airtable之间同步数据

wagtail-airtable的Python项目详细描述


Wagtail的一个扩展,允许在Airtable表和Wagtail/Django模型之间传输内容。在

Torchbox开发,The Motley Fool赞助。在

https://raw.githubusercontent.com/wagtail/wagtail-airtable/master/examples/preview.gif

View the repo README for more details

安装和配置

  • 使用pip install wagtail-airtable
  • 'wagtail_airtable'添加到项目的INSTALLED_APPS
  • 在您的设置中,您需要将模型映射到Airtable设置。要映射到Airtable表的每个模型都需要:
    • 一个AIRTABLE_BASE_KEY。当您登录到时,您可以在Airtable文档中找到基密钥Airtable.com网站在
    • 确定要连接到哪个表的AIRTABLE_TABLE_NAME。在
    • 一个AIRTABLE_UNIQUE_IDENTIFIER。它可以是字符串,也可以是字典,将Airtable列名映射到模型中的唯一字段。
      • AIRTABLE_UNIQUE_IDENTIFIER: 'slug',这将使模型上的slug字段与Airtable中的slug列名相匹配。如果模型字段和Airtable列名相同,请使用此选项。在
      • AIRTABLE_UNIQUE_IDENTIFIER: {'Airtable Column Name': 'model_field_name'},这将把Airtable Column Name映射到名为model_field_name的模型字段。如果Airtable列名和model字段名不同,请使用此选项。在
    • 接受序列化程序的字符串路径的AIRTABLE_SERIALIZER。这有助于将Airtable中的传入数据映射到模型字段。为此需要Django Rest框架。有关序列化程序示例,请参见[examples/](examples/)目录。在
  • 最后确保使用WAGTAIL_AIRTABLE_ENABLED = True启用wagtail airtable。默认情况下,这是禁用的,这样Wagtail站点和Airtable表中的数据不会被意外覆盖。数据很难恢复,此选项有助于防止意外数据丢失。在

基本配置示例

下面是一个基本配置或ModelNameOtherModelName(都是注册的Wagtail代码段),以及HomePage。在

# your settings.pyAIRTABLE_API_KEY='yourSuperSecretKey'WAGTAIL_AIRTABLE_ENABLED=TrueAIRTABLE_IMPORT_SETTINGS={'appname.ModelName':{'AIRTABLE_BASE_KEY':'app3ds912jFam032S','AIRTABLE_TABLE_NAME':'Your Airtable Table Name','AIRTABLE_UNIQUE_IDENTIFIER':'slug',# Must match the Airtable Column name'AIRTABLE_SERIALIZER':'path.to.your.model.serializer.CustomModelSerializer'},'appname.OtherModelName':{'AIRTABLE_BASE_KEY':'app4ds902jFam035S','AIRTABLE_TABLE_NAME':'Your Airtable Table Name','AIRTABLE_UNIQUE_IDENTIFIER':'Page Slug':'slug',# 'Page Slug' column name in Airtable, 'slug' field name in Wagtail.},'AIRTABLE_SERIALIZER':'path.to.your.model.serializer.OtherCustomModelSerializer'},'pages.HomePage':{'AIRTABLE_BASE_KEY':'app2ds123jP23035Z','AIRTABLE_TABLE_NAME':'Wagtail Page Tracking Table','AIRTABLE_UNIQUE_IDENTIFIER':'Wagtail Page ID':'pk',},'AIRTABLE_SERIALIZER':'path.to.your.pages.serializer.PageSerializer',# Below are OPTIONAL settings.# By disabling `AIRTABLE_IMPORT_ALLOWED` you can prevent Airtable imports# Use cases may be:#   - disabling page imports since they are difficult to setup and maintain,#   - one-way sync to Airtable only (ie. when a model/Page is saved)# Default is True'AIRTABLE_IMPORT_ALLOWED':False,# Add the AIRTABLE_BASE_URL setting if you would like to provide a nice link# to the Airtable Record after a snippet or Page has been saved.# To get this URL open your Airtable base on Airtable.com and paste the link.# The recordId will be automatically added so please don't add that# You can add the below setting. This is optional and disabled by default.'AIRTABLE_BASE_URL':'https://airtable.com/tblxXxXxXxXxXxXx/viwxXxXxXxXxXxXx',},# ...}

View the repo README for more details

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

推荐PyPI第三方库


热门话题
Spring启动测试中的java MockBean注释导致NonuniqueBeandDefinitionException   java Spring Hateoas调试模板不能为null   递归培根游戏Java程序?   java在Android中保存少量数据(对象)的最简单方法是什么?   异常处理Java中finally块的要点是什么?   是java。util。货币真的是工厂方法模式吗?   java如何输入字符以停止循环   java如何对流的某些部分执行缩减操作   java new Gson()。单例类的toJson(object)返回null   java Itext泰米尔字体显示不正确   java运行时。getRuntime()。gpg命令不起作用的exec()   java如何在preparedstatemenet中将字符连接到SQL字符串   java将同一实体的多个表示形式与lazyload合并时出错   JavaSpring、Hibernate和JPA:在entitymanager上调用persist似乎并没有提交到数据库   java osgi r6服务。组成部分注释属性列表