python - Django project - two app's two views in one url how to solve -


in django project have created 1 app log-in users. , app sign-up user. in .html template both sign-up , log-in function given on same page means in 1 url 1 .html file . show means have use 2 apps 2 different views in 1 url 1 .html file . how possible
cannot combine them in 1 app cause both of app has lots of other related functionalities also. should make different app according html page/ or 1 url 1 app method ?

you can not have 2 views 1 url.

but can make view , link url , in view decide function should used.

if have both login , signup form in 1 page can use 2 different forms , decide function should used.

this solution you:

1 - make single view url

2 - make 2 forms, 1 signup , 1 login.

3 - in template add name submit buttons , give them value based on form:

# login form <form>     # form fields     <button type="submit" name="button-name" value="login"> </form>  # signup form <form>     # form fields     <button type="submit" name="button-name" value="signup"> </form> 

now in view can decide function should used:

if request.post.get('button-name') , request.post.get('button-name') == "signup":     # signup user elif request.post.get('button-name') , request.post.get('button-name') == "login":     # login user 

i don't recommend call view in view because views should render template or ... recommend make 2 different functions login , signup can anywhere , call them , decide want based on return.

or can here.


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -