Re: using .annotate on a queryset and output field is a result of function

2021-06-17 Thread Nikeet NA
Its not the perfect method you can optimize ot more if you want.
You can prefer this Link
<https://docs.djangoproject.com/en/3.2/topics/db/managers/#custom-managers>

On Thu, 17 Jun 2021 at 18:06, Nikeet NA  wrote:

> You can do it like this :
>
> class TransactionEntry(models.Manager):
>def get_total_prices(self):
>  return
> self.queryset().defer("users").annotate.(total_price=F("num_shares")*F("price_per_share"))
>
> On Thu, 17 Jun 2021 at 15:31, VISHESH MANGLA <
> f20170...@pilani.bits-pilani.ac.in> wrote:
>
>> what about overwriting the manager? How to make the manager auto-add
>> those computed properties ?
>>
>> On Thursday, June 17, 2021 at 8:50:27 AM UTC+5:30 Nikeet NA wrote:
>>
>>> You cannot use properties in django orm , it does not allow that.
>>>
>>> TransactionEntry.objects.defer("users").annotate(total_price=F("num_shares")*F("price_per_share")).values('total_price')
>>> On Thursday, 17 June 2021 at 03:23:01 UTC+5:30 VISHESH MANGLA wrote:
>>>
>>>> Hello,
>>>>
>>>> I wanted to know that how for the model below,  how can I get a
>>>> queryset with  all the fields excluding the `user` and including the
>>>> output of get_output_field? Please avoid hardcoding.
>>>> One way is
>>>>
>>>> `TransactionEntry
>>>> .objects.defer("users").annotate(total_price=F("num_shares")*F("price_per_share"))`
>>>>
>>>> but that is undesirable. I just want to use that function on the model
>>>> and not hard code the formula.
>>>> Thanks,
>>>>
>>>>
>>>>
>>>> class TransactionEntry(models.Model):
>>>> """Model to save data of users who want to buy/sell shares"""
>>>>
>>>> user = models.ForeignKey(
>>>> to=Relative,
>>>> on_delete=models.CASCADE,
>>>> related_name="transaction_entry",
>>>> )
>>>>
>>>> num_shares = models.PositiveIntegerField(null=False, blank=False)
>>>> date_of_trade = models.DateField(null=False, blank=False)
>>>> transaction_type = models.CharField(
>>>> max_length=1,
>>>> choices=TransactionType.choices,
>>>> default=TransactionType.SELL,
>>>> null=False,
>>>> )
>>>> price_per_share = models.FloatField(null=False, blank=False)
>>>>
>>>> def get_total_price(self):
>>>> return self.num_shares * self.price_per_share
>>>>
>>>> --
>> 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/35d917c8-e321-42eb-8050-f7849c0374e8n%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/35d917c8-e321-42eb-8050-f7849c0374e8n%40googlegroups.com?utm_medium=email_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/CAFOOHnP8Y285E9HztCq8LUcTwZ3G%2BDT2T%2BgB35j_JfdK8va6ow%40mail.gmail.com.


Re: using .annotate on a queryset and output field is a result of function

2021-06-17 Thread Nikeet NA
You can do it like this :

class TransactionEntry(models.Manager):
   def get_total_prices(self):
 return
self.queryset().defer("users").annotate.(total_price=F("num_shares")*F("price_per_share"))

On Thu, 17 Jun 2021 at 15:31, VISHESH MANGLA <
f20170...@pilani.bits-pilani.ac.in> wrote:

> what about overwriting the manager? How to make the manager auto-add those
> computed properties ?
>
> On Thursday, June 17, 2021 at 8:50:27 AM UTC+5:30 Nikeet NA wrote:
>
>> You cannot use properties in django orm , it does not allow that.
>>
>> TransactionEntry.objects.defer("users").annotate(total_price=F("num_shares")*F("price_per_share")).values('total_price')
>> On Thursday, 17 June 2021 at 03:23:01 UTC+5:30 VISHESH MANGLA wrote:
>>
>>> Hello,
>>>
>>> I wanted to know that how for the model below,  how can I get a queryset
>>> with  all the fields excluding the `user` and including the  output of
>>> get_output_field? Please avoid hardcoding.
>>> One way is
>>>
>>> `TransactionEntry
>>> .objects.defer("users").annotate(total_price=F("num_shares")*F("price_per_share"))`
>>>
>>> but that is undesirable. I just want to use that function on the model
>>> and not hard code the formula.
>>> Thanks,
>>>
>>>
>>>
>>> class TransactionEntry(models.Model):
>>> """Model to save data of users who want to buy/sell shares"""
>>>
>>> user = models.ForeignKey(
>>> to=Relative,
>>> on_delete=models.CASCADE,
>>> related_name="transaction_entry",
>>> )
>>>
>>> num_shares = models.PositiveIntegerField(null=False, blank=False)
>>> date_of_trade = models.DateField(null=False, blank=False)
>>> transaction_type = models.CharField(
>>> max_length=1,
>>> choices=TransactionType.choices,
>>> default=TransactionType.SELL,
>>> null=False,
>>> )
>>> price_per_share = models.FloatField(null=False, blank=False)
>>>
>>> def get_total_price(self):
>>> return self.num_shares * self.price_per_share
>>>
>>> --
> 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/35d917c8-e321-42eb-8050-f7849c0374e8n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/35d917c8-e321-42eb-8050-f7849c0374e8n%40googlegroups.com?utm_medium=email_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/CAFOOHnOj%2BhdAvGe9AZs-oQwrhN%3DP%3DwRy9072ki3nY4wQByRZoQ%40mail.gmail.com.


Re: Need to volunteer in a django project to emprove my knowledge

2021-06-17 Thread Nikeet NA
OK that interesting I can help.

On Thursday, 17 June 2021 at 17:03:28 UTC+5:30 flavie...@gmail.com wrote:

