Re: How to extract a number from a url

2018-12-06 Thread Sourajit Mohanty
But how do I access the pk_url_kwarg(ie. the album_id) in the respective model?? I have a model class Song and I need 2 access the album_id in the get_absolute_url() On Thu 6 Dec, 2018, 6:32 PM Jason you have to set up the URL with it in your urls.py to map to the view > method. > > what that doe

Re: How to extract a number from a url

2018-12-06 Thread Jason
you have to set up the URL with it in your urls.py to map to the view method. what that does is tells django you want the regex in the url path you defined to be the parameter you send to the view method pk_url_kwarg = 'pk' set that in your view, and ensure the url definition you have maps t

Re: How to extract a number from a url

2018-12-05 Thread Sourajit Mohanty
I am using Model forms.. class CreateSong(CreateView) model=Song fields=['song_title'] So this class is gonna call the model Song class..how can i pass the album_id?? On Thu 6 Dec, 2018, 9:13 AM Pankaj Kumar Try using regular expression (?P[0-9]+) > similar to this: > > url(r'^m

Re: How to extract a number from a url

2018-12-05 Thread Pankaj Kumar
Try using regular expression (?P[0-9]+) similar to this: url(r'^music/(?P[0-9]+)/newsongs$', views.your_view_function()) cheers! On 12/6/18, Sourajit Mohanty wrote: > I am working with Class based Views..so I dont think this is gonna work > > On Thu 6 Dec, 2018, 2:33 AM shiva kumar wrote: >

Re: How to extract a number from a url

2018-12-05 Thread Sourajit Mohanty
I am working with Class based Views..so I dont think this is gonna work On Thu 6 Dec, 2018, 2:33 AM shiva kumar Use > > in place of number > > An add extra parameter in views which u will relate this to > > On Thu 6 Dec, 2018 2:18 am Sourajit Mohanty >> I want to extract the number from this u

Re: How to extract a number from a url

2018-12-05 Thread shiva kumar
Use in place of number An add extra parameter in views which u will relate this to On Thu 6 Dec, 2018 2:18 am Sourajit Mohanty I want to extract the number from this url 'music/6/newsongs/' so that I > can use that number to redirect it to another page.. > How can I do that?? > > -- > You rec

How to extract a number from a url

2018-12-05 Thread Sourajit Mohanty
I want to extract the number from this url 'music/6/newsongs/' so that I can use that number to redirect it to another page.. How can I do that?? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving