Antonio
Antonio

Reputation: 1

misunderstanding on django html, css, view functions

I'm new on django development. I had created any html files and now I want to integrate on django. The problem is that I can't achieve it.

If I type the following on urls.py I can see css but I can't run the function on views.py that I need to save data on database or for example to check fields on web.

(r'^(?P<path>.*)$', 'django.views.static.serve', {'document_root': 'templates/', 'show_indexes': True})

I had set all my html, css and images on templates folder.

Do you understand what I am trying to explain?

Thanks in advance

Upvotes: 0

Views: 201

Answers (1)

espenhogbakk
espenhogbakk

Reputation: 11728

You should really have a look at the django tutorial, but essentially you need to route you urls to the views.py functions.

This is an example from the django tutorial:

from django.conf.urls import patterns, url, include

urlpatterns = patterns('',
    (r'^articles/2003/$', 'news.views.special_case_2003'),
    (r'^articles/(\d{4})/$', 'news.views.year_archive'),
    (r'^articles/(\d{4})/(\d{2})/$', 'news.views.month_archive'),
    (r'^articles/(\d{4})/(\d{2})/(\d+)/$', 'news.views.article_detail'),
)

Here you can see that the different urls are routed to the different functions in a views.py file.

So you need to create a url config for each different url, and then you will be able to handle it with a view function.

Upvotes: 2

Related Questions