Re: regarding django hosting

2019-01-25 Thread tribhuvan kishor
can you please help me with some elaboration because i am completely
beginner in hosting i am completely unaware with nginx and gunicor
n

On Sat, Jan 26, 2019 at 1:09 PM Anirudh Jain 
wrote:

> AWS EC2 is good with nginx and gunicorn
>
> On Sat, 26 Jan 2019, 13:04 tribhuvan kishor  wrote:
>
>>
>> can you guys please help which is best hosting solution for django
>> --
>> regards
>> Tribhuvan Kishor Bhaskar
>>
>> --
>> 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/CACiphSWHbayZp1sFM3i%3DayNV9nqB4v0UuO6ZojQvxDa-9eQa4A%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/CAC3mK7ffrtjH_eGFepRev5fE5hq7f631R1ieOyWrm%3DJyQ8UdXA%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
regards
Tribhuvan Kishor Bhaskar

-- 
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/CACiphSXRrsaB%3D7NC33Eq9yzZaKramfEFvPhzx5-0WOFm0Vucdg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: regarding django hosting

2019-01-25 Thread Anirudh Jain
AWS EC2 is good with nginx and gunicorn

On Sat, 26 Jan 2019, 13:04 tribhuvan kishor 
> can you guys please help which is best hosting solution for django
> --
> regards
> Tribhuvan Kishor Bhaskar
>
> --
> 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/CACiphSWHbayZp1sFM3i%3DayNV9nqB4v0UuO6ZojQvxDa-9eQa4A%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/CAC3mK7ffrtjH_eGFepRev5fE5hq7f631R1ieOyWrm%3DJyQ8UdXA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


regarding django hosting

2019-01-25 Thread tribhuvan kishor
can you guys please help which is best hosting solution for django
-- 
regards
Tribhuvan Kishor Bhaskar

-- 
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/CACiphSWHbayZp1sFM3i%3DayNV9nqB4v0UuO6ZojQvxDa-9eQa4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Admin form_url breakout problem

2019-01-25 Thread Mike Dewhirst

Matthew

I think I'll back everything out and start again. There must be a basic 
blunder somewhere.


Just talking it through, I can definitely launch payment_view from the 
Admin when all the ducks are in a line. That view populates the hidden 
..._id fields and Stripe API fields in the form then calls the Stripe 
API which initiates the  Stripe javascript in the Payment template which 
resubmits the request with POST direct to Stripe so it can gather the 
card detail and send back the json containing the token which proves the 
card worked. At that point payment is made and my payment_view has lost 
all the context because Stripe made the request not Django. payment_view 
detects the Stripe response and must reconstruct the model instances 
from the data pre-placed in the hidden form fields. Once the instances 
are retrieved that payment_view code updates the subscription record, 
creates a receipt record , assembles a message for the success_view and 
sends an email to the user.


I am having trouble understanding the correct way to launch payment_view 
so that Admin doesn't get confused wanting to add payment/ to the url 
and thus keeping it all within the Admin.


Regarding your comment on using reverse to derive the link, I agree. I 
was just being somewhat paranoid and skipping the reverse code which I 
haven't taken the time to study. I will.


Thanks again

Mike


On 26/01/2019 1:59 am, Matthew Pava wrote:


Based on the error message, it looks like you’re trying to call 
reverse(‘admin’) somewhere, but that’s not in the code you shared.  
Actually, you probably want to use a reverse call when populating 
content[‘link’].


*From:*django-users@googlegroups.com 
[mailto:django-users@googlegroups.com] *On Behalf Of *Mike Dewhirst

*Sent:* Friday, January 25, 2019 3:35 AM
*To:* django-users@googlegroups.com
*Subject:* Re: Admin form_url breakout problem

On 25/01/2019 2:40 am, Matthew Pava wrote:

Hi Mike,

I'm not really seeing why this is throwing errors at you.  It seems like 
you've done everything right.  Could you provide the code (or the relevant 
parts) for the Substance Admin form?

Thanks!


Matthew

I'm still in trouble and including some code. I'm not being precious 
about it just hoping not to overwhelm you. Please ask for the next 
instalment ...


class SubstanceAdmin(admin.ModelAdmin):

    def subscribe(self, sm2mi, fee_type, fullyear=False):
    """
    sm2mi is the substance<-ingredient m2m through record
    fee_type determines the subscription fee amount
    fullyear=False means calculate the fee pro-rata to 30 September

    We don't need a request here so this can be imported from 
elsewhere.
    Only called if a fee is payable. Only returns a subscription 
if no token or

        fullyear == True meaning a subscription renewal is due
    """
    subscription, new = Subscription.objects.get_or_create(
    licensee=sm2mi.substance.division.company,
    ingredient=sm2mi.ingredient,
    fee_type=fee_type,
    )
    if not subscription.token or fullyear:
    return subscription

    def change_view(self, request, object_id, form_url='', 
extra_context=None):

    """
    For the billing system we want to include all the context data 
so the

    change_form populates itself properly. See collect_content
    self = SubstanceAdmin
    request = wsgi request object
    object_id = substance
    form_url = no idea!
    extra_context = no_idea
    """
    sm2mis = 
Substance_Ingredients.objects.filter(substance_id=object_id)

    for sm2mi in sm2mis:
    payable, fee_type = sm2mi.fee_payable()  # eg., True, 
PAID_DATA

    if payable:
    subscription = self.subscribe(sm2mi, fee_type)
    if subscription:    # we need to collect money for the 
owner

    self.change_form_template = 'payment.html'
    content = collect_content(
    sm2mi,
    subscription,
    )
    return payment_view(
    request,
    sm2mi,
    subscription,
    content=content
    )

    return super(SubstanceAdmin, self).change_view(
    request, object_id, form_url, extra_context=extra_context,
    )

Here is the payment form ... which is further down in admin.py

    class IngredientsInline(admin.StackedInline):

    class PaymentForm(admin.StackedInline.form):
    sm2mi_id = forms.CharField(widget=forms.HiddenInput, 
required=False)
    ingredient_id = forms.CharField(widget=forms.HiddenInput, 
required=False)
    subscription_id = 
forms.CharField(widget=forms.HiddenInput, required=False)
    licensee_id = forms.CharField(widget=forms.HiddenInput, 
required=False)


    stripeToken = 

Re: Job Request

2019-01-25 Thread Khushal Kumar
I'll be happy to help.

On Fri, 25 Jan 2019, 11:49 pm Roshan Shah  I do have a project that I want to get built on. Can I get some help from
> people who are starting in Django to work on it?
>
> Roshan
> Founder Cogdina Inc
> http://www.cogdina.com
>
> On Fri, Jan 25, 2019 at 11:47 AM Okware Aldo 
> wrote:
>
>> I am looking for projects I can contribute on. so if you have a project I
>> can contribute on. I am happy to help 2 hours of code in a week for free.
>>
>> On Fri, Jan 25, 2019 at 3:51 PM Nitin Kalmaste 
>> wrote:
>>
>>> Where can I find Live Projects to work on So that I can Improve My
>>> python Skills
>>>
>>> On Thursday, January 24, 2019 at 9:05:39 PM UTC+5:30, Motaz Hejaze wrote:

 Hi all ,

 Is there any remote job regarding Django , i am a beginner to mid-level
 in Django ..

 Thanks all ..

>>> --
>>> 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/abc65682-9f58-4898-b555-88e8752c0957%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/CAMEZma9T34QG-q%2B5VGqgNW6kuQNaYK7sJRyjt7WEO86LfwCZgQ%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> --
>
> Roshan Shah / Sr. IT Consultant
> techieros...@gmail.com / (519) 496-8860
>
> This e-mail message may contain confidential or legally privileged
> information and is intended only for the use of the intended recipient(s).
> Any unauthorized disclosure, dissemination, distribution, copying or the
> taking of any action in reliance on the information herein is prohibited.
> E-mails are not secure and cannot be guaranteed to be error free as they
> can be intercepted, amended, or contain viruses. Anyone who communicates
> with me by e-mail is deemed to have accepted these risks.
>
> --
> 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/CALX19NjanqdvHy1YXDta4PGXAJbwDNcrZaAtrLuMeuMXLqtJPg%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/CAKOftJjTmHHWgxGEqpGwCtURQPaQsCzTxYOe_4JVU0EgZYwPTw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Job Request

2019-01-25 Thread Nitin Kalmaste
Yes you can start it on GitHub we will definitely contribute

On Fri, Jan 25, 2019, 11:50 PM Roshan Shah  I do have a project that I want to get built on. Can I get some help from
> people who are starting in Django to work on it?
>
> Roshan
> Founder Cogdina Inc
> http://www.cogdina.com
>
> On Fri, Jan 25, 2019 at 11:47 AM Okware Aldo 
> wrote:
>
>> I am looking for projects I can contribute on. so if you have a project I
>> can contribute on. I am happy to help 2 hours of code in a week for free.
>>
>> On Fri, Jan 25, 2019 at 3:51 PM Nitin Kalmaste 
>> wrote:
>>
>>> Where can I find Live Projects to work on So that I can Improve My
>>> python Skills
>>>
>>> On Thursday, January 24, 2019 at 9:05:39 PM UTC+5:30, Motaz Hejaze wrote:

 Hi all ,

 Is there any remote job regarding Django , i am a beginner to mid-level
 in Django ..

 Thanks all ..

>>> --
>>> 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/abc65682-9f58-4898-b555-88e8752c0957%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/CAMEZma9T34QG-q%2B5VGqgNW6kuQNaYK7sJRyjt7WEO86LfwCZgQ%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> --
>
> Roshan Shah / Sr. IT Consultant
> techieros...@gmail.com / (519) 496-8860
>
> This e-mail message may contain confidential or legally privileged
> information and is intended only for the use of the intended recipient(s).
> Any unauthorized disclosure, dissemination, distribution, copying or the
> taking of any action in reliance on the information herein is prohibited.
> E-mails are not secure and cannot be guaranteed to be error free as they
> can be intercepted, amended, or contain viruses. Anyone who communicates
> with me by e-mail is deemed to have accepted these risks.
>
> --
> 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/CALX19NjanqdvHy1YXDta4PGXAJbwDNcrZaAtrLuMeuMXLqtJPg%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/CAKroR%2B1V7A%3Dc--ehycHya5xdLKg%3DTJD0SyjC7VdWdXAvpc20Ug%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how can I reference a field from one model to another model

2019-01-25 Thread carlos
Thank Mike Dewhirst is working well

Cheers

On Fri, Jan 25, 2019 at 6:49 AM 'Amitesh Sahay' via Django users <
django-users@googlegroups.com> wrote:

> hi,
>
> All the above should work. If you are working on django REST, then you can
> use ModelSerializer helper function. This will automatically sync with the
> table fields, and if there are any foreign key and primary key. They would
> be mapped automatically.
>
> Regards,
> Amitesh Sahay
> *91-750 797 8619*
>
>
> On Friday, 25 January, 2019, 5:44:04 PM IST, Anirudh Jain <
> anirudhajain@gmail.com> wrote:
>
>
> You can do this easily by creating creating an object of that model from
> which you want to get the value or input a value by using
> 'get_object_or_404' or 'get_list_or_404' by importing from
> django.shortucts. Reas about these two functions and difference between
> them in documentation.
>
> Use them, for eg :-
>  derive = get_object_or_404(ModelChild1, ModelDad=request.user) #object
> created of model ModelChild1
>
> access = derive.number #will give the value of number that has been input
> by user
>
> On Fri, 25 Jan 2019, 17:29 NAveeN Kumar Reddy <
> knaveenkumarredd...@gmail.com wrote:
>
> You can use this where you want you to link tables with foreign key
>
> models.ForeignKey(Model_Name,on_delete=models.CASCADE)
>
> That's it  both tables will be in relation after migration of models into
> database
>
>
>
> On Fri, Jan 25, 2019 at 12:20 PM Mike Dewhirst 
> wrote:
>
> On 24/01/2019 5:28 pm, carlos wrote:
> > Hello,
> > I do not know if I'm asking the question correctly, but I need to call
> > a field of one model in another model
> > example:
> > class ModelDad(models.Model):
> > name = blablabla
> >
> > class ModelChild1():
> >fk(ModelDad)
> >number = models.IntegerField()
> >
> > class ModelChild2():
> >   fk(ModelDad)
> >   another_number = models.IntegerField()
> >
> >def make_proces(self):
> >   return self.another_number * ModelChild1.number #this is my
> question
> >
> > how can I send a call number within the function (make_proces ) of
> > ModelChild2
>
> You need a mechanism to find ModelChild1 and the Django ORM provides
> Queries for exactly that.
>
> There is a default model manager called 'objects' which you can use to
> find instances of models. By that I mean you can pinpoint a row in the
> database table which that model represents. For example ... (but to make
> it clearer I'll adjust your models above slightly)
>
> class ModelDad(models.Model):
>  name = blablabla
>
> class ModelChild1(models.Model):
> dad = models.ForeignKey(ModelDad)
> number = models.IntegerField()
>
> class ModelChild2(models.Model):
> dad = models.ForeignKey(ModelDad)
> another_number = models.IntegerField()
>
> def make_proces(self):
>  child1 = ModelChild1.objects.get(dad=self.dad)
>  return self.another_number *child1.number
>
> Visit Django documentation https://docs.djangoproject.com and scroll
> down past "First steps" to  "The model layer" and click on a link in the
> "Quersets" line. The answers will be in there.
>
> >
> > is posible
> >
> >
> >
> > --
> > att.
> > Carlos Rocha
> > --
> > 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/CAM-7rO125r3pox%3D137GOfmjnmFaf3cekaNj-j%2B9A0Cwc%3DEM0Fg%40mail.gmail.com
> > <
> https://groups.google.com/d/msgid/django-users/CAM-7rO125r3pox%3D137GOfmjnmFaf3cekaNj-j%2B9A0Cwc%3DEM0Fg%40mail.gmail.com?utm_medium=email_source=footer
> >.
> > 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/522c40aa-2736-3f57-b23b-9c283c9a59e0%40dewhirst.com.au
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> Naveen Kumar  Reddy
>
> --
> 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.
> 

Re: Job Request

2019-01-25 Thread shinan nazar
can you hire me??

On Fri, Jan 25, 2019 at 11:50 PM Roshan Shah  wrote:

> I do have a project that I want to get built on. Can I get some help from
> people who are starting in Django to work on it?
>
> Roshan
> Founder Cogdina Inc
> http://www.cogdina.com
>
> On Fri, Jan 25, 2019 at 11:47 AM Okware Aldo 
> wrote:
>
>> I am looking for projects I can contribute on. so if you have a project I
>> can contribute on. I am happy to help 2 hours of code in a week for free.
>>
>> On Fri, Jan 25, 2019 at 3:51 PM Nitin Kalmaste 
>> wrote:
>>
>>> Where can I find Live Projects to work on So that I can Improve My
>>> python Skills
>>>
>>> On Thursday, January 24, 2019 at 9:05:39 PM UTC+5:30, Motaz Hejaze wrote:

 Hi all ,

 Is there any remote job regarding Django , i am a beginner to mid-level
 in Django ..

 Thanks all ..

>>> --
>>> 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/abc65682-9f58-4898-b555-88e8752c0957%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/CAMEZma9T34QG-q%2B5VGqgNW6kuQNaYK7sJRyjt7WEO86LfwCZgQ%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> --
>
> Roshan Shah / Sr. IT Consultant
> techieros...@gmail.com / (519) 496-8860
>
> This e-mail message may contain confidential or legally privileged
> information and is intended only for the use of the intended recipient(s).
> Any unauthorized disclosure, dissemination, distribution, copying or the
> taking of any action in reliance on the information herein is prohibited.
> E-mails are not secure and cannot be guaranteed to be error free as they
> can be intercepted, amended, or contain viruses. Anyone who communicates
> with me by e-mail is deemed to have accepted these risks.
>
> --
> 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/CALX19NjanqdvHy1YXDta4PGXAJbwDNcrZaAtrLuMeuMXLqtJPg%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/CAGcdbGnHT6YKf2BSzqu-R2ShOEc_-xSTkYwWMkdyr1Mov3DAFw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Job Request

2019-01-25 Thread Nitin Kumar
@Roshan
I am interested.

On Fri, Jan 25, 2019 at 11:49 PM Roshan Shah  wrote:

> I do have a project that I want to get built on. Can I get some help from
> people who are starting in Django to work on it?
>
> Roshan
> Founder Cogdina Inc
> http://www.cogdina.com
>
> On Fri, Jan 25, 2019 at 11:47 AM Okware Aldo 
> wrote:
>
>> I am looking for projects I can contribute on. so if you have a project I
>> can contribute on. I am happy to help 2 hours of code in a week for free.
>>
>> On Fri, Jan 25, 2019 at 3:51 PM Nitin Kalmaste 
>> wrote:
>>
>>> Where can I find Live Projects to work on So that I can Improve My
>>> python Skills
>>>
>>> On Thursday, January 24, 2019 at 9:05:39 PM UTC+5:30, Motaz Hejaze wrote:

 Hi all ,

 Is there any remote job regarding Django , i am a beginner to mid-level
 in Django ..

 Thanks all ..

>>> --
>>> 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/abc65682-9f58-4898-b555-88e8752c0957%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/CAMEZma9T34QG-q%2B5VGqgNW6kuQNaYK7sJRyjt7WEO86LfwCZgQ%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> --
>
> Roshan Shah / Sr. IT Consultant
> techieros...@gmail.com / (519) 496-8860
>
> This e-mail message may contain confidential or legally privileged
> information and is intended only for the use of the intended recipient(s).
> Any unauthorized disclosure, dissemination, distribution, copying or the
> taking of any action in reliance on the information herein is prohibited.
> E-mails are not secure and cannot be guaranteed to be error free as they
> can be intercepted, amended, or contain viruses. Anyone who communicates
> with me by e-mail is deemed to have accepted these risks.
>
> --
> 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/CALX19NjanqdvHy1YXDta4PGXAJbwDNcrZaAtrLuMeuMXLqtJPg%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/CAKzNicF4-gDmjAOSP6EcY4B%2BtiN0x-HQiA-8z-AtsowZj2k5kg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Access to the last object of model inside model itself

2019-01-25 Thread Jason
This really should be in a custom model manager, and not the model itself.

-- 
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/26336e5e-a6be-4811-b2ed-3f4667c4bf8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Job Request

2019-01-25 Thread Roshan Shah
I do have a project that I want to get built on. Can I get some help from
people who are starting in Django to work on it?

Roshan
Founder Cogdina Inc
http://www.cogdina.com

On Fri, Jan 25, 2019 at 11:47 AM Okware Aldo  wrote:

> I am looking for projects I can contribute on. so if you have a project I
> can contribute on. I am happy to help 2 hours of code in a week for free.
>
> On Fri, Jan 25, 2019 at 3:51 PM Nitin Kalmaste 
> wrote:
>
>> Where can I find Live Projects to work on So that I can Improve My python
>> Skills
>>
>> On Thursday, January 24, 2019 at 9:05:39 PM UTC+5:30, Motaz Hejaze wrote:
>>>
>>> Hi all ,
>>>
>>> Is there any remote job regarding Django , i am a beginner to mid-level
>>> in Django ..
>>>
>>> Thanks all ..
>>>
>> --
>> 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/abc65682-9f58-4898-b555-88e8752c0957%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/CAMEZma9T34QG-q%2B5VGqgNW6kuQNaYK7sJRyjt7WEO86LfwCZgQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
-- 

Roshan Shah / Sr. IT Consultant
techieros...@gmail.com / (519) 496-8860

This e-mail message may contain confidential or legally privileged
information and is intended only for the use of the intended recipient(s).
Any unauthorized disclosure, dissemination, distribution, copying or the
taking of any action in reliance on the information herein is prohibited.
E-mails are not secure and cannot be guaranteed to be error free as they
can be intercepted, amended, or contain viruses. Anyone who communicates
with me by e-mail is deemed to have accepted these risks.

-- 
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/CALX19NjanqdvHy1YXDta4PGXAJbwDNcrZaAtrLuMeuMXLqtJPg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Access to the last object of model inside model itself

2019-01-25 Thread Mohammad Etemaddar
Hello
I need the last object of model inside it.
for example I have:
class Field(models.Model):
category = models.ForeignKey(Category, related_name='fields', on_delete=
models.CASCADE,
default = get_last_factory_field_category())

def get_last_factory_field_category():
return Field.objects.last().category

In this definition, will get not defined error. because the function is 
defined after model.

preivously, I used *lambda* to get access to the last category. But 
*makemigrations 
*did not work while using lambda.

The clear problem is getting access to the last object of model inside of 
it.

-- 
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/7de3335f-4afe-4f4b-ac1d-067e326cad1b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Job Request

2019-01-25 Thread Okware Aldo
I am looking for projects I can contribute on. so if you have a project I
can contribute on. I am happy to help 2 hours of code in a week for free.

On Fri, Jan 25, 2019 at 3:51 PM Nitin Kalmaste 
wrote:

> Where can I find Live Projects to work on So that I can Improve My python
> Skills
>
> On Thursday, January 24, 2019 at 9:05:39 PM UTC+5:30, Motaz Hejaze wrote:
>>
>> Hi all ,
>>
>> Is there any remote job regarding Django , i am a beginner to mid-level
>> in Django ..
>>
>> Thanks all ..
>>
> --
> 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/abc65682-9f58-4898-b555-88e8752c0957%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/CAMEZma9T34QG-q%2B5VGqgNW6kuQNaYK7sJRyjt7WEO86LfwCZgQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Queryset - exclude one data over two

2019-01-25 Thread C. Kirby
You can use islice from itertools in this way 

islice('ABCDEFG', 0, None, 2) --> A C E G

In your case you would replace 
chart = temp_db.objects.filter(date__gte=beg_range)

with
chart = [x for x in islice(temp_db.objects.filter(date__gte=beg_range), 0, 
None, 2)]


That will give you every other instance from your query set starting with the 
first


On Friday, January 25, 2019 at 9:02:33 AM UTC-5, Stéphane Manguette wrote:
>
> Hello;
>
> I've a DBB with a lot of values which are recorded every 2 minutes (this 
> cannot be changed).
>
> I'm trying to get all values recorded over the last 24h
>
> def dashboard(request):
> version = version_global
> end_range = datetime.now()
> beg_range = end_range - timedelta(days=1)
> chart = temp_db.objects.filter(date__gte=beg_range)
> last_entry = chart.latest('date')
> return render(request, 'index.html', locals())
>
> The following code works perfectly. The goal is to populate a Chart.js in 
> index.html. Unfortunately, there is a lot to transmit making it long to 
> charge. Since my chart is not mainly meant to show trends; I could skip one 
> data over two. Is there a function do do so? 
>
> Thanks a lot,
>
> Stéphane
>
>

-- 
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/b62c45f4-7143-4e60-b9eb-7cf65902a25d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Charfield variable length

2019-01-25 Thread C. Kirby
https://docs.djangoproject.com/en/2.1/ref/models/fields/#binaryfield


-- 
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/eb1372b6-0181-4703-87d9-34cafd83bfdf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Noob question about model and view

2019-01-25 Thread Arturo Fernandez
The new form that I'm trying to make is the one with the variable: form, I 
forgot to mention that

On Friday, January 25, 2019 at 10:08:03 AM UTC-5, Arturo Fernandez wrote:
>
> Hello, I'm trying to make a simple form so I can dissect it and learn but 
> from the guide that I'm reading, they are doing it differently from what 
> I'm trying to accomplish. This are the two links:
>
> model.py: https://tutorial.djangogirls.org/en/django_models/
> view.py, forms.py: https://tutorial.djangogirls.org/en/django_forms/ 
>
> Just for the sake of learning I copied pasted those codes, now... she's 
> trying to create multiple pages in that tutorial, one for create and one 
> for edit but I only want to have 1 page which I have created, it's my 
> profile page, and there I want to edit it whether it's empty or not and 
> save it.
>
> If I do it like this in my view.py (which is where the error is happening):
>
>
> @login_required
> def profile(request):
> if request.method == 'POST':
> u_Passform = PasswordChangeForm(request.user, request.POST)
> u_form = UserUpdateForm(request.POST, instance=request.user)
> p_form = ProfileUpdateForm(request.POST,
> request.FILES,
> instance=request.user.profile)
>
>
> form = PostForm(request.POST, instance=post)
>
> if u_form.is_valid() and p_form.is_valid() and u_Passform.is_valid() and 
> form.is_valid():
> u_Passform.save()
> u_form.save()
> p_form.save()
>
> post = form.save(commit=False)
> post.author = request.user
> post.save()
>
> update_session_auth_hash(request, u_Passform)
> messages.success(request, f'Your account has been updated!')
>
> return redirect('profile')
>
> else:
> form = PostForm(instance=post)
> u_Passform = PasswordChangeForm(request.user)
> u_form = UserUpdateForm(instance=request.user)
> p_form = ProfileUpdateForm(instance=request.user.profile)
>
> context = {
> 'form': form,
> 'user_AddressForm': AddressForm,
> 'u_Passform': u_Passform,
> 'u_form': u_form,
> 'p_form': p_form
> }
>
> return render(request, 'users/profile.html', context)
>
>
> it says: UnboundLocalError: local variable 'post' referenced before 
> assignment
>
> the error I think that is basically on the form declaration right? how can 
> I get the data from the form? I created an admin section for it and I see 
> that the form data was saved there, but how can I display it on the view? 
> Note: the profile.html works fine, it's just the view.py the one with the 
> problem I think.
>
> Thanks guys
>
>
>
>

-- 
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/c2258e02-798d-4778-84d3-db8686712506%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Noob question about model and view

2019-01-25 Thread Arturo Fernandez
Hello, I'm trying to make a simple form so I can dissect it and learn but 
from the guide that I'm reading, they are doing it differently from what 
I'm trying to accomplish. This are the two links:

model.py: https://tutorial.djangogirls.org/en/django_models/
view.py, forms.py: https://tutorial.djangogirls.org/en/django_forms/ 

Just for the sake of learning I copied pasted those codes, now... she's 
trying to create multiple pages in that tutorial, one for create and one 
for edit but I only want to have 1 page which I have created, it's my 
profile page, and there I want to edit it whether it's empty or not and 
save it.

If I do it like this in my view.py (which is where the error is happening):


@login_required
def profile(request):
if request.method == 'POST':
u_Passform = PasswordChangeForm(request.user, request.POST)
u_form = UserUpdateForm(request.POST, instance=request.user)
p_form = ProfileUpdateForm(request.POST,
request.FILES,
instance=request.user.profile)


form = PostForm(request.POST, instance=post)

if u_form.is_valid() and p_form.is_valid() and u_Passform.is_valid() and 
form.is_valid():
u_Passform.save()
u_form.save()
p_form.save()

post = form.save(commit=False)
post.author = request.user
post.save()

update_session_auth_hash(request, u_Passform)
messages.success(request, f'Your account has been updated!')

return redirect('profile')

else:
form = PostForm(instance=post)
u_Passform = PasswordChangeForm(request.user)
u_form = UserUpdateForm(instance=request.user)
p_form = ProfileUpdateForm(instance=request.user.profile)

context = {
'form': form,
'user_AddressForm': AddressForm,
'u_Passform': u_Passform,
'u_form': u_form,
'p_form': p_form
}

return render(request, 'users/profile.html', context)


it says: UnboundLocalError: local variable 'post' referenced before 
assignment

the error I think that is basically on the form declaration right? how can 
I get the data from the form? I created an admin section for it and I see 
that the form data was saved there, but how can I display it on the view? 
Note: the profile.html works fine, it's just the view.py the one with the 
problem I think.

Thanks guys



-- 
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/1cafc729-e3f2-4833-9f28-f31d208233db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: Admin form_url breakout problem

2019-01-25 Thread Matthew Pava
Based on the error message, it looks like you’re trying to call 
reverse(‘admin’) somewhere, but that’s not in the code you shared.  Actually, 
you probably want to use a reverse call when populating content[‘link’].


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Mike Dewhirst
Sent: Friday, January 25, 2019 3:35 AM
To: django-users@googlegroups.com
Subject: Re: Admin form_url breakout problem

On 25/01/2019 2:40 am, Matthew Pava wrote:

Hi Mike,

I'm not really seeing why this is throwing errors at you.  It seems like you've 
done everything right.  Could you provide the code (or the relevant parts) for 
the Substance Admin form?

Thanks!

Matthew

I'm still in trouble and including some code. I'm not being precious about it 
just hoping not to overwhelm you. Please ask for the next instalment ...

class SubstanceAdmin(admin.ModelAdmin):

def subscribe(self, sm2mi, fee_type, fullyear=False):
"""
sm2mi is the substance<-ingredient m2m through record
fee_type determines the subscription fee amount
fullyear=False means calculate the fee pro-rata to 30 September

We don't need a request here so this can be imported from elsewhere.
Only called if a fee is payable. Only returns a subscription if no 
token or
fullyear == True meaning a subscription renewal is due
"""
subscription, new = Subscription.objects.get_or_create(
licensee=sm2mi.substance.division.company,
ingredient=sm2mi.ingredient,
fee_type=fee_type,
)
if not subscription.token or fullyear:
return subscription

def change_view(self, request, object_id, form_url='', extra_context=None):
"""
For the billing system we want to include all the context data so the
change_form populates itself properly. See collect_content
self = SubstanceAdmin
request = wsgi request object
object_id = substance
form_url = no idea!
extra_context = no_idea
"""
sm2mis = Substance_Ingredients.objects.filter(substance_id=object_id)
for sm2mi in sm2mis:
payable, fee_type = sm2mi.fee_payable()  # eg., True, PAID_DATA
if payable:
subscription = self.subscribe(sm2mi, fee_type)
if subscription:# we need to collect money for the owner
self.change_form_template = 'payment.html'
content = collect_content(
sm2mi,
subscription,
)
return payment_view(
request,
sm2mi,
subscription,
content=content
)

return super(SubstanceAdmin, self).change_view(
request, object_id, form_url, extra_context=extra_context,
)

Here is the payment form ... which is further down in admin.py

class IngredientsInline(admin.StackedInline):

class PaymentForm(admin.StackedInline.form):
sm2mi_id = forms.CharField(widget=forms.HiddenInput, required=False)
ingredient_id = forms.CharField(widget=forms.HiddenInput, 
required=False)
subscription_id = forms.CharField(widget=forms.HiddenInput, 
required=False)
licensee_id = forms.CharField(widget=forms.HiddenInput, 
required=False)

stripeToken = forms.CharField(widget=forms.HiddenInput, 
required=False)
stripeEmail = forms.CharField(widget=forms.HiddenInput, 
required=False)
stripeBillingName = forms.CharField(widget=forms.HiddenInput, 
required=False)
stripeBillingAddressLine1 = 
forms.CharField(widget=forms.HiddenInput, required=False)
stripeBillingAddressZip = forms.CharField(widget=forms.HiddenInput, 
required=False)
stripeBillingAddressState = 
forms.CharField(widget=forms.HiddenInput, required=False)
stripeBillingAddressCity = 
forms.CharField(widget=forms.HiddenInput, required=False)
stripeBillingAddressCountry = 
forms.CharField(widget=forms.HiddenInput, required=False)

form = PaymentForm

All of the above is working so far as launching the Stripe javascript popup and 
generating the receipt record correctly and so on but does not return to the 
admin nor render the success page.

The try/except block in payment_view() barfs as follows ...

content['sm2mi'] = sm2mi
content['receipt'] = receipt
content['subscription'] = subscription
content['message'] = mark_safe(display_message)
content['link'] = '/admin/substance/substance/{0}/change/'.format(
sm2mi.substance.id
)
# report success to the card payer
try:
return render(
template_name='success.html',
 

Re: validator not working in serializers.ModelSerializer

2019-01-25 Thread Andréas Kühne
If you want to change the output, you can override the fields that you
output in your serializer. That's what the fields are for?

I think it would be helpful if you provide more information because at
least I don't really understand your use-case.

The way I would do it is to change the fields and format them the way I
wanted them to be on a get request.

Regards,

Andréas


Den fre 25 jan. 2019 kl 02:47 skrev Maurya Allimuthu :

> Hi Andreas Kuhne,
>
> Thanks on the quick answer and great help. :-)
>
> Hi Andreas Kuhne/All,
>
> Is there a way or any kind of approach, I can use validators/anything in
> GET method to format/change the output of the data coming from database and
> before getting changed by serializer as stream of strings.
> Please let me know if any.
>
> Regards,
> Maurya
>
> On Thu, Jan 24, 2019 at 8:40 PM Andréas Kühne 
> wrote:
>
>> Hi,
>>
>> Validators are only called when you are updating something on the model -
>> a get request doesn't update anything and the validators will not be called
>> (there is no data sent to the server to validate). The validators will be
>> called on a POST, PUT or PATCH request.
>>
>> Regards,
>>
>> Andréas
>>
>>
>> Den tors 24 jan. 2019 kl 13:19 skrev Maurya Allimuthu <
>> catchmau...@gmail.com>:
>>
>>> Hi All,
>>>
>>> I use  serializers.ModelSerializer and viewset DetailViewset(APIView).
>>>
>>> The validators are not getting called on GET request of the viewset via
>>> URLS, but the GET request is working.
>>>
>>>
>>> def validate(self, attrs):
>>> if attrs.get('password') != attrs.get('confirm_password'):
>>> raise serializers.ValidationError("Those passwords don't match.")
>>> return attrs
>>>
>>> OR
>>>
>>>
>>> class Meta:
>>> model = *
>>> fields = ('***', )
>>> validators = [
>>> trigger_validator
>>> ]
>>>
>>>
>>> Thanks,
>>> Maurya
>>>
>>> --
>>> 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/ef2204c4-eed2-411c-a157-d8e1d1d63744%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/CAK4qSCcnMq6jGwToc8cw4EZ1Ksg5pA-1g5KawF26R2AwB%3DXaAw%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/CAEqjY81wfmvchoQcNvz0G2s7mR2vk2B17-KA1XSLiLv%3D4Cnk%2Bg%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/CAK4qSCdkwXA5FGcm64jhxJFF1e8%3D02OMtYvxBVdJhqbtiFZMbA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Queryset - exclude one data over two

2019-01-25 Thread Stéphane Manguette
Hello;

I've a DBB with a lot of values which are recorded every 2 minutes (this 
cannot be changed).

I'm trying to get all values recorded over the last 24h

def dashboard(request):
version = version_global
end_range = datetime.now()
beg_range = end_range - timedelta(days=1)
chart = temp_db.objects.filter(date__gte=beg_range)
last_entry = chart.latest('date')
return render(request, 'index.html', locals())

The following code works perfectly. The goal is to populate a Chart.js in 
index.html. Unfortunately, there is a lot to transmit making it long to 
charge. Since my chart is not mainly meant to show trends; I could skip one 
data over two. Is there a function do do so? 

Thanks a lot,

Stéphane

-- 
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/de79bb25-83fb-4600-940b-97ede086fe1c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


DjangoJSONEncoder does not aware of UUID

2019-01-25 Thread VladT
though it looks that it suggested to 

.
In source for DjangoJSONEncoder we see

class DjangoJSONEncoder(json.JSONEncoder):
...

elif isinstance(o, (decimal.Decimal, uuid.UUID, Promise)):
return str(o)

...

and it should handle only types that are passed through _value_from_field 

:

def _value_from_field(self, obj, field):
value = field.value_from_object(obj)
# Protected types (i.e., primitives like None, numbers, dates,
# and Decimals) are passed through as is. All other values are
# converted to string first.
return value if is_protected_type(value) else field.value_to_string(obj)


But in _PROTECTED_TYPES we don't see uuid.UUID included 
, 
so I can't hook and override UUID serialization.

Am I missing something or is it a bug?

-- 
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/b2a4219e-8706-46d7-8eca-ddb43ec7e559%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Looking for a Django Co-Founder.

2019-01-25 Thread 'Amitesh Sahay' via Django users
@Zack, 
  
I am available on Skype. You can search for me by amitesh.sa...@yahoo.com, or 
share your skype ID, I will add you. Probably we can discuss 10.30 am EST if 
you are available. Or, just let me know what is your preferred time. Morning or 
Evening. We can sync accordingly.




Regards,
Amitesh Sahay91-750 797 8619 

On Wednesday, 23 January, 2019, 10:10:09 AM IST, Zack Amaral 
 wrote:  
 
 @Amitesh

What's your email, I don't want to call internationally at the moment. I can 
call you on zoom, skype or whatsapp. Let me know what works for you.
Cheers,
Zack
On Tue, Jan 22, 2019 at 5:45 AM 'Amitesh Sahay' via Django users 
 wrote:

Hello Zack, 
I am based in Indian Standard Time zone. Please let me know about your time 
zone so that we could try to sync.


Regards,
Amitesh Sahay91-750 797 8619 

On Tuesday, 22 January, 2019, 5:56:27 PM IST, Zack Amaral 
 wrote:  
 
 Abhinav,

What’s your availability this week? I’d love to setup a call with you! 
Thanks for the reply, I look forward to hearing back from you!
Cheers,
Zack
On Tue, Jan 22, 2019 at 3:03 AM Abhinav tuteja  
wrote:

Hey i am a django developer and i we are a team of  2 people with 3 years of 
experience plz feel free to contactWhats app - 9540824924
On Tue, 22 Jan 2019 at 9:23 AM, Zack Amaral  wrote:

This message is eligible for Automatic Cleanup! (zack.j.ama...@gmail.com) Add 
cleanup rule | More info
 Django Community,
Hey you guys, I'm trying to build a platform as a service similar to twitch.tv, 
are their any django developers out there that would be interested in 
co-founding my company and helping me develop a MVP to get a seed round of 
funding? If you're interested I can send you a link to my business plan and 
UI/UX Design. 
Respectfully,
Zack AmaralWe Love Music, LLC

-- 
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/894392e9-e171-47fd-9f2b-17335c7b9189%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



-- 
You received this message because you are subscribed to a topic in the Google 
Groups "Django users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/django-users/dzCLmS7-7Dg/unsubscribe.
To unsubscribe from this group and all its topics, 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/CAEN0qXXUwTomg-jNRXqxOPJbx10XT_8X%3DVDe_v-TJMYf1hmXKA%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/CANG%3DrDmUV5dw8XcjnEUMWT4AUNTxQOEG9%3DrZUd9UGaTo%2BE8h7g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
  

-- 
You received this message because you are subscribed to a topic in the Google 
Groups "Django users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/django-users/dzCLmS7-7Dg/unsubscribe.
To unsubscribe from this group and all its topics, 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/1820766029.1680865.1548161080415%40mail.yahoo.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/CANG%3DrD%3DKih0%2B%3DQSaf%3DrTfDQbCt2b%3DzAo8a_wknFXQ1pyn08wpQ%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 

Re: Job Request

2019-01-25 Thread Nitin Kalmaste
Where can I find Live Projects to work on So that I can Improve My python 
Skills

On Thursday, January 24, 2019 at 9:05:39 PM UTC+5:30, Motaz Hejaze wrote:
>
> Hi all ,
>
> Is there any remote job regarding Django , i am a beginner to mid-level in 
> Django ..
>
> Thanks all ..
>

-- 
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/abc65682-9f58-4898-b555-88e8752c0957%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how can I reference a field from one model to another model

2019-01-25 Thread 'Amitesh Sahay' via Django users
hi, 
All the above should work. If you are working on django REST, then you can use 
ModelSerializer helper function. This will automatically sync with the table 
fields, and if there are any foreign key and primary key. They would be mapped 
automatically. 


Regards,
Amitesh Sahay91-750 797 8619 

On Friday, 25 January, 2019, 5:44:04 PM IST, Anirudh Jain 
 wrote:  
 
 You can do this easily by creating creating an object of that model from which 
you want to get the value or input a value by using 'get_object_or_404' or 
'get_list_or_404' by importing from django.shortucts. Reas about these two 
functions and difference between them in documentation.
Use them, for eg :- derive = get_object_or_404(ModelChild1, 
ModelDad=request.user) #object created of model ModelChild1
access = derive.number #will give the value of number that has been input by 
user
On Fri, 25 Jan 2019, 17:29 NAveeN Kumar Reddy  wrote:

On 24/01/2019 5:28 pm, carlos wrote:
> Hello,
> I do not know if I'm asking the question correctly, but I need to call 
> a field of one model in another model
> example:
> class ModelDad(models.Model):
>     name = blablabla
>
> class ModelChild1():
>    fk(ModelDad)
>    number = models.IntegerField()
>
> class ModelChild2():
>   fk(ModelDad)
>   another_number = models.IntegerField()
>
>    def make_proces(self):
>       return self.another_number * ModelChild1.number #this is my question
>
> how can I send a call number within the function (make_proces ) of 
> ModelChild2

You need a mechanism to find ModelChild1 and the Django ORM provides 
Queries for exactly that.

There is a default model manager called 'objects' which you can use to 
find instances of models. By that I mean you can pinpoint a row in the 
database table which that model represents. For example ... (but to make 
it clearer I'll adjust your models above slightly)

class ModelDad(models.Model):
     name = blablabla

class ModelChild1(models.Model):
    dad = models.ForeignKey(ModelDad)
    number = models.IntegerField()

class ModelChild2(models.Model):
    dad = models.ForeignKey(ModelDad)
    another_number = models.IntegerField()

    def make_proces(self):
 child1 = ModelChild1.objects.get(dad=self.dad)
 return self.another_number *child1.number

Visit Django documentation https://docs.djangoproject.com and scroll 
down past "First steps" to  "The model layer" and click on a link in the 
"Quersets" line. The answers will be in there.

>
> is posible
>
>
>
> -- 
> att.
> Carlos Rocha
> -- 
> 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/CAM-7rO125r3pox%3D137GOfmjnmFaf3cekaNj-j%2B9A0Cwc%3DEM0Fg%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/522c40aa-2736-3f57-b23b-9c283c9a59e0%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.



-- 
Naveen Kumar  Reddy

-- 
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/CA%2BC2Q82%2Bp47A92koj2%3Djq4aOvFetD%2BEuSikSCSbofTeSxWz-8Q%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 

Re: Job Request

2019-01-25 Thread Pyngineer Systems
Gain expertise and then try for a job. Beginners are not hired unless its a
training company's scam project my sincere advise

On Fri, Jan 25, 2019 at 8:53 AM amit pant  wrote:

> why all non IT and cs student be in IT and cs?
>
> On Thu, Jan 24, 2019 at 11:28 PM RETAIL CYBER 
> wrote:
>
>> They can I'll be looking for more jobs soon I'd personally if u get it
>> learned I'd go-to Fiverr
>>
>> On Thu, Jan 24, 2019, 9:35 AM Motaz Hejaze >
>>> Hi all ,
>>>
>>> Is there any remote job regarding Django , i am a beginner to mid-level
>>> in Django ..
>>>
>>> Thanks all ..
>>>
>>> --
>>> 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/CAHV4E-eipXC8kxPcWg%2BhOBeiL0jw3b82Sohv%3D-S5s9F%2BimvO_A%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/CAGNKn_C_u7afXm0%3DGm66GwwoXS2USUXp9vzXHNasFrFhuumgKQ%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/CAF2Ah_F-bUqzhfRzdJvxNLLYwamOSkuTV6Abw4YhYHT-U%3DKyFQ%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/CAEyUpt-NRaED_6G2XxGsuM9N9EkAou3Nc0U0%3DnJsnDwXcGE1RQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how can I reference a field from one model to another model

2019-01-25 Thread Anirudh Jain
You can do this easily by creating creating an object of that model from
which you want to get the value or input a value by using
'get_object_or_404' or 'get_list_or_404' by importing from
django.shortucts. Reas about these two functions and difference between
them in documentation.

Use them, for eg :-
 derive = get_object_or_404(ModelChild1, ModelDad=request.user) #object
created of model ModelChild1

access = derive.number #will give the value of number that has been input
by user

On Fri, 25 Jan 2019, 17:29 NAveeN Kumar Reddy  You can use this where you want you to link tables with foreign key
>
> models.ForeignKey(Model_Name,on_delete=models.CASCADE)
>
> That's it  both tables will be in relation after migration of models into
> database
>
>
>
> On Fri, Jan 25, 2019 at 12:20 PM Mike Dewhirst 
> wrote:
>
>> On 24/01/2019 5:28 pm, carlos wrote:
>> > Hello,
>> > I do not know if I'm asking the question correctly, but I need to call
>> > a field of one model in another model
>> > example:
>> > class ModelDad(models.Model):
>> > name = blablabla
>> >
>> > class ModelChild1():
>> >fk(ModelDad)
>> >number = models.IntegerField()
>> >
>> > class ModelChild2():
>> >   fk(ModelDad)
>> >   another_number = models.IntegerField()
>> >
>> >def make_proces(self):
>> >   return self.another_number * ModelChild1.number #this is my
>> question
>> >
>> > how can I send a call number within the function (make_proces ) of
>> > ModelChild2
>>
>> You need a mechanism to find ModelChild1 and the Django ORM provides
>> Queries for exactly that.
>>
>> There is a default model manager called 'objects' which you can use to
>> find instances of models. By that I mean you can pinpoint a row in the
>> database table which that model represents. For example ... (but to make
>> it clearer I'll adjust your models above slightly)
>>
>> class ModelDad(models.Model):
>>  name = blablabla
>>
>> class ModelChild1(models.Model):
>> dad = models.ForeignKey(ModelDad)
>> number = models.IntegerField()
>>
>> class ModelChild2(models.Model):
>> dad = models.ForeignKey(ModelDad)
>> another_number = models.IntegerField()
>>
>> def make_proces(self):
>>  child1 = ModelChild1.objects.get(dad=self.dad)
>>  return self.another_number *child1.number
>>
>> Visit Django documentation https://docs.djangoproject.com and scroll
>> down past "First steps" to  "The model layer" and click on a link in the
>> "Quersets" line. The answers will be in there.
>>
>> >
>> > is posible
>> >
>> >
>> >
>> > --
>> > att.
>> > Carlos Rocha
>> > --
>> > 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/CAM-7rO125r3pox%3D137GOfmjnmFaf3cekaNj-j%2B9A0Cwc%3DEM0Fg%40mail.gmail.com
>> > <
>> https://groups.google.com/d/msgid/django-users/CAM-7rO125r3pox%3D137GOfmjnmFaf3cekaNj-j%2B9A0Cwc%3DEM0Fg%40mail.gmail.com?utm_medium=email_source=footer
>> >.
>> > 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/522c40aa-2736-3f57-b23b-9c283c9a59e0%40dewhirst.com.au
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> Naveen Kumar  Reddy
>
> --
> 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/CA%2BC2Q82%2Bp47A92koj2%3Djq4aOvFetD%2BEuSikSCSbofTeSxWz-8Q%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" 

Re: how can I reference a field from one model to another model

2019-01-25 Thread NAveeN Kumar Reddy
You can use this where you want you to link tables with foreign key

models.ForeignKey(Model_Name,on_delete=models.CASCADE)

That's it  both tables will be in relation after migration of models into
database



On Fri, Jan 25, 2019 at 12:20 PM Mike Dewhirst 
wrote:

> On 24/01/2019 5:28 pm, carlos wrote:
> > Hello,
> > I do not know if I'm asking the question correctly, but I need to call
> > a field of one model in another model
> > example:
> > class ModelDad(models.Model):
> > name = blablabla
> >
> > class ModelChild1():
> >fk(ModelDad)
> >number = models.IntegerField()
> >
> > class ModelChild2():
> >   fk(ModelDad)
> >   another_number = models.IntegerField()
> >
> >def make_proces(self):
> >   return self.another_number * ModelChild1.number #this is my
> question
> >
> > how can I send a call number within the function (make_proces ) of
> > ModelChild2
>
> You need a mechanism to find ModelChild1 and the Django ORM provides
> Queries for exactly that.
>
> There is a default model manager called 'objects' which you can use to
> find instances of models. By that I mean you can pinpoint a row in the
> database table which that model represents. For example ... (but to make
> it clearer I'll adjust your models above slightly)
>
> class ModelDad(models.Model):
>  name = blablabla
>
> class ModelChild1(models.Model):
> dad = models.ForeignKey(ModelDad)
> number = models.IntegerField()
>
> class ModelChild2(models.Model):
> dad = models.ForeignKey(ModelDad)
> another_number = models.IntegerField()
>
> def make_proces(self):
>  child1 = ModelChild1.objects.get(dad=self.dad)
>  return self.another_number *child1.number
>
> Visit Django documentation https://docs.djangoproject.com and scroll
> down past "First steps" to  "The model layer" and click on a link in the
> "Quersets" line. The answers will be in there.
>
> >
> > is posible
> >
> >
> >
> > --
> > att.
> > Carlos Rocha
> > --
> > 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/CAM-7rO125r3pox%3D137GOfmjnmFaf3cekaNj-j%2B9A0Cwc%3DEM0Fg%40mail.gmail.com
> > <
> https://groups.google.com/d/msgid/django-users/CAM-7rO125r3pox%3D137GOfmjnmFaf3cekaNj-j%2B9A0Cwc%3DEM0Fg%40mail.gmail.com?utm_medium=email_source=footer
> >.
> > 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/522c40aa-2736-3f57-b23b-9c283c9a59e0%40dewhirst.com.au
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Naveen Kumar  Reddy

-- 
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/CA%2BC2Q82%2Bp47A92koj2%3Djq4aOvFetD%2BEuSikSCSbofTeSxWz-8Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Admin form_url breakout problem

2019-01-25 Thread Mike Dewhirst

  
  
On 25/01/2019 2:40 am, Matthew Pava
  wrote:


  Hi Mike,
I'm not really seeing why this is throwing errors at you.  It seems like you've done everything right.  Could you provide the code (or the relevant parts) for the Substance Admin form?
Thanks!


Matthew

I'm still in trouble and including some code. I'm not being precious
about it just hoping not to overwhelm you. Please ask for the next
instalment ...

class SubstanceAdmin(admin.ModelAdmin):

    def subscribe(self, sm2mi, fee_type, fullyear=False):
    """
    sm2mi is the substance<-ingredient m2m through
  record
    fee_type determines the subscription fee amount
    fullyear=False means calculate the fee pro-rata to
  30 September

    We don't need a request here so this can be
  imported from elsewhere.
    Only called if a fee is payable. Only returns a
  subscription if no token or
        fullyear == True meaning a subscription renewal is
  due
    """
    subscription, new =
  Subscription.objects.get_or_create(
    licensee=sm2mi.substance.division.company,
    ingredient=sm2mi.ingredient,
    fee_type=fee_type,
    )
    if not subscription.token or fullyear:
    return subscription

    def change_view(self, request, object_id, form_url='',
  extra_context=None):
    """
    For the billing system we want to include all the
  context data so the
    change_form populates itself properly. See
  collect_content
    self = SubstanceAdmin
    request = wsgi request object
    object_id = substance
    form_url = no idea!
    extra_context = no_idea
    """
    sm2mis =
  Substance_Ingredients.objects.filter(substance_id=object_id)
    for sm2mi in sm2mis:
    payable, fee_type = sm2mi.fee_payable()  # eg.,
  True, PAID_DATA
    if payable:
    subscription = self.subscribe(sm2mi,
  fee_type)
    if subscription:    # we need to collect
  money for the owner
    self.change_form_template =
  'payment.html'
    content = collect_content(
    sm2mi,
    subscription,
    )
    return payment_view(
    request,
    sm2mi,
    subscription,
    content=content
    )

    return super(SubstanceAdmin, self).change_view(
    request, object_id, form_url,
  extra_context=extra_context,
    )

Here is the payment form ... which is further down in admin.py

    class IngredientsInline(admin.StackedInline):

    class PaymentForm(admin.StackedInline.form):
    sm2mi_id =
  forms.CharField(widget=forms.HiddenInput, required=False)
    ingredient_id =
  forms.CharField(widget=forms.HiddenInput, required=False)
    subscription_id =
  forms.CharField(widget=forms.HiddenInput, required=False)
    licensee_id =
  forms.CharField(widget=forms.HiddenInput, required=False)

    stripeToken =
  forms.CharField(widget=forms.HiddenInput, required=False)
    stripeEmail =
  forms.CharField(widget=forms.HiddenInput, required=False)
    stripeBillingName =
  forms.CharField(widget=forms.HiddenInput, required=False)
    stripeBillingAddressLine1 =
  forms.CharField(widget=forms.HiddenInput, required=False)
    stripeBillingAddressZip =
  forms.CharField(widget=forms.HiddenInput, required=False)
    stripeBillingAddressState =
  forms.CharField(widget=forms.HiddenInput, required=False)
    stripeBillingAddressCity =
  forms.CharField(widget=forms.HiddenInput, required=False)
    stripeBillingAddressCountry =
  forms.CharField(widget=forms.HiddenInput, required=False)

    form = PaymentForm

All of the above is working so far as launching the Stripe
_javascript_ popup and generating the receipt record correctly and so
on but does not return to the admin nor render the success page.

The try/except block in payment_view() barfs as follows ...

    content['sm2mi'] = sm2mi
      content['receipt'] = receipt
      content['subscription'] = subscription
      content['message'] = mark_safe(display_message)
      content['link'] =