Django_nuuuub Django_nuuuub - 1 year ago 90
Python Question

Django: import two different views to same

I was wondering if it is possible to link to two different files (in different directories) within one, and how this might be done?

More specifically, I am looking for a way to include the from 'myapp' directory in in 'details' directory together with the that is in 'details'.

Thanks for any help !

Answer Source

its possible , you need to import your views with different names , if they have same name you can do this :

from . import views
from import views as views2

urlpatterns = [
    url(r'^$', views.index, name='index'),
    url(r'^test/', views2.index, name='index2')),

but its not a cool idea , you can define the second URL in the related to the module .

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download