Re: capture client side location in Django

2020-09-25 Thread Salima Begum
Hi all,

I tried use https://docs.djangoproject.com/en/3.1/ref/contrib/gis/geoip2/
and This particular package requires
GeoLite2-Country.mmdb.gz
GeoLite2-City.mmdb.gz
These databases are not free. We are looking for an open source API or
package for our web application.

I appreciate if someone can share suitable pointers.

Thanks
~Salima


On Fri, Sep 25, 2020 at 2:48 AM Kasper Laudrup 
wrote:

> 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+unsubscr...@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
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMSz6bnu_soSSbdqPQTqB%3Dw9PNkpzOY620t0x0gCFZ7qKhkJKg%40mail.gmail.com.


Re: Storing secret keys in Django

2020-09-25 Thread Theresa Taye
Thank you Kasper
I appreciate this
On Sep 25, 2020 22:47, "Kasper Laudrup"  wrote:

> Hi Theresa,
>
> On 25/09/2020 23.00, Theresa Taye wrote:
>
>> Hello guys,
>>
>> Please can anyone help with the best way to store/hide secret key in
>> django and if possible share a link to a straight forward YouTube tutorial.
>>
>>
> There's rarely a "best way", since use cases differ and people tend to
> have different preferences, but I personally use django-configurations:
>
> https://github.com/jazzband/django-configurations
>
> And then use an environment variable for my secret key which is set in the
> service file I use for starting my Django UWSGI application in production.
>
> Using django-configurations has the added benefit that I can easily have
> different configurations in development and production and the secret key
> is more or less the only thing I don't keep in revision control (git).
>
> Of course, not sure if that's the "best way", but it's one way at least :-)
>
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/ms
> gid/django-users/f6f938b0-7a9e-a635-cead-ae38a10e835c%40stacktrace.dk.
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAENBRfMcZ%2BVpsFsRhTv0qmpLJBKfdZtjeU_CvhKKKTogO51Pvg%40mail.gmail.com.


Re: Storing secret keys in Django

2020-09-25 Thread Kasper Laudrup

Hi Theresa,

On 25/09/2020 23.00, Theresa Taye wrote:

Hello guys,

Please can anyone help with the best way to store/hide secret key in 
django and if possible share a link to a straight forward YouTube tutorial.




There's rarely a "best way", since use cases differ and people tend to 
have different preferences, but I personally use django-configurations:


https://github.com/jazzband/django-configurations

And then use an environment variable for my secret key which is set in 
the service file I use for starting my Django UWSGI application in 
production.


Using django-configurations has the added benefit that I can easily have 
different configurations in development and production and the secret 
key is more or less the only thing I don't keep in revision control (git).


Of course, not sure if that's the "best way", but it's one way at least :-)

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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f6f938b0-7a9e-a635-cead-ae38a10e835c%40stacktrace.dk.


Re: Django shared-cache for in-memory SQLite3 is not working

2020-09-25 Thread Krishna Chaitanya
On Sat, Sep 26, 2020 at 1:20 AM Krishna Chaitanya
 wrote:
>
> Hi,
>
> I am using Django 1.11 (default on 18.04). But I am still seeing
> https://code.djangoproject.com/ticket/12118 which is fixed in 1.8.
>
> models.save() in a thread is not being committed and not reflected in the
> main thread. I am using py3.6 and sqlite3 version is also met.
>
> $ python3 -c "from sqlite3 import dbapi2 as Database; print
> (Database.__name__, Database.sqlite_version__info)"
>
> sqlite3.dbapi2 (3, 22, 0)
>
> Am I missing something? Any help is appreciated.
>
> Cheers.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABPxzYL_uHDjtxrxtF%3DmH4TscXHU-ZU4iR4Kzz98jicf1y9thQ%40mail.gmail.com.


Re: Recruitment

2020-09-25 Thread Abimbola Felix
Am interested

On Wed, Sep 23, 2020, 3:43 PM Anh Nguyen  wrote:

> I’m, interested!
>
> On Sep 23, 2020, at 14:23, Harish Thiyagharajan <
> harishthiyagh...@gmail.com> wrote:
>
> I want a interested django user , DM mail for more details , all the
> details including payment can be discussed ...looking for for you 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/7b7956bc-d239-4b63-9194-0644b8a6eeben%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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CE1F0D68-DFB1-43DF-BF25-269F030896FD%40gmail.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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEzNMdCEno5srwnG%3DLrBLxGnMHKHrNSZ7e%3Dbe3MFHs-S0L8oew%40mail.gmail.com.


Storing secret keys in Django

2020-09-25 Thread Theresa Taye
Hello guys,

Please can anyone help with the best way to store/hide secret key in django
and if possible share a link to a straight forward YouTube tutorial.

Thanks in anticipation

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAENBRfN2_kuUM9OYNqowfWyy8sz-q6aNbdvyU6PjUzdqpyuLvw%40mail.gmail.com.


Re: Django admin page redirecting to some another page

2020-09-25 Thread coolguy
Please check if you have defined/changed LOGIN_URL settings in settings.py

On Friday, September 25, 2020 at 2:51:23 PM UTC-4 deepra...@gmail.com wrote:

> I go for super user login then it redirects to template which i made not 
> going to django admin login and django admin page,
>
> please suggest me any solution
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b568aa88-d340-44ac-a749-41c27af56e84n%40googlegroups.com.


Re: Django admin page redirecting to some another page

2020-09-25 Thread coolguy
Did you change LOGIN_REDIRECT_URL settings in settings.py?

On Friday, September 25, 2020 at 2:51:23 PM UTC-4 deepra...@gmail.com wrote:

> I go for super user login then it redirects to template which i made not 
> going to django admin login and django admin page,
>
> please suggest me any solution
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7bb1e7f7-be10-4ffa-b400-c1d1ad321fb9n%40googlegroups.com.


Re: Setting up models and postgres in django 3.1

2020-09-25 Thread Patrick Carra
Figured it out 3.1 is more strict about how it creates tables in postgres.  
The workaround I used was to put the tables into the various 
appname/models.py and then import them as needed when I need them.  

On Friday, September 25, 2020 at 12:38:19 PM UTC-5 Patrick Carra wrote:

> So I have worked in django 2.2 where I have multiple apps that I use the 
> same models.py file in for all of them (same meaning I make sure each one 
> is exactly the same as the others not one single models.py).  When I do 
> migrations I have no problem with anything.  When I started using django 
> 3.1 if I try to do the same it creates tables in the postgres database for  
> each app.  For example I have  a table called Menu_Item it creates tables 
> for home_Menu_Item, custOrders_Menu_Item, and menu_Menu_Item.  How to get 
> them all to use the same postgres table Menu_Item.   Why is django 3 acting 
> differently.  I'm not sure what changed but it isn't working out well for 
> me.
>
> menu/models.py
> from django.db import models
> # Create your models here.
> class Menu_Item(models.Model):
> class MenuTypes(models.TextChoices):
> APPETIZER = "Appetizer"
> ENTREE = "Entree"
> DESSERT = "Dessert"
> WINE = "Wine"
> BEER = "Beer"
> COCKTAIL = "Cocktail"
> name = models.CharField(max_length = 50)
> description = models.CharField(max_length = 250)
> price = models.DecimalField(max_digits = 4, decimal_places= 2)
> item_type = models.CharField(max_length = 10, 
> choices=MenuTypes.choices, default=MenuTypes.APPETIZER)
>   
> 
> def __str__(self):
> return self.name + ' - ' + self.item_type
> class Menu_Drink_Item(models.Model):
> class DrinkChoices(models.TextChoices):
> WINE = "Wine"
> BEER = "Beer"
> COCKTAIL = "Cocktail"
> name = models.CharField(max_length = 50)
> description = models.CharField(max_length = 250)
> price = models.DecimalField(max_digits = 4, decimal_places= 2)
> drink_type = models.CharField(max_length = 10, 
> choices=DrinkChoices.choices, default=DrinkChoices.COCKTAIL)
> pairing_options = models.ForeignKey(Menu_Item, null=True, blank=True, 
> on_delete = models.SET_NULL)
> def __str__(self):
> return self.name
>
> custOrders/models.py
> from django.db import models
> from menu.models import Menu_Item
> # Create your models here.
> class tableTable(models.Model):
> tableTypeChoices = [
> ('bar', 'bar'),
> ('booth', 'booth'),
> ('table', 'table'),
> ('hi-top', 'hi-top'),
> ('patio', 'patio'),
> ]
> statusChoices = [
> ('cleaned', 'cleaned'),
> ('seated', 'seated'),
> ('closed', 'closed'),
> ('reserved', 'reserved'),
> ]
> #primary key field
> seats = models.IntegerField(blank=False, null=False)
> tableType = models.CharField(max_length=255, blank=False, null=False, 
> choices=tableTypeChoices)
> status = models.CharField(max_length=255, blank=False, null=False, 
> choices=statusChoices)
> server = models.CharField(max_length=255, blank=False, null=False)
> def __str__(self):
> return '%s %s' % (self.id, self.tableType)
> class Menu_Item(models.Model):
> class MenuTypes(models.TextChoices):
> APPETIZER = "Appetizer"
> ENTREE = "Entree"
> DESSERT = "Dessert"
> WINE = "Wine"
> BEER = "Beer"
> COCKTAIL = "Cocktail"
> name = models.CharField(max_length = 50)
> description = models.CharField(max_length = 250)
> price = models.DecimalField(max_digits = 4, decimal_places= 2)
> item_type = models.CharField(max_length = 10, 
> choices=MenuTypes.choices, default=MenuTypes.APPETIZER)
>   
> 
> def __str__(self):
> return self.name + ' - ' + self.item_type
>
>
> Any ideas?
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/10a8253c-53df-40d2-808e-d9737e5e6e42n%40googlegroups.com.


Django admin page redirecting to some another page

2020-09-25 Thread Deepraj Devikar
I go for super user login then it redirects to template which i made not
going to django admin login and django admin page,

please suggest me any solution

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAL0P1EVq062TL2V18rXJCvzr-rb2g3C2ERWwPd%3DV%2BMaKXtuGsw%40mail.gmail.com.


Setting up models and postgres in django 3.1

2020-09-25 Thread Patrick Carra
So I have worked in django 2.2 where I have multiple apps that I use the 
same models.py file in for all of them (same meaning I make sure each one 
is exactly the same as the others not one single models.py).  When I do 
migrations I have no problem with anything.  When I started using django 
3.1 if I try to do the same it creates tables in the postgres database for  
each app.  For example I have  a table called Menu_Item it creates tables 
for home_Menu_Item, custOrders_Menu_Item, and menu_Menu_Item.  How to get 
them all to use the same postgres table Menu_Item.   Why is django 3 acting 
differently.  I'm not sure what changed but it isn't working out well for 
me.

menu/models.py
from django.db import models
# Create your models here.
class Menu_Item(models.Model):
class MenuTypes(models.TextChoices):
APPETIZER = "Appetizer"
ENTREE = "Entree"
DESSERT = "Dessert"
WINE = "Wine"
BEER = "Beer"
COCKTAIL = "Cocktail"
name = models.CharField(max_length = 50)
description = models.CharField(max_length = 250)
price = models.DecimalField(max_digits = 4, decimal_places= 2)
item_type = models.CharField(max_length = 10, 
choices=MenuTypes.choices, default=MenuTypes.APPETIZER)
  

def __str__(self):
return self.name + ' - ' + self.item_type
class Menu_Drink_Item(models.Model):
class DrinkChoices(models.TextChoices):
WINE = "Wine"
BEER = "Beer"
COCKTAIL = "Cocktail"
name = models.CharField(max_length = 50)
description = models.CharField(max_length = 250)
price = models.DecimalField(max_digits = 4, decimal_places= 2)
drink_type = models.CharField(max_length = 10, 
choices=DrinkChoices.choices, default=DrinkChoices.COCKTAIL)
pairing_options = models.ForeignKey(Menu_Item, null=True, blank=True, 
on_delete = models.SET_NULL)
def __str__(self):
return self.name

custOrders/models.py
from django.db import models
from menu.models import Menu_Item
# Create your models here.
class tableTable(models.Model):
tableTypeChoices = [
('bar', 'bar'),
('booth', 'booth'),
('table', 'table'),
('hi-top', 'hi-top'),
('patio', 'patio'),
]
statusChoices = [
('cleaned', 'cleaned'),
('seated', 'seated'),
('closed', 'closed'),
('reserved', 'reserved'),
]
#primary key field
seats = models.IntegerField(blank=False, null=False)
tableType = models.CharField(max_length=255, blank=False, null=False, 
choices=tableTypeChoices)
status = models.CharField(max_length=255, blank=False, null=False, 
choices=statusChoices)
server = models.CharField(max_length=255, blank=False, null=False)
def __str__(self):
return '%s %s' % (self.id, self.tableType)
class Menu_Item(models.Model):
class MenuTypes(models.TextChoices):
APPETIZER = "Appetizer"
ENTREE = "Entree"
DESSERT = "Dessert"
WINE = "Wine"
BEER = "Beer"
COCKTAIL = "Cocktail"
name = models.CharField(max_length = 50)
description = models.CharField(max_length = 250)
price = models.DecimalField(max_digits = 4, decimal_places= 2)
item_type = models.CharField(max_length = 10, 
choices=MenuTypes.choices, default=MenuTypes.APPETIZER)
  

def __str__(self):
return self.name + ' - ' + self.item_type


Any ideas?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ebd76d62-ca29-40df-94e9-1e1dcd831916n%40googlegroups.com.


Re: How to resize image when uploading to the cloudinary?

2020-09-25 Thread RANGA BHARATH JINKA
Hi,

Check this.
https://cloudinary.com/documentation/django_image_manipulation

On Fri, Sep 25, 2020 at 8:49 PM abhay santra  wrote:

>
> Hi,
> I would like to know how to resize any image when uploading to the
> cloudinary in 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d9eaaea0-b3e3-42a5-8ccf-884662258ddcn%40googlegroups.com
> 
> .
>


-- 
Thanks and Regards

J. Ranga Bharath
cell: 9110334114

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK5m314P%2BimAdbk4yeGm0BuLtsvc-QA4tFppUSpfoummOgbMSA%40mail.gmail.com.


Re: How to resize image when uploading to the cloudinary?

2020-09-25 Thread Kasper Laudrup

Hi Abbay,

On 25/09/2020 16.21, abhay santra wrote:


Hi,
I would like to know how to resize any image when uploading to the 
cloudinary in django?




You use Pillow:

https://pillow.readthedocs.io/en/stable/

It's hard for anyone to give you a better answer until you try to write 
a better question.


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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/59552e32-d06a-fa87-560e-29b946eff843%40stacktrace.dk.


How to resize image when uploading to the cloudinary?

2020-09-25 Thread abhay santra

Hi, 
I would like to know how to resize any image when uploading to the 
cloudinary in 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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d9eaaea0-b3e3-42a5-8ccf-884662258ddcn%40googlegroups.com.


Re: Recruitment

2020-09-25 Thread Let's Code
Hi, I'm interested!

On Wed, Sep 23, 2020, 8:10 PM Harish Thiyagharajan <
harishthiyagh...@gmail.com> wrote:

> I want a interested django user , DM mail for more details , all the
> details including payment can be discussed ...looking for for you 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/7b7956bc-d239-4b63-9194-0644b8a6eeben%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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAONyrwnamZwEVwBzd1mW0%2Bsz8i%2BYhGYqAERC%3Dmh_Xd0n1v3XZA%40mail.gmail.com.


Double query to retrieve a Paginator's page

2020-09-25 Thread hldev

Paginator.page() 
 
when called for the first time will trigger the evaluation of the cached 
property "count", which performs a COUNT query on the database. It will 
generally happen every time, since a new Paginator object is made for each 
new request.
The problem here is that the COUNT query costs almost the same as the main 
query which retrieves the page's items, so in effect it's doubling the 
needed query.
How can I avoid that duplication?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1debc300-2413-4a7c-96e6-c56496ed7a3an%40googlegroups.com.


Re: Stuck with Calculated feild

2020-09-25 Thread Frederic Salvetat


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 

Re: Stuck with Calculated feild

2020-09-25 Thread Frederic Salvetat
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+unsubscr...@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.


Backend exception after upgrade.

2020-09-25 Thread Kirill Maksimov
Hello guys. I'm using Python3.8 and Django2.2. 

After upgrade to django 2.2, I'm getting weird exception which happens only 
on ecs sever:

*AttributeError partially initialized module 'django_redis.cache' has no 
attribute 'RedisCache' (most likely due to a circular import)*

Also had similar exceptions for mysql backend:

*AttributeError partially initialized module 
'django.db.backends.mysql.compiler' has no attribute 'SQLInsertCompiler' 
(most likely due to a circular import)*

I wonder why it could happen? Also if I build and run the same container 
locally it works fine. Big thanks for any help.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/aa9fe29b-d1de-42c5-bfd3-114f1dac4255n%40googlegroups.com.


Regarding OTP based login- Django

2020-09-25 Thread Rahul Gour
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+unsubscr...@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: How to change http:127.0.0.1:8000/sitemap.xml to https://domain.com/sitemap.xml in production?

2020-09-25 Thread Kasper Laudrup

Hi dum dum,

On 25/09/2020 13.27, dum dum wrote:
I can't access https://domain.com/sitemap.xml, because it gave me 404 
error because the page not exist.
But in local http:127.0.0.1:8000/sitemap.xml 
 works.


Any suggestions?


Look in your log files for details. That should give you a clue.

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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e90d9fde-f526-2139-371c-72e5dca06ca4%40stacktrace.dk.


How to change http:127.0.0.1:8000/sitemap.xml to https://domain.com/sitemap.xml in production?

2020-09-25 Thread dum dum
I can't access https://domain.com/sitemap.xml, because it gave me 404 error
because the page not exist.
But in local http:127.0.0.1:8000/sitemap.xml works.

Any suggestions?
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANV3w%3DbVK_TZXmV9qKVgXFdiUyZDdnd6AUH%2BSOqF-0NWDxEY%2Bw%40mail.gmail.com.


domain/sitemap.xml HTTP Error 500, site matching query does not exist

2020-09-25 Thread dum dum
I don't understand this.
In local, when I access 127.0.0.1:8000/sitemap.xml. I can see my xml file.
But in production
domain.com/sitemap.xml gave me this HTTP 500 Error. Site matching query
does not exist.

Anyone experienced this?
Please help, 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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANV3w%3DaDu2jTz97JnqX1R7MLnbPeZ4bhfsNb%3D90K4cr0tpjmLg%40mail.gmail.com.


Re: job portal using django

2020-09-25 Thread Kunal Solanke
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  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 
> 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+unsubscr...@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+unsubscr...@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+unsubscr...@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

2020-09-25 Thread Kasper Laudrup

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+unsubscr...@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.