Thursday, July 22, 2010

Two apps with same url's in one project.

Hi,

I wrote two apps in same project. There're quite similar, and this is
the problem here. They have two idetical urls.py files :

App 1 :

from django.conf.urls.defaults import *
from web_aplikacje.promocje.models import Promocja, Producent, Dodatek

info = { 'queryset' : Producent.objects.all(),
'template_object_name': 'producent',
'extra_context': { 'dodatek' : Dodatek.objects.all }
}

urlpatterns = patterns('web_aplikacje.promocje.views',
url(r'^search/$', 'search', name="link-search"),
)

urlpatterns += patterns('django.views.generic.list_detail',
url(r'^(?P<slug>[-\w]+)/$', 'object_detail', info, name="link-
prod"),
url(r'^$','object_list', info, name="link-home"),

)

App 2:

from django.conf.urls.defaults import *
from web_aplikacje.cenniki.models import Opis, Producent, Cennik

info = { 'queryset' : Producent.objects.all(),
'template_object_name': 'producent',
'extra_context': { 'cennik' : Cennik.objects.all }
}

urlpatterns = patterns('web_aplikacje.cenniki.views',
url(r'^search/$', 'search', name="link-search"),
)

urlpatterns += patterns('django.views.generic.list_detail',
url(r'^(?P<slug>[-\w]+)/$', 'object_detail', info, name="link-
prod"),
url(r'^$','object_list', info, name="link-home"),

)

My main urls.py in root catalog for project :

from django.conf.urls.defaults import *
from django.conf import settings
from django.contrib import admin

admin.autodiscover()

urlpatterns = patterns('',
(r'^promocje/', include('web_aplikacje.promocje.urls')),
(r'^cenniki/', include('web_aplikacje.cenniki.urls')),
(r'^admin/', include(admin.site.urls)),
)

if settings.DEBUG:
urlpatterns += patterns('',
(r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': '/home/virtual/web_aplikacje/img/'}),
)

Now every url which is generated by generic views have word 'cennik'.
'promocje' just gone from displaying in url's. I know this is because
same generic view with slug in it, but I don't have idea how to
separate them. I would like to have access to data in this form:

http://some_site_name/promocje/producent-1/
http://some_site_name/promocje/producent-2/

http://some_site_name/cenniki/producent-1/
http://some_site_name/cenniki/producent-2/

Is it possible with this form of two apps in one project ? I can be
even :

http://some_site_name/some_main_site/promocje/producent-1/
http://some_site_name/some_main_site/cenniki/producent-1/

Any ideas ?


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate