Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
django-url-follower
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikolaos S. Papaspyrou
django-url-follower
Commits
f6884a7c
Commit
f6884a7c
authored
Jun 15, 2015
by
Nikolaos S. Papaspyrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add part 4a, simple views
parent
eb3596a7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
0 deletions
+26
-0
README.md
README.md
+6
-0
urls.py
redurl/urls.py
+1
-0
urls.py
urlapp/urls.py
+9
-0
views.py
urlapp/views.py
+10
-0
No files found.
README.md
View file @
f6884a7c
...
...
@@ -89,3 +89,9 @@ Remove the `User` model and replace with that in `django.contrib.auth.models`.
python manage.py makemigrations urlapp
python manage.py migrate
Part 4
------
Add default view.
Edit
`urlapp/views.py`
, create
`urlapp/urls.py`
.
Edit
`redurl/urls.py`
.
redurl/urls.py
View file @
f6884a7c
...
...
@@ -17,5 +17,6 @@ from django.conf.urls import include, url
from
django.contrib
import
admin
urlpatterns
=
[
url
(
r'^'
,
include
(
'urlapp.urls'
)),
url
(
r'^admin/'
,
include
(
admin
.
site
.
urls
)),
]
urlapp/urls.py
0 → 100644
View file @
f6884a7c
from
django.conf.urls
import
url
from
.
import
views
urlpatterns
=
[
url
(
r'^$'
,
views
.
index
,
name
=
'index'
),
url
(
r'^(?P<url_id>[0-9]+)/$'
,
views
.
redir
,
name
=
'redir'
),
url
(
r'^url=(?P<url_id>[0-9]+)/$'
,
views
.
url
,
name
=
'url'
),
]
urlapp/views.py
View file @
f6884a7c
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
# Create your views here.
def
index
(
request
):
return
HttpResponse
(
"Hello, world!"
)
def
redir
(
request
,
url_id
):
return
HttpResponse
(
"You're following URL {}."
.
format
(
url_id
))
def
url
(
request
,
url_id
):
return
HttpResponse
(
"You're looking at URL {}."
.
format
(
url_id
))
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