TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Unicorn – A full-stack web framework for Django

133 点作者 siavash将近 2 年前

19 条评论

pabe将近 2 年前
I wondered how Unicorn compared to htmx. They&#x27;re giving an answer on their website:<p>htmx and alpine.js are great libraries to provide interactivity to your HTML. Both of those libraries are generalized front-end framework that you could use with any server-side framework (or just regular HTML). They are both well-supported, battle-tested, and answers to how they work are probably Google-able (or on Stackoverflow).<p>Unicorn isn’t in the same league as either htmx or alpine.js. But, the benefit of Unicorn is that it is tightly integrated with Django and it should “feel” like an extension of the core Django experience. For example:<p>* redirecting from an action uses the Django redirect shortcut<p>* validation uses Django forms<p>* Django Models are tightly integrated<p>* Django messages “just work” the way you would expect them to<p>* you won’t have to create extra URLs&#x2F;views for AJAX calls to send back HTML because Unicorn handles all of that for you
评论 #36998508 未加载
评论 #36996445 未加载
doix将近 2 年前
I guess the biggest problem&#x2F;downside&#x2F;flaw with this is that you wait for a response from the backend to update the UI. Which is mostly fine, but I&#x27;ve come to expect either a round trip to the server, or instantaneous updates.<p>This is the uncanny valley for me, it&#x27;s neither the old school web or &quot;SPA land&quot; (for a lack of a better term). In the todo example, I write some garbage and press &quot;Add&quot;, there is absolutely 0 feedback anything happened. I then press it again. About 100ms later, the first thing I typed appeared, then slightly later it got replaced with nothing.<p>I have no idea how I&#x27;d fix that in this framework, there&#x27;s too much magic for me to figure out where I&#x27;d insert a &quot;fix&quot; for this. I&#x27;d probably start writing my own javascript to disable the button while it&#x27;s submitting (which isn&#x27;t great, but better than today), at which point the &quot;magic&quot; is lost.
评论 #36998011 未加载
adparadox将近 2 年前
I&#x27;m the creator of Unicorn, so this is neat to see it on Hacker News again. I&#x27;ve been working on Unicorn nights and weekends since July 2020, slowly adding in new functionality and improving it. I have a conference talk explaining the origins a little bit: <a href="https:&#x2F;&#x2F;github.com&#x2F;adamghill&#x2F;djangocon-eu-2021-conference-talk">https:&#x2F;&#x2F;github.com&#x2F;adamghill&#x2F;djangocon-eu-2021-conference-ta...</a>.<p>I never expected Unicorn to completely replace larger SPA frameworks, but I have found it solves for most of the use cases I need for my sites.<p>Thanks for checking it out -- all PRs are greatly appreciated to add new features or fix bugs!
jer0me将近 2 年前
See also:<p>Laravel Livewire (<a href="https:&#x2F;&#x2F;livewire.laravel.com" rel="nofollow noreferrer">https:&#x2F;&#x2F;livewire.laravel.com</a>)<p>HTMX (<a href="https:&#x2F;&#x2F;htmx.org" rel="nofollow noreferrer">https:&#x2F;&#x2F;htmx.org</a>)<p>Hotwire (<a href="https:&#x2F;&#x2F;hotwired.dev&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;hotwired.dev&#x2F;</a>)<p>Phoenix LiveView (<a href="https:&#x2F;&#x2F;github.com&#x2F;phoenixframework&#x2F;phoenix_live_view">https:&#x2F;&#x2F;github.com&#x2F;phoenixframework&#x2F;phoenix_live_view</a>)
评论 #36995685 未加载
评论 #36995786 未加载
评论 #36998535 未加载
samwillis将近 2 年前
Unicorn is awesome, and I think most would agree that it&#x27;s the Django communities answer to Livewire&#x2F;Liveview&#x2F;etc. Adam has built a brilliant project and the time he must dedicate to it is amazing!<p>Last year I had a month free and I had a go at building something for Django in this area, with a bunch of interesting ideas - built on Alpine.js, resumable server side component state, inline component templates. But sadly time is limited and I just can&#x27;t spend the time needed to push it further. One day I may be able to pivot back to it, but would be very happy for someone to take some of these ideas and run with them - <a href="https:&#x2F;&#x2F;www.tetraframework.com&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;www.tetraframework.com&#x2F;</a><p>What I really want to see is a modern asset + front end build solution for Django. It would enable more of these sorts of projects. Thats what needs to be built into Django.
EmilStenstrom将近 2 年前
Django was a &quot;batteries included&quot; framework about 10 years ago. But the core team had very strong opinions about javascript, saying that picking a javascript framework should NOT be part of those batteries. Time has passed, and javascript is now part of every single website or app we build. Django still doesn&#x27;t give any help to developers that wants to build a modern site.<p>My opinion: They should go the Phoenix Live View-route: adding a small websocket js layer, that permits reactivity while deferring as much logic to the backend as possible.
评论 #36996739 未加载
评论 #36996912 未加载
评论 #36996763 未加载
评论 #36996605 未加载
评论 #36996568 未加载
评论 #36997087 未加载
评论 #36999469 未加载
评论 #37012653 未加载
nologic01将近 2 年前
Great to see the growing effort to explore all the fields left uncultivated by the breathless SPA&#x2F;angular&#x2F;react&#x2F;vue bandwagons of the past decade. It feels like a ratonal reallocation of tasks to where they can be executed best.<p>Something that is nagging me though is the (still) rather incomplete take on client-side reactivity. Alpine.js is by-and-large addressing this in a pleasantly minimalistic way, but for this new take to become a defacto standard of lean and mean modern web development I feel there should be uniform semantics and integration that spans the different server-side stacks. This way code and knowledge would be reusable and not tied to a specific language&#x2F;web platform.
xwowsersx将近 2 年前
Given gunicorn and uvicorn, I can&#x27;t help but feel this name can and will cause some confusion. We gotta be able to pick different names lol
评论 #36997690 未加载
评论 #36996186 未加载
评论 #36997945 未加载
评论 #36997125 未加载
评论 #36996393 未加载
tedunangst将近 2 年前
Isn&#x27;t unicorn the ruby web server? Name collisions are kinda unavoidable, but I&#x27;d at least try to avoid them in the same space.
评论 #36995697 未加载
评论 #36997671 未加载
ofrzeta将近 2 年前
How is it a &quot;full-stack framework&quot; when it&#x27;s &quot;for Django&quot; that provides the backend service? Also on their own homepage they mention &quot;Using <i>other</i> frontend frameworks with Django&quot;, so I&#x27;ll conclude it is in fact a frontend framework for Django.
评论 #36996260 未加载
评论 #36996249 未加载
robbywashere_将近 2 年前
React aside… hooks, classes redux fatigue whatever- JSX is beautiful and any other framework that builds this quasi irb+mustache+html-like-markup is taking 2 steps back. I would like to see JSX survive the framework wars of 2024-2025
评论 #37006190 未加载
评论 #36999255 未加载
pid-1将近 2 年前
I wish there was something like Streamlit, but for non-data apps. Personal sites, blogs, etc... Something that skipped templating and allowed me to declare compenents in a high level way.<p>ST was easily the most pleasant experience I&#x27;ve ever had developing front end using a Python backend.
sgt将近 2 年前
My first thought when seeing their validation examples - when I build a Django app and add validations, I start off with a normal form that does a full submit. This is the easiest to get going. As requirements become a bit more complex, I might add JS validation so that a POST is not necessary. Looking at their validation examples:<p><a href="https:&#x2F;&#x2F;www.django-unicorn.com&#x2F;examples&#x2F;validation" rel="nofollow noreferrer">https:&#x2F;&#x2F;www.django-unicorn.com&#x2F;examples&#x2F;validation</a><p>This does a POST each time, albeit automatically on typing. It still means a lag for a kind of validation that could have been done client side.
评论 #36997931 未加载
throwaway154将近 2 年前
Does<p><pre><code> class TodoView(UnicornView): </code></pre> create a model?<p><pre><code> class UnicornView(TemplateView) </code></pre> and<p><pre><code> from django.views.generic.base import TemplateView </code></pre> Is this Django magic a Flasker doesn&#x27;t get?
评论 #36995595 未加载
vorticalbox将近 2 年前
Reminds me a lot of <a href="https:&#x2F;&#x2F;fresh.deno.dev&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;fresh.deno.dev&#x2F;</a>
Ultimatt将近 2 年前
Does anyone know of something similar but targeting FastAPI and SQLModel?
drcongo将近 2 年前
Shame there&#x27;s no jinja support, I really can&#x27;t stand Django templates.
评论 #36999303 未加载
ano88888将近 2 年前
isn&#x27;t Django already a web framework?
评论 #36995868 未加载
andrewstuart将近 2 年前
I&#x27;ve done extensive development with Flask, Bottle, Django, Falcon, Django Rest Framework, Starlette, Sanic and FastAPI over about 13 years or so.<p>These days I prefer to build my back end applications with nodejs, TypeScript and plain SQL (no ORM) talking to Postgres.<p>I like Django but it pissed me off no end that it&#x27;s called &quot;batteries included&quot;, except that the very first thing you need to do with any Django project is going and find some batteries for the user signup auth flow. That&#x27;s not batteries included, and its not something you should need to figure out for yourself in a batteries included framework. It&#x27;s time consuming, complex and error prone and should be built in.<p>Anyhow as I say, I&#x27;ve prefer nodejs though I still do use Python for lots of stuff.
评论 #36996310 未加载
评论 #36995937 未加载
评论 #36998401 未加载