Can't I specify two functions with the same url in djangourl?

Asked 2 years ago, Updated 2 years ago, 42 views

urlpatterns = [
    path('', views.index, name='index'),
    path('', views.birthday_check, name='birthday_check'),
]

Can't we assign two functions to one url in this way?

django

2022-09-21 18:18

1 Answers

So, do you want to congratulate the member who accessed the main screen of the homepage on his birthday that day? Then just include the logic of the index function with the logic of checking the member's birthday and printing additional congratulatory messages. I don't know if there's a reason why I shouldn't do that.

Because... To answer the question itself... It is impossible for one route to do two different actions until the method, and it is not a very recommended idea even if it is forced to do something.

Looking at the questions you posted before, it's a matter that you just have to do well in the arrangement of the members whose birthday is today, but I think you're getting farther away from the starting point. Why don't you upload more code and show us more about how the data is in the DB?


2022-09-21 18:18

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.