Decoupling the URLconfs is not complete
|Reported by:||anonymous||Owned by:||jacob|
|Severity:||Keywords:||decouple urlconf view|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The example of Decoupling the URLconfs in Tutorial 03 is not a very good one.
urlpatterns = patterns('mysite.polls.views', (r'^$', 'index'), (r'^(?P<poll_id>\d+)/$', 'detail'), (r'^(?P<poll_id>\d+)/results/$', 'results'), (r'^(?P<poll_id>\d+)/vote/$', 'vote'), )
While the 'mysite.polls...' stuff remains, the URLconfs is not fully decoupled from the views. How about using the function names and relative import?
from .views import index, detail, results, vote urlpatterns = patterns('', (r'^$', index), (r'^(?P<poll_id>\d+)/$', detail), (r'^(?P<poll_id>\d+)/results/$', results), (r'^(?P<poll_id>\d+)/vote/$', vote), )
Better decoupling, isn't it?
Change History (3)
comment:1 Changed 7 years ago by ubernostrum
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Resolution set to duplicate
- Status changed from new to closed
comment:2 Changed 7 years ago by anonymous
- Resolution duplicate deleted
- Status changed from closed to reopened