url probs

22 views
Skip to first unread message

ngangsia akumbo

unread,
Jul 19, 2014, 8:01:44 AM7/19/14
to django...@googlegroups.com
Good After Django Users

I still have problems with urls.
Please somebody should take a carful look at this urls

urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)),
    #new urls
    url(r'^$', PostListView.as_view(), name='news-list'),

    url(r'^(?P<slug>[-_\w]+)/$', PostDetailView.as_view(), name='blogs-detail'),

    #events urls
    url(r'^$', EventListView.as_view(), name='events-list'),
    url(r'^(?P<slug>[-_\w]+)/$', EventDetailView.as_view(), name='events-detail'),
)
  
when i type http://127.0.0.1:8000/ on the browser, this url

url(r'^$', PostListView.as_view(), name='news-list'), 

will list all the news by their headlin in the form of a link.

when i click on the url it output the content of the news , that is giving me the detail url of that news headline.
this url
 
url(r'^(?P<slug>[-_\w]+)/$', PostDetailView.as_view(), name='blogs-detail'),

will take care of outputting the content

Ok now i have created a second app called events with the following urls

 url(r'^$', EventListView.as_view(), name='events-list'),
 url(r'^(?P<slug>[-_\w]+)/$', EventDetailView.as_view(), name='events-detail'),

so how do i open the url for event cos when i type http://127.0.0.1:8000/ it outputs only
the url for news, that is the first url above.

monoBOT

unread,
Jul 19, 2014, 1:02:57 PM7/19/14
to django...@googlegroups.com
The urls are a first come first served ... that is the first url that match is served 

On your url file there are 4 urls that match on the same pattern. I recommend you to write urls that are impossible to match against each other, and if some url is able to match others write that one in the last possition in the list.

Peace!




--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/380a0bd3-85a2-4765-91b2-1888f4ea0b73%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
monoBOT
Visite mi sitio(Visit my site): monobotsoft.es/blog/
Reply all
Reply to author
Forward
0 new messages