Re: Sorting price and discount price (urgent)

2021-07-01 Thread Aritra Ray
Hi,

I will avoid using 'urgent'. The problem is as described above, I want to
sort my products in ascending or descending price order which will include
the discount price too if it exists. Right now, if there are two products,
A and B; A being ₹900 and B being ₹1200 too but after discount, ₹ 800, the
sorting order highest to lowest price is: B,A instead of A,B. As Shailesh
asked, discount_price is a model field as I've given in the code about. And
the 'fields = {'price': 'discount_price'}' is wrong after I searched a bit
on the internet, kindly ignore that.

Kindly suggest a way to include discount_price in the sorting parameter
where it'll be considered instead of the original price itself.

On Thu, 1 Jul, 2021, 4:06 pm Shailesh Yadav, 
wrote:

> yes, I agree with Kasper please don't use urgent  OR very urgent, and
> please describe your questions in detail.
> from where you getting this *discount_price* and why you using the *price*
> key for two different values. (can you check by printing *discount_price*)
>
> fields={
> 'price': 'price',
> 'price':'discount_price'
> },
>
>
>
> Thanks & Regards
> Shailesh Yadav
>
>
>
> On Thu, Jul 1, 2021 at 1:33 PM Aritra Ray  wrote:
>
>> I tried to describe the problem but till my capability and it is urgent,
>> not just for increasing the possibility of getting help. Thank you for your
>> advice and help.
>>
>> On Thu, 1 Jul, 2021, 1:30 pm Kasper Laudrup, 
>> wrote:
>>
>>> On 7/1/21 8:03 AM, Aritra Ray wrote:
>>> > I am facing a problem in including the discount_price into
>>> consideration
>>> > when sorting price through the products. Kindly help me to do so. The
>>> > below attached files are filters.py, views.py and  models.py.
>>> >
>>>
>>> Instead of writing "urgent" in hope it will increase your chances of
>>> getting help faster, you'll have a much better chance of getting some
>>> useful help if you spend some time describing the exact problem you have
>>> instead of just "a problem".
>>>
>>> This might help you:
>>>
>>>
>>> https://betterprogramming.pub/how-to-ask-questions-about-programming-dcd948fcd2b
>>>
>>> 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/0c454b7d-cb51-ea95-d0e8-ca4be0c2bad7%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/CAFecadvpnYg3CWXRtZfNjWpLPbd4KyqndZ5EdmVUmaP_dbvR0Q%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAFecadvpnYg3CWXRtZfNjWpLPbd4KyqndZ5EdmVUmaP_dbvR0Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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/CAMQ-AEVPDkAeFihwbd1xYWNskvUc8zta-9FZW1ePr_rYZ0vnGA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAMQ-AEVPDkAeFihwbd1xYWNskvUc8zta-9FZW1ePr_rYZ0vnGA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAFecaduF3yum-%2BXVDqYTmcaBgSK5UajT8tBYYyErWGoJe7FsAw%40mail.gmail.com.


Re: Sorting price and discount price (urgent)

2021-07-01 Thread Aritra Ray
I tried to describe the problem but till my capability and it is urgent,
not just for increasing the possibility of getting help. Thank you for your
advice and help.

On Thu, 1 Jul, 2021, 1:30 pm Kasper Laudrup,  wrote:

> On 7/1/21 8:03 AM, Aritra Ray wrote:
> > I am facing a problem in including the discount_price into consideration
> > when sorting price through the products. Kindly help me to do so. The
> > below attached files are filters.py, views.py and  models.py.
> >
>
> Instead of writing "urgent" in hope it will increase your chances of
> getting help faster, you'll have a much better chance of getting some
> useful help if you spend some time describing the exact problem you have
> instead of just "a problem".
>
> This might help you:
>
>
> https://betterprogramming.pub/how-to-ask-questions-about-programming-dcd948fcd2b
>
> 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/0c454b7d-cb51-ea95-d0e8-ca4be0c2bad7%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/CAFecadvpnYg3CWXRtZfNjWpLPbd4KyqndZ5EdmVUmaP_dbvR0Q%40mail.gmail.com.


Sorting price and discount price (urgent)

2021-06-30 Thread Aritra Ray
I am facing a problem in including the discount_price into consideration
when sorting price through the products. Kindly help me to do so. The below
attached files are filters.py, views.py and  models.py.

Regards,
Aritra

class ProductFilter(django_filters.FilterSet):
sort = OrderingFilter(
choices=(
('price', 'Lowest to Highest'),
('-price', 'Highest to Lowest'),
),
fields={
'price': 'price',
'price':'discount_price'
},
)
price = RangeFilter()
class Meta:
model = Items
fields = ['size', 'category']

class Product(ListView):
model = Items
paginate_by = 6
template_name = 'products.html'
ordering = ["-id"]

def get_queryset(self):
queryset = super().get_queryset()
filter = ProductFilter(self.request.GET, queryset)
return filter.qs

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
queryset = self.get_queryset()
filter = ProductFilter(self.request.GET, queryset)
context["filter"] = filter
return context
class Items(BaseModel):
title = models.CharField(max_length=100, null=True, blank=True)
price = models.FloatField(null=True, blank=True)
discount_price = models.FloatField(max_length=100, blank=True, null=True
)
description = models.TextField(max_length=500)
size = models.CharField(choices=SIZES, default=SIZES[0][0], max_length=
10)
category = models.CharField(choices=CATEGORY, default=CATEGORY[0][0
], max_length=1)
featured = models.BooleanField(default=False)
availability = models.CharField(choices=AVAILABILITY, default=
AVAILABILITY[0][0], max_length=1)
image = ResizedImageField(upload_to="", null=True, blank=True)
slug = models.SlugField(max_length=100)
date_added = models.DateField(default=timezone.now)

-- 
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/CAFecadsUerZLP7gj7M23DLjytHQcuWc1ys2nqEcs_JNLKMc_Qg%40mail.gmail.com.


Re: In need of urgent help for products sorting and displaying

2021-06-28 Thread Aritra Ray
We've realised the error but are unable to fix it. We'll be grateful if you
can solve it for us as we've been stuck on this for a long time. The search
function in the views.py is conditioning the products via products.html
filter form which is requesting for a "products-list url" which looks like
this: path('products', Product.as_view(), name='products-list').
The problem is the url pattern. Can you help us resolve this issue?
The GitHub link to our repo is
https://github.com/First-project-01/Django-ecommerce


Will be of great help
Regards,
Aritra.


On Mon, 28 Jun 2021 at 16:40, Kasper Laudrup  wrote:

> On 28/06/2021 12.51, Adarsh Sarda wrote:
> >  I've been building a Django E-commerce website and I'm facing problems
> > displaying the sorted products on the products page of my website. I can
> > display the products by category sorting in which I'm using crispy-forms
> > to display the form but I am unable to display the products when sorted
> > by price. I've attached the required files below.
> >
> > Do let me know if anything else is needed.
> > Thanks for your help in advance
> >
>
> Check the "action" parameter to your form. Where exactly does the string
> given to that parameter end?
>
> That should help you figure out how to fix it.
>
> 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/bec6b39c-53a2-2905-eb4c-77cb24ba6c25%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/CAFecadvCQGUGmCpd9O%3DHXrgnMV83uHUBhYv5m2qyOqi_Cf10Dw%40mail.gmail.com.


