Django - Import views from separate apps

后端 未结 5 845
轻奢々
轻奢々 2021-02-19 07:59

I\'m new to Django and working my way through \"The Django Book\" by Holovaty and Kaplan-Moss. I have a project called \"mysite\" that contains two applications called \"books\

5条回答
  •  半阙折子戏
    2021-02-19 08:50

    from books import views
    from contact import views
    

    You are overwriting the name views. You need to import them as different names or as absolute names.

    import books.views
    import contact.views
    

    ... or ...

    from books import views as books_views
    from contact import views as contact_views
    

    Then use the correct name when defining your URLs. (books.views.search or books_views.search depending on the method you choose)

提交回复
热议问题