Enable API for config_config_templates table

12 views
Skip to first unread message

Amit Goyal

unread,
Dec 20, 2019, 3:52:40 AM12/20/19
to OpenWISP
Hi Federico 

I want to enable API for config_config_template table but I could not find any config_config_template model which can be used in urls.py .
I was checking in /usr/local/lib/python3.6/site-packages/openwisp_controller/config/models.py but there is no class for this table . 

even in base https://github.com/openwisp/django-netjsonconfig/tree/master/django_netjsonconfig/base , No base class mentioned for this class .

Can you please suggest what need to be done for enabling api for this table . Please share if any reference . 

Thanks
Amit 

Federico Capoano

unread,
Dec 20, 2019, 4:10:35 AM12/20/19
to OpenWISP
Hi Amit,

Templates have a many2many relationship to config. The intermediate table which keeps track of how many config objects a template is assigned to does not have a model defined, because in most cases it's not needed and it's handled automatically by django, except some special cases in which additional fields need to be added to this intermediate table (we have a few of those as well).

You'll still be able to do what you need, I suggest you to start with studying many2many relationships in Django: https://docs.djangoproject.com/en/3.0/topics/db/examples/many_to_many/

Best regards
Federico

--
You received this message because you are subscribed to the Google Groups "OpenWISP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openwisp+u...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/openwisp/057c0c9d-de37-4c8e-80a0-470dfea3a496%40googlegroups.com.

Amit Goyal

unread,
Dec 20, 2019, 4:23:43 AM12/20/19
to OpenWISP
ok thanks Federico ! I will look into this


On Friday, December 20, 2019 at 2:40:35 PM UTC+5:30, Federico Capoano wrote:
Hi Amit,

Templates have a many2many relationship to config. The intermediate table which keeps track of how many config objects a template is assigned to does not have a model defined, because in most cases it's not needed and it's handled automatically by django, except some special cases in which additional fields need to be added to this intermediate table (we have a few of those as well).

You'll still be able to do what you need, I suggest you to start with studying many2many relationships in Django: https://docs.djangoproject.com/en/3.0/topics/db/examples/many_to_many/

Best regards
Federico

On Fri, Dec 20, 2019 at 9:52 AM Amit Goyal <amitg...@gmail.com> wrote:
Hi Federico 

I want to enable API for config_config_template table but I could not find any config_config_template model which can be used in urls.py .
I was checking in /usr/local/lib/python3.6/site-packages/openwisp_controller/config/models.py but there is no class for this table . 

even in base https://github.com/openwisp/django-netjsonconfig/tree/master/django_netjsonconfig/base , No base class mentioned for this class .

Can you please suggest what need to be done for enabling api for this table . Please share if any reference . 

Thanks
Amit 

--
You received this message because you are subscribed to the Google Groups "OpenWISP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages