我试图通过使用django动态输入用户名来获取特定用户的GitHub详细信息。但是我没有得到详细信息,当我单击index.html代码中的查看按钮时,它返回的是“未找到”。
这是我的代码
forms.py
class GithubInfo(forms.ModelForm):
class Meta():
model = Github
fields = ['name']
views.py
from django.shortcuts import render
from .forms import UserForm,UserProfileInfoForm,GithubInfo
from django.contrib.auth import authenticate, login, logout
from django.http import HttpResponseRedirect, HttpResponse
from django.urls import reverse
def index(request):
form = GithubInfo(request.POST)
if form.is_valid():
form.save()
return render(request,'signupapp/index.html',{'form':form})
index.html
<h2>Github repos</h2>
<form action="{% url 'signupapp:index' %}" method="POST">
{% csrf_token %}
{{ form.as_p }}
<a href="https://api.github.com/users/{{form.name}}/">
<input type="button" value="view"/>
</a>
</form>
urls.py
from django.conf.urls import url
from signupapp import views
app_name = 'signupapp'
urlpatterns=[
url(r'^index/$',views.index,name='index')
]
谁能帮助我实现这一目标