Replies: 2 comments 3 replies
-
Thanks for the kind words @frbor!
from django.shortcuts import redirect
def save_book(self):
book = Book(title="Title)
book.save()
return redirect("edit-book", pk=book.id) Does that seem reasonable? If so, I'll try to include support for HTTP redirects into the next release (0.12.0). |
Beta Was this translation helpful? Give feedback.
-
@frbor I added this functionality in 0.12.0 which is now on PyPI. Documentation is here: https://www.django-unicorn.com/documentation/components/redirecting. Let me know if you run into any bugs. Thanks for the suggestion! |
Beta Was this translation helpful? Give feedback.
-
First of all, I really appreciate the effort that has put into this framework. From my initial testing it seems like it can replace all javascript code in many projects.
However, I have found one issue that I'm unable to solve.
On a component I have a function that creates a new instance from a model object. I then want to redirect the user to a specific page where the ID of the newly crated instance is part of the url. Can that be achieved in any way?
So from this in the view:
redirect to url
/book/<book.id>
Can this be solved by any functionality here today?
It might that this should be solved using a combination of form/action, but my thought is that validation needs to be done in the view, and I prefer not to POST until I have created the model instance and now the new id.
I managed to partly solve it by manually updating a value that is rendered in the template with this content:
However, this is some what a hack, and I did not get it to work in Firefox (only in Chrome).
If you have any input on how to solve this problem, or alternatives that I have overlooked in the documentation it would really help.
best regards, Fredrik
Beta Was this translation helpful? Give feedback.
All reactions