Repository navigation
Replies: 2 comments 2 replies
|
I'd separate the Python context model from the serialized payload that the TypeScript types describe. For the conversion step in this prototype, import The shown
|
|
I think this kind of approach could be the right idea, but we need to think a bit deeper about this, in general. Passing the data as context values is probably the wrong approach. I think we're better off writing a REST API that the visualisation code uses to get the data directly from the database. So the view will not pull anything from the database and will just provide the authenticated user, which the JS code can use to get the data. It's a bit of a refactor, but I think it separates things more cleanly and actually makes it more tightly integrated for the type-matching question you have here. An aside (but I think related)We should look at refactoring the views, in general, to remove as much business logic (ie DB transactions) from them. I think this will line up with my above suggestion more nicely, also. (This thinking comes from this Django style guide) |
Uh oh!
There was an error while loading. Please reload this page.
@sbland and @AdrianDAlessandro discussed approaches to typing view return contexts and then matching this to typescript types in the javascript components.
One approach would be to have dataclass classes as a context return type as below:
All reactions