简体   繁体   中英

How to forward requests to apps from one project to another in django

I have a Django project A with 2 apps currently. One is a fruits app and another an auth app. When a user logs in to http://myip/auth/login , a log in message is displayed based on a successful or an unsuccessful attempt. The user can then access http://myip/auth/fruits which displays all fruits in the system.

There is another standalone Django project B that was written by another author which deals with vegetables. I want my project to act like a proxy for the vegetables project which has many more apps. When a user requests http://myip/auth/vegetables , I want my app to forward the request to the vegetable app in the other project.

Please note that these are two different projects and they have two different settings files. Project A connects to 2 databases and Project B to one. They are all different.

Please tell me how this can be achieved.

Thanks in advance.

if you are only interested in redirection you can use the built in redirect function which wraps HttpResponseRedirect

from django.shortcuts import redirect
def my_view(request):
    ...
    return redirect('http://myip/auth/vegetables')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM