Skip to content

try "www.xxx.com" twice got the same page #8

Open
@haosuwei

Description

@haosuwei

I try to put "www.xxx,com" twice ,but I got the same page "Success",
I think it would be better to change the post function in HomeView
'''
def post(self, request, *args, **kwargs):
pform = SubmitUrlForm(request.POST)
context = {
"title": "Kirr.co",
"form": pform
}
template = "shortener/home.html"
if pform.is_valid():
#print pform.cleaned_data
new_url = pform.cleaned_data.get("url")
new2_url = validate_url(new_url)
obj, created = KirrURL.objects.get_or_create(url=new2_url)
context = {
"object": obj,
"created": created,
}
if created:
template = "shortener/success.html"
else:
template = "shortener/already-exists.html"
return render(request, template ,context)
'''

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions