Re: Django relationships

2021-06-25 Thread David Crandell
the way I manage my inventory system is keep all devices in one table and 
flag assigned or unassigned like you're trying to do. Each is then assigned 
to a locationID.

On Thursday, June 24, 2021 at 4:24:22 PM UTC-5 murad...@gmail.com wrote:

> Hi Django developers,
> i am new in Python,
>
> i want to develop a simple app stock management.
>
> can you give me a brief idea how to add device to stock if it hasnt 
> assigned to employee
>
> i have below models
>
> class Device(models.Model):
> STATUS = ( 
> ('in use', in use),
>  ('available', 'available')
> )
> status =models.Charfield(choices=STATUS, max_length=32)
> name = models.Charfield(max_length=32)
>
>
> class Employee(models.Model):
> name = models.Charfield(max_length=32)
>
>
> class Assign(models.Model):
>notebook =  models.ForeignKey(' Device  ', on_delete=models.CASCADE)
> subscriber = models.ForeignKey('Employee', on_delete=models.CASCADE)
>
>
> class Stock(models.Model):
> pass
>
>
> I want if device is already has subscribers then aply its status to 
> 'in_use' and remove it from Stock model and if device status is available 
> then move it to Stock
>

-- 
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/774cd9f0-cb85-4c4a-a47c-239cc8eaef5fn%40googlegroups.com.


Re: Django relationships

2021-06-25 Thread David Crandell
You'll have to define "in_use" as a models.BooleanField()

I would have base class Devices

and have Stock and Assign inherit from those

On Thursday, June 24, 2021 at 4:24:22 PM UTC-5 murad...@gmail.com wrote:

> Hi Django developers,
> i am new in Python,
>
> i want to develop a simple app stock management.
>
> can you give me a brief idea how to add device to stock if it hasnt 
> assigned to employee
>
> i have below models
>
> class Device(models.Model):
> STATUS = ( 
> ('in use', in use),
>  ('available', 'available')
> )
> status =models.Charfield(choices=STATUS, max_length=32)
> name = models.Charfield(max_length=32)
>
>
> class Employee(models.Model):
> name = models.Charfield(max_length=32)
>
>
> class Assign(models.Model):
>notebook =  models.ForeignKey(' Device  ', on_delete=models.CASCADE)
> subscriber = models.ForeignKey('Employee', on_delete=models.CASCADE)
>
>
> class Stock(models.Model):
> pass
>
>
> I want if device is already has subscribers then aply its status to 
> 'in_use' and remove it from Stock model and if device status is available 
> then move it to Stock
>

-- 
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/c2d782c8-0a8c-41ac-b471-8075aab01e14n%40googlegroups.com.


Re: DRF | Django | Up votes | Down Votes

2021-06-25 Thread DJANGO DEVELOPER
Hi Mr Mike.
Can you please share you knowledge here to help me?

On Sat, Jun 26, 2021 at 6:54 AM Mike Dewhirst  wrote:

> HE lmbo pop l9m6oo9k
>
>
>
> --
> (Unsigned mail from my phone)
>
>
>
>  Original message 
> From: DJANGO DEVELOPER 
> Date: 26/6/21 04:38 (GMT+10:00)
> To: Django users 
> Subject: Re: DRF | Django | Up votes | Down Votes
>
> Ryan Thank you so much. I will give it try. and let you know about the
> results
>
> On Fri, Jun 25, 2021 at 8:59 PM Ryan Nowakowski 
> wrote:
>
>> On Thu, Jun 24, 2021 at 07:15:09AM -0700, DJANGO DEVELOPER wrote:
>> > Hi Django experts.
>> > I am building a Django, DRF based mobile app and I want to have
>> > functionality of up votes and down votes for posts that user will post.
>> > So what I want to say here that, if an user upvotes a post then it
>> should
>> > be get higher ranks as quora questions do. and if there are more down
>> votes
>> > than up votes then a post should be moved down ward rather than going
>> up.
>> > I have applied a logic already here and shared the screenshots as well.
>> but
>> > I am sure that there is a better logic or solution for this problem.
>>
>> Do you want your users to be able to change or delete their vote?
>> In that case, you'll need to keep track of who voted what. Maybe create
>> a model like this:
>>
>> class VoteQuerySet(models.QuerySet):
>>
>> def down(self):
>> """Return only the down votes"""
>> return self.filter(value__lt=0)
>>
>> def up(self):
>> """Return only the up votes"""
>> return self.filter(value__gt=0)
>>
>> def down_total(self):
>> """Return the down vote total as a negative number"""
>> return self.down().aggregate(Sum('value'))['value__sum']
>>
>> def up_total(self):
>> """Return the up vote total as a positive number"""
>> return self.up().aggregate(Sum('value'))['value__sum']
>>
>> def total(self):
>> """Return the total of all up and down votes"""
>> return self.aggregate(Sum('value'))['value__sum']
>>
>>
>> class Vote(models.Model):
>> """A user's up or down vote for a post
>>
>> "value" should be -1 for a down vote and 1 for an up vote
>>
>> """
>> user = models.ForeignKey(User, on_delete=models.CASCADE)
>> post = models.ForeignKey(Post, on_delete=models.CASCADE)
>> value = models.SmallIntegerField()
>>
>> objects = VoteQuerySet.as_manager()
>>
>> class Meta:
>> unique_together = (user, post)
>>
>> def vote_up(self):
>> self.value = 1
>>
>> def vote_down(self):
>> self.value = -1
>>
>>
>> You can then vote like this:
>>
>> vote = Vote(user=user, post=post)
>> vote.vote_up()  # or vote.vote_down()
>> vote.save()
>>
>>
>> Here's a post's up vote count:
>>
>> post.vote_set.up_total()
>>
>>
>> You can change a user's vote like this:
>>
>> vote = user.vote_set.get(post=post)
>> vote.vote_down()
>>
>> ... or delete:
>>
>> vote.delete()
>>
>>
>> Any finally, here's how you can sort your posts:
>>
>>
>> Post.objects.all().annotate(vote_total=Sum('vote__value')).order_by('-vote_total')
>>
>>
>> Caveat: code untested
>>
>>
>>
>> Hope this helps!
>>
>> Ryan
>>
>> --
>> 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/20210625155946.GC16290%40fattuba.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/CAKPY9pnmqN46L93O38djOKdCKP3Vp%2B_vHLetC479zDxuOU6x_g%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/60d688c8.1c69fb81.bbb11.3564SMTPIN_ADDED_MISSING%40gmr-mx.google.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving email

Re: DRF | Django | Up votes | Down Votes

2021-06-25 Thread Mike Dewhirst
HE lmbo pop l9m6oo9k--(Unsigned mail from my phone)
 Original message From: DJANGO DEVELOPER 
 Date: 26/6/21  04:38  (GMT+10:00) To: Django users 
 Subject: Re: DRF | Django | Up votes | Down 
Votes Ryan Thank you so much. I will give it try. and let you know about the 
resultsOn Fri, Jun 25, 2021 at 8:59 PM Ryan Nowakowski  
wrote:On Thu, Jun 24, 2021 at 07:15:09AM -0700, DJANGO DEVELOPER wrote:
> Hi Django experts.
> I am building a Django, DRF based mobile app and I want to have 
> functionality of up votes and down votes for posts that user will post.
> So what I want to say here that, if an user upvotes a post then it should 
> be get higher ranks as quora questions do. and if there are more down votes 
> than up votes then a post should be moved down ward rather than going up.
> I have applied a logic already here and shared the screenshots as well. but 
> I am sure that there is a better logic or solution for this problem.

Do you want your users to be able to change or delete their vote?
In that case, you'll need to keep track of who voted what. Maybe create
a model like this:

    class VoteQuerySet(models.QuerySet):

        def down(self):
            """Return only the down votes"""
            return self.filter(value__lt=0)

        def up(self):
            """Return only the up votes"""
            return self.filter(value__gt=0)

        def down_total(self):
            """Return the down vote total as a negative number"""
            return self.down().aggregate(Sum('value'))['value__sum']

        def up_total(self):
            """Return the up vote total as a positive number"""
            return self.up().aggregate(Sum('value'))['value__sum']

        def total(self):
            """Return the total of all up and down votes"""
            return self.aggregate(Sum('value'))['value__sum']


    class Vote(models.Model):
        """A user's up or down vote for a post

        "value" should be -1 for a down vote and 1 for an up vote

        """
        user = models.ForeignKey(User, on_delete=models.CASCADE)
        post = models.ForeignKey(Post, on_delete=models.CASCADE)
        value = models.SmallIntegerField()

        objects = VoteQuerySet.as_manager()

        class Meta:
            unique_together = (user, post)

        def vote_up(self):
            self.value = 1

        def vote_down(self):
            self.value = -1


You can then vote like this:

    vote = Vote(user=user, post=post)
    vote.vote_up()  # or vote.vote_down()
    vote.save()


Here's a post's up vote count:

    post.vote_set.up_total()


You can change a user's vote like this:

    vote = user.vote_set.get(post=post)
    vote.vote_down()

... or delete:

    vote.delete()


Any finally, here's how you can sort your posts:

    
Post.objects.all().annotate(vote_total=Sum('vote__value')).order_by('-vote_total')


Caveat: code untested



Hope this helps!

Ryan

-- 
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/20210625155946.GC16290%40fattuba.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/CAKPY9pnmqN46L93O38djOKdCKP3Vp%2B_vHLetC479zDxuOU6x_g%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/60d688c8.1c69fb81.bbb11.3564SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


how does Django handle outbound requests?

2021-06-25 Thread Glenn Rutkowski
Can anyone point me in the right direction?  We are using Django as an API 
Endpoint that accepts a request and then repackages it and sends it to an 
external service and waits for a response.  I'm interested in the external 
call and how it is handled.  If it times out or takes forever, what it the 
effect on the Django server?  Am I blocking any other execution from 
happening while waiting for the response?  

>From what I have read it seems as if the best idea is to pass the job off 
to a queue and then check for job status alerts or updates.  If I have to 
rethink this - I'd rather do it now. 

Thanks for reading, looking forward to responses!

-g



-- 
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/20152777-2847-4b94-974c-27be70ee04can%40googlegroups.com.


Re: DRF | Django | Up votes | Down Votes

2021-06-25 Thread DJANGO DEVELOPER
Ryan Thank you so much. I will give it try. and let you know about the
results

On Fri, Jun 25, 2021 at 8:59 PM Ryan Nowakowski  wrote:

> On Thu, Jun 24, 2021 at 07:15:09AM -0700, DJANGO DEVELOPER wrote:
> > Hi Django experts.
> > I am building a Django, DRF based mobile app and I want to have
> > functionality of up votes and down votes for posts that user will post.
> > So what I want to say here that, if an user upvotes a post then it
> should
> > be get higher ranks as quora questions do. and if there are more down
> votes
> > than up votes then a post should be moved down ward rather than going up.
> > I have applied a logic already here and shared the screenshots as well.
> but
> > I am sure that there is a better logic or solution for this problem.
>
> Do you want your users to be able to change or delete their vote?
> In that case, you'll need to keep track of who voted what. Maybe create
> a model like this:
>
> class VoteQuerySet(models.QuerySet):
>
> def down(self):
> """Return only the down votes"""
> return self.filter(value__lt=0)
>
> def up(self):
> """Return only the up votes"""
> return self.filter(value__gt=0)
>
> def down_total(self):
> """Return the down vote total as a negative number"""
> return self.down().aggregate(Sum('value'))['value__sum']
>
> def up_total(self):
> """Return the up vote total as a positive number"""
> return self.up().aggregate(Sum('value'))['value__sum']
>
> def total(self):
> """Return the total of all up and down votes"""
> return self.aggregate(Sum('value'))['value__sum']
>
>
> class Vote(models.Model):
> """A user's up or down vote for a post
>
> "value" should be -1 for a down vote and 1 for an up vote
>
> """
> user = models.ForeignKey(User, on_delete=models.CASCADE)
> post = models.ForeignKey(Post, on_delete=models.CASCADE)
> value = models.SmallIntegerField()
>
> objects = VoteQuerySet.as_manager()
>
> class Meta:
> unique_together = (user, post)
>
> def vote_up(self):
> self.value = 1
>
> def vote_down(self):
> self.value = -1
>
>
> You can then vote like this:
>
> vote = Vote(user=user, post=post)
> vote.vote_up()  # or vote.vote_down()
> vote.save()
>
>
> Here's a post's up vote count:
>
> post.vote_set.up_total()
>
>
> You can change a user's vote like this:
>
> vote = user.vote_set.get(post=post)
> vote.vote_down()
>
> ... or delete:
>
> vote.delete()
>
>
> Any finally, here's how you can sort your posts:
>
>
> Post.objects.all().annotate(vote_total=Sum('vote__value')).order_by('-vote_total')
>
>
> Caveat: code untested
>
>
>
> Hope this helps!
>
> Ryan
>
> --
> 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/20210625155946.GC16290%40fattuba.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/CAKPY9pnmqN46L93O38djOKdCKP3Vp%2B_vHLetC479zDxuOU6x_g%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
>> 
>> .
>>
> --
> 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
> 
> .
>

-- 
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.


Re: DRF | Django | Up votes | Down Votes

2021-06-25 Thread Ryan Nowakowski
On Thu, Jun 24, 2021 at 07:15:09AM -0700, DJANGO DEVELOPER wrote:
> Hi Django experts.
> I am building a Django, DRF based mobile app and I want to have 
> functionality of up votes and down votes for posts that user will post.
> So what I want to say here that, if an user upvotes a post then it should 
> be get higher ranks as quora questions do. and if there are more down votes 
> than up votes then a post should be moved down ward rather than going up.
> I have applied a logic already here and shared the screenshots as well. but 
> I am sure that there is a better logic or solution for this problem.

Do you want your users to be able to change or delete their vote?
In that case, you'll need to keep track of who voted what. Maybe create
a model like this:

class VoteQuerySet(models.QuerySet):

def down(self):
"""Return only the down votes"""
return self.filter(value__lt=0)

def up(self):
"""Return only the up votes"""
return self.filter(value__gt=0)

def down_total(self):
"""Return the down vote total as a negative number"""
return self.down().aggregate(Sum('value'))['value__sum']

def up_total(self):
"""Return the up vote total as a positive number"""
return self.up().aggregate(Sum('value'))['value__sum']

def total(self):
"""Return the total of all up and down votes"""
return self.aggregate(Sum('value'))['value__sum']


class Vote(models.Model):
"""A user's up or down vote for a post

"value" should be -1 for a down vote and 1 for an up vote

"""
user = models.ForeignKey(User, on_delete=models.CASCADE)
post = models.ForeignKey(Post, on_delete=models.CASCADE)
value = models.SmallIntegerField()

objects = VoteQuerySet.as_manager()

class Meta:
unique_together = (user, post)

def vote_up(self):
self.value = 1

def vote_down(self):
self.value = -1


You can then vote like this:

vote = Vote(user=user, post=post)
vote.vote_up()  # or vote.vote_down()
vote.save()


Here's a post's up vote count:

post.vote_set.up_total()


You can change a user's vote like this:

vote = user.vote_set.get(post=post)
vote.vote_down()

... or delete:

vote.delete()


Any finally, here's how you can sort your posts:


Post.objects.all().annotate(vote_total=Sum('vote__value')).order_by('-vote_total')


Caveat: code untested



Hope this helps!

Ryan

-- 
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/20210625155946.GC16290%40fattuba.com.


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

2021-06-25 Thread Symaxx
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
> 
> .
>

-- 
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.


Re: Partner

2021-06-25 Thread Symaxx
Hi there, I'm interested in helping with this you can email me at
bukhosizimc...@gmail.com or bukh...@symaxx.com

On Fri, Jun 25, 2021 at 12:33 PM Bukhosi Moyo  wrote:

> Hi there, I'm interested in helping with this you can email me at
> bukhosizimc...@gmail.com or bukh...@symaxx.com
>
> On Wed, Jun 23, 2021 at 5:19 PM ericki...@gmail.com <
> erickimosa...@gmail.com> wrote:
>
>> hello guys am looking for any one good at Django and DRF i have couple of
>> personal projects which needs this tech spec am not good at them if any one
>> is interested plz i will be grateful
>>
>> --
>> 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/b21836a0-1b17-4467-9b3c-5aba128e2c23n%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/CANPYDAs5NPZC%3DqG%2BsY71qJiLSk8V%2BD1vo1ibqPpbcFWGX%3DGwxA%40mail.gmail.com.


Re: i am trying to learn django from django documentation but i am getting an error message in the first part of the documentation

2021-06-25 Thread Symaxx
I started learning Django from the documentation but it was very hard for
me and it took me a very long time to grasp the concept

I suggest you try using books by w.s vincent http://wsvincent.com/books/ these
are the best for me and them help you stay engaged

On Wed, Jun 23, 2021 at 5:19 PM vatsal narula 
wrote:

> Using the URLconf defined in blogs.urls, Django tried these URL patterns,
> in this order:
>
> admin/ The current path, polls/, didn’t match any of these. this is the
> error i am getting after i wrote the following code:
>
>1.
>
>for urls.py
>from django.contrib import admin from django.urls import include, path
>urlpatterns = [ path('polls/', include('polls.urls')), path('admin/',
>admin.site.urls), ]
>2.
>
>for polls/urls.py
>from django.urls import path from . import views urlpatterns = [
>path('', views.index, name='index'), ]
>
> 3.for polls/views.py
>
>  """ from django.http import HttpResponse
> def index(request): return HttpResponse("Hello, world. You're at the polls
> index.") """
>
> *how i can i remove this error in vs code*
>
> --
> 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/5750b076-eddf-400d-b180-4ec7d46aa0e3n%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/CANPYDAttdvo3pLcQQ_j5uS3T0%2BNvYB_eSXn%2BMmS%2BO9s9n0i4OQ%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.


Re: DRF | Django | Up votes | Down Votes

2021-06-25 Thread DJANGO DEVELOPER
Chetan I got what you're saying. so how diff_votes will be updated? do have
I to apply the same logic as Oba discussed above?
and yes by calculating the up and down votes at the same time was that, if
a user up votes my post and another user down votes my post then should be
ranked accordingly.
means I just want to rank my post higher if there are more up votes than
down votes. I think I have described well, what I want to apply at the
moment.

On Fri, Jun 25, 2021 at 2:17 PM Chetan Ganji  wrote:

> You should have a field on Votes Model diff_vote as integerfield, which
> will be updated when a user upvote or downvote.
>
> WHY??
> Calculating this value on list view will result in higher latency.
> So we can dump that calculation on creating on updating.
>
> What do you mean by calculate the up votes and down votes at the same time?
>
>
> Regards,
> Chetan Ganji
> +91-900-483-4183
> ganji.che...@gmail.com
> http://ryucoder.in
>
>
> On Fri, Jun 25, 2021 at 12:39 PM DJANGO DEVELOPER 
> wrote:
>
>> Oba Thank you so much. and let me try it.
>> and one more thing that I want to ask that how can I calculate the up
>> votes and down votes at the same time? as Facebook likes and dislikes do.
>> can you guide me in this regard?
>>
>> On Fri, Jun 25, 2021 at 11:15 AM oba stephen 
>> wrote:
>>
>>> Hi,
>>>
>>> One way would be to create an extra field to track the difference in
>>> both fields and then in your meta information on that model set the
>>> ordering to that field.
>>>
>>> Another approach which is better is to do something like this.
>>>
>>> Votes.objects.extra(select={'diff': 'upvote - downvote'}).order_by('diff')
>>>
>>>
>>> Best regards
>>>
>>> Stephen Oba
>>>
>>> On Fri, Jun 25, 2021, 6:03 AM DJANGO DEVELOPER 
>>> wrote:
>>>
 Is there anyone who can help me here?

 On Thu, Jun 24, 2021 at 7:15 PM DJANGO DEVELOPER <
 abubakarbr...@gmail.com> wrote:

> Hi Django experts.
> I am building a Django, DRF based mobile app and I want to have
> functionality of up votes and down votes for posts that user will post.
> So what I want to say here that, if an user upvotes a post then it
> should be get higher ranks as quora questions do. and if there are more
> down votes than up votes then a post should be moved down ward rather than
> going up.
> I have applied a logic already here and shared the screenshots as
> well. but I am sure that there is a better logic or solution for this
> problem.
> Thanks in advance.
> Mr Mike and Mr Lalit can you guide me here please?
>
> --
> 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/c72fefe7-58d2-4c43-84b8-0faa3d9747b0n%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/CAKPY9pkAYcmio_U%2BAUPMcxzxbdT8QM1QPfPDftMgrj2NQvsJRQ%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/CAAJsLnras7ETsnRc5yj2F-S%3DMo5xfEMWDbVXPOvm08oQDxoFAg%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/CAKPY9pkYmP2xvW8FYRxBH8a55kURefFwrJGE59O-g%2Be8ktF%2B0g%40mail.gmail.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" grou

Re: DRF | Django | Up votes | Down Votes

2021-06-25 Thread Chetan Ganji
You should have a field on Votes Model diff_vote as integerfield, which
will be updated when a user upvote or downvote.

WHY??
Calculating this value on list view will result in higher latency.
So we can dump that calculation on creating on updating.