> Actually im not working on any django project but i was working on
> geodjango in the past
> Flavien
>
> On 6/17/21, Nikeet NA  wrote:
> > What type of project are you working upon ?
> >
> > On Thursday, 17 June 2021 at 16:51:01 UTC+5:30 flavie...@gmail.com 
> wrote:
> >
> >> hi guys in term of improving my knowledge in building Django project,
> >> i need to be a volunteer
> >> I'm good in English and fluent in French
> >>
> >> My WhatsApp number:+243815357825 <+243%20815%20357%20825> 
> <+243%20815%20357%20825>
> >> thank you so much
> >> Flavien
> >>
> >> --
> >> FLAVIEN HERI
> >>
> >> *Information management AscociateUNHCR-Kinshasa*
> >> Tél:+243978587009 <+243%20978%20587%20009> <+243%20978%20587%20009>
> >> Skype: flavien.heri1
> >> Facebook: flavien semi
> >>
> >
> > --
> > 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...@googlegroups.com.
> > To view this discussion on the web visit
> > 
> https://groups.google.com/d/msgid/django-users/12f66979-6742-4552-b09e-eec6dc9e169an%40googlegroups.com
> .
> >
>
>
> -- 
> FLAVIEN HERI
>
> *Information management AscociateUNHCR-Kinshasa*
> Tél:+243978587009 <+243%20978%20587%20009>
> Skype: flavien.heri1
> Facebook: flavien semi
>

-- 
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/6691c88c-14d5-40b1-91fe-7b8466c559a6n%40googlegroups.com.


Re: Need to volunteer in a django project to emprove my knowledge

2021-06-17 Thread Nikeet NA
What type of project are you working upon ?

On Thursday, 17 June 2021 at 16:51:01 UTC+5:30 flavie...@gmail.com wrote:

> hi guys in term of improving my knowledge in building Django project,
> i need to be a volunteer
> I'm good in English and fluent in French
>
> My WhatsApp number:+243815357825 <+243%20815%20357%20825>
> thank you so much
> Flavien
>
> -- 
> FLAVIEN HERI
>
> *Information management AscociateUNHCR-Kinshasa*
> Tél:+243978587009 <+243%20978%20587%20009>
> Skype: flavien.heri1
> Facebook: flavien semi
>

-- 
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/12f66979-6742-4552-b09e-eec6dc9e169an%40googlegroups.com.


Re: using .annotate on a queryset and output field is a result of function

2021-06-16 Thread Nikeet NA
You cannot use properties in django orm , it does not allow that.
TransactionEntry.objects.defer("users").annotate(total_price=F("num_shares")*F("price_per_share")).values('total_price')
On Thursday, 17 June 2021 at 03:23:01 UTC+5:30 VISHESH MANGLA wrote:

> Hello, 
>
> I wanted to know that how for the model below,  how can I get a queryset 
> with  all the fields excluding the `user` and including the  output of 
> get_output_field? Please avoid hardcoding.
> One way is
>
> `TransactionEntry
> .objects.defer("users").annotate(total_price=F("num_shares")*F("price_per_share"))`
>
> but that is undesirable. I just want to use that function on the model and 
> not hard code the formula.
> Thanks,
>
>
>
> class TransactionEntry(models.Model):
> """Model to save data of users who want to buy/sell shares"""
>
> user = models.ForeignKey(
> to=Relative,
> on_delete=models.CASCADE,
> related_name="transaction_entry",
> )
>
> num_shares = models.PositiveIntegerField(null=False, blank=False)
> date_of_trade = models.DateField(null=False, blank=False)
> transaction_type = models.CharField(
> max_length=1,
> choices=TransactionType.choices,
> default=TransactionType.SELL,
> null=False,
> )
> price_per_share = models.FloatField(null=False, blank=False)
>
> def get_total_price(self):
> return self.num_shares * self.price_per_share
>
>

-- 
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/d4270b04-4fee-4c95-8da0-d525f1a4999cn%40googlegroups.com.


Re: How to use django template tags in .js file ??

2021-06-16 Thread Nikeet NA
Or you can store the url in the variable then use it.

On Thursday, 17 June 2021 at 00:29:00 UTC+5:30 Nikeet NA wrote:

> Do like this use 
> var obj_slug = object.slug inside script tag below it include your js file 
> with the above js script. in js file you can acces it with obj_slug 
> variable.
>
> On Wednesday, 16 June 2021 at 22:31:39 UTC+5:30 kuassi...@paydunya.com 
> wrote:
>
>> I also had the problem once. But what I understood is that the 
>> interpretation of the DJANGO syntax in statics files only works when the 
>> file has an HTML extension. So if you really want to do something separate 
>> with the script you can just create another HTML file but in another folder 
>> where you will put the script content surrounded by the SCRIPT tags and 
>> then you will just include with the directive {% INCLUDE %} in 
>> your main HTML file.
>>
>> On Wednesday, June 16, 2021 at 3:59:16 PM UTC bisht.a...@gmail.com wrote:
>>
>>> while doing great stuff with django I have found some clumsy behaviour 
>>> of django in handling .js file. Is there a way to effectively integrate all 
>>> the stuff of   in a separate file and effectively used it 
>>> with rest of the html code. 
>>>
>>> for example : 
>>>
>>> // *file.html 
>>> ..*
>>>
>>> 
>>>   
>>>
>>> >> method="POST" id="likes-form">
>>> {% csrf_token %}
>>>
>>> >> id="like-{{
>>> object.pk}}">
>>> 
>>>   
>>>   
>>> {{ object.total_likes }}
>>>   
>>> 
>>>
>>>
>>>
>>>
>>> //  *file.js file*  
>>> ..
>>>
>>> $("#likes-form").submit(function (e)
>>> {  e.preventDefault();
>>>   var serializedData = $(this).serializeArray();
>>>   $.ajax({
>>>   type: 'POST',
>>>   url: '{% url 'blog_likes' object.slug  %}',
>>>   data: serializedData,
>>>   success: function (response) {
>>> var like_count = JSON.parse(response["like"]);
>>> like_flag = JSON.parse(response["flag"]);
>>> 
>>> console.log(like_flag);
>>>   
>>> if(like_flag == 0){  
>>> $(".like-inner-flex-1").toggleClass('like-animate');   
>>>   }else
>>>   $(".like-inner-flex-1").toggleClass('like-animate'); 
>>>   
>>>   if(like_flag){
>>>
>>>   $('.like-btn').css({"background-color": "#d629801a" , "outline": 
>>> "none"});
>>>
>>> $('.like-inner-flex-1').css({"background-position": "right",  
>>> "filter": "grayscale(0%)"});
>>>
>>> } else {
>>>
>>> $('.like-btn').css({"background-color": "transparent", "outline": 
>>> "none"});
>>>
>>> $('.like-inner-flex-1').css({"background-position": "right",  
>>> "filter": "grayscale(100%)"});
>>>
>>> }
>>>
>>> $("#likes").text(`${like_count}`);
>>> }})
>>> })
>>>
>>> ..
>>>
>>> if I use above script inside the same html file then it works, but in 
>>> above case its not working ?? If there is any work around to do this thing 
>>> , then please suggest me .
>>>
>>> Thank you...
>>>
>>>  
>>>
>>>
>>>

-- 
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/3e005ecb-77c9-4fac-aa10-ba0d7059c758n%40googlegroups.com.


Re: CUSTOM AUTH WITH CELERY WORKER FOR SENDING EMAIL

2021-06-16 Thread Nikeet NA
Can you describe in detail , sending mails is possible through celery but i 
am un clear about auth part.

On Wednesday, 16 June 2021 at 22:31:41 UTC+5:30 kuassi...@paydunya.com 
wrote:

> Hello Community. I would like to have recommendations on how to implement 
> a custom authentication with the use of CELERY for sending mails which will 
> be QUEUE and managed by a workers that I will start on my server with the 
> BROKER REDIS.
>
> Please if anyone have suggestions for me or any articles for that i'm glad 
> to receive them.
>

-- 
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/e5961172-716a-4a6b-a21f-54502a20a045n%40googlegroups.com.


Re: How to use django template tags in .js file ??

2021-06-16 Thread Nikeet NA
Do like this use 
var obj_slug = object.slug inside script tag below it include your js file 
with the above js script. in js file you can acces it with obj_slug 
variable.

On Wednesday, 16 June 2021 at 22:31:39 UTC+5:30 kuassi...@paydunya.com 
wrote:

> I also had the problem once. But what I understood is that the 
> interpretation of the DJANGO syntax in statics files only works when the 
> file has an HTML extension. So if you really want to do something separate 
> with the script you can just create another HTML file but in another folder 
> where you will put the script content surrounded by the SCRIPT tags and 
> then you will just include with the directive {% INCLUDE %} in 
> your main HTML file.
>
> On Wednesday, June 16, 2021 at 3:59:16 PM UTC bisht.a...@gmail.com wrote:
>
>> while doing great stuff with django I have found some clumsy behaviour of 
>> django in handling .js file. Is there a way to effectively integrate all 
>> the stuff of   in a separate file and effectively used it 
>> with rest of the html code. 
>>
>> for example : 
>>
>> // *file.html 
>> ..*
>>
>> 
>>   
>>
>> > method="POST" id="likes-form">
>> {% csrf_token %}
>>
>> > id="like-{{
>> object.pk}}">
>> 
>>   
>>   
>> {{ object.total_likes }}
>>   
>> 
>>
>>
>>
>>
>> //  *file.js file*  
>> ..
>>
>> $("#likes-form").submit(function (e)
>> {  e.preventDefault();
>>   var serializedData = $(this).serializeArray();
>>   $.ajax({
>>   type: 'POST',
>>   url: '{% url 'blog_likes' object.slug  %}',
>>   data: serializedData,
>>   success: function (response) {
>> var like_count = JSON.parse(response["like"]);
>> like_flag = JSON.parse(response["flag"]);
>> 
>> console.log(like_flag);
>>   
>> if(like_flag == 0){  
>> $(".like-inner-flex-1").toggleClass('like-animate');   
>>   }else
>>   $(".like-inner-flex-1").toggleClass('like-animate'); 
>>   
>>   if(like_flag){
>>
>>   $('.like-btn').css({"background-color": "#d629801a" , "outline": 
>> "none"});
>>
>> $('.like-inner-flex-1').css({"background-position": "right",  
>> "filter": "grayscale(0%)"});
>>
>> } else {
>>
>> $('.like-btn').css({"background-color": "transparent", "outline": 
>> "none"});
>>
>> $('.like-inner-flex-1').css({"background-position": "right",  
>> "filter": "grayscale(100%)"});
>>
>> }
>>
>> $("#likes").text(`${like_count}`);
>> }})
>> })
>>
>> ..
>>
>> if I use above script inside the same html file then it works, but in 
>> above case its not working ?? If there is any work around to do this thing 
>> , then please suggest me .
>>
>> Thank you...
>>
>>  
>>
>>
>>

-- 
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/5646832c-ab1a-4e58-8e10-0b178ddab1c0n%40googlegroups.com.


Re: Desperately need help.

2021-06-15 Thread Nikeet NA

In your withdraw view you have return render this should be missing check 
inside if statements or inside your custom logic which you have written 
without seeing the actual code its hard to tell.

On Wednesday, 16 June 2021 at 03:14:26 UTC+5:30 Ken Smith wrote:

> jul, thank you so very much for your very simple and honest answer. This 
> was the best response I could have ever received from anyone and I 
> appreciate it. I'm getting a bit old at 66 it seems my brain doesn't work 
> as good as it did even 10 years ago for learning something as difficult as 
> coding. Although your suggestion makes good sense and holds merit. I do 
> thank you for your response. I only ask one more simple thing can you tell 
> me which line of the code the HTTP response is missing from.
>
> Your answer has really opened up my brain to the possibility that the 
> website has left that out on purpose so that members cannot withdraw their 
> money.
>
> Again thank you so very much for your response and have a wonderful day
> On Tuesday, June 15, 2021 at 5:39:54 PM UTC-4 jul.ale...@gmail.com wrote:
>
>> Pretty easy to be honest. The web page need an http response and it's 
>> give none instead. :) 
>>
>>
>> If you don't know about the code, maybe you should hire a developer or 
>> learn by yourself. 
>>
>> El mar., 15 de junio de 2021 3:14 p. m., Ken Smith  
>> escribió:
>>
>>> There is the issue to solve that is the result of pressing the button to 
>>> complete your transaction. And it may be dumb because I don't know a damn 
>>> thing about  django and I assume that I would get an intelligent response 
>>> on this forum.  This was in fact a sincere request because I know nothing 
>>> about this code. If I did I would've discovered it myself. I merely had the 
>>> stupid assumption that someone would actually consider this a challenge. 
>>> But apparently not even your up to a challenge maybe it's too hard for you. 
>>> That is coded in django as I understand I may be wrong. I only read what 
>>> was presented on the error page. If it's not that would you please direct 
>>> me to what code it could possibly be as I am not a coder in any way shape 
>>> or form. I stopped even trying long before these new methods of coding came 
>>> out. I think the last time I tried to write code was in the 1990s. I know 
>>> there is a solution to my question I just hope there is someone with the 
>>> intelligence to take on the challenge for me or at least direct me to where 
>>> I need to go instead of making jokes. Perhaps someone can tell me something 
>>> about where I need to go or what I need to do there is a lot of money 
>>> involved in getting this code correct so that I can send the corrected 
>>> information to the company who owns the webpage. Not everybody here knows 
>>> how to code some of us are actually wanting some answers to questions that 
>>> we have. I am by trade an aircraft mechanic. So I can laugh at you if I 
>>> asked you to go clean the air sock and you don't even know what I'm talking 
>>> about but I won't because you don't know what I'm talking about. Neither do 
>>> I know anything about what I presented and I don't pretend to know that's 
>>> why I asked for some intelligent information. Have a good day regards Ken
>>> On Monday, June 14, 2021 at 5:21:42 PM UTC-4 jacobgr...@gmail.com wrote:
>>>
 Lol what do you expect anyone to do? You just post some random HTML, 
 zero code, no backtrace, nothing to even indicate there is an issue that 
 someone could solve even IF they were willing... This has nothing to do 
 with Django. I don't understand what you thought was going to happen. This 
 is possibly the dumbest "question" I have ever read. I'd be willing to 
 consult at double my normal hourly rate if you are the point of contact. 

 On Mon, Jun 14, 2021 at 12:12 PM Kasper Laudrup  
 wrote:

> On 14/06/2021 05.15, Ken Smith wrote:
> > I sure hope that somebody can take the time to do this. I'm just
> > wondering one of you brilliant programmers can look at this webpage 
> and
> > tell me where the errors are so that it can be fixed? Apparently the
> > programmers at the website are not as smart as you people are. If
> > someone has the time and inclination to do so with a please go over 
> the
> > code and highlight where the errors are in the corrections necessary 
> in
> > send back to me in a file in response. I would greatly be so happy.
> > Thank you and have a wonderful day.
> > 
>
> Instead of wasting space on meaningless flattering of the very diverse
> members of this list/forum and begin rude to the developers at
> safewayfx.com you would have a much better chance of getting help if 
> you
> instead showed that you were willing to do at least a minimal effort
> yourself.
>
> What errors are you talking about and what have you done to try and
> solve them?
>
> 

Re: File in nested serializer

2021-06-15 Thread Nikeet NA
Can you show me your nested serializer code.

On Wed, 16 Jun 2021 at 06:07, narendra thapa 
wrote:

> Actual problem is nested serializer is not accepting a QueryDIct data it
> accepts only the parent data and delete the child automatically. when i
> parse the QueryDIct data to JSON json.dumps() it will accept the child one
> but problem here is json.dumps() cannot convert InMEmoryField data type. So
> what will be the best way to do it. If you have some idea please share with
> me
>
>
> On Tue, Jun 15, 2021 at 2:49 PM Nikeet NA  wrote:
>
>> Use This Drf nested serializer
>> <https://pypi.org/project/drf-nested-serializer/>
>>
>> On Tuesday, 15 June 2021 at 10:48:22 UTC+5:30 narendra...@gmail.com
>> wrote:
>>
>>> Hi Folks,
>>> I'm having a problem to insert a data in nested serializers with
>>> FileField. If anybody know the idea of doing that would you guys please
>>> just help me out. I googled it for the solution but found the problem asked
>>> but not a solution. And somewhere in git i found that it is hard to manged
>>> with nested serializers with file field.
>>>
>> --
>> 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/588eed3a-7900-443c-9e9f-124136ba3933n%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/588eed3a-7900-443c-9e9f-124136ba3933n%40googlegroups.com?utm_medium=email_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/CAEtntjX4-U9xzVCj-zWN1%2BC_EeTm2--%3D8KYQzSmW2%2BaEqKnaqw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAEtntjX4-U9xzVCj-zWN1%2BC_EeTm2--%3D8KYQzSmW2%2BaEqKnaqw%40mail.gmail.com?utm_medium=email_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/CAFOOHnM15R2Y%2BRxuFas-PWZSLRenLPnGqZ1JPikig-DfTQ5d_Q%40mail.gmail.com.


Re: Find number of days between two date excluding weekend days and display the number in text field

2021-06-15 Thread Nikeet NA
You need to hit an ajax request to the server on the api when there is 
change event on the field from were you are taking the second date as input 
send both first and second date as data in post request to the backend and 
send the days as response 

On Tuesday, 15 June 2021 at 15:57:07 UTC+5:30 eugenet...@gmail.com wrote:

> Dear NA,
>
> I accomplished this with numpy. How can I get the value (difference 
> between the two dates) when I select the second date for example in the 
> text field? I know Javascript  can be used but how?
>
> On Tue, 15 Jun 2021 at 11:14, Nikeet NA  wrote:
>
>> You need to loop through the dates maintain a count variable get the 
>> weekday for every datetime object with date.weekday() exclude as per your 
>> need for days you dont want to count.
>>
>> On Tuesday, 15 June 2021 at 11:30:21 UTC+5:30 eugenet...@gmail.com wrote:
>>
>>> Team,
>>>
>>> I have date1 and date2 fields. I am able to calculate number of days 
>>> between the two dates using relativedelta as shown below:
>>>
>>> date1 = datetime.datetime.strptime(str(end_date), '%Y-%m-%d')
>>> date2 = datetime.datetime.strptime(str(start_date), '%Y-%m-%d')
>>> r = relativedelta.relativedelta(date1, date2)
>>> n_days=r.days
>>> What I want now is calculating the days but excluding weekends days. 
>>> Again I want to pick the second date and get the number of days 
>>> (date2-date1) in the text field directly.
>>>
>>> Please help.
>>>
>>> Thanks
>>> -- 
>>> *Eugene*
>>>
>>>
>>> -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/16ba7533-93ba-4925-9f93-e430d7128342n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/16ba7533-93ba-4925-9f93-e430d7128342n%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>
>
> -- 
> *TUYIZERE Eugene*
>
>
>
> *Msc Degree in Mathematical Science*
>
> *African Institute for Mathematical Sciences (AIMS Cameroon)Crystal 
> Garden-Lime, Cameroon*
>
> Bsc in Computer Science
>
> *UR-Nyagatare Campus*
>
> Email: eugene@aims-cameroon.org
>eugenet...@gmail.com
>
> Tel: (+250) 7 88 26 33 38, (+250) 7 22 26 33 38
>

-- 
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/f90effb8-2ba5-49fa-b340-cd8862d3e039n%40googlegroups.com.


Re: Find number of days between two date excluding weekend days and display the number in text field

2021-06-15 Thread Nikeet NA
You need to loop through the dates maintain a count variable get the 
weekday for every datetime object with date.weekday() exclude as per your 
need for days you dont want to count.

On Tuesday, 15 June 2021 at 11:30:21 UTC+5:30 eugenet...@gmail.com wrote:

> Team,
>
> I have date1 and date2 fields. I am able to calculate number of days 
> between the two dates using relativedelta as shown below:
>
> date1 = datetime.datetime.strptime(str(end_date), '%Y-%m-%d')
> date2 = datetime.datetime.strptime(str(start_date), '%Y-%m-%d')
> r = relativedelta.relativedelta(date1, date2)
> n_days=r.days
> What I want now is calculating the days but excluding weekends days. Again 
> I want to pick the second date and get the number of days (date2-date1) in 
> the text field directly.
>
> Please help.
>
> Thanks
> -- 
> *Eugene*
>
>
>

-- 
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/16ba7533-93ba-4925-9f93-e430d7128342n%40googlegroups.com.


Re: Django Query vs SQL query

2021-06-15 Thread Nikeet NA
use the related name on the staff model for project field with __ lookup as 
in 
class Staff(models.Model):
.
.

project = foreignkey relationship (related_name='staffs')

SO the query would be Projects.objects.filter(staffs__project_id=F('pk'))

On Tuesday, 15 June 2021 at 14:13:26 UTC+5:30 eugenet...@gmail.com wrote:

> Team,
>
> I am a little bit confused: I have a table callect Projects and another 
> called Staffs. I want a particular staff member to view only the project 
> he/she has a role in. In the Staffs table I have a project foreign key 
> project_id. But I am confused about how to construct the query. I think of 
> the SQL as below
>
> *Select * from Projects where Projects.id = Staffs.projects_id *
>
> I want to transform this query into a django query.
>
> Assist please
>
> -- 
> *Eugene*
>
>

-- 
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/6f74a18a-9798-4080-a462-6eff3231d7acn%40googlegroups.com.


Re: location based web app with django and geodjango

2021-06-15 Thread Nikeet NA
Your app is not registered in settings file as stated by Aritra.

On Tuesday, 15 June 2021 at 14:22:45 UTC+5:30 arit...@gmail.com wrote:

> 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...@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/274673a6-fd60-403e-a9e0-c6976bff99d4n%40googlegroups.com.


Re: File in nested serializer

2021-06-15 Thread Nikeet NA
Use This Drf nested serializer 


On Tuesday, 15 June 2021 at 10:48:22 UTC+5:30 narendra...@gmail.com wrote:

> Hi Folks,
> I'm having a problem to insert a data in nested serializers with 
> FileField. If anybody know the idea of doing that would you guys please 
> just help me out. I googled it for the solution but found the problem asked 
> but not a solution. And somewhere in git i found that it is hard to manged 
> with nested serializers with file field. 
>

-- 
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/588eed3a-7900-443c-9e9f-124136ba3933n%40googlegroups.com.


Re: Github - ( Image formation Issue )

2021-06-15 Thread Nikeet NA
Can you show me your code for html where you are adding those images. 

On Tuesday, 15 June 2021 at 10:22:53 UTC+5:30 vn241...@gmail.com wrote:

>
>   image.png 
> <https://drive.google.com/file/d/1jKqLwhWUeitREDGPhSSwJkpBEAGn0y9I/view?usp=drivesdk>
>  
>
>
> On Tue, Jun 15, 2021, 10:13 Sakshi jain  wrote:
>
>> both ...in project folder I make one new folder and add all image's 
>>
>> On Tue, Jun 15, 2021, 10:11 Nikeet NA  wrote:
>>
>>> The image is it in your project root folder inside static ??
>>>
>>> On Tuesday, 15 June 2021 at 10:00:02 UTC+5:30 vn241...@gmail.com wrote:
>>>
>>>> warning: could not open directory 'AppData/Local/Application Data/': 
>>>> Permission denied
>>>> warning: could not open directory 'AppData/Local/History/': Permission 
>>>> denied
>>>> warning: could not open directory 
>>>> 'AppData/Local/Microsoft/Windows/INetCache/Content.IE5/': Permission denied
>>>> warning: could not open directory 
>>>> 'AppData/Local/Microsoft/Windows/INetCache/Low/Content.IE5/': Permission 
>>>> denied
>>>> warning: could not open directory 
>>>> 'AppData/Local/Microsoft/Windows/Temporary Internet Files/': Permission 
>>>> denied
>>>> warning: could not open directory 'AppData/Local/Temporary Internet 
>>>> Files/': Permission denied
>>>> warning: could not open directory 'Application Data/': Permission denied
>>>> warning: could not open directory 'Cookies/': Permission denied
>>>> warning: could not open directory 'Documents/My Music/': Permission 
>>>> denied
>>>> warning: could not open directory 'Documents/My Pictures/': Permission 
>>>> denied
>>>> warning: could not open directory 'Documents/My Videos/': Permission 
>>>> denied
>>>> warning: could not open directory 'Local Settings/': Permission denied
>>>> warning: could not open directory 'My Documents/': Permission denied
>>>> warning: could not open directory 'NetHood/': Permission denied
>>>> warning: could not open directory 'PrintHood/': Permission denied
>>>> warning: could not open directory 'Recent/': Permission denied
>>>> warning: could not open directory 'SendTo/': Permission denied
>>>> warning: could not open directory 'Start Menu/': Permission denied
>>>> warning: could not open directory 'Templates/': Permission denied
>>>> warning: LF will be replaced by CRLF in .bash_history.
>>>> The file will have its original line endings in your working directory
>>>> warning: LF will be replaced by CRLF in .vscode/argv.json.
>>>> The file will have its original line endings in your working directory
>>>> warning: LF will be replaced by CRLF in 
>>>> AppData/Local/Adobe/Acrobat/DC/AdobeCMapFnt15.lst.
>>>> The file will have its original line endings in your working directory
>>>> warning: LF will be replaced by CRLF in 
>>>> AppData/Local/Adobe/Acrobat/DC/AdobeCMapFnt21.lst.
>>>> The file will have its original line endings in your working directory
>>>> warning: LF will be replaced by CRLF in 
>>>> AppData/Local/Adobe/Acrobat/DC/AdobeSysFnt15.lst.
>>>> The file will have its original line endings in your working directory
>>>> warning: LF will be replaced by CRLF in 
>>>> AppData/Local/Adobe/Acrobat/DC/AdobeSysFnt21.lst.
>>>> The file will have its original line endings in your working directory
>>>> warning: LF will be replaced by CRLF in 
>>>> AppData/Local/Adobe/Acrobat/DC/Cache/AcroFnt15.lst.
>>>> The file will have its original line endings in your working directory
>>>> warning: LF will be replaced by CRLF in 
>>>> AppData/Local/Adobe/Acrobat/DC/Cache/AcroFnt21.lst.
>>>> The file will have its original line endings in your working directory
>>>> warning: LF will be replaced by CRLF in 
>>>> AppData/Local/ConnectedDevicesPlatform/51cc00f7372e5af2.cdp.
>>>> The file will have its original line endings in your working directory
>>>> warning: LF will be replaced by CRLF in 
>>>> AppData/Local/ConnectedDevicesPlatform/51cc00f7372e5af2.cdpresource.
>>>> The file will have its original line endings in your working directory
>>>> warning: LF will be replaced by CRLF in 
>>>> AppData/Local/ConnectedDevicesPlatform/AAD.952fa1a5-8441-46c8-99d1-712c83fb9dfc.cdp.
>>>> The file will have its original line endings in your working direct

Re: Github - ( Image formation Issue )

2021-06-14 Thread Nikeet NA
tion/6668/LICENSE.
> The file will have its original line endings in your working directory
> warning: LF will be replaced by CRLF in AppData/Local/Google/Chrome/User 
> Data/CertificateRevocation/6668/manifest.json.
> The file will have its original line endings in your working directory
> warning: LF will be replaced by CRLF in AppData/Local/Google/Chrome/User 
> Data/CertificateRevocation/6669/LICENSE.
> The file will have its original line endings in your working directory
> warning: LF will be replaced by CRLF in AppData/Local/Google/Chrome/User 
> Data/CertificateRevocation/6669/manifest.json.
> The file will have its original line endings in your working directory
> warning: LF will be replaced by CRLF in AppData/Local/Google/Chrome/User 
> Data/Crowd Deny/2021.6.7.1141/manifest.json.
> The file will have its original line endings in your working directory
> error: open("AppData/Local/Google/Chrome/User Data/Default/Cache/data_0"): 
> Permission denied
> error: unable to index file 'AppData/Local/Google/Chrome/User 
> Data/Default/Cache/data_0'
> fatal: adding files failed
>
>
> It's a new issue when I try to use git bash upload my img folder on github 
> repo.
>
> On Mon, Jun 14, 2021, 23:02 Nikeet NA  wrote:
>
>> Move those images to static folder then add then with static tag. Do 
>> upload the static folder to on your server.
>>
>> On Monday, 14 June 2021 at 21:45:00 UTC+5:30 vn241...@gmail.com wrote:
>>
>>> Hello team, 
>>> I'm  Er. Sakshi jain 
>>>
>>> I'm trying to design simple E-commerce website without using any 
>>> database , 
>>>
>>> When I trying to upload my website on my github account in my website 
>>> image is not completely shown 
>>>
>>>
>>> http://sakshijain.electrohost.co/kanaksingh/
>>>
>>> Plz anyone help me ..
>>>
>>>
>>> Thank you 
>>>
>>>
>>>
>>> -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/89d06ac5-b24f-4ace-9024-cb25906a9506n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/89d06ac5-b24f-4ace-9024-cb25906a9506n%40googlegroups.com?utm_medium=email_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/b760e00f-9da8-4de5-9197-ef48594aceefn%40googlegroups.com.


Re: location based web app with django and geodjango

2021-06-14 Thread Nikeet NA
Replace admin.site.register(Report) with this @admin.register(Report)

On Tuesday, 15 June 2021 at 05:46:46 UTC+5:30 staka...@gmail.com 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/15cbe9a7-fb69-4498-a726-1b6613c6536an%40googlegroups.com.


Re: In need of help regarding HTML Submit button

2021-06-14 Thread Nikeet NA
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 it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 

Re: Github - ( Image formation Issue )

2021-06-14 Thread Nikeet NA
Move those images to static folder then add then with static tag. Do upload 
the static folder to on your server.

On Monday, 14 June 2021 at 21:45:00 UTC+5:30 vn241...@gmail.com wrote:

> Hello team, 
> I'm  Er. Sakshi jain 
>
> I'm trying to design simple E-commerce website without using any database 
> , 
>
> When I trying to upload my website on my github account in my website 
> image is not completely shown 
>
>
> http://sakshijain.electrohost.co/kanaksingh/
>
> Plz anyone help me ..
>
>
> Thank you 
>
>
>
>

-- 
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/89d06ac5-b24f-4ace-9024-cb25906a9506n%40googlegroups.com.


Re: CHOICES

2021-06-13 Thread Nikeet NA
from django.db.models import Sum, DecimalField
from django.db.models.functions import Cast

Model.objects.annotate(deci_con_factor=Cast('conversion_factor', 
DecimalField()).aggregate(sum=Sum('deci_con_factor')).get('sum')

You need to change your char type to decimal type , you can use CAST 
operator, you will cast you charfield to decimal field and annotate it on 
every object then use that annotated field in aggregate func. 

On Sunday, 13 June 2021 at 15:38:05 UTC+5:30 sebasti...@gmail.com wrote:

> Hello,
>
> i think this is the right answer:
>
> from django.db.models import Sum
>
> ModelName.objects.filter(field_name__isnull=True).aggregate(Sum('field_name'))#
>  returns {'field_name__sum': 1000} for example
>
>
> Am So., 13. Juni 2021 um 12:04 Uhr schrieb www.forum-gh.com <
> lada...@gmail.com>:
>
>> Hello friends 
>> please i have: conversion_fqctor = models.charfield(choices=FACTOR)
>>
>> i want to sum the conversion_factor inside my view.py how do i convert it 
>> to a decimal and use the Sum()
>>
>> -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CALYpPT8_5sMsyjzvpdGZ3gBQbqiwQW7EHgZ61i4LdLQ1z38LYg%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/1eff5efd-0d61-4d5d-8dca-1cbdd7aa4a85n%40googlegroups.com.


Re: Make permissions according branch id

2021-06-13 Thread Nikeet NA
What you are trying to do is called object-level permission in Django, 
normally people use is model-level permission, you can use this module Django 
guardian .

On Sunday, 13 June 2021 at 10:33:06 UTC+5:30 waelmuh...@gmail.com wrote:

> Did any one understands what I mean
> ?
> في السبت، 12 يونيو 2021 في تمام الساعة 3:43:09 م UTC+3، كتب ‪wael 
> muhammed‬‏ رسالة نصها:
>
>>
>> I want to make permissions according branch id
>>  for more details 
>> 
>>
>

-- 
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/9ea27faa-b344-46d8-aa4b-3054ce90a7a3n%40googlegroups.com.


Re: User matching query does not exist.

2021-06-12 Thread Nikeet NA
There is no user with id 1.
Wrap this statement inside try catch block :
   user = User.objects.get(id=uid)
   and catch the DoesNotExist exception as except User.DoesNotExist:

On Saturday, 12 June 2021 at 18:13:09 UTC+5:30 shilpa...@gmail.com wrote:

> Environment:
>
>
> Request Method: GET
> Request URL: http://127.0.0.1:8000/addToCart/1
>
> Django Version: 3.2.3
> Python Version: 3.9.1
> Installed Applications:
> ['django.contrib.admin',
>  'django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.messages',
>  'django.contrib.staticfiles',
>  'MusicalApp.apps.MusicalappConfig',
>  'CartApp.apps.CartappConfig']
> Installed Middleware:
> ['django.middleware.security.SecurityMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.middleware.common.CommonMiddleware',
>  'django.middleware.csrf.CsrfViewMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.contrib.messages.middleware.MessageMiddleware',
>  'django.middleware.clickjacking.XFrameOptionsMiddleware']
>
>
>
> Traceback (most recent call last):
>   File 
> "D:\DjangoDemos\venv\lib\site-packages\django\core\handlers\exception.py", 
> line 47, in inner
> response = get_response(request)
>   File 
> "D:\DjangoDemos\venv\lib\site-packages\django\core\handlers\base.py", line 
> 181, in _get_response
> response = wrapped_callback(request, *callback_args, **callback_kwargs)
>   File "D:\DjangoDemos\CartApp\views.py", line 15, in addToCart
> user = User.objects.get(id=uid)
>   File 
> "D:\DjangoDemos\venv\lib\site-packages\django\db\models\manager.py", line 
> 85, in manager_method
> return getattr(self.get_queryset(), name)(*args, **kwargs)
>   File "D:\DjangoDemos\venv\lib\site-packages\django\db\models\query.py", 
> line 435, in get
> raise self.model.DoesNotExist(
>
> Exception Type: DoesNotExist at /addToCart/1
> Exception Value: User matching query does not exist.
>

-- 
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/1b7cff79-a0eb-4559-ab17-1d9d0f701343n%40googlegroups.com.


Re: Allow field validation in ajax.

2021-06-12 Thread Nikeet NA
You are not submitting your form which Inturn is not validating. For 
validations to run you need to submit a form.

Give the submit button attribute type="submit", then add an event listener 
for form submit in your javascript.
$("#ReportForm").on('submit', function(event) {
   // here event is submit type event object
   event.preventDefault() // this is added to prevent default execution 
of form submit event which will stop the page reload. 
   // here event.target is your form so you can use that to get data as 
let data = new FormData(event.target) 
})

On Saturday, 12 June 2021 at 22:09:26 UTC+5:30 eugenet...@gmail.com wrote:

> Friends,
>
> The ajax codes below successfully save the records in the database without 
> page loading. But what I want is to validate the fields first before 
> saving. The codes do not validate the empty field. How can I include that 
> validation ? please help
>
> 
> $(".submit_btn").click(function(){
> var form=new FormData($("#ReportForm")[0]);
> //AJAX CODE
> var xhr=new XMLHttpRequest();
> xhr.onreadystatechange=function(){
> if(xhr.status==200){
> console.log(xhr.responseText);
> }
> }
> xhr.open("POST","{% url 'report_create' %}",true);
> $("#progressbar").show();
>
> //UPDATING PROGRESS BAR
> xhr.upload.addEventListener("progress",function(ev){
> if(ev.lengthComputable){
> var percentage=(ev.loaded/ev.total*100|0);
> $("#progressbar").css({"width":""+percentage+"%"}).text("Uploading .."+
> percentage+"%");
> console.log(percentage);
> if(percentage>=100){
> location.reload()
>
> }
> }
> });
>
> xhr.send(form);
> })
> 
>
> Regards,
> *Eugene*
>
>
>

-- 
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/d4c70f2f-2b3f-4d64-a94a-ee31b9ecdd03n%40googlegroups.com.


Re: IndexError at /

2021-06-12 Thread Nikeet NA
Your list is empty check for it then return count as 0 if the list is not
empty  then return qs[0].items.count()

On Sat, 12 Jun 2021 at 02:55, Jacob Greene 
wrote:

> The backtrace is pretty clear..
>
> Here's the import part:
>  File "C:\Users\GEMINI INNOVATIONS\Documents\WEB DEV TUTOR FULL
> STACK\django_project_boilerplate-master\ECOMMERCE\core\templatetags\cart_template_tags.py",
> line 13, in cart_item_count return qs[0].items.count()
>
> "qs" is probably an empty list and you are trying access the 1st item via
> qs[0]
>
> I'd consider posting future questions not in all caps. Really weird post
> dude.
>
>
> On Fri, Jun 11, 2021 at 2:14 PM Tayo Akinnayajo 
> wrote:
>
>> PLS IM WORKING ON THIS CAN ANYONE HELP FIX THE ERROR
>>
>> Environment: Request Method: GET Request URL: http://127.0.0.1:8000/ Django
>> Version: 3.1.4 Python Version: 3.9.0 Installed Applications: 
>> ['django.contrib.admin',
>> 'django.contrib.auth', 'django.contrib.contenttypes', 
>> 'django.contrib.sessions',
>> 'django.contrib.messages', 'django.contrib.staticfiles', 
>> 'django.contrib.sites',
>> 'allauth', 'allauth.account', 'allauth.socialaccount', 'core', 
>> 'crispy_forms',
>> 'django_countries'] Installed Middleware: 
>> ['django.middleware.security.SecurityMiddleware',
>> 'django.contrib.sessions.middleware.SessionMiddleware', 
>> 'django.middleware.common.CommonMiddleware',
>> 'django.middleware.csrf.CsrfViewMiddleware', 
>> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>> 'django.contrib.messages.middleware.MessageMiddleware', 
>> 'django.middleware.clickjacking.XFrameOptionsMiddleware']
>> Template error: In template C:\Users\GEMINI INNOVATIONS\Documents\WEB
>> DEV TUTOR FULL
>> STACK\django_project_boilerplate-master\ECOMMERCE\templates\navbar.html,
>> error at line 41 list index out of range 31 :  32 :
>> > target="_blank">Checkout 33 :  --> 34 :  35 : 36 :  37 :  38 : {% if
>> request.user.is_authenticated %} 39 :  40 : > href="{% url 'core:order-summary' %}" class="nav-link waves-effect"> 41
>> :  42 :  43
>> :  Cart  44 :
>>  45 :  46 :  47 :  48 : > class="clearfix d-none d-sm-inline-block"> Logout  49 :  50 :
>>  51 : {% else %} Traceback (most recent call last): File
>> "C:\Users\GEMINI
>> INNOVATIONS\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\handlers\exception.py",
>> line 47, in inner response = get_response(request) File "C:\Users\GEMINI
>> INNOVATIONS\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\handlers\base.py",
>> line 202, in _get_response response = response.render() File
>> "C:\Users\GEMINI
>> INNOVATIONS\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\response.py",
>> line 105, in render self.content = self.rendered_content File
>> "C:\Users\GEMINI
>> INNOVATIONS\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\response.py",
>> line 83, in rendered_content return template.render(context,
>> self._request) File "C:\Users\GEMINI
>> INNOVATIONS\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\backends\django.py",
>> line 61, in render return self.template.render(context) File
>> "C:\Users\GEMINI
>> INNOVATIONS\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\base.py",
>> line 170, in render return self._render(context) File "C:\Users\GEMINI
>> INNOVATIONS\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\base.py",
>> line 162, in _render return self.nodelist.render(context) File
>> "C:\Users\GEMINI
>> INNOVATIONS\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\base.py",
>> line 938, in render bit = node.render_annotated(context) File
>> "C:\Users\GEMINI
>> INNOVATIONS\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\base.py",
>> line 905, in render_annotated return self.render(context) File
>> "C:\Users\GEMINI
>> INNOVATIONS\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\loader_tags.py",
>> line 150, in render return compiled_parent._render(context) File
>> "C:\Users\GEMINI
>> INNOVATIONS\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\base.py",
>> line 162, in _render return self.nodelist.render(context) File
>> "C:\Users\GEMINI
>> INNOVATIONS\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\base.py",
>> line 938, in render bit = node.render_annotated(context) File
>> "C:\Users\GEMINI
>> INNOVATIONS\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\base.py",
>> line 905, in render_annotated return self.render(context) File
>> "C:\Users\GEMINI
>> INNOVATIONS\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\loader_tags.py",
>> line 192, in render return template.render(context) File
>> "C:\Users\GEMINI
>> INNOVATIONS\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\base.py",
>> line 172, in render return self._render(context) File 

Re: django cron Job Functionality

2021-06-11 Thread Nikeet NA
You should use celery for running cron jobs.

On Friday, 11 June 2021 at 19:49:41 UTC+5:30 kells...@gmail.com wrote:

>
> What I would do in such case, is to write a function somewhere that checks 
> if a user applied for a leave, then check if the leave time is within a 
> day, then do whatever you want, like setting is_active to False. Then set 
> the cron job to run this function every day, every hour, or however you'd 
> like.
> On Fri, Jun 11, 2021 at 15:10 Chetan Ganji  wrote:
>
>> This will help you
>>
>> https://pypi.org/project/django-celery-beat/
>>
>>
>> On Fri, Jun 11, 2021, 5:34 PM Eugene TUYIZERE  
>> wrote:
>>
>>> Dear Team, 
>>>
>>> In my application, I want a user to set for example a leave plan in the 
>>> system and the system notify the user by email for example one day before 
>>> the start leave date. At the same time the system disables the user in the 
>>> system. Here I have a field *is_active *and I want the system to set it 
>>> to False from the leave date to the end date. And also to set Ongoing 
>>> status on the leave plan user list. I heard somewhere that Django Cron Job 
>>> can do this but I never use it and I do not know how to use it in the 
>>> application.
>>> If someone has used  it for some time please I need help. 
>>>
>>> Thank you
>>>
>>> -- 
>>> *Eugene*
>>>
>>> -- 
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/CABxpZHt2hqPgNU%2BvyDb8Eua%2B6_OMM8H6xsMzTgJ-73-0erfmKw%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...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CAMKMUjvErhZDkdA1ZYPOxHq4yuEWk%3DKUsbrgSyX3LOm7FBhFyw%40mail.gmail.com
>>  
>> 
>> .
>>
> -- 
> 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/bf837066-b07b-47fb-a404-098b64516ec0n%40googlegroups.com.


Re: [DRF] Serializing a field of type choice

2021-06-10 Thread Nikeet NA
You must me getting the keys of your choices rather than your choice text ,
you can override the field  with serializer method field  and return your
text according to your choice key.

On Thu, 10 Jun 2021 at 09:57, Lalit Suthar  wrote:

> can I see that model field, I don't think any extra configuration is
> required for it
>
> On Thu, 10 Jun 2021 at 04:44, ezequia...@gmail.com <
> ezequias.ro...@gmail.com> wrote:
>
>> Hey guys
>>
>> Could you help me with a Django Rest Framework question?
>>
>> I have a field in my model that has possible input values, so I'm using
>> the *choices=* attribute in my model.
>>
>> I'm having difficulty serializing the return of this data in drf.
>>
>> Could someone give me a hint on how best to implement this, please?
>>
>> Sincerely
>> Hezekiah Rock
>>
>> --
>> 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/b6cd89ca-06be-4d5d-bdd0-ba9cbb952e72n%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/CAGp2JVFT22C-6m4121LLQWpXZuzAy8Vtbqviy2TVVTJu3JJTKA%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/CAFOOHnMS8%3DnEOnw9EHYiJw2H6%3DhnBm%3DPWHu3iRJxMNYXzbp4yg%40mail.gmail.com.