Re: Kindly help me with Django filer, urgent need.

2021-06-25 Thread Aritra Ray
Right, kindly heed to the problem as early as possible, The GitHub link is
provided below.
https://github.com/First-project-01/Django-ecommerce/issues/12

On Fri, 25 Jun 2021 at 19:34, Symaxx  wrote:

> This is easier to work with on GitHub, do you have a GitHub account?
>
> You can raise an issue then share the link here 🙂
>
> On Fri, 25 Jun 2021, 3:04 PM Aritra Ray,  wrote:
>
>> Hi,
>> This is my second request regarding the same issue. I've been building a
>> Django E-commerce website and I'm facing problems filtering the product
>> according to price. I used django-filter to filter category and size.
>> Please suggest a solution for price in the following manner: Latest
>> products, Lowest to Highest and Highest to Lowest. I've made some progress
>> in the template without using django-filter. Kindly help me tie it up with
>> the backend.
>>
>> Do let me know if anything else is needed.
>> Thanks for your help in advance
>>
>> Regards,
>> Aritra
>>
>> #products-html
>>  
>> 
>>   
>>   
>> {{filter.form|crispy}}
>> 
>>   Select sorting criteria
>>   
>>   
>>   
>>   > '-date_added' %}selected{% endif %}>Latest collection
>>   >  %} selected {% endif %}>Lowest to Highest
>>   >  %} selected {% endif %}>Highest to Lowest
>>   
>>   
>>   
>>   
>> > class="glyphicon glyphicon-search"> Search
>> 
>>   
>> 
>>
>> #views.py
>>
>> class Product(ListView):
>> model = Items
>> paginate_by = 6
>> template_name = 'products.html'
>> ordering = ["-id"]
>>
>> def get_queryset(self):
>> queryset = super().get_queryset()
>> filter = ProductFilter(self.request.GET, queryset)
>> return filter.qs
>>
>> def get_context_data(self, **kwargs):
>> context = super().get_context_data(**kwargs)
>> queryset = self.get_queryset()
>> filter = ProductFilter(self.request.GET, queryset)
>> context["filter"] = filter
>> return context
>>
>> # filters.py
>> import django_filters
>> from .models import Items
>>
>> class ProductFilter(django_filters.FilterSet):
>> class Meta:
>> model = Items
>> fields = ['size', 'category']
>>
>> --
>> 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/CAFecadt5eYOdDX3sL46kbscLfbhwAzEcvwUpM9TF_s%2B9YhBGVQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAFecadt5eYOdDX3sL46kbscLfbhwAzEcvwUpM9TF_s%2B9YhBGVQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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/CANPYDAtyWhqy%3DGM%3DEGpwVrUFDrTuctmgpN4xPcrLyKYgOv23cg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CANPYDAtyWhqy%3DGM%3DEGpwVrUFDrTuctmgpN4xPcrLyKYgOv23cg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAFecaduYnX1yYU-f1B2rOKZjX4_XnU-%2BVDGVPZan4DikY_e19A%40mail.gmail.com.


Kindly help me with Django filer, urgent need.

2021-06-25 Thread Aritra Ray
Hi,
This is my second request regarding the same issue. I've been building a
Django E-commerce website and I'm facing problems filtering the product
according to price. I used django-filter to filter category and size.
Please suggest a solution for price in the following manner: Latest
products, Lowest to Highest and Highest to Lowest. I've made some progress
in the template without using django-filter. Kindly help me tie it up with
the backend.

Do let me know if anything else is needed.
Thanks for your help in advance

Regards,
Aritra

#products-html
 

  
  
{{filter.form|crispy}}

  Select sorting criteria
  
  
  
  Latest collection
  Lowest to Highest
  Highest to Lowest
  
  
  
  
 Search

  


#views.py

class Product(ListView):
model = Items
paginate_by = 6
template_name = 'products.html'
ordering = ["-id"]

def get_queryset(self):
queryset = super().get_queryset()
filter = ProductFilter(self.request.GET, queryset)
return filter.qs

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
queryset = self.get_queryset()
filter = ProductFilter(self.request.GET, queryset)
context["filter"] = filter
return context

# filters.py
import django_filters
from .models import Items

class ProductFilter(django_filters.FilterSet):
class Meta:
model = Items
fields = ['size', 'category']

-- 
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/CAFecadt5eYOdDX3sL46kbscLfbhwAzEcvwUpM9TF_s%2B9YhBGVQ%40mail.gmail.com.


In need of urgent help as I've been stuck on this for a while

2021-06-24 Thread Aritra Ray
Hi,
This is my second request regarding the same issue. I've been building a
Django E-commerce website and I'm facing problems filtering the product
according to price. I used django-filter to filter category and size.
Please suggest a solution for price in the following manner: Latest
products, Lowest to Highest and Highest to Lowest. I've made some progress
in the template without using django-filter. Kindly help me tie it up with
the backend.

Do let me know if anything else is needed.
Thanks for your help in advance

Regards,
Aritra

#products-html
 

  
  
{{filter.form|crispy}}

  Select sorting criteria
  
  
  
  Latest collection
  Lowest to Highest
  Highest to Lowest
  
  
  
  
 Search

  


#views.py

class Product(ListView):
model = Items
paginate_by = 6
template_name = 'products.html'
ordering = ["-id"]

def get_queryset(self):
queryset = super().get_queryset()
filter = ProductFilter(self.request.GET, queryset)
return filter.qs

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
queryset = self.get_queryset()
filter = ProductFilter(self.request.GET, queryset)
context["filter"] = filter
return context

# filters.py
import django_filters
from .models import Items

class ProductFilter(django_filters.FilterSet):
class Meta:
model = Items
fields = ['size', 'category']

-- 
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/CAFecadukpt-gAgFwT5%2BKGM2tp3u3fdFDj98MQHWPgbY42dMGVQ%40mail.gmail.com.


Re: Need urgent help with filter system (django-filter) in Django

2021-06-23 Thread Aritra Ray
Can you write the class based function of the above views.py. I'm unable to
do so. Will be of great help.


On Wed, 23 Jun 2021 at 21:54, Shailesh Yadav 
wrote:

> in Html code
>
> 
> {{items_filter.form}}
> 
>  Search
> 
> 
>
> Thanks & Regards
> Shailesh Yadav
> +91-9920886044
>
>   [image: Linkedin] <https://in.linkedin.com/in/shailesh-yadav-b7ab89110>
>
>
>
> On Wed, Jun 23, 2021 at 9:50 PM Shailesh Yadav <
> shaileshyadav7...@gmail.com> wrote:
>
>> Okay.
>> If you using the Django filter then, please try like below in your views..
>>
>> abc_list = ModelName.objects.all()
>> result_filter = ModelNameFilter(request.GET, queryset=abc_list)
>>
>> Thanks & Regards
>> Shailesh Yadav
>> +91-9920886044
>>
>>   [image: Linkedin] <https://in.linkedin.com/in/shailesh-yadav-b7ab89110>
>>
>>
>>
>>
>> On Wed, Jun 23, 2021 at 9:13 PM Aritra Ray  wrote:
>>
>>> Sorry, it's not working. I tried items_filter.form but it didn't work.
>>> Kindly check my views.py if that'll be of any help or require any changes.
>>>
>>>
>>> On Wed, 23 Jun 2021 at 15:02, Shailesh Yadav <
>>> shaileshyadav7...@gmail.com> wrote:
>>>
>>>> Okay use below in html
>>>> {{yourmodelnameinsmall_filter.form}}
>>>>
>>>> Thanks & Regards
>>>> Shailesh Yadav
>>>> +91-9920886044
>>>>
>>>>   [image: Linkedin]
>>>> <https://in.linkedin.com/in/shailesh-yadav-b7ab89110>
>>>>
>>>>
>>>>
>>>> On Wed, Jun 23, 2021 at 2:58 PM Aritra Ray  wrote:
>>>>
>>>>> This isn't working. When we are supplying a filter, the html is
>>>>> displaying all the products irrespective of the requested.
>>>>>
>>>>> On Wed, 23 Jun, 2021, 2:57 pm Shailesh Yadav, <
>>>>> shaileshyadav7...@gmail.com> wrote:
>>>>>
>>>>>> Can you help with what ERROR you are getting?
>>>>>>
>>>>>> Thanks & Regards
>>>>>> Shailesh Yadav
>>>>>> +91-9920886044
>>>>>>
>>>>>>   [image: Linkedin]
>>>>>> <https://in.linkedin.com/in/shailesh-yadav-b7ab89110>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Wed, Jun 23, 2021 at 2:25 PM Aritra Ray 
>>>>>> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>> I've been trying to introduce a filter system in my Django-ecommerce
>>>>>>> website and I've been struggling despite reading the documents, etc. I 
>>>>>>> am
>>>>>>> using 'django-filter' and below are filters.py, models.py, views.py and 
>>>>>>> the
>>>>>>> template. To check out the project, follow the github link:
>>>>>>> https://github.com/First-project-01/Django-ecommerce.
>>>>>>>
>>>>>>> Will be grateful if anyone can sort this out. Thanks in advance.
>>>>>>> Regards,
>>>>>>> Aritra
>>>>>>>
>>>>>>> #filters.py
>>>>>>> class ProductFilter(django_filters.FilterSet):
>>>>>>> price = django_filters.NumberFilter()
>>>>>>> price__gt = django_filters.NumberFilter(field_name='price'
>>>>>>> , lookup_expr='gt')
>>>>>>> price__lt = django_filters.NumberFilter(field_name='price'
>>>>>>> , lookup_expr='lt')
>>>>>>> class Meta:
>>>>>>> model = Items
>>>>>>> fields = ['size', 'availability']
>>>>>>>
>>>>>>> #views.py
>>>>>>> class Product(ListView):
>>>>>>> model = Items
>>>>>>> paginate_by = 6
>>>>>>> template_name = 'products.html'
>>>>>>> def get_context_data(self, **kwargs):
>>>>>>> context = super(Product, self).get_context_data(**kwargs)
>>>>>>> context['filter'] = ProductFilter(self.request.GET, queryset
>>>>>>> =self.get_queryset())
>>>>>>> return context
>>>>

Re: Need urgent help with filter system (django-filter) in Django

2021-06-23 Thread Aritra Ray
Like this?

class Product(ListView):
model = Items.objects.all()
paginate_by = 6
template_name = 'products.html'
result_filter = ProductFilter(request.GET, queryset=model)

On Wed, 23 Jun 2021 at 21:51, Shailesh Yadav 
wrote:

> Okay.
> If you using the Django filter then, please try like below in your views..
>
> abc_list = ModelName.objects.all()
> result_filter = ModelNameFilter(request.GET, queryset=abc_list)
>
> Thanks & Regards
> Shailesh Yadav
> +91-9920886044
>
>   [image: Linkedin] <https://in.linkedin.com/in/shailesh-yadav-b7ab89110>
>
>
>
> On Wed, Jun 23, 2021 at 9:13 PM Aritra Ray  wrote:
>
>> Sorry, it's not working. I tried items_filter.form but it didn't work.
>> Kindly check my views.py if that'll be of any help or require any changes.
>>
>>
>> On Wed, 23 Jun 2021 at 15:02, Shailesh Yadav 
>> wrote:
>>
>>> Okay use below in html
>>> {{yourmodelnameinsmall_filter.form}}
>>>
>>> Thanks & Regards
>>> Shailesh Yadav
>>> +91-9920886044
>>>
>>>   [image: Linkedin]
>>> <https://in.linkedin.com/in/shailesh-yadav-b7ab89110>
>>>
>>>
>>>
>>> On Wed, Jun 23, 2021 at 2:58 PM Aritra Ray  wrote:
>>>
>>>> This isn't working. When we are supplying a filter, the html is
>>>> displaying all the products irrespective of the requested.
>>>>
>>>> On Wed, 23 Jun, 2021, 2:57 pm Shailesh Yadav, <
>>>> shaileshyadav7...@gmail.com> wrote:
>>>>
>>>>> Can you help with what ERROR you are getting?
>>>>>
>>>>> Thanks & Regards
>>>>> Shailesh Yadav
>>>>> +91-9920886044
>>>>>
>>>>>   [image: Linkedin]
>>>>> <https://in.linkedin.com/in/shailesh-yadav-b7ab89110>
>>>>>
>>>>>
>>>>>
>>>>> On Wed, Jun 23, 2021 at 2:25 PM Aritra Ray 
>>>>> wrote:
>>>>>
>>>>>> Hi,
>>>>>> I've been trying to introduce a filter system in my Django-ecommerce
>>>>>> website and I've been struggling despite reading the documents, etc. I am
>>>>>> using 'django-filter' and below are filters.py, models.py, views.py and 
>>>>>> the
>>>>>> template. To check out the project, follow the github link:
>>>>>> https://github.com/First-project-01/Django-ecommerce.
>>>>>>
>>>>>> Will be grateful if anyone can sort this out. Thanks in advance.
>>>>>> Regards,
>>>>>> Aritra
>>>>>>
>>>>>> #filters.py
>>>>>> class ProductFilter(django_filters.FilterSet):
>>>>>> price = django_filters.NumberFilter()
>>>>>> price__gt = django_filters.NumberFilter(field_name='price'
>>>>>> , lookup_expr='gt')
>>>>>> price__lt = django_filters.NumberFilter(field_name='price'
>>>>>> , lookup_expr='lt')
>>>>>> class Meta:
>>>>>> model = Items
>>>>>> fields = ['size', 'availability']
>>>>>>
>>>>>> #views.py
>>>>>> class Product(ListView):
>>>>>> model = Items
>>>>>> paginate_by = 6
>>>>>> template_name = 'products.html'
>>>>>> def get_context_data(self, **kwargs):
>>>>>> context = super(Product, self).get_context_data(**kwargs)
>>>>>> context['filter'] = ProductFilter(self.request.GET, queryset=
>>>>>> self.get_queryset())
>>>>>> return context
>>>>>> #models.py
>>>>>> AVAILABILITY = (
>>>>>> ('Y', 'Available'),
>>>>>> ('N', 'Out of Stock'),
>>>>>> )
>>>>>>
>>>>>> SIZES = (
>>>>>> ('K', 'King - 108 x 120'),
>>>>>> ('Q', 'Queen - 90 x 108')
>>>>>> )
>>>>>> class Items(BaseModel):
>>>>>> title = models.CharField(max_length=100, null=True, blank=True)
>>>>>> price = models.FloatField(null=True, blank=True)
>>>>>&g

Re: Need urgent help with filter system (django-filter) in Django

2021-06-23 Thread Aritra Ray
Sorry, it's not working. I tried items_filter.form but it didn't work.
Kindly check my views.py if that'll be of any help or require any changes.


On Wed, 23 Jun 2021 at 15:02, Shailesh Yadav 
wrote:

> Okay use below in html
> {{yourmodelnameinsmall_filter.form}}
>
> Thanks & Regards
> Shailesh Yadav
> +91-9920886044
>
>   [image: Linkedin] <https://in.linkedin.com/in/shailesh-yadav-b7ab89110>
>
>
>
> On Wed, Jun 23, 2021 at 2:58 PM Aritra Ray  wrote:
>
>> This isn't working. When we are supplying a filter, the html is
>> displaying all the products irrespective of the requested.
>>
>> On Wed, 23 Jun, 2021, 2:57 pm Shailesh Yadav, <
>> shaileshyadav7...@gmail.com> wrote:
>>
>>> Can you help with what ERROR you are getting?
>>>
>>> Thanks & Regards
>>> Shailesh Yadav
>>> +91-9920886044
>>>
>>>   [image: Linkedin]
>>> <https://in.linkedin.com/in/shailesh-yadav-b7ab89110>
>>>
>>>
>>>
>>> On Wed, Jun 23, 2021 at 2:25 PM Aritra Ray  wrote:
>>>
>>>> Hi,
>>>> I've been trying to introduce a filter system in my Django-ecommerce
>>>> website and I've been struggling despite reading the documents, etc. I am
>>>> using 'django-filter' and below are filters.py, models.py, views.py and the
>>>> template. To check out the project, follow the github link:
>>>> https://github.com/First-project-01/Django-ecommerce.
>>>>
>>>> Will be grateful if anyone can sort this out. Thanks in advance.
>>>> Regards,
>>>> Aritra
>>>>
>>>> #filters.py
>>>> class ProductFilter(django_filters.FilterSet):
>>>> price = django_filters.NumberFilter()
>>>> price__gt = django_filters.NumberFilter(field_name='price'
>>>> , lookup_expr='gt')
>>>> price__lt = django_filters.NumberFilter(field_name='price'
>>>> , lookup_expr='lt')
>>>> class Meta:
>>>> model = Items
>>>> fields = ['size', 'availability']
>>>>
>>>> #views.py
>>>> class Product(ListView):
>>>> model = Items
>>>> paginate_by = 6
>>>> template_name = 'products.html'
>>>> def get_context_data(self, **kwargs):
>>>> context = super(Product, self).get_context_data(**kwargs)
>>>> context['filter'] = ProductFilter(self.request.GET, queryset=
>>>> self.get_queryset())
>>>> return context
>>>> #models.py
>>>> AVAILABILITY = (
>>>> ('Y', 'Available'),
>>>> ('N', 'Out of Stock'),
>>>> )
>>>>
>>>> SIZES = (
>>>> ('K', 'King - 108 x 120'),
>>>> ('Q', 'Queen - 90 x 108')
>>>> )
>>>> class Items(BaseModel):
>>>> title = models.CharField(max_length=100, null=True, blank=True)
>>>> price = models.FloatField(null=True, blank=True)
>>>> size = models.CharField(choices=SIZES, default=SIZES[0][0
>>>> ], max_length=1)
>>>> description = models.TextField(max_length=500)
>>>> availability = models.CharField(choices=AVAILABILITY, default=
>>>> AVAILABILITY[0][0], max_length=1)
>>>> ...
>>>>
>>>> #product-list.html
>>>> 
>>>>  
>>>> {{ filter.form| crispy }}
>>>> Search
>>>>  
>>>> 
>>>>
>>>> --
>>>> 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/CAFecadtwZG0%3DLwE989gsFkusgAnAGkvEspF3i5WC1-uWO6OOHw%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/CAFecadtwZG0%3DLwE989gsFkusgAnAGkvEspF3i5WC1-uWO6OOHw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" 

Re: Need urgent help with filter system (django-filter) in Django

2021-06-23 Thread Aritra Ray
Okay, will try and let you know.
Thank you for your response.

On Wed, 23 Jun, 2021, 3:02 pm Shailesh Yadav, 
wrote:

> Okay use below in html
> {{yourmodelnameinsmall_filter.form}}
>
> Thanks & Regards
> Shailesh Yadav
> +91-9920886044
>
>   [image: Linkedin] <https://in.linkedin.com/in/shailesh-yadav-b7ab89110>
>
>
>
> On Wed, Jun 23, 2021 at 2:58 PM Aritra Ray  wrote:
>
>> This isn't working. When we are supplying a filter, the html is
>> displaying all the products irrespective of the requested.
>>
>> On Wed, 23 Jun, 2021, 2:57 pm Shailesh Yadav, <
>> shaileshyadav7...@gmail.com> wrote:
>>
>>> Can you help with what ERROR you are getting?
>>>
>>> Thanks & Regards
>>> Shailesh Yadav
>>> +91-9920886044
>>>
>>>   [image: Linkedin]
>>> <https://in.linkedin.com/in/shailesh-yadav-b7ab89110>
>>>
>>>
>>>
>>> On Wed, Jun 23, 2021 at 2:25 PM Aritra Ray  wrote:
>>>
>>>> Hi,
>>>> I've been trying to introduce a filter system in my Django-ecommerce
>>>> website and I've been struggling despite reading the documents, etc. I am
>>>> using 'django-filter' and below are filters.py, models.py, views.py and the
>>>> template. To check out the project, follow the github link:
>>>> https://github.com/First-project-01/Django-ecommerce.
>>>>
>>>> Will be grateful if anyone can sort this out. Thanks in advance.
>>>> Regards,
>>>> Aritra
>>>>
>>>> #filters.py
>>>> class ProductFilter(django_filters.FilterSet):
>>>> price = django_filters.NumberFilter()
>>>> price__gt = django_filters.NumberFilter(field_name='price'
>>>> , lookup_expr='gt')
>>>> price__lt = django_filters.NumberFilter(field_name='price'
>>>> , lookup_expr='lt')
>>>> class Meta:
>>>> model = Items
>>>> fields = ['size', 'availability']
>>>>
>>>> #views.py
>>>> class Product(ListView):
>>>> model = Items
>>>> paginate_by = 6
>>>> template_name = 'products.html'
>>>> def get_context_data(self, **kwargs):
>>>> context = super(Product, self).get_context_data(**kwargs)
>>>> context['filter'] = ProductFilter(self.request.GET, queryset=
>>>> self.get_queryset())
>>>> return context
>>>> #models.py
>>>> AVAILABILITY = (
>>>> ('Y', 'Available'),
>>>> ('N', 'Out of Stock'),
>>>> )
>>>>
>>>> SIZES = (
>>>> ('K', 'King - 108 x 120'),
>>>> ('Q', 'Queen - 90 x 108')
>>>> )
>>>> class Items(BaseModel):
>>>> title = models.CharField(max_length=100, null=True, blank=True)
>>>> price = models.FloatField(null=True, blank=True)
>>>> size = models.CharField(choices=SIZES, default=SIZES[0][0
>>>> ], max_length=1)
>>>> description = models.TextField(max_length=500)
>>>> availability = models.CharField(choices=AVAILABILITY, default=
>>>> AVAILABILITY[0][0], max_length=1)
>>>> ...
>>>>
>>>> #product-list.html
>>>> 
>>>>  
>>>> {{ filter.form| crispy }}
>>>> Search
>>>>  
>>>> 
>>>>
>>>> --
>>>> 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/CAFecadtwZG0%3DLwE989gsFkusgAnAGkvEspF3i5WC1-uWO6OOHw%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/CAFecadtwZG0%3DLwE989gsFkusgAnAGkvEspF3i5WC1-uWO6OOHw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>>> 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 i

Re: Need urgent help with filter system (django-filter) in Django

2021-06-23 Thread Aritra Ray
This isn't working. When we are supplying a filter, the html is displaying
all the products irrespective of the requested.

On Wed, 23 Jun, 2021, 2:57 pm Shailesh Yadav, 
wrote:

> Can you help with what ERROR you are getting?
>
> Thanks & Regards
> Shailesh Yadav
> +91-9920886044
>
>   [image: Linkedin] <https://in.linkedin.com/in/shailesh-yadav-b7ab89110>
>
>
>
> On Wed, Jun 23, 2021 at 2:25 PM Aritra Ray  wrote:
>
>> Hi,
>> I've been trying to introduce a filter system in my Django-ecommerce
>> website and I've been struggling despite reading the documents, etc. I am
>> using 'django-filter' and below are filters.py, models.py, views.py and the
>> template. To check out the project, follow the github link:
>> https://github.com/First-project-01/Django-ecommerce.
>>
>> Will be grateful if anyone can sort this out. Thanks in advance.
>> Regards,
>> Aritra
>>
>> #filters.py
>> class ProductFilter(django_filters.FilterSet):
>> price = django_filters.NumberFilter()
>> price__gt = django_filters.NumberFilter(field_name='price'
>> , lookup_expr='gt')
>> price__lt = django_filters.NumberFilter(field_name='price'
>> , lookup_expr='lt')
>> class Meta:
>> model = Items
>> fields = ['size', 'availability']
>>
>> #views.py
>> class Product(ListView):
>> model = Items
>> paginate_by = 6
>> template_name = 'products.html'
>> def get_context_data(self, **kwargs):
>> context = super(Product, self).get_context_data(**kwargs)
>> context['filter'] = ProductFilter(self.request.GET, queryset=self
>> .get_queryset())
>> return context
>> #models.py
>> AVAILABILITY = (
>> ('Y', 'Available'),
>> ('N', 'Out of Stock'),
>> )
>>
>> SIZES = (
>> ('K', 'King - 108 x 120'),
>> ('Q', 'Queen - 90 x 108')
>> )
>> class Items(BaseModel):
>> title = models.CharField(max_length=100, null=True, blank=True)
>> price = models.FloatField(null=True, blank=True)
>> size = models.CharField(choices=SIZES, default=SIZES[0][0
>> ], max_length=1)
>> description = models.TextField(max_length=500)
>> availability = models.CharField(choices=AVAILABILITY, default=
>> AVAILABILITY[0][0], max_length=1)
>> ...
>>
>> #product-list.html
>> 
>>  
>> {{ filter.form| crispy }}
>> Search
>>  
>> 
>>
>> --
>> 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/CAFecadtwZG0%3DLwE989gsFkusgAnAGkvEspF3i5WC1-uWO6OOHw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAFecadtwZG0%3DLwE989gsFkusgAnAGkvEspF3i5WC1-uWO6OOHw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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/CAMQ-AEXsJ%2B19X3aO740%3DD%2BZUhcEYujh2FWScZDXCqM4cB0Bikg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAMQ-AEXsJ%2B19X3aO740%3DD%2BZUhcEYujh2FWScZDXCqM4cB0Bikg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAFecaduw28greFLXGqsTuit5JmCrzfHqawOU9HKvoojfXQLYtg%40mail.gmail.com.


Need urgent help with filter system (django-filter) in Django

2021-06-23 Thread Aritra Ray
Hi,
I've been trying to introduce a filter system in my Django-ecommerce
website and I've been struggling despite reading the documents, etc. I am
using 'django-filter' and below are filters.py, models.py, views.py and the
template. To check out the project, follow the github link:
https://github.com/First-project-01/Django-ecommerce.

Will be grateful if anyone can sort this out. Thanks in advance.
Regards,
Aritra

#filters.py
class ProductFilter(django_filters.FilterSet):
price = django_filters.NumberFilter()
price__gt = django_filters.NumberFilter(field_name='price', lookup_expr=
'gt')
price__lt = django_filters.NumberFilter(field_name='price', lookup_expr=
'lt')
class Meta:
model = Items
fields = ['size', 'availability']

#views.py
class Product(ListView):
model = Items
paginate_by = 6
template_name = 'products.html'
def get_context_data(self, **kwargs):
context = super(Product, self).get_context_data(**kwargs)
context['filter'] = ProductFilter(self.request.GET, queryset=self.
get_queryset())
return context
#models.py
AVAILABILITY = (
('Y', 'Available'),
('N', 'Out of Stock'),
)

SIZES = (
('K', 'King - 108 x 120'),
('Q', 'Queen - 90 x 108')
)
class Items(BaseModel):
title = models.CharField(max_length=100, null=True, blank=True)
price = models.FloatField(null=True, blank=True)
size = models.CharField(choices=SIZES, default=SIZES[0][0], max_length=1
)
description = models.TextField(max_length=500)
availability = models.CharField(choices=AVAILABILITY, default=
AVAILABILITY[0][0], max_length=1)
...

#product-list.html

 
{{ filter.form| crispy }}
Search
 


-- 
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/CAFecadtwZG0%3DLwE989gsFkusgAnAGkvEspF3i5WC1-uWO6OOHw%40mail.gmail.com.


Re: In need of urgent help regarding dynamic image display v

2021-06-23 Thread Aritra Ray
Thank you, it worked.


On Fri, 18 Jun 2021 at 00:08, Ayush Bisht  wrote:

> I think there is 2 method which you can do to get the work done. ...
>
> *1 : first one* .. you can declare a property decorator which just return
> the url of that image
>
>
>   class Banner(BaseModel):
> image = ResizedImageField(upload_to="banner", null=True,
> blank=True)
>
> @property
>   def get_image_url(self):
>   return str(self.image.url).replace(" ", "")
>
> and then you can simply access this function like normal attributes..
>
>  
> {% for banner in banners %}
> 
> {% endfor %}
>
> 
>
>
> *2 Method :  *you can create a   root path for static files as well
>
>
> STATIC_URL = '/static/'
> STATICFILES_DIRS = [os.path.join(BASE_DIR,'static')]
>
>
> now , with this root path I can access all the file belonging to that
> particular folder 
>
> folder structure ...
>
> * static
>*Banner
>  *banner1.jpg
>
>
>
> now u can simply access all the stuff ...
>
> .banner-item-01 {
> padding:300px 0px;
> background-size: cover;
> background-image: url('/static/Banner/banner1.jpg');
> background-repeat: no-repeat;
> background-position: center center;
> }
>
> On Thursday, June 17, 2021 at 4:11:11 AM UTC-7 arit...@gmail.com wrote:
>
>> Hi,
>> I've been building a Django E-commerce website and I'm facing this
>> problem.
>> I have created a Banner model which will take in images via
>> django.ResizedImage and then display it in the homepage. But I'm unable to
>> process them in CSS.
>> Kindly help me out.
>>
>> PS: I'll have to process it as background-image orelse when passed as
>>  in html, we're getting extra wrapped spaces which aren't needed.
>>
>> Below given are: views.py, models.py, index.html, css block.
>> Kindly help me out as it is urgent. Thank you for your support in advance.
>>
>> Regards,
>> Aritra
>>
>> class HomeView(ListView):
>> context_object_name = 'items'
>> template_name = "index.html"
>> queryset = Items.objects.all()
>>
>> def get_context_data(self, **kwargs):
>> context = super(HomeView, self).get_context_data(**kwargs)
>> context['banners'] = Banner.objects.all()
>> return context
>>
>> class Banner(BaseModel):
>> image = ResizedImageField(upload_to="banner", null=True, blank=True)
>>
>> 
>> 
>>   {% for banner in banners %}
>> > {{banner.image.url}}>
>>   {% endfor %}
>> 
>> 
>>
>>   .banner-item-01 {
>>padding:300px 0px;
>>background-size: cover;
>>background-image: url(var(--item));
>>background-repeat: no-repeat;
>>background-position: center center;
>> }
>>
>>
>> --
> 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/241a1f08-a093-4f3a-a01f-46e0a3e73ce1n%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/CAFecadu_Gjnr4nzRV_GEkfCpG%3DGWP%3DaNKoR0yZxqzqk8cE3MGQ%40mail.gmail.com.


Re: In need of help regarding HTML Submit button

2021-06-17 Thread Aritra Ray
Thank you, it worked!

On Tue, 15 Jun 2021 at 00:13, Nikeet NA  wrote:

> Change the type of button back to type='button" rather than type="submit"
>
> On Monday, 14 June 2021 at 22:39:27 UTC+5:30 arit...@gmail.com wrote:
>
>> Hi,
>> I'm facing an error with the Place Order button not working when the user
>> is choosing the default address. Kindly help me out in this regard and let
>> me know if any other files are needed.
>> Thank you in advance
>> Regards,
>> Aritra.
>>
>> class Address(BaseModel):
>> user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, 
>> blank=True)
>> address = models.CharField(max_length=500, null=True)
>> phone = models.CharField(max_length=10, null=False)
>> city = models.CharField(max_length=100, null=True)
>> state = models.CharField(max_length=100, null=True)
>> pincode = models.CharField(max_length=100, null=False)
>> default = models.BooleanField(default=False, null=True, blank=True)
>>
>> def __str__(self):
>> return self.user.username
>>
>> class Meta:
>> verbose_name_plural = 'Addresses'
>>
>> 
>>  {% if default_address %}
>>  
>>  > id="use_default">
>>  Use default 
>> shipping address: {{ default_address.address|truncatechars:40 }}
>>  
>>  {% endif %}
>> 
>> 
>>  
>>  > >Back
>>  
>>  Place 
>> Order
>> 
>>
>> class CheckoutView(View):
>> def get(self, *args, **kwargs):
>> try:
>> order = Cart.objects.get(user=self.request.user, ordered=False)
>> form = CheckoutForm()
>> context = {
>> 'form': form,
>> 'order': order,
>> }
>>
>> shipping_address_qs = Address.objects.filter(
>> user=self.request.user,
>> default=True
>> )
>> if shipping_address_qs.exists():
>> context.update(
>> {'default_address': shipping_address_qs[0]})
>> return render(self.request, "checkout.html", context)
>> except ObjectDoesNotExist:
>> messages.info(self.request, "You do not have an active order")
>> return redirect(reverse('store:cart-page'))
>>
>> def post(self, *args, **kwargs):
>> form = CheckoutForm(self.request.POST)
>> try:
>> order = Cart.objects.get(user=self.request.user, ordered=False)
>> if form.is_valid():
>> use_default = form.cleaned_data.get(
>> 'use_default')
>> if use_default:
>> print("Using the default shipping address")
>> address_qs = Address.objects.filter(
>> user=self.request.user,
>> default=True
>> )
>> if address_qs.exists():
>> shipping_address = address_qs[0]
>> order.shipping_address = shipping_address
>> order.save()
>> else:
>> messages.info(self.request, "No default shipping 
>> address available")
>> return redirect('store:cart-page')
>> else:
>> address = form.cleaned_data.get('address')
>> pincode = form.cleaned_data.get('zip')
>> phone = form.cleaned_data.get('phone')
>> city = form.cleaned_data.get('city')
>> state = form.cleaned_data.get('state')
>> if form.is_valid():
>> shipping_address = Address(
>> user=self.request.user,
>> address=address,
>> pincode=pincode,
>> state=state,
>> city=city,
>> phone=phone
>> )
>> shipping_address.save()
>> order.shipping_address = shipping_address
>> order.save()
>>
>> set_default = form.cleaned_data.get(
>> 'set_default')
>> if set_default:
>> shipping_address.default = True
>> shipping_address.save()
>>
>> else:
>> messages.info(self.request, "Please fill in the 
>> required shipping address fields")
>> except ObjectDoesNotExist:
>> messages.warning(self.request, "You do not have an active order")
>> return redirect(reverse('store:cart-page'))
>> return redirect(reverse('store:payment-page'))
>>
>> --
> 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

In need of urgent help regarding dynamic image display v

2021-06-17 Thread Aritra Ray
Hi,
I've been building a Django E-commerce website and I'm facing this problem.
I have created a Banner model which will take in images via
django.ResizedImage and then display it in the homepage. But I'm unable to
process them in CSS.
Kindly help me out.

PS: I'll have to process it as background-image orelse when passed as 
in html, we're getting extra wrapped spaces which aren't needed.

Below given are: views.py, models.py, index.html, css block.
Kindly help me out as it is urgent. Thank you for your support in advance.

Regards,
Aritra

class HomeView(ListView):
context_object_name = 'items'
template_name = "index.html"
queryset = Items.objects.all()

def get_context_data(self, **kwargs):
context = super(HomeView, self).get_context_data(**kwargs)
context['banners'] = Banner.objects.all()
return context

class Banner(BaseModel):
image = ResizedImageField(upload_to="banner", null=True, blank=True)



  {% for banner in banners %}

  {% endfor %}



  .banner-item-01 {
   padding:300px 0px;
   background-size: cover;
   background-image: url(var(--item));
   background-repeat: no-repeat;
   background-position: center center;
}

-- 
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/CAFecadvDi5V4%3DuetJhSZo1FSyOyGsvLH_s7K%2Bhc-vMLU%2BHLBpA%40mail.gmail.com.


Re: location based web app with django and geodjango

2021-06-15 Thread Aritra Ray
Hello,
Register your app in setting.py-> INSTALLED_APPS like
'appname.apps.appnameConfig' from your apps.py. Alternatively, you can
write 'app_name' instead of the whole sentence.

Regards,
Aritra.

On Tue, 15 Jun 2021 at 05:46, Stathis Angelou  wrote:

> good evening all,
>
> I have started building a webapp using python, django and linux, but i'm
> afraid the app does not appear under admin tab in 127.0.0.1:8000/admin
> I am sure I am missing something, attached is my code
>
> Thank you in advance
> Stathis
>
> --
> 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/f96dec5e-7f33-43d5-b48b-283460668f5an%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/CAFecadsoLmb6WPRyZG1WaMu54a0_jg15zQBE70XvLBzoznysTw%40mail.gmail.com.


In need of help regarding HTML Submit button

2021-06-14 Thread Aritra Ray
Hi,
I'm facing an error with the Place Order button not working when the user
is choosing the default address. Kindly help me out in this regard and let
me know if any other files are needed.
Thank you in advance
Regards,
Aritra.

class Address(BaseModel):
user = models.ForeignKey(User, on_delete=models.SET_NULL,
null=True, blank=True)
address = models.CharField(max_length=500, null=True)
phone = models.CharField(max_length=10, null=False)
city = models.CharField(max_length=100, null=True)
state = models.CharField(max_length=100, null=True)
pincode = models.CharField(max_length=100, null=False)
default = models.BooleanField(default=False, null=True, blank=True)

def __str__(self):
return self.user.username

class Meta:
verbose_name_plural = 'Addresses'


 {% if default_address %}
 
 
 Use
default shipping address: {{ default_address.address|truncatechars:40
}}
 
 {% endif %}


 
 Back
 
 Place Order


class CheckoutView(View):
def get(self, *args, **kwargs):
try:
order = Cart.objects.get(user=self.request.user, ordered=False)
form = CheckoutForm()
context = {
'form': form,
'order': order,
}

shipping_address_qs = Address.objects.filter(
user=self.request.user,
default=True
)
if shipping_address_qs.exists():
context.update(
{'default_address': shipping_address_qs[0]})
return render(self.request, "checkout.html", context)
except ObjectDoesNotExist:
messages.info(self.request, "You do not have an active order")
return redirect(reverse('store:cart-page'))

def post(self, *args, **kwargs):
form = CheckoutForm(self.request.POST)
try:
order = Cart.objects.get(user=self.request.user, ordered=False)
if form.is_valid():
use_default = form.cleaned_data.get(
'use_default')
if use_default:
print("Using the default shipping address")
address_qs = Address.objects.filter(
user=self.request.user,
default=True
)
if address_qs.exists():
shipping_address = address_qs[0]
order.shipping_address = shipping_address
order.save()
else:
messages.info(self.request, "No default
shipping address available")
return redirect('store:cart-page')
else:
address = form.cleaned_data.get('address')
pincode = form.cleaned_data.get('zip')
phone = form.cleaned_data.get('phone')
city = form.cleaned_data.get('city')
state = form.cleaned_data.get('state')
if form.is_valid():
shipping_address = Address(
user=self.request.user,
address=address,
pincode=pincode,
state=state,
city=city,
phone=phone
)
shipping_address.save()
order.shipping_address = shipping_address
order.save()

set_default = form.cleaned_data.get(
'set_default')
if set_default:
shipping_address.default = True
shipping_address.save()

else:
messages.info(self.request, "Please fill in
the required shipping address fields")
except ObjectDoesNotExist:
messages.warning(self.request, "You do not have an active order")
return redirect(reverse('store:cart-page'))
return redirect(reverse('store:payment-page'))

-- 
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/CAFecadue4NPnM7K12gr1R8PhCOgk9cX0P0JmOTWD%2BD0UhB%3DaMg%40mail.gmail.com.


Re: In immediate help of a long time pending request, kindly help.

2021-06-04 Thread Aritra Ray
Hello

I tried this but I'm still seeing the list of cart items. Can you tell me
where I am going wrong?

Regards,
Aritra

On Tue, 1 Jun 2021 at 21:23, Joel Tanko <7thog...@gmail.com> wrote:

> If you want to show the items relative to the currently logged in user,
> try adding this option => limit_choices_to={'user' : 'user'}, to your items
> field in models.py
>
>
>
> On Tuesday, 1 June 2021, Aritra Ray  wrote:
>
>> Right, thank you so much.
>>
>> Regards.
>>
>> On Tue, 1 Jun, 2021, 8:27 pm oba stephen,  wrote:
>>
>>> You should return this if you want to redirect to cart;
>>>
>>> return redirect(reverse("store:cart-page", kwargs={"id": >> cart>}))
>>>
>>> Best regards
>>>
>>> Stephen Oba
>>>
>>> On Tue, Jun 1, 2021, 3:27 PM Aritra Ray  wrote:
>>>
>>>> Sure, here's the file.
>>>>
>>>> [image: 2021-06-01 (6).png]
>>>>
>>>> Regards,
>>>> Aritra.
>>>>
>>>> On Tue, 1 Jun 2021 at 19:45, oba stephen  wrote:
>>>>
>>>>> Can I see your urls.py?
>>>>>
>>>>> Best regards
>>>>>
>>>>> Stephen Oba
>>>>>
>>>>> On Tue, Jun 1, 2021, 3:05 PM Aritra Ray  wrote:
>>>>>
>>>>>> Oh, okay. I was unaware of that. Although, my cart page is getting
>>>>>> redirected back to home page. Can you spot any mistake in the provided
>>>>>> screenshots?
>>>>>> Also, can you please guide on how to redirect a function to the
>>>>>> previously visited page? Like add-to-cart should redirect to either
>>>>>> products page or cart page itself depending on which page the user called
>>>>>> it from.
>>>>>>
>>>>>> On Tue, 1 Jun, 2021, 6:37 pm oba stephen, 
>>>>>> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I don't think you have an error here. Although I haven't looked at
>>>>>>> the code, but from your django admin page I can see that none of those
>>>>>>> items are selected.
>>>>>>>
>>>>>>> If you run a query from your terminal, you would notice that the
>>>>>>> items would return as empty.
>>>>>>>
>>>>>>> When you create a many to many relationship in django, all objects
>>>>>>> on that related model would display this way.
>>>>>>>
>>>>>>> What is the difference between different carts?  The difference is,
>>>>>>> the items would be selected or highlighted in a cart they belong to.
>>>>>>>
>>>>>>> Regards
>>>>>>>
>>>>>>> Best regards
>>>>>>>
>>>>>>> Stephen Oba
>>>>>>>
>>>>>>> On Tue, Jun 1, 2021, 1:52 PM Aritra Ray  wrote:
>>>>>>>
>>>>>>>>
>>>>>>>> Hello,
>>>>>>>> This is Aritra reposting the same error. I have a problem regarding
>>>>>>>> an E-commerce Django website where the cart model on the admin page is
>>>>>>>> showing the items added to cart by one user to all other users as well.
>>>>>>>> I have a Profile model and a Cart model attached below. The
>>>>>>>> views.py has been attached too. Kindly comment back if anything else is
>>>>>>>> needed.
>>>>>>>> Thanks in advance.
>>>>>>>>
>>>>>>>>
>>>>>>>> Regards,
>>>>>>>> Aritra
>>>>>>>>
>>>>>>>> Error:
>>>>>>>>
>>>>>>>> [image: 2021-06-01 (4).png]
>>>>>>>>
>>>>>>>> Views.py
>>>>>>>>
>>>>>>>> [image: 2021-06-01 (1).png][image: 2021-06-01 (5).png]
>>>>>>>>
>>>>>>>> Models.py
>>>>>>>>
>>>>>>>> [image: 2021-06-01 (2).png][image: 2021-06-01 (3).png]
>>>>>>>>
>>>>>>>> --
>>>>>>>> You received this message b

Re: In immediate help of a long time pending request, kindly help.

2021-06-01 Thread Aritra Ray
Right, will try and let you know.

On Tue, 1 Jun, 2021, 9:23 pm Joel Tanko, <7thog...@gmail.com> wrote:

> If you want to show the items relative to the currently logged in user,
> try adding this option => limit_choices_to={'user' : 'user'}, to your items
> field in models.py
>
>
>
> On Tuesday, 1 June 2021, Aritra Ray  wrote:
>
>> Right, thank you so much.
>>
>> Regards.
>>
>> On Tue, 1 Jun, 2021, 8:27 pm oba stephen,  wrote:
>>
>>> You should return this if you want to redirect to cart;
>>>
>>> return redirect(reverse("store:cart-page", kwargs={"id": >> cart>}))
>>>
>>> Best regards
>>>
>>> Stephen Oba
>>>
>>> On Tue, Jun 1, 2021, 3:27 PM Aritra Ray  wrote:
>>>
>>>> Sure, here's the file.
>>>>
>>>> [image: 2021-06-01 (6).png]
>>>>
>>>> Regards,
>>>> Aritra.
>>>>
>>>> On Tue, 1 Jun 2021 at 19:45, oba stephen  wrote:
>>>>
>>>>> Can I see your urls.py?
>>>>>
>>>>> Best regards
>>>>>
>>>>> Stephen Oba
>>>>>
>>>>> On Tue, Jun 1, 2021, 3:05 PM Aritra Ray  wrote:
>>>>>
>>>>>> Oh, okay. I was unaware of that. Although, my cart page is getting
>>>>>> redirected back to home page. Can you spot any mistake in the provided
>>>>>> screenshots?
>>>>>> Also, can you please guide on how to redirect a function to the
>>>>>> previously visited page? Like add-to-cart should redirect to either
>>>>>> products page or cart page itself depending on which page the user called
>>>>>> it from.
>>>>>>
>>>>>> On Tue, 1 Jun, 2021, 6:37 pm oba stephen, 
>>>>>> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I don't think you have an error here. Although I haven't looked at
>>>>>>> the code, but from your django admin page I can see that none of those
>>>>>>> items are selected.
>>>>>>>
>>>>>>> If you run a query from your terminal, you would notice that the
>>>>>>> items would return as empty.
>>>>>>>
>>>>>>> When you create a many to many relationship in django, all objects
>>>>>>> on that related model would display this way.
>>>>>>>
>>>>>>> What is the difference between different carts?  The difference is,
>>>>>>> the items would be selected or highlighted in a cart they belong to.
>>>>>>>
>>>>>>> Regards
>>>>>>>
>>>>>>> Best regards
>>>>>>>
>>>>>>> Stephen Oba
>>>>>>>
>>>>>>> On Tue, Jun 1, 2021, 1:52 PM Aritra Ray  wrote:
>>>>>>>
>>>>>>>>
>>>>>>>> Hello,
>>>>>>>> This is Aritra reposting the same error. I have a problem regarding
>>>>>>>> an E-commerce Django website where the cart model on the admin page is
>>>>>>>> showing the items added to cart by one user to all other users as well.
>>>>>>>> I have a Profile model and a Cart model attached below. The
>>>>>>>> views.py has been attached too. Kindly comment back if anything else is
>>>>>>>> needed.
>>>>>>>> Thanks in advance.
>>>>>>>>
>>>>>>>>
>>>>>>>> Regards,
>>>>>>>> Aritra
>>>>>>>>
>>>>>>>> Error:
>>>>>>>>
>>>>>>>> [image: 2021-06-01 (4).png]
>>>>>>>>
>>>>>>>> Views.py
>>>>>>>>
>>>>>>>> [image: 2021-06-01 (1).png][image: 2021-06-01 (5).png]
>>>>>>>>
>>>>>>>> Models.py
>>>>>>>>
>>>>>>>> [image: 2021-06-01 (2).png][image: 2021-06-01 (3).png]
>>>>>>>>
>>>>>>>> --
>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>> Groups "Django users"

Re: In need of immediate help from Django community

2021-05-24 Thread Aritra Ray
Thank you for your response. It worked out perfectly.

On Tue, 25 May, 2021, 4:39 am Kelvin Sajere,  wrote:

> Import the User model in your forms.py and use it instead of Profile. As
> the error clearly states, the Profile model does not have a username field.
> Django actually recommends using the AbstractUser, or the AbstractBaseUser
> to extend the default User model if you wish to create something like a
> profile.
>
> On Mon, May 24, 2021 at 9:31 PM Omkar Parab  wrote:
>
>> Error is in forms.py file.
>>
>> "model = User" not profile.
>>
>> Default "User" model comes with username, email filed.
>>
>> Why you're creating another email field in the Profile model?
>>
>> Just fetch it using {{ user.email }}
>>
>>
>> On Tue, May 25, 2021, 1:38 AM Aritra Ray  wrote:
>>
>>> Hi,
>>>
>>> I've been facing a problem recently in creating a Django Profile model
>>> for an E-commerce website.
>>> Error: FieldError(message) django.core.exceptions.FieldError: Unknown
>>> field(s) (username) specified for Profile
>>> Kindly help me out if possible. The screenshots have been attached below
>>> and the github link for the project has been provided.
>>>
>>> Link: https://github.com/First-project-01/Django-ecommerce (Check out
>>> the 'changes' branch)
>>>
>>> Regards,
>>> Aritra
>>>
>>> --
>>> 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/CAFecadvxBCa6w02%3DZ887%2BnaEdY-R6B9%2BVVFzVW5zYvkt1gA2hg%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAFecadvxBCa6w02%3DZ887%2BnaEdY-R6B9%2BVVFzVW5zYvkt1gA2hg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> 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/CAJY8mfzFT-GqqZ0YvdLKH9gKcTAv%2B1srG9973pXYfA5f_qVA7w%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAJY8mfzFT-GqqZ0YvdLKH9gKcTAv%2B1srG9973pXYfA5f_qVA7w%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> --
> KeLLs
>
> --
> 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/CADYqDX1dm1Y-T89W9%3DyZQs1bH04eNUj5qcCpwieOSDoY%2BDy9Kg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CADYqDX1dm1Y-T89W9%3DyZQs1bH04eNUj5qcCpwieOSDoY%2BDy9Kg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAFecadt6r70L7v78%3Dy63MfyNdFLYJwfKJaP2BeuxO-%3Dgp9fmMg%40mail.gmail.com.