{"repo":"openwisp/django-swappable-models","free":true,"listed":false,"github":"https://github.com/openwisp/django-swappable-models","clone":"git clone https://github.com/openwisp/django-swappable-models.git","description":"Swapper - The unofficial Django swappable models API. Maintained by the OpenWISP project.","language":"Python","stars":250,"topics":["swappable-models","django","reusable-app","foreign-keys","swapper","migrations","django-models"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"Swapper Django Swappable Models - No longer only for auth.User! Swapper is an unofficial API for the [undocumented] but very powerful Django feature: swappable models. Swapper facilitates implementing arbitrary swappable models in your own reusable apps. Requirements - Python 3.10 or later - Django 4.2 or later Motivation Suppose your reusable app has two related tables: Suppose further that you want to allow the user to subclass either or both of these models and supplement them with their own additional fields. You could use Abstract classes (e.g. BaseParent and BaseChild ) for this, but then you would either need to: 1. Avoid putting the foreign key on BaseChild and tell the user they need to do it. 2. Put the foreign key on BaseChild , but make Parent a concrete model that can't be swapped 3. Use swappable models, together with ForeignKeys that read the swappable settings. This third approach is taken by Django to facilitate [swapping the auth.User model]. The auth.User swappable code was implemented in a generic way that allows it to be used for any model. Although this capability is currently [undocumented] while any remaining issues are being sorted out, it has proven to be very stable and useful in our experience. Swapper is essentially a simple API wrapper around this existing functionality. Note that Swapper is primarily a tool for library authors; users of your reusable app generally should not need to know about Swapper in order to use it. (See the notes on End Us","default_branch":null,"files":null,"tree":[],"storefront":"/r/openwisp","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/openwisp/django-swappable-models/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}