Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
go
Commits
78becf69
Commit
78becf69
authored
Jan 02, 2017
by
David Haynes
Browse files
Begin PY3 modifications to views
parent
1b9367ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
go/go/views.py
View file @
78becf69
...
...
@@ -41,21 +41,21 @@ def index(request):
# Initialize a URL form
url_form
=
URLForm
(
host
=
request
.
META
.
get
(
'HTTP_HOST'
))
# unbound form
url_form
=
URLForm
(
host
=
request
.
META
.
get
(
'HTTP_HOST'
))
# unbound form
# If a POST request is received, then the user has submitted a form and it's
# time to parse the form and create a new URL object
if
request
.
method
==
'POST'
:
# Now we initialize the form again but this time we have the POST
# request
url_form
=
URLForm
(
request
.
POST
,
host
=
request
.
META
.
get
(
'HTTP_HOST'
))
url_form
=
URLForm
(
request
.
POST
,
host
=
request
.
META
.
get
(
'HTTP_HOST'
))
# Django will check the form to make sure it's valid
if
url_form
.
is_valid
():
# We don't commit the url object yet because we need to add its
# owner, and parse its date field.
url
=
url_form
.
save
(
commit
=
False
)
url
=
url_form
.
save
(
commit
=
False
)
url
.
owner
=
request
.
user
.
registereduser
# If the user entered a short url, it's already been validated,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment