Replies: 18 comments
-
Hey @Joetib, thanks for checking |
Beta Was this translation helpful? Give feedback.
-
Thanks for tending to this quickly. However can you suggest some workaround I can do? Perhaps with Django forms that won't interrupt with unicorn |
Beta Was this translation helpful? Give feedback.
-
Yep, you can mix a Django Sorry I don't have better news, but I will try to work on this next -- I just can't promise when it will be done. :) Making a file upload that "just works" is going to require some work (see the hoops that |
Beta Was this translation helpful? Give feedback.
-
I attached #167 with some initial code, but still needs a lot more thought to make sure it will all work as expected. But, it's in process! |
Beta Was this translation helpful? Give feedback.
-
That's very good news I'm excited. By the way, could you possibly have a document explaining how to contribute. I would love to understand and add a contribution to this project. I love it. |
Beta Was this translation helpful? Give feedback.
-
I checked the pr. Is there a way to get it to test? |
Beta Was this translation helpful? Give feedback.
-
Nope, nothing to test, yet! I just marked the PR as a draft because it's still early. I'll let you know when I get all the pieces working together, though.
That's a great idea. https://github.com/adamghill/django-unicorn/blob/master/DEVELOPING.md#developing is the basic gist, but I will create a more comprehensive document with more details. |
Beta Was this translation helpful? Give feedback.
-
Thank you. I will be waiting for a more detailed guide explaining how the pieces fit together |
Beta Was this translation helpful? Give feedback.
-
I threw this architecture doc together to give a rough overview of how it all works, but let me know if you have specific questions or would like more details about any area. |
Beta Was this translation helpful? Give feedback.
-
I had a read through the architecture doc. I understand better now. |
Beta Was this translation helpful? Give feedback.
-
Very opinionated but still helpful comment I guess: use Google Cloud Storage or any other object storages, https://googleapis.dev/python/google-resumable-media/latest/resumable_media/requests.html#resumable-uploads IMHO it's not high priority issue... |
Beta Was this translation helpful? Give feedback.
-
I'm sorry but this issue already has draft PR on it. I think that is enough and the "it's not a high priority issue..." isn't that necessary. Oh and I've been able to split my problem up and fixed them with a separate upload step that directly uses Django forms |
Beta Was this translation helpful? Give feedback.
-
I tell about Django forms because of you commented
Its a good idea to deprecate forms Django usage and suggest to use Pydantic for validation instead, some object storages for uploading files etc.
Yes but may be we should deprecate this feature at all and suggest to use better alternatives... Sorry, I'm new user of this project, so I didn't seen this issue 2 Mar (issue creation date) but better to say now and prevent from doing something ugly than never. Just opinion. |
Beta Was this translation helpful? Give feedback.
-
I use Django Forms only for validation now (I don't use the widgets at all). You can see an example here: https://www.django-unicorn.com/docs/validation/. I agree that Django Forms mix validation with presentation, but for just using that as a validation layer it seemed like a good first approach. For anyone with an existing Django site or going through the tutorial they will most likely already use/have a Django Form class.
I already support the Pydantic base model for serialization. Using it for validation as well is a possibility. I don't particularly want to build a bunch of different ways that validation could be enabled (I'd rather have "one way" to do it). But, it's still a good idea. If you want to make a separate issue just with that request, that makes sense to me.
Yep,
I sort of agree that there are (maybe better) ways to do a file upload, but I think having a drop-in solution would also be useful as part of |
Beta Was this translation helpful? Give feedback.
-
But Django disagree with you https://github.com/django/django/blob/main/django/forms/forms.py#L98-L107 :-) I like modular design, unix way (https://en.wikipedia.org/wiki/Unix_philosophy) and may be DDD. That's why I do not suggest read Django docs usually. Instead, I suggest to read https://phalt.github.io/django-api-domains/. I's about pragmatical way to integrate DDD ideas with Django modern development. Do not use fat models, use Django ORM only in service files etc. I think despite the fact this guide is about API development, most of this guide can be useful for django-unicorn based projects too. django-unicorn help to create layer, which may replace some of APIs. With django-unicorn you create components instead of API but other layers are the same. Also you may still need API for some partners integrations, cli-tools and mobile apps... Proper composition is matter. It also allow you to switch, for example, Django to Starlette or FastAPI (which is based on Starlette and extend it as DRF do with Django) in future. (Because of https://www.techempower.com/benchmarks/#section=data-r20&hw=ph&test=fortune&l=zijzen-sf benchmark result) You project support AJAX instead of WebSockets. It may become big benefit for some serverless environments. It's just my opinion about what would I like to get as user. I would like to get Vue.python ( This may or may not be your goal to be useful for big companies and big projects. But if it's your goal then modular design is requirement and in this case it's good to minimise dependencies to Django components. Anyway I see it's good solution for MVP and it's already very useful for many projects, good job. |
Beta Was this translation helpful? Give feedback.
-
For right now my goal is to be the best reactive component library for Django. That alone is an ambitious enough side project! :) I use Django in my day job and for all of my side projects, so it's what I know and what I want to use. I do take your comments to heart about it being modular and being able to use I welcome any and all PRs, though! :) |
Beta Was this translation helpful? Give feedback.
-
Django is good system for a lot of projects, I completely agree.
It's hard to "sell" system with, for example, only Django validators to team. They think about "that component will increase vendor lock-in to Django". So that marketing reasons exist too...
It can be even Django but frontend version of Django (with Redis cache may be), without models, with GraphQL Python client to get/send data to internal GraphQL API, for example. (or OpenAPI or gRPC)
Again, great project. I like it. There are some reasons (https://cloud.google.com/run/docs/triggering/websockets#multiple-instances) why do I prefer AJAX over WebSockets. I hope it's safe to use this project with multiple instances... One more suggestion also - it's not clear how to test components. May be need add doc page about it. IMHO we should not mix this frontend components with services (some business logic) and auth system (checking permissions), it's different layers. Good example about how to test only frontend part of system (server components and browser scripts). I see django-unicorn as alternative to Vue.js or Vue.js with Node.js (SSR). May be I can reuse some examples here: https://github.com/adamghill/django-unicorn/tree/master/tests P.S. Sorry for offtopic in this issue. |
Beta Was this translation helpful? Give feedback.
-
For those browsing, one way to do file uploads with Django Unicorn is just via base64 encoding the file. This is not super efficient but for my case (<10mb images) it works fine. Create a JS file:
Have some sort of input like:
Then when a user clicks a save button we have a python method in the component like:
|
Beta Was this translation helpful? Give feedback.
-
I took unicorn for a spin just a night ago and I've really taken a liking to it. However, reading throughout the documentation, I do not see anything about file uploads. I have some forms that I want simplified with unicorn's magic. Am I missing something? How do I approach this?
Beta Was this translation helpful? Give feedback.
All reactions