wiki:S3/CustomTables

Custom Tables

Templates can define their own custom models without needing to touch the core code.

  1. Create a file with S3Model(s) in, just as if it was going into s3db/ although change the s3 import path to from s3 import *
  1. Add this to mytemplate/__init__.py, e.g. for a module called 'custom':
    __all__ = ("custom",
               )
    
    import templates.mytemplate.custom
    
  1. Add to mytemplate/config.py:
    settings.base.custom_models = {"custom": "mytemplate",
                                   }
    settings.modules["custom"] = {"name_nice": T("My Custom Module"), "module_type": 10}
    
  1. If wanting to have a REST controller for them, then see S3/S3REST/s3_rest_controller

i.e. add an entry to mytemplate/config.py:

settings.base.rest_controllers = {("custom", resourcename): ("custom", resourcename)}
Last modified 3 months ago Last modified on 09/13/21 15:52:31
Note: See TracWiki for help on using the wiki.