Comments (2)
Yes, there isn't an XLSForm equivalent for boolean fields, so a ChoiceField
would be the most straightforward alternative. If you want to take a look at this, it could be addressed in ModelSerializer by customizing the field mapping. As a start, you could extend get_fields_for_config()
:
def get_fields_for_config(self):
fields = self.get_fields()
for name, field in list(fields.items()):
if name == 'id' or field.read_only:
fields.pop(name)
+ elif isinstance(field, serializers.BooleanField):
+ fields[name] = serializers.ChoiceField(choices=...)
return fields
This approach is nice because it lets DRF still view the field as a boolean (since get_fields()
is unchanged), while generating a useful configuration for use by wq.app and the templates.
However, there is one complication, which is that the default detail templates assume that any field with choices is accompanied with a read-only *_label
showing the label for the selected choice. So, you might also want to extend get_label_fields()
to generate an equivalent label for boolean fields. The cleanest way to do this is probably to define a custom ReadOnlyField
(see LocalDateTimeField
for an example).
from wq.db.
This is working now in wq.db 1.1.3.
from wq.db.
Related Issues (20)
- add_lookups: only pull in id and label for related items HOT 1
- alternative for method overridding
- "This field may not be null." for models.CharField declared with blank=True HOT 2
- no user profile information available in login.json HOT 2
- don't assume nested serializers always have get_wq_config
- server equivalent of wq/app.js _default_attachments
- list_exclude causes fields to not show up in config HOT 6
- update python-social-auth
- default_attachments not passing query string parameters to get_lookup_choices
- Handling of context misses for type filters HOT 4
- wq.db.rest.serializers.ModelSerializer's context contains no request HOT 4
- Django 2 support
- Django REST framework requires details field HOT 1
- result_inline.html character encoding issue HOT 2
- DRF 3.10 breaking change HOT 1
- Custom OAuth authentication
- Issue in SPATIALITE_LIBRARY_PATH for Windows os HOT 1
- STATIC Contents are loading HOT 1
- Django 3.1 compatibility HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wq.db.