WebAug 3, 2024 · You can use redirect from http shortcuts. from django.shortcuts import redirect def my_view(request): ... object = MyModel.objects.get(...) return redirect(object) #or return redirect('/some/url/') Here is the link to official docs. WebThe redirect () function is used to redirect to the specific URL. It returns an HttpResponseRedirect to the appropriate URL for the argument passed. Let's see the following syntax. Syntax - redirect (to, *args, permanent=False, **kwargs) Parameters - A model: The model's get_absolute_url () function will be called.
Django实现图片上传至数据库_学不会的码农的博客-CSDN …
WebIn this lesson, I’m going to dive into Django’s redirect() shortcut, and how to use it. In the introduction, I quickly demonstrated the use of the Django redirect() shortcut. 00:15 Why is it a shortcut? Well, because you can do it without the shortcut. Here’s a handmade version of what it’s doing. First off, you need an HttpResponse object. Web3 Answers Sorted by: 9 You can use HttpResponseRedirect: from django.http import HttpResponseRedirect # ... return HttpResponseRedirect ('/url/url1/') Where "url" and "url1" equals the path to the redirect. Share Improve this answer Follow edited Nov 17, 2024 at 10:22 fedorqui 269k 102 540 591 answered Jan 1, 2014 at 22:50 Joe 3,070 3 24 29 barry atsma wikipedia
django - don
WebMar 29, 2013 · If you are on Django 1.6 or above, you can do this: from django.views.generic import RedirectView urlpatterns = patterns ('', url (r'^some-page/$', RedirectView.as_view (pattern_name='my_named_pattern', permanent=False)), ... In Django 1.9, the default value of permanent has changed from True to False. Because of … WebApr 11, 2024 · from django.shortcuts import render, redirect from .models import Todo # Create your views here. def index (request): todo = Todo.objects.all () if request.method == 'POST': new_todo = Todo ( title = request.POST ['title'] ) new_todo.save () return redirect ('/') return render (request, 'index.html', {'todos': todo}) def delete (request, pk): … WebApr 13, 2024 · 实现 Django 导入 Excel 文件到数据库的方法有很多种,其中一种常用的方法是使用第三方库 pandas 和 openpyxl。您可以先安装这两个库,然后在 Django 中编写 … barry avenue plating tijuana