What do you mean by calculate the up votes and down votes at the same time?


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Fri, Jun 25, 2021 at 12:39 PM DJANGO DEVELOPER 
wrote:

> Oba Thank you so much. and let me try it.
> and one more thing that I want to ask that how can I calculate the up
> votes and down votes at the same time? as Facebook likes and dislikes do.
> can you guide me in this regard?
>
> On Fri, Jun 25, 2021 at 11:15 AM oba stephen 
> wrote:
>
>> Hi,
>>
>> One way would be to create an extra field to track the difference in both
>> fields and then in your meta information on that model set the ordering to
>> that field.
>>
>> Another approach which is better is to do something like this.
>>
>> Votes.objects.extra(select={'diff': 'upvote - downvote'}).order_by('diff')
>>
>>
>> Best regards
>>
>> Stephen Oba
>>
>> On Fri, Jun 25, 2021, 6:03 AM DJANGO DEVELOPER 
>> wrote:
>>
>>> Is there anyone who can help me here?
>>>
>>> On Thu, Jun 24, 2021 at 7:15 PM DJANGO DEVELOPER <
>>> abubakarbr...@gmail.com> wrote:
>>>
 Hi Django experts.
 I am building a Django, DRF based mobile app and I want to have
 functionality of up votes and down votes for posts that user will post.
 So what I want to say here that, if an user upvotes a post then it
 should be get higher ranks as quora questions do. and if there are more
 down votes than up votes then a post should be moved down ward rather than
 going up.
 I have applied a logic already here and shared the screenshots as well.
 but I am sure that there is a better logic or solution for this problem.
 Thanks in advance.
 Mr Mike and Mr Lalit can you guide me here please?

 --
 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/c72fefe7-58d2-4c43-84b8-0faa3d9747b0n%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/CAKPY9pkAYcmio_U%2BAUPMcxzxbdT8QM1QPfPDftMgrj2NQvsJRQ%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/CAAJsLnras7ETsnRc5yj2F-S%3DMo5xfEMWDbVXPOvm08oQDxoFAg%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/CAKPY9pkYmP2xvW8FYRxBH8a55kURefFwrJGE59O-g%2Be8ktF%2B0g%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/CAMKMUjs%2BCj4ygtXt4wwU4AhieyHMfWU9231tO0E28s0UUkNnog%40mail.gmail.com.


Re: DRF | Django | Up votes | Down Votes

2021-06-25 Thread DJANGO DEVELOPER
Oba Thank you so much. and let me try it.
and one more thing that I want to ask that how can I calculate the up votes
and down votes at the same time? as Facebook likes and dislikes do. can you
guide me in this regard?

On Fri, Jun 25, 2021 at 11:15 AM oba stephen  wrote:

> Hi,
>
> One way would be to create an extra field to track the difference in both
> fields and then in your meta information on that model set the ordering to
> that field.
>
> Another approach which is better is to do something like this.
>
> Votes.objects.extra(select={'diff': 'upvote - downvote'}).order_by('diff')
>
>
> Best regards
>
> Stephen Oba
>
> On Fri, Jun 25, 2021, 6:03 AM DJANGO DEVELOPER 
> wrote:
>
>> Is there anyone who can help me here?
>>
>> On Thu, Jun 24, 2021 at 7:15 PM DJANGO DEVELOPER 
>> wrote:
>>
>>> Hi Django experts.
>>> I am building a Django, DRF based mobile app and I want to have
>>> functionality of up votes and down votes for posts that user will post.
>>> So what I want to say here that, if an user upvotes a post then it
>>> should be get higher ranks as quora questions do. and if there are more
>>> down votes than up votes then a post should be moved down ward rather than
>>> going up.
>>> I have applied a logic already here and shared the screenshots as well.
>>> but I am sure that there is a better logic or solution for this problem.
>>> Thanks in advance.
>>> Mr Mike and Mr Lalit can you guide me here please?
>>>
>>> --
>>> 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/c72fefe7-58d2-4c43-84b8-0faa3d9747b0n%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/CAKPY9pkAYcmio_U%2BAUPMcxzxbdT8QM1QPfPDftMgrj2NQvsJRQ%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/CAAJsLnras7ETsnRc5yj2F-S%3DMo5xfEMWDbVXPOvm08oQDxoFAg%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/CAKPY9pkYmP2xvW8FYRxBH8a55kURefFwrJGE59O-g%2Be8ktF%2B0g%40mail.gmail.com.