I have a django test, on an amazon ec2 instance,
I see the “It worked!” page,
i have commented the necessary lines to have access to the admin,
but i cannot see the admin page,
I have to configure properly the urls.py to show the view in my app,
from django.conf.urls.defaults import patterns, include, url
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'micopiloto.views.home', name='home'),
url(r'^$', 'portfolio.views.view', name='home'),
# url(r'^micopiloto/', include('micopiloto.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
)
the view for my app is in:
/home/ubuntu/djangoProj/micopiloto/portfolio/views.py
but I have an empty views.py [as i just created the app]
so how do I set the urls.py to connect with my app,
do i need some basic code to see the views.py of my app?
and how to load the admin page?
thanks!
Each view (a function in views.py file) in django is related to a url, that is when the url is visited, that view funciton will be called and the output will be shown in the browser.
To create a simple view function, open the views.py file of the app with a text editor, and add this function to it:
Now you can view your first page by visiting /, and also can see the admin page in /admin.
Note that the function name must be same as the one you enter in the urls.py (here view as in: ‘portfolio.view.view‘).
Also note that if you have a error in your urls.py files (and some other files like settings.py, admin.py, etc.) you cannot see the admin page, here the error what that you referenced a function called portfolio.views.view in urls.py but there was not such function in your views.py file.