Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
haosuwei opened this issue Dec 23, 2016 · 0 comments
Open

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

haosuwei opened this issue Dec 23, 2016 · 0 comments

Comments

@haosuwei
Copy link

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)
'''

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant