Friday, September 25, 2020

capture client side location in Django

Hi all,

How to capture client side location in django can any one help to achieve this?


Thank you
~Salima

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMSz6bnm%3D7AjMNTpR3TowCPZjRPsVfSLTzYk%2Byo5hERmkiYfqw%40mail.gmail.com.

Re: Stuck with Calculated feild

Hi Eankomah,
You have several solutions depending upon your need:

>Le mercredi 23 septembre 2020 07:24:05 UTC+2, eankomah a écrit :
>Hi all am stuck at getting total_price Calculated in my model
>
>class inventory(models.Model):
>    def __str__(self):
>        return self.name
>  ...
>    total_price = models.FloatField(total=('unit_price' * 'quantity'))
>  ...
>Thanks

First dr neyx de godlove's answer is the more elegant if you do not need a dedicated db field.
You just need to remove the 'get_' prefix  in get_total_price :

    @property
    def total_price(self):
        total_price = self.unit_price * self.quantity
        return total_price

(@dr neyx de godlove, thank I learned the use of property in django trying you solution)

Then if you really need a dedicated field, create it and override the save method in your model :
    total_price = models.FloatField()

    def save(self, *args, **kwargs):
        #change total_price
        # Transaction.save(update_fields['total_price'])
        self.total_price = self.unit_price * self.quantity
        super(Inventory, self).save(*args, **kwargs)


Best Regards
--
Frédéric Salvetat 
Le mercredi 23 septembre 2020 à 17:13:32 UTC+2, Kasper Laudrup a écrit :
Hi Harish,

On 23/09/2020 11.27, Harish Thiyagharajan wrote:
> I think you mailed me instead of mailing someone
>

No. If you look at the mail header, you can see this was sent to the
django-users mailing list.

Kind regards,

Kasper Laudrup

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b9412f55-35c5-461e-b984-42b5a8e6e95cn%40googlegroups.com.

Re: Stuck with Calculated feild

Hi Eankomah,

You have several solution depending upon your need:

 

Le mercredi 23 septembre 2020 07:24:05 UTC+2, eankomah a écrit :
Hi all am stuck at getting total_price Calculated in my model
 
class inventory(models.Model):
    def __str__(self):
        return self.name
  ...
    total_price = models.FloatField(total=('unit_price' * 'quantity'))
  ...
Thanks

 

First dr neyx de godlove answer is the more elegant if you do not need a dedicated db field.

You just need to remove the 'get_' prefix  in get_total_price :

 

    @property

    def total_price(self):

        total_price = self.unit_price * self.quantity

        return total_price

 

(@dr neyx de godlove, thank I learned the use of property in django trying you solution)

 

Then if you really need a dedicated field, create it and override the save method in your model :

    total_price = models.FloatField()

 

    def save(self, *args, **kwargs):

        #change total_price

        # Transaction.save(update_fields['total_price'])

        self.total_price = self.unit_price * self.quantity

        super(Inventory, self).save(*args, **kwargs)


Best Regards
--
Frédéric Salvetat 

Le mercredi 23 septembre 2020 07:24:05 UTC+2, eankomah a écrit :
Hi all am stuck at getting total_price Calculated in my model

class inventory(models.Model):
    def __str__(self):
        return self.name

    category = models.ForeignKey(Category, null=True, on_delete = models.SET_NULL)
    Supplier = models.ForeignKey(Supplier, null=True, on_delete = models.SET_NULL)
    product = models.ForeignKey(Product, null=True, on_delete = models.SET_NULL)
    quantity = models.FloatField()
    unit_price = models.FloatField()
    total_price = models.FloatField(total=('unit_price' * 'quantity'))
    selling_price = models.FloatField()
    date_created = models.DateTimeField(auto_now_add=True) 


Thanks

Le mercredi 23 septembre 2020 07:24:05 UTC+2, eankomah a écrit :
Hi all am stuck at getting total_price Calculated in my model

class inventory(models.Model):
    def __str__(self):
        return self.name

    category = models.ForeignKey(Category, null=True, on_delete = models.SET_NULL)
    Supplier = models.ForeignKey(Supplier, null=True, on_delete = models.SET_NULL)
    product = models.ForeignKey(Product, null=True, on_delete = models.SET_NULL)
    quantity = models.FloatField()
    unit_price = models.FloatField()
    total_price = models.FloatField(total=('unit_price' * 'quantity'))
    selling_price = models.FloatField()
    date_created = models.DateTimeField(auto_now_add=True) 


Thanks

Le mercredi 23 septembre 2020 07:24:05 UTC+2, eankomah a écrit :
Hi all am stuck at getting total_price Calculated in my model

class inventory(models.Model):
    def __str__(self):
        return self.name

    category = models.ForeignKey(Category, null=True, on_delete = models.SET_NULL)
    Supplier = models.ForeignKey(Supplier, null=True, on_delete = models.SET_NULL)
    product = models.ForeignKey(Product, null=True, on_delete = models.SET_NULL)
    quantity = models.FloatField()
    unit_price = models.FloatField()
    total_price = models.FloatField(total=('unit_price' * 'quantity'))
    selling_price = models.FloatField()
    date_created = models.DateTimeField(auto_now_add=True) 


Thanks

Le mercredi 23 septembre 2020 07:24:05 UTC+2, eankomah a écrit :
Hi all am stuck at getting total_price Calculated in my model

class inventory(models.Model):
    def __str__(self):
        return self.name

    category = models.ForeignKey(Category, null=True, on_delete = models.SET_NULL)
    Supplier = models.ForeignKey(Supplier, null=True, on_delete = models.SET_NULL)
    product = models.ForeignKey(Product, null=True, on_delete = models.SET_NULL)
    quantity = models.FloatField()
    unit_price = models.FloatField()
    total_price = models.FloatField(total=('unit_price' * 'quantity'))
    selling_price = models.FloatField()
    date_created = models.DateTimeField(auto_now_add=True) 


Thanks

Le mercredi 23 septembre 2020 07:24:05 UTC+2, eankomah a écrit :
Hi all am stuck at getting total_price Calculated in my model

class inventory(models.Model):
    def __str__(self):
        return self.name

    category = models.ForeignKey(Category, null=True, on_delete = models.SET_NULL)
    Supplier = models.ForeignKey(Supplier, null=True, on_delete = models.SET_NULL)
    product = models.ForeignKey(Product, null=True, on_delete = models.SET_NULL)
    quantity = models.FloatField()
    unit_price = models.FloatField()
    total_price = models.FloatField(total=('unit_price' * 'quantity'))
    selling_price = models.FloatField()
    date_created = models.DateTimeField(auto_now_add=True) 


Thanks

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/68f3c6fd-192e-40a1-9a1b-0f7e095ee5bao%40googlegroups.com.

Re: job portal using django

Anson developer ,not a big youtuber but ,he has been doing same project with react .You can just take an idea or if you want to make your project little bit intersting ,do it with react and django.👌👌

On Fri, Sep 25, 2020, 09:14 Lane Campbell <lane@strapr.com> wrote:
There are a lot of tutorials for creating apps in Django that store and read data submitted by users.

You can adapt the instructions to create a job portal.



On Thu, Sep 24, 2020 at 7:19 PM Ayush Shukla <acroayush01@gmail.com> wrote:
is there any tutorial on creating job portals (like indeed ) using django

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a0915fd4-d33b-4333-8d05-74664b047c44n%40googlegroups.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CADQXWrUzur0skHNGvhxVynJ%2BtDEkm_G10-%2Bo64kbEhgeUBj-Ew%40mail.gmail.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOecAnzFxrsV78dKuo5%3DmpSe695Fgm%3D-ZF-ubhUVc8XbB_38-g%40mail.gmail.com.

Re: capture client side location in Django

On 25/09/2020 06.10, Stats Student wrote:
> You can read the client's IP address with -
>
> request.META['REMOTE_ADDR'] -- ( not sure how it handles proxies, etc )
>

Proxies should set the X-Forwarded-For header:

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For

the value of which will then be used in the META dictionary.

Worth noticing that it's trivially possible for any client to set that
header as well and there's no way to reliably get the actual IP address
of the client simply because of how HTTP works.

Of course that's just a variation of "never trust the client" :-)

Kind regards,

Kasper Laudrup

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c5aedd33-9611-0624-2dd4-7d3589b03c7d%40stacktrace.dk.

Thursday, September 24, 2020

Regarding OTP based login- Django

Hello,

TIA.

I am new in django, can anyone help me for OTP based login in my app.

I am working on a ecommerce app and want to login otp based login and dont know or getting much on google that how to integrate phone number with django user model or want to use custom user model.


Regards,
Rahul Gour

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFi6BNX1qfhDF1zqY7xt4aD%2B7F7mgNXmApxZ%2BquigQYxSgsinw%40mail.gmail.com.

Re: capture client side location in Django

You can read the client's IP address with -

request.META['REMOTE_ADDR'] -- ( not sure how it handles proxies, etc )

then use GeoIP2 to get the location info -

https://docs.djangoproject.com/en/3.1/ref/contrib/gis/geoip2/



On Thu, Sep 24, 2020 at 6:42 PM Salima Begum
<salima.b@rohteksolutions.com> wrote:
>
> Hi all,
>
> How to capture client side location in django can any one help to achieve this?
>
>
> Thank you
> ~Salima
>
> --
> 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+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMSz6bnm%3D7AjMNTpR3TowCPZjRPsVfSLTzYk%2Byo5hERmkiYfqw%40mail.gmail.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMZO7w%2B6LQ38LqqTt%3D_UDyA3MH3fvvQHRX8DJQ3Luzwh13JfLQ%40mail.gmail.com.