"otro"機能の価値をどのように得ることができますか?このコードは動作しますが、get関数の値だけが表示されます。 otroの価値をどのように得ることができますか?私はURLでそれを行う方法を理解していません。Python Django、urlsによる関数値へのアクセス?
views:
from django.views.generic import ListView, View
from . models import Autor
from django.shortcuts import render, redirect
from django.http import HttpResponse, HttpResponseRedirect
def inicio(request):
return HttpResponse('HOLA')
# Create your views here.
class MiVista(View):
def get(self, request):
# <la logica de la vista>
return HttpResponse('resultado')
def otro(self, request):
# <la logica de la vista>
return HttpResponse('otro')
urls:
from django.conf.urls import url, include
from django.contrib import admin
from .import views
from .views import MiVista
urlpatterns = [
url(r'^hola$', views.inicio),
url(r'^indice/', MiVista.as_view()),
]
理由だけではなく、 'otro'のための新しいビューを作成し、GET内のすべてのロジックを入れていないのですか? –