aca un ejemplo de mi urls.py deberia funcionar pero no funciona cuando actualizo la base de datos
Código Python:
Ver original#encoding:utf-8
from django.conf.urls import patterns, include, url
import os,sys
# Uncomment the next two lines to enable the admin:
from django.conf import settings
from django.contrib import admin
from catalogo.models import Categories,Product
from html.models import Page
sys.dont_write_bytecode = True
def fromRelativePath(*relativeComponents):
RUTA_PROYECTO = os.path.dirname(os.path.realpath(__file__))
return os.path.join(RUTA_PROYECTO, *relativeComponents).replace("\\","/")
def add_catalog_product_url(urlpatterns):
for product in Product.get_all_products():
slug= r'^catalogo/detalle/%s' % product.slug
item= url(slug, 'catalogo.views.product_detail')
urlpatterns += patterns('',item)
def add_catalog_categories_url(urlpatterns):
for category in Categories.get_all_categories():
slug= r'^catalogo/%s' % category.slug
item= url(slug, 'catalogo.views.catalog')
urlpatterns += patterns('',item)
for category in Categories.list_categories():
sub_slug= r'^catalogo/%s/%s' % (category.parent.slug,category.slug)
sub_item= url(sub_slug, 'catalogo.views.sub_catalog')
urlpatterns += patterns('',sub_item)
def add_html_page_url(urlpatterns):
for thepage in Page.get_all_pages():
slug= r'^%s' % thepage.slug
item= url(slug, 'html.views.list_the_page',name=thepage.slug)
urlpatterns += patterns('',item)
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
url(r'^$', 'catalogo.views.home', name='home'),
url(r'^catalogo/search$', 'catalogo.views.catalog_search', name='catalog_search'),
url(r'^contacto$', 'html.views.contact_form', name='contact_form'),
url(r'^process/contact$', 'html.views.process_contact', name='process_contact_form'),
#url(r'^zandalia-larga', 'catalogo.views.home', name='home2'),
#url(r'^catalogo/(?P<slug>)', 'catalogo.views.catalog', name='catalog'),
# url(r'^mysite/', include('mysite.foo.urls')),
# url(r'^lista/$', 'backend.views.lista_groups'),
(r'^js/(?P<path>.*)$', 'django.views.static.serve', {'document_root':fromRelativePath('../design/static')}),
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root':fromRelativePath('../media')}),
(r'^admins/(?P<path>.*)$', 'django.views.static.serve', {'document_root':fromRelativePath('../design/static/admins'), 'show_indexes': True}),
# 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)),
url("^admin-media/(?P<path>.*)$", "django.views.static.serve", {"document_root": fromRelativePath( "../design/static/admin-media")})
)
add_catalog_product_url(urlpatterns)
add_catalog_categories_url(urlpatterns)
add_html_page_url(urlpatterns)