Reversing namespaced URLs in Django: multiple instances of the same app

前端 未结 5 1836
鱼传尺愫
鱼传尺愫 2020-12-30 07:09

I\'ve been working with Django for a while now (currently on version 1.2), but just recently started working on an app that needs to support multiple instances. E.g., the p

5条回答
  •  悲哀的现实
    2020-12-30 07:26

    The current_app variable is something you have to set yourself to something you like.

    Personally I'd recommend setting it to something like __name__.rsplit('.', 1)[0] so you get spam in spam/views.py.

    But you can define it to be anything you like, as long as your app name is consistent with what you define in your urls file.

提交回复
热议问题