Hello, there are two models about the club and the member, I don’t know how to register. I can get the member’s Id number with request.user, but I cannot do the same for the club.
Models.py
Views.py
I may be a little amateurish. I am open to more practical and professional methods that you suggest.
How would you know which club the person is going to join?
Have they selected one from a form?
Side note: What you have created here is that ClubJoin is a “through” table for a many-to-many relationship between User and StudentClub. You could, in addition to this model definition, add a ManyToMany field in StudentClub identifying ClubJoin as the through
attribute for that relationship. It may provide benefits to you in the future.
I am using a button. I am redirecting button student_to_join_club. What I want to do is to automatically add club and member information when clicked.
I can get member information with request.user but not for club.
Do I need to request club id in the button like this? {% url ‘home:clubjoin’ id=club.id %}.
In this way, when I request club id, it works without any problems. But what I want is to make this process automatic
Yes, but which club? How is your view going to know which club to associate a specific user with?
That depends - there’s not enough information here to answer that.
I don’t know what you mean by this.