Hi,
So I am using django 2.2.7 and following videos on youtube for learning Python Django.
My models.py file consists of a class for an Album object and a class for a Song object.
Inside this models.py file I have declared a function called get_absolute_url (please see the attached image models).
I want to allow the user of the website to be able to create a new Album object by filling in a form and then clicking submit. Therefore, I have created this form - its consists of two separate codes shown in album_form.jpg and form-template.jpg. They just enter values for for input fields album, artist, genre and logo. Then they click submit. I have attached an image of what the actual forum looks like on the web.
However, the issue I am having is that clicking submit does not seem to do anything at all. The least I was expecting was to be redirected to the url written inside the get_absolute_url function which is "music:detail" passing in the primary key that gets created when new object of Album is made. The "music:detail" is the name for the url and it is path('<int:pk>/', views.DetailView.as_view(), name='detail')
Does anyone know why this is happening? Some people have mentioned changing the action in form code but the tutorials I am following leave the action as blank i.e. action="" so that's why I left it as blank. Not sure if that is the issue?
Thanks,
So I am using django 2.2.7 and following videos on youtube for learning Python Django.
My models.py file consists of a class for an Album object and a class for a Song object.
Inside this models.py file I have declared a function called get_absolute_url (please see the attached image models).
I want to allow the user of the website to be able to create a new Album object by filling in a form and then clicking submit. Therefore, I have created this form - its consists of two separate codes shown in album_form.jpg and form-template.jpg. They just enter values for for input fields album, artist, genre and logo. Then they click submit. I have attached an image of what the actual forum looks like on the web.
However, the issue I am having is that clicking submit does not seem to do anything at all. The least I was expecting was to be redirected to the url written inside the get_absolute_url function which is "music:detail" passing in the primary key that gets created when new object of Album is made. The "music:detail" is the name for the url and it is path('<int:pk>/', views.DetailView.as_view(), name='detail')
Does anyone know why this is happening? Some people have mentioned changing the action in form code but the tutorials I am following leave the action as blank i.e. action="" so that's why I left it as blank. Not sure if that is the issue?
Thanks,