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:
>
>> 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 > wrote:
>>
>>> 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 emails from it, send
>>> an
>>> email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/8512424b-8a0e-40a2-92f0-2e9d4f8995a1%40googlegroups.com
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAMsYeuHeAbwr6SgozHM4wxkqMFiWhLnQc6ODy75FHm0qBs9O0Q%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMh8ciYOg36bQ%3DP%2BLvuuvoCpDaO7C1bMH2O8nPaP6YFeBeYk%3DA%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMAa5dOeDZYaujTXhOn%3DsGEU%3D_aDkgQ3mKrJyNEoBvbAB%3D9qhQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


RE: Best way to structure this Django project

2018-12-03 Thread Pankaj Kumar
Thats a valid workflow in my opinion. Many Django works take that approach.

But alternatively, if you want you can pass the product info as parameters
in the Payment app while redirecting and can have a model in the Payment
app to capture and integrate product and payment parameters together. That
way you can avoid importing the Product model but retaining the product
informations along with payment informations.

On 3 Dec 2018 9:50 p.m., "Matthew Pava"  wrote:

> I don't think there's a way around it, but that's okay.  I have
> dependencies between several apps in my project, and the apps help organize
> the project.
> If you don't want to necessarily hard-code the app model, you could pass
> in the model as an argument and use apps.get_model(app_name, model_name)
> inside the function.
>
> -Original Message-
> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com]
> On Behalf Of Simon Connah
> Sent: Sunday, December 2, 2018 5:31 PM
> To: django-users@googlegroups.com
> Subject: Best way to structure this Django project
>
> Hi,
>
> I have a bit of a problem with structuring a Django project. I have a
> UserProfile app which stores extra information about users using a
> OneToOneField to the Django auth user model.
>
> I have a products app which has two models relating to two types of
> products and finally I have a payments app which contains all the code
> needed to integrate with the Stripe payment processor.
>
> My problem is fairly simple. When someone buys a product I obviously
> want to take them to a payment page but if I carry on with my current
> structure that would require redirecting to a view in the payments app
> as it will contain code to work with the Stripe API but it would also
> require access to the product model(s) which would hard code a
> dependency between the payments app and the products app.
>
> Is there anyway I can rearrange my project so I can avoid this hard
> coded dependency?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/12030aa1-69ad-dc7f-c3be-72e8e2f9b50e%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/1b12d5105a8c457e8fc7b1f45312141c%40iss2.ISS.LOCAL.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMAa5dNNmcJ%2Bz2HR%3DFuNJiFwP1T-dv5OTr3gJNx5-9v7NiwgWg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.