Re: Help:What is the problem in this code?

2020-09-14 Thread 'Amitesh Sahay' via Django users
have you configured the django env in virtual env, and are you trying to 
execute the commands outside the virtual env?


Regards,
Amitesh
On Sunday, 13 September, 2020, 09:39:59 pm IST, Kasper Laudrup 
 wrote:  
 
 Hi Hassan,

There's nothing wrong with this code. It's just that it's only valid in 
Python 3, so you're probably using a Python 2 interpreter.

Without really knowing what you're trying to do, I'd suggest you start 
out by following the "getting started" documentation carefully instead 
of getting lost in the code generated by Django.

Kind regards,

Kasper Laudrup



On 13/09/2020 17.35, Hassan Shuvo wrote:
> manage.PNGcode.PNG
> 
> -- 
> 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/d3fa106f-2db2-4c63-a12e-178f5bce9ca9n%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/e33aee7e-cba1-2d9a-c647-af1eeadcdaf6%40stacktrace.dk.
  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/407688207.1597212.1600139051632%40mail.yahoo.com.


Re: I am getting this error while I click on comment button which i mention in line 51 in html file.

2020-09-14 Thread Yash Lanjewar
Post is my model which I created already. Sent from my Huawei phone Original message From: coolguy Date: Tue, 15 Sep 2020, 01:46To: Django users Subject: Re: I am getting this error while I click on comment button which i mention in line 51 in html file.This is not the same error...What is this 'Post' in your >>> post=Post.objects.filter(Post, pk=ID)based on the django error you are using model here which is not how filter works...this should be a field name like xxx.filter(field_name__id=ID)I would suggest you to refer to documentation on filter to familiarize yourself.https://docs.djangoproject.com/en/3.1/topics/db/aggregation/https://docs.djangoproject.com/en/3.1/topics/db/aggregation/#filter-and-excludeOn Monday, September 14, 2020 at 3:09:04 PM UTC-4 yashlan...@gmail.com wrote:still i am getting error.On Saturday, September 12, 2020 at 9:59:16 PM UTC+5:30 coolguy wrote:Can't see the line number in your provided screens.However, i can see you have additional id id={{ i.id }}added to your button line. (remove it)You have already provided the id in href="" url 'userpage:post_detail' i.id %}" attribute.On Saturday, September 12, 2020 at 4:34:10 AM UTC-4 yashlan...@gmail.com wrote:




-- 
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/cukEVWOSX2A/unsubscribe.
To unsubscribe from this group and all its topics, 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/d6eb7545-8312-419a-ac5a-07edaaee6fb8n%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/-81i1q4-s6wl2cw0wi9m-xsjnqwy3vi673lf5ps-y01ngo-l9k1my-woqwhq-41n7y6b5z22a498rg4-rbzskl2hpa6c-xrdkao-5mqs1l-ho6ll6d2b1wgwcmjsh-56oyg2okgxbbccsmvq3y8xoq-soesas.1600135886496%40email.android.com.


Re: Environment Variables for Django Secret Key etc On Windows 10 and Heroku

2020-09-14 Thread coolguy
Did you input the variable value under single quote or without it?

e.g. ''

On Saturday, September 12, 2020 at 12:35:29 PM UTC-4 hanz...@gmail.com 
wrote:

> Yes, I've seen so many tutorials. I did the same thing, and didn't work. 
> I believe there is something wrong with my Django Project. I don't know 
> what it is.
> Still tinkering.
>
>
> On Sat, Sep 12, 2020 at 9:38 PM Mbah Victor  wrote:
>
>> Have you try googling your problem
>>
>> Victor
>>
>> On Sat, Sep 12, 2020, 9:34 AM dum dum  wrote:
>>
>>> I tried to put my Django Secret Key in Environment Variables.
>>>
>>> SECRET_KEY = os.environ.get('SECRET_KEY')
>>>
>>> I did save the SECRET_KEY on env var windows 10 like this
>>> [image: image.png]
>>>
>>>
>>> When I tried to py manage.py runserver, I got this error
>>>
>>> django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must 
>>> not be empty.
>>>
>>> I followed this 
>>>
>>> https://stackoverflow.com/questions/19681102/my-django-secret-key-is-in-an-environment-variable-but-i-cant-do-syncdb
>>>
>>> But no idea with the solution..
>>>
>>> At this point, strange thing even occurred, I tried to py manage.py 
>>> without any SECRET_KEY on my Env Var on windows 10, and just leaving 
>>>   SECRET_KEY = os.environ.get('SECRET_KEY') 
>>> in my settings.py.
>>>
>>> I got no error.
>>>
>>> Strange.. But when I deployed it on heroku, it says the same error like 
>>> this 
>>> django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting 
>>> must not be empty. 
>>>
>>> Is anyone here experienced the same stuck like me? Please kindly advise. 
>>> Thanks 
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-users...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/CANV3w%3DYdb3SuiC7KYrkN4bfieQx-fQxhm%2BPeMLpxJDWubVbwyA%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/CANTsAyc%3D%3DBLN7a0_c8rYd%3DsLHyWq78CHxAQr6Sa_PMcqtP7Cwg%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/11d60767-06d3-4d4c-8435-10151e5726cdn%40googlegroups.com.


Re: Account activity How to logout a particular device to logout.

2020-09-14 Thread Farai M
*Browser fingerprinting*” is a method of tracking web *browsers* by the
configuration and settings information they make visible to websites,
rather than traditional tracking methods such as IP addresses and unique
cookies. *Browser fingerprinting* is both difficult to detect and and
extremely difficult to thwart.

This should solve most of our problems l an sure they are already
algorithms available for python or javascript ready to use


On Mon, Sep 14, 2020, 2:17 PM Farai M  wrote:

> You might need to capture mac address on login then associate it with the
> login session
>
> On Mon, Sep 14, 2020, 1:48 PM Salima Begum 
> wrote:
>
>> Hi all,
>> By using python and django.
>>
>>
>>1. User Login with one account in different devices.
>>2. If he login into another device we sent user to email. Saying that
>>New device login.
>>3. After we show user in his/her account activity page With that
>>account how many devices are login.
>>4. Then if user clicks on sign-out to a particular device then that
>>particular device should be logoff and deleted from activity list.
>>5. The only remain thing is that signout to a particular device.
>>6. How to do signout to a particular device from his activity list.
>>
>>   For example, User has 2 devices and He/She login from 2 devices with
>> one account. In his account activity it will show 2 devices how to signout
>> another device from his account activity. In python and django
>>
>> Thank You in advance
>> ~ Salima
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAMSz6bkQhOy8bA%3D1XgUZ6%2BXryhu0cf%3Dr%2BXGJ5UVNPZdxL6n90g%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/CAMeub5PHhZte1H9XvPEVP-iEDH8R3KMZ765m%2BaErXm1dUHPgwg%40mail.gmail.com.


Re: HTML5 drag and drop: How does it really work?

2020-09-14 Thread coolguy
The changes are done through script which you are doing at this time... the 
changes would only be visual for user and would not impact the source code.

following may be irrelevant for you but i would add this here...
Lets take an example of an online-course where instructor of the course can 
make changes to the order number of the course-contents.. suppose dnd 
functionality has been provided to him. When he shuffles the 
course-contents, a new order number is assigned to each content accordingly 
and persisted in database through a field setup for it in the model. In 
this case also, there will be no changes in the source-code rather changes 
will be saved in database and loaded when page is refreshed.

On Monday, September 14, 2020 at 12:36:01 PM UTC-4 Elliot wrote:

> I am familiar with the various events in building a dnd.  I am trying to 
> find out what is supposed to happen to the HTML source when a drag and drop 
> works. Can anyone explain this to me.? After an apparently successful drag 
> and drop I see no changes to the underlying HTML. I have been using Django 
> 3.0.10 and Python 3.8.1 and javascript. 
>
> If I do a "view source" after a dnd should the source code now reflect the 
> changes made by the dnd?  Exactly what is supposed to happen?  I am not 
> submitting any code because I just want to find out how it is supposed to 
> work.
>

-- 
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/b776f2b9-2e4b-4ef0-bfa2-9fe24ddb5f51n%40googlegroups.com.


Re: HTML5 drag and drop: How does it really work?

2020-09-14 Thread coolguy
The changes are done through script which you are doing at this time... the 
changes would only be visual for user and would not impact the source code.

following may be irrelevant for you but i would added this here...
Lets take an example of an online-course where instructor of the course can 
make changes to the order number of the course-contents.. suppose dnd 
functionality has been provided to him. When he shuffles the 
course-contents, a new order number is assigned to each content accordingly 
and persisted in database through a field setup for it in the model. In 
this case also, there will be no changes in the source-code rather changes 
will be saved in database and loaded when page is refreshed.

On Monday, September 14, 2020 at 12:36:01 PM UTC-4 Elliot wrote:

> I am familiar with the various events in building a dnd.  I am trying to 
> find out what is supposed to happen to the HTML source when a drag and drop 
> works. Can anyone explain this to me.? After an apparently successful drag 
> and drop I see no changes to the underlying HTML. I have been using Django 
> 3.0.10 and Python 3.8.1 and javascript. 
>
> If I do a "view source" after a dnd should the source code now reflect the 
> changes made by the dnd?  Exactly what is supposed to happen?  I am not 
> submitting any code because I just want to find out how it is supposed to 
> work.
>

-- 
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/ee507e6d-5a0b-4e01-8142-ca6a9baae830n%40googlegroups.com.


Re: Change DateField Like this

2020-09-14 Thread coolguy
please explain in detail where do you want this change views? 

On Monday, September 14, 2020 at 3:56:37 PM UTC-4 kkwaq...@gmail.com wrote:

> How to change date format in django (mmdd to ddmm)
>

-- 
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/d2aa631e-7f10-476d-bb01-c844c673877en%40googlegroups.com.


Re: Help me with the view please

2020-09-14 Thread coolguy
not sure what are you looking for... but based on your model setup... 
school fees is setup once so we picked it up from first object/record from 
table, while paid fees are collected quarterly or whatever means there will 
be more than one transaction in fee table. We have already calculated the 
"paid_fees" from fee table like this
>>>  
  paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))

I definitely want to help as long as i know what you are looking for :)


On Monday, September 14, 2020 at 4:26:48 PM UTC-4 dex9...@gmail.com wrote:

> Thanks it has worked, but it doesn’t work with my total_paid_fees, I want 
> to be automatically checked when school_fees substracts summation of all 
> paid_fees, just like this solution you provided me with the last time
>
> first_record = student.fee_set.first()
>
>  school_fees = first_record.school_fees
>
>   paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))
>
>balance_fees =  school_fees - paid_fees["total_paid_fees"] 
>
>  
>
>  
>
> Sent from Mail  for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Monday, September 14, 2020 9:09 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> Its simple... in your fee models' save method check that 
> self.remaining_fees is zero then make self.completed field to true... I 
> added else clause in case if admin make changes to paid fees and after 
> changes student still has some dues.
>
>  
>
> def save(self, *args, **kwargs):
>
>  
>
> self.remaining_fees = self.school_fees - self.paid_fees
>
> if self.remaining_fees == 0:
>
> self.completed = True
>
> else:
>
> self.completed = False
>
> 
>
> super().save(*args, **kwargs)
>
>  
>
> On Monday, September 14, 2020 at 7:11:51 AM UTC-4 dex9...@gmail.com wrote:
>
> Thank you brother @coolguy, I have put to work your latest solution and it 
> has worked like a charm.I have been learning a lot from you lately, as you 
> know i am still a beginner, i would love to learn one more thing from 
> you..i have a boolean field "completed", and i want django to automatically 
> check it when balance_fees or remaining_fees is equal to zero, 
>
> Here is  my model
>
>  my template
>
>  
>
>  
>
> Sent from Mail  for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Friday, September 11, 2020 8:51 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> Technically your Fee model is designed incorrectly. You should have 
> separate models for 'fees' and 'fees_paid' where fee would have been the 
> foreign key in 'fees_paid. Fee should have a property like annual fee etc 
> for each student as fee may be different based on student discounts etc. 
> Then when student pays the fees, fees should go in a separate transactional 
> table i.e. 'fees paid'. In your scenario, does each row in fee table 
> carries the annual/school fee? if so then yes summing them up will 
> definitely cause incorrect figure.
>
>  
>
> Here is what i would do if i don't change my models structure.
>
>  
>
> views.py
>
> ===
>
> def student_detail(request, pk):
>
> student = Student.objects.get(id=pk)
>
> 
>
> *# in your case pick the first record from fee_set*
>
> first_record = student.fee_set.first()
>
> school_fees = first_record.school_fees
>
> 
>
> paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))
>
> 
>
> balance_fees =  school_fees - paid_fees["total_paid_fees"] 
>
>  
>
> context = {"student": student,
>
>"paid_fees": paid_fees,
>
>"school_fees": school_fees,
>
>"balance_fees": balance_fees, }
>
>  
>
> return render(request, "student_details.html", context)
>
>  
>
> template
>
> ===
>
> 
>
> Student Detail
>
> Student name: {{ student.name }}
>
> School fees: {{ school_fees }}
>
> Paid fees: {{ paid_fees.total_paid_fees }}
>
> Remaining fees: {{ balance_fees }}
>
> 
>
>  
>
> Output:
>
> 
>
> Student name: student1
>
> School fees: 10.0
>
> Paid fees: 35000.0
>
> Remaining fees: 65000.0
>
>  
>
> On Friday, September 11, 2020 at 5:25:28 AM UTC-4 dex9...@gmail.com wrote:
>
> Sorry for bothering you @coolguy, you’re the only person who seems to be 
> nice to a Django beginner developer like me, and I would like to bother you 
> one more time
>
> Your solution for using methods in models is perfectly fine
>
> You see I want school_fees to be a fixed amount, example $300
>
> So when a student pays more than once(student.fee_set), lets say this 
> month student 1 pays $50 
>
> And another month pays $100 dollars, I want payments to added and 
> subtracted from fixed schools_fees($300)
>
> Remainingfees to be $300 – (($50)+($100))
>
>  
>
> BUT what “ 
> fees = 

RE: Help me with the view please

2020-09-14 Thread fadhil alex
Thanks it has worked, but it doesn’t work with my total_paid_fees, I want to be automatically checked when school_fees substracts summation of all paid_fees, just like this solution you provided me with the last timefirst_record = student.fee_set.first() school_fees = first_record.school_fees  paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))   balance_fees =  school_fees - paid_fees["total_paid_fees"]   Sent from Mail for Windows 10 From: coolguySent: Monday, September 14, 2020 9:09 PMTo: Django usersSubject: Re: Help me with the view please Its simple... in your fee models' save method check that self.remaining_fees is zero then make self.completed field to true... I added else clause in case if admin make changes to paid fees and after changes student still has some dues.     def save(self, *args, **kwargs): self.remaining_fees = self.school_fees - self.paid_feesif self.remaining_fees == 0:self.completed = Trueelse:self.completed = Falsesuper().save(*args, **kwargs) On Monday, September 14, 2020 at 7:11:51 AM UTC-4 dex9...@gmail.com wrote:Thank you brother @coolguy, I have put to work your latest solution and it has worked like a charm.I have been learning a lot from you lately, as you know i am still a beginner, i would love to learn one more thing from you..i have a boolean field "completed", and i want django to automatically check it when balance_fees or remaining_fees is equal to zero, Here is  my model my template  Sent from Mail for Windows 10 From: coolguySent: Friday, September 11, 2020 8:51 PMTo: Django usersSubject: Re: Help me with the view please Technically your Fee model is designed incorrectly. You should have separate models for 'fees' and 'fees_paid' where fee would have been the foreign key in 'fees_paid. Fee should have a property like annual fee etc for each student as fee may be different based on student discounts etc. Then when student pays the fees, fees should go in a separate transactional table i.e. 'fees paid'. In your scenario, does each row in fee table carries the annual/school fee? if so then yes summing them up will definitely cause incorrect figure. Here is what i would do if i don't change my models structure. views.py===def student_detail(request, pk):student = Student.objects.get(id=pk)# in your case pick the first record from fee_setfirst_record = student.fee_set.first()school_fees = first_record.school_feespaid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))balance_fees =  school_fees - paid_fees["total_paid_fees"]  context = {"student": student,   "paid_fees": paid_fees,   "school_fees": school_fees,   "balance_fees": balance_fees, } return render(request, "student_details.html", context) template===Student DetailStudent name: {{ student.name }}School fees: {{ school_fees }}Paid fees: {{ paid_fees.total_paid_fees }}Remaining fees: {{ balance_fees }} Output:Student name: student1School fees: 10.0Paid fees: 35000.0Remaining fees: 65000.0 On Friday, September 11, 2020 at 5:25:28 AM UTC-4 dex9...@gmail.com wrote:Sorry for bothering you @coolguy, you’re the only person who seems to be nice to a Django beginner developer like me, and I would like to bother you one more timeYour solution for using methods in models is perfectly fineYou see I want school_fees to be a fixed amount, example $300So when a student pays more than once(student.fee_set), lets say this month student 1 pays $50 And another month pays $100 dollars, I want payments to added and subtracted from fixed schools_fees($300)Remainingfees to be $300 – (($50)+($100)) BUT what “ fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'), total_school_fees=Sum('school_fees'))” does is that it sums both paid fees school fees every time a student pays, I want only paid fees to added every time a student pays but not school fees   Sent from Mail for Windows 10 From: coolguySent: Friday, September 11, 2020 4:27 AMTo: Django usersSubject: Re: Help me with the view please If i choose to go with your way of calculation, i would do this... def student_detail(request, pk):student = Student.objects.get(id=pk)fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'), total_school_fees=Sum('school_fees')) balance_fees = fees["total_school_fees"] - fees["total_paid_fees"] context = {"student": student, "fees": fees, "balance_fees": balance_fees, } return render(request, "student_details.html", context) Template e.g.Student DetailStudent name: {{ student.name }}School fees: {{ fees.total_school_fees }}Paid fees: {{ fees.total_paid_fees }}Remaining fees: {{ balance_fees }} Result:Student DetailStudent name: student1School fees: 10.0Paid fees: 25000.0Remaining fees: 75000.0I hope this helps!On Thursday, September 10, 2020 at 2:16:27 PM UTC-4 

Re: I am getting this error while I click on comment button which i mention in line 51 in html file.

2020-09-14 Thread coolguy
This is not the same error...

What is this 'Post' in your >>> post=Post.objects.filter(Post, pk=ID)
based on the django error you are using model here which is not how filter 
works...

this should be a field name like xxx.filter(field_name__id=ID)

I would suggest you to refer to documentation on filter to familiarize 
yourself.

https://docs.djangoproject.com/en/3.1/topics/db/aggregation/

https://docs.djangoproject.com/en/3.1/topics/db/aggregation/#filter-and-exclude




On Monday, September 14, 2020 at 3:09:04 PM UTC-4 yashlan...@gmail.com 
wrote:

> still i am getting error.[image: 8.PNG][image: 10.PNG][image: 13.PNG][image: 
> 12.PNG]
>
> On Saturday, September 12, 2020 at 9:59:16 PM UTC+5:30 coolguy wrote:
>
>> Can't see the line number in your provided screens.
>> However, i can see you have additional id id={{ i.id }}added to your 
>> button line. (remove it)
>> You have already provided the id in href="{% url 'userpage:post_detail' 
>> i.id %}" attribute.
>>
>> On Saturday, September 12, 2020 at 4:34:10 AM UTC-4 yashlan...@gmail.com 
>> wrote:
>>
>>> [image: 1..PNG]
>>> [image: 2.PNG]
>>> [image: 3.PNG]
>>> [image: 4.PNG]
>>>
>>

-- 
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/d6eb7545-8312-419a-ac5a-07edaaee6fb8n%40googlegroups.com.


Change DateField Like this

2020-09-14 Thread kkwaq...@gmail.com
How to change date format in django (mmdd to ddmm)

-- 
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/fd00441a-bede-49cb-ab16-704d0177a416n%40googlegroups.com.


Re: Help me with the view please

2020-09-14 Thread coolguy
Its simple... in your fee models' save method check that 
self.remaining_fees is zero then make self.completed field to true... I 
added else clause in case if admin make changes to paid fees and after 
changes student still has some dues.

def save(self, *args, **kwargs):
self.remaining_fees = self.school_fees - self.paid_fees
if self.remaining_fees == 0:
self.completed = True
else:
self.completed = False

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

On Monday, September 14, 2020 at 7:11:51 AM UTC-4 dex9...@gmail.com wrote:

> Thank you brother @coolguy, I have put to work your latest solution and 
> it has worked like a charm.I have been learning a lot from you lately, as 
> you know i am still a beginner, i would love to learn one more thing from 
> you..i have a boolean field "completed", and i want django to automatically 
> check it when balance_fees or remaining_fees is equal to zero, 
>
> Here is  my model
> [image: image.png]
>
>  my template
> [image: image.png]
>
>  
>
>  
>
> Sent from Mail  for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Friday, September 11, 2020 8:51 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> Technically your Fee model is designed incorrectly. You should have 
> separate models for 'fees' and 'fees_paid' where fee would have been the 
> foreign key in 'fees_paid. Fee should have a property like annual fee etc 
> for each student as fee may be different based on student discounts etc. 
> Then when student pays the fees, fees should go in a separate transactional 
> table i.e. 'fees paid'. In your scenario, does each row in fee table 
> carries the annual/school fee? if so then yes summing them up will 
> definitely cause incorrect figure.
>
>  
>
> Here is what i would do if i don't change my models structure.
>
>  
>
> views.py
>
> ===
>
> def student_detail(request, pk):
>
> student = Student.objects.get(id=pk)
>
> 
>
> *# in your case pick the first record from fee_set*
>
> first_record = student.fee_set.first()
>
> school_fees = first_record.school_fees
>
> 
>
> paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))
>
> 
>
> balance_fees =  school_fees - paid_fees["total_paid_fees"] 
>
>  
>
> context = {"student": student,
>
>"paid_fees": paid_fees,
>
>"school_fees": school_fees,
>
>"balance_fees": balance_fees, }
>
>  
>
> return render(request, "student_details.html", context)
>
>  
>
> template
>
> ===
>
> 
>
> Student Detail
>
> Student name: {{ student.name }}
>
> School fees: {{ school_fees }}
>
> Paid fees: {{ paid_fees.total_paid_fees }}
>
> Remaining fees: {{ balance_fees }}
>
> 
>
>  
>
> Output:
>
> 
>
> Student name: student1
>
> School fees: 10.0
>
> Paid fees: 35000.0
>
> Remaining fees: 65000.0
>
>  
>
> On Friday, September 11, 2020 at 5:25:28 AM UTC-4 dex9...@gmail.com wrote:
>
> Sorry for bothering you @coolguy, you’re the only person who seems to be 
> nice to a Django beginner developer like me, and I would like to bother you 
> one more time
>
> Your solution for using methods in models is perfectly fine
>
> You see I want school_fees to be a fixed amount, example $300
>
> So when a student pays more than once(student.fee_set), lets say this 
> month student 1 pays $50 
>
> And another month pays $100 dollars, I want payments to added and 
> subtracted from fixed schools_fees($300)
>
> Remainingfees to be $300 – (($50)+($100))
>
>  
>
> BUT what “ 
> fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'), 
> total_school_fees=Sum('school_fees'))” 
> does is that it sums both paid fees school fees every time a student pays, 
> I want only paid fees to added every time a student pays but not school fees
>
>  
>
>  
>
>  
>
> Sent from Mail  for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Friday, September 11, 2020 4:27 AM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> If i choose to go with your way of calculation, i would do this...
>
>  
>
> def student_detail(request, pk):
>
> student = Student.objects.get(id=pk)
>
>
> fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'), 
> total_school_fees=Sum('school_fees'))
>
>  
>
> balance_fees = fees["total_school_fees"] - fees["total_paid_fees"]
>
>  
>
> context = {"student": student, 
> "fees": fees, "balance_fees": balance_fees, }
>
>  
>
> return render(request, "student_details.html", context)
>
>  
>
> Template e.g.
>
> 
>
> Student Detail
>
> Student name: {{ student.name }}
>
> School fees: {{ fees.total_school_fees }}
>
> Paid fees: {{ fees.total_paid_fees }}
>
> Remaining fees: {{ balance_fees }}
>
> 
>
>  
>
> Result:
>
> Student Detail
>
> Student 

Re: AttributeError: object has no attribute 'user' while trying to access instance.user.id

2020-09-14 Thread coolguy
If i had to stick to your code then i would save the file with 
instance.username. username is available and folder would be readable as 
well.

However, as i mentioned in my last reply and seems you agreed, 
save/register the employee and then have employee upload the picture.

On Monday, September 14, 2020 at 8:20:21 AM UTC-4 mislav@gmail.com 
wrote:

> What I can do is first register the employee via a register form, then 
> once he logs in ask him/her for the profile picture. *Can I do that this 
> way? *
>
> If I do it this way, I don't have to change my model in any way.
>
> Dana nedjelja, 13. rujna 2020. u 18:11:18 UTC+2 korisnik coolguy napisao 
> je:
>
>> not sure about the purpose of showing that example in Django 
>> documentation while its comments are clear that "object will not have been 
>> saved to the database yet, so if it uses the default AutoField, *it 
>> might not yet have a value for its primary key field*."
>>
>> so that's the reason for having None with file path.
>>
>> In this approach what i can see is to save the employee first without 
>> file and then edit and select the file.
>>
>> I would not use this approach and rather keep it simple as followed:
>>
>> photo = models.ImageField(upload_to='employee/%Y/%m/%d/', blank=True)
>>
>> On Sunday, September 13, 2020 at 5:41:18 AM UTC-4 mislav@gmail.com 
>> wrote:
>>
>>> Hey coolguy,
>>>
>>> thanks for responding. After I changed that line as you suggested that 
>>> error is solved, *but when I add the user through the admin interface, 
>>> I get None as the ID* (the folder that gets created in the 
>>> */media/users* is titled *None*). I'm not sure if this is expected 
>>> behavior.
>>>
>>> I haven't added the registration or the login yet, so maybe the ID gets 
>>> a value when someone is actually registering.
>>>
>>> Let me know.
>>>
>>> Best,
>>> Mislav
>>>
>>> Dana subota, 12. rujna 2020. u 21:57:21 UTC+2 korisnik coolguy napisao 
>>> je:
>>>
 I wanted to see your model to understand but i realized after my last 
 post that you are using "instance.user.id" while your employee 
 instance does not have user field. (had to go somewhere urgently) >>> 
 return "employees/media/users/{0}/profile_picture.{1}".format(
 instance.user.id, extension)  

 change it as follow and remove user from it.
 return "employees/media/users/{0}/profile_picture.{1}".format(
 instance.id , extension)  

 It should work...

 On Saturday, September 12, 2020 at 3:17:28 PM UTC-4 
 mislav@gmail.com wrote:

> coolguy here is the complete Employee model:
>
> class Employee(models.Model): #TODO: Double-check this
> username = models.CharField(max_length=50, unique=True)
> email = models.EmailField()
> password = models.CharField(max_length=50)
> first_name = models.CharField(max_length=150)
> last_name = models.CharField(max_length=100)
> website = models.URLField(max_length=200, blank=True)
>
> profile_picture = models.ImageField(upload_to=get_upload_path, 
> blank=True, null=True)
> 
> def __str__(self):
> return str(self.first_name) + str(self.last_name)
>
> *Why do I need the foreign key to User in the first place?* I don't 
> recall seing the foreign key to User in any one of the tutorials.
> Dana subota, 12. rujna 2020. u 20:20:11 UTC+2 korisnik coolguy napisao 
> je:
>
>> Please share the complete employee model. It seems you are missing 
>> User foreign key in it.
>>
>> On Saturday, September 12, 2020 at 2:03:20 PM UTC-4 
>> mislav@gmail.com wrote:
>>
>>> Hey guys,
>>>
>>> I have the following code in models.py file in one of my apps:
>>>
>>> def get_upload_path(instance, filename):
>>> extension = filename.split('.')[-1]
>>> return "employees/media/users/{0}/profile_picture.{1}".format(
>>> instance.user.id, extension)
>>>
>>> class Employee(models.Model):
>>> # some attributes here
>>> profile_picture = models.ImageField(upload_to=get_upload_path, 
>>> blank=True, null=True)
>>>
>>> I am getting the following error when I try to add an Employee via 
>>> the admin interface:
>>>
>>> AttributeError at /admin/employees/employee/add/
>>>
>>> 'Employee' object has no attribute 'user'
>>>
>>> *I don't know where this error is stemming from.* I took the 
>>> get_upload_path function from the official Django FIleField 
>>> documentation 
>>> 
>>> .
>>>
>>> Any ideas as to what is going on here?
>>>
>>> Best,
>>> Mislav
>>>
>>

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

Re: Help me with the view please

2020-09-14 Thread coolguy
Its simple... in your fee models' save method check that 
self.remaining_fees is zero then make self.completed field to true..

def save(self, *args, **kwargs):
self.remaining_fees = self.school_fees - self.paid_fees
if self.remaining_fees == 0:
self.completed = True
super().save(*args, **kwargs)

On Monday, September 14, 2020 at 7:11:51 AM UTC-4 dex9...@gmail.com wrote:

> Thank you brother @coolguy, I have put to work your latest solution and 
> it has worked like a charm.I have been learning a lot from you lately, as 
> you know i am still a beginner, i would love to learn one more thing from 
> you..i have a boolean field "completed", and i want django to automatically 
> check it when balance_fees or remaining_fees is equal to zero, 
>
> Here is  my model
> [image: image.png]
>
>  my template
> [image: image.png]
>
>  
>
>  
>
> Sent from Mail  for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Friday, September 11, 2020 8:51 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> Technically your Fee model is designed incorrectly. You should have 
> separate models for 'fees' and 'fees_paid' where fee would have been the 
> foreign key in 'fees_paid. Fee should have a property like annual fee etc 
> for each student as fee may be different based on student discounts etc. 
> Then when student pays the fees, fees should go in a separate transactional 
> table i.e. 'fees paid'. In your scenario, does each row in fee table 
> carries the annual/school fee? if so then yes summing them up will 
> definitely cause incorrect figure.
>
>  
>
> Here is what i would do if i don't change my models structure.
>
>  
>
> views.py
>
> ===
>
> def student_detail(request, pk):
>
> student = Student.objects.get(id=pk)
>
> 
>
> *# in your case pick the first record from fee_set*
>
> first_record = student.fee_set.first()
>
> school_fees = first_record.school_fees
>
> 
>
> paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))
>
> 
>
> balance_fees =  school_fees - paid_fees["total_paid_fees"] 
>
>  
>
> context = {"student": student,
>
>"paid_fees": paid_fees,
>
>"school_fees": school_fees,
>
>"balance_fees": balance_fees, }
>
>  
>
> return render(request, "student_details.html", context)
>
>  
>
> template
>
> ===
>
> 
>
> Student Detail
>
> Student name: {{ student.name }}
>
> School fees: {{ school_fees }}
>
> Paid fees: {{ paid_fees.total_paid_fees }}
>
> Remaining fees: {{ balance_fees }}
>
> 
>
>  
>
> Output:
>
> 
>
> Student name: student1
>
> School fees: 10.0
>
> Paid fees: 35000.0
>
> Remaining fees: 65000.0
>
>  
>
> On Friday, September 11, 2020 at 5:25:28 AM UTC-4 dex9...@gmail.com wrote:
>
> Sorry for bothering you @coolguy, you’re the only person who seems to be 
> nice to a Django beginner developer like me, and I would like to bother you 
> one more time
>
> Your solution for using methods in models is perfectly fine
>
> You see I want school_fees to be a fixed amount, example $300
>
> So when a student pays more than once(student.fee_set), lets say this 
> month student 1 pays $50 
>
> And another month pays $100 dollars, I want payments to added and 
> subtracted from fixed schools_fees($300)
>
> Remainingfees to be $300 – (($50)+($100))
>
>  
>
> BUT what “ 
> fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'), 
> total_school_fees=Sum('school_fees'))” 
> does is that it sums both paid fees school fees every time a student pays, 
> I want only paid fees to added every time a student pays but not school fees
>
>  
>
>  
>
>  
>
> Sent from Mail  for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Friday, September 11, 2020 4:27 AM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> If i choose to go with your way of calculation, i would do this...
>
>  
>
> def student_detail(request, pk):
>
> student = Student.objects.get(id=pk)
>
>
> fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'), 
> total_school_fees=Sum('school_fees'))
>
>  
>
> balance_fees = fees["total_school_fees"] - fees["total_paid_fees"]
>
>  
>
> context = {"student": student, 
> "fees": fees, "balance_fees": balance_fees, }
>
>  
>
> return render(request, "student_details.html", context)
>
>  
>
> Template e.g.
>
> 
>
> Student Detail
>
> Student name: {{ student.name }}
>
> School fees: {{ fees.total_school_fees }}
>
> Paid fees: {{ fees.total_paid_fees }}
>
> Remaining fees: {{ balance_fees }}
>
> 
>
>  
>
> Result:
>
> Student Detail
>
> Student name: student1
>
> School fees: 10.0
>
> Paid fees: 25000.0
>
> Remaining fees: 75000.0
>
> I hope this helps!
>
> On Thursday, September 10, 2020 at 2:16:27 PM UTC-4 

Re: Account activity How to logout a particular device to logout.

2020-09-14 Thread Kasper Laudrup

Hi Salima,

On 15/09/2020 02.18, Salima Begum wrote:

Hi all,
By using python and django.

 1. User Login with one account in different devices.
 2. If he login into another device we sent user to email. Saying that
New device login.
 3. After we show user in his/her account activity page With that
account how many devices are login.
 4. Then if user clicks on sign-out to a particular device then that
particular device should be logoff and deleted from activity list.
 5. The only remain thing is that signout to a particular device.
 6. How to do signout to a particular device from his activity list.

   For example, User has 2 devices and He/She login from 2 devices with 
one account. In his account activity it will show 2 devices how to 
signout another device from his account activity. In python and django




I don't have any experience with that, but I'd look into how you could 
make sessions persistent and have multiple sessions associated with the 
same user account.


That way it should be possible to have the user expire/delete any of the 
current sessions after a successful login.


You might have to a bit of extra trickery to try and associate a session 
with a device. The device in that case would be whatever client was 
saving the session cookies, e.g. two different browsers on the same 
device would equal two different devices.


That's probably what I would try to do. Be aware that it's probably 
impossible to this in a reliable way no matter what and of course, don't 
ever trust whatever the client sends you.


Hope that helps a bit.

Kind regards,

Kasper Laudrup

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6b5f1a14-cca6-29d9-3ed3-66cd1a26e3b4%40stacktrace.dk.


Re: Account activity How to logout a particular device to logout.

2020-09-14 Thread Kasper Laudrup

Hi Farai,

On 14/09/2020 14.17, Farai M wrote:
You might need to capture mac address on login then associate it with 
the login session




You can't do that. Or, you could probably look up the IP address in the 
HTTP header in the local ARP cache on the server where your Django 
application is running. In case that both the client and the server are 
on the same network, you might be able to find it, but that's a very 
limited use case and definitely not reliable even if it could be assumed 
that the devices would always be on the same network.


If you control the client to some extent, you might be able to send the 
local MAC address in eg. the HTTP header, but then you might as well use 
a more reliable unique identifier, but that all depends on what you are 
able to retrieve on the client side. Of course, none of that information 
should actually be trusted though.


Kind regards,

Kasper Laudrup

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4646dd3e-623e-1a03-e564-05baec20818b%40stacktrace.dk.


Re: I've got two apps in my project and each one should have different authentication model. How do achieve this?

2020-09-14 Thread dum dum
You can actually just extend it like the First app.
1. Create new Model for Second App authentication.
2. Just connect with User model the fields that are needed, the rest you
can add it on the new Model

It could be the one of the easy ways.
Thanks

On Mon, Sep 14, 2020 at 11:00 PM Mislav Jurić 
wrote:

> Hey guys,
>
> as the title says, I've got two apps in my project and each one should
> have different authentication model.
>
> My first app just extends the User class, which I have done following the
> instructions here
> .
> However, my second app should have a custom User class (with just the
> username, email and password) and I have read the instructions here
> ,
> but those instructions imply that I would have to change the configuration
> of my project, which I don't want, because my first app uses the default
> User class and just extends it.
>
> I deleted my database and am starting fresh.
>
> *How do I do this?* Do I change the project-wide setting as described here
> ,
> add the class *User(AbstractUser)* to both of my apps's *models.py* files
> and then in my second app create a new user class based on my needs (i.e.
> *MyUser(User)*)?
>
> Best,
> Mislav
>
> --
> 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/CABTqP_F%3DV1spho7D78QqqfaCVKdUhuPGL1s3wdxdc9okubHKjg%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/CANV3w%3DYBzjbUxeAOqaFmTwtuse7e3B4HCrzUr0xnbeM2La_9ug%40mail.gmail.com.


HTML5 drag and drop: How does it really work?

2020-09-14 Thread Elliot
I am familiar with the various events in building a dnd.  I am trying to 
find out what is supposed to happen to the HTML source when a drag and drop 
works. Can anyone explain this to me.? After an apparently successful drag 
and drop I see no changes to the underlying HTML. I have been using Django 
3.0.10 and Python 3.8.1 and javascript. 

If I do a "view source" after a dnd should the source code now reflect the 
changes made by the dnd?  Exactly what is supposed to happen?  I am not 
submitting any code because I just want to find out how it is supposed to 
work.

-- 
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/4f113b77-800c-4592-bd91-43406b78589cn%40googlegroups.com.


I've got two apps in my project and each one should have different authentication model. How do achieve this?

2020-09-14 Thread Mislav Jurić
Hey guys,

as the title says, I've got two apps in my project and each one should have
different authentication model.

My first app just extends the User class, which I have done following the
instructions here
.
However, my second app should have a custom User class (with just the
username, email and password) and I have read the instructions here
,
but those instructions imply that I would have to change the configuration
of my project, which I don't want, because my first app uses the default
User class and just extends it.

I deleted my database and am starting fresh.

*How do I do this?* Do I change the project-wide setting as described here
,
add the class *User(AbstractUser)* to both of my apps's *models.py* files
and then in my second app create a new user class based on my needs (i.e.
*MyUser(User)*)?

Best,
Mislav

-- 
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/CABTqP_F%3DV1spho7D78QqqfaCVKdUhuPGL1s3wdxdc9okubHKjg%40mail.gmail.com.


Re: AttributeError: object has no attribute 'user' while trying to access instance.user.id

2020-09-14 Thread Mislav Jurić
What I can do is first register the employee via a register form, then once 
he logs in ask him/her for the profile picture. *Can I do that this way? *

If I do it this way, I don't have to change my model in any way.

Dana nedjelja, 13. rujna 2020. u 18:11:18 UTC+2 korisnik coolguy napisao je:

> not sure about the purpose of showing that example in Django documentation 
> while its comments are clear that "object will not have been saved to the 
> database yet, so if it uses the default AutoField, *it might not yet have 
> a value for its primary key field*."
>
> so that's the reason for having None with file path.
>
> In this approach what i can see is to save the employee first without file 
> and then edit and select the file.
>
> I would not use this approach and rather keep it simple as followed:
>
> photo = models.ImageField(upload_to='employee/%Y/%m/%d/', blank=True)
>
> On Sunday, September 13, 2020 at 5:41:18 AM UTC-4 mislav@gmail.com 
> wrote:
>
>> Hey coolguy,
>>
>> thanks for responding. After I changed that line as you suggested that 
>> error is solved, *but when I add the user through the admin interface, I 
>> get None as the ID* (the folder that gets created in the */media/users* 
>> is titled *None*). I'm not sure if this is expected behavior.
>>
>> I haven't added the registration or the login yet, so maybe the ID gets a 
>> value when someone is actually registering.
>>
>> Let me know.
>>
>> Best,
>> Mislav
>>
>> Dana subota, 12. rujna 2020. u 21:57:21 UTC+2 korisnik coolguy napisao je:
>>
>>> I wanted to see your model to understand but i realized after my last 
>>> post that you are using "instance.user.id" while your employee instance 
>>> does not have user field. (had to go somewhere urgently) >>> return 
>>> "employees/media/users/{0}/profile_picture.{1}".format(instance.user.id, 
>>> extension)  
>>>
>>> change it as follow and remove user from it.
>>> return "employees/media/users/{0}/profile_picture.{1}".format(
>>> instance.id , extension)  
>>>
>>> It should work...
>>>
>>> On Saturday, September 12, 2020 at 3:17:28 PM UTC-4 mislav@gmail.com 
>>> wrote:
>>>
 coolguy here is the complete Employee model:

 class Employee(models.Model): #TODO: Double-check this
 username = models.CharField(max_length=50, unique=True)
 email = models.EmailField()
 password = models.CharField(max_length=50)
 first_name = models.CharField(max_length=150)
 last_name = models.CharField(max_length=100)
 website = models.URLField(max_length=200, blank=True)

 profile_picture = models.ImageField(upload_to=get_upload_path, 
 blank=True, null=True)
 
 def __str__(self):
 return str(self.first_name) + str(self.last_name)

 *Why do I need the foreign key to User in the first place?* I don't 
 recall seing the foreign key to User in any one of the tutorials.
 Dana subota, 12. rujna 2020. u 20:20:11 UTC+2 korisnik coolguy napisao 
 je:

> Please share the complete employee model. It seems you are missing 
> User foreign key in it.
>
> On Saturday, September 12, 2020 at 2:03:20 PM UTC-4 
> mislav@gmail.com wrote:
>
>> Hey guys,
>>
>> I have the following code in models.py file in one of my apps:
>>
>> def get_upload_path(instance, filename):
>> extension = filename.split('.')[-1]
>> return "employees/media/users/{0}/profile_picture.{1}".format(
>> instance.user.id, extension)
>>
>> class Employee(models.Model):
>> # some attributes here
>> profile_picture = models.ImageField(upload_to=get_upload_path, 
>> blank=True, null=True)
>>
>> I am getting the following error when I try to add an Employee via 
>> the admin interface:
>>
>> AttributeError at /admin/employees/employee/add/
>>
>> 'Employee' object has no attribute 'user'
>>
>> *I don't know where this error is stemming from.* I took the 
>> get_upload_path function from the official Django FIleField 
>> documentation 
>> .
>>
>> Any ideas as to what is going on here?
>>
>> Best,
>> Mislav
>>
>

-- 
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/428c96ea-d71b-4174-a8e7-ff5ad45f5ec3n%40googlegroups.com.


Re: Account activity How to logout a particular device to logout.

2020-09-14 Thread Farai M
You might need to capture mac address on login then associate it with the
login session

On Mon, Sep 14, 2020, 1:48 PM Salima Begum 
wrote:

> Hi all,
> By using python and django.
>
>
>1. User Login with one account in different devices.
>2. If he login into another device we sent user to email. Saying that
>New device login.
>3. After we show user in his/her account activity page With that
>account how many devices are login.
>4. Then if user clicks on sign-out to a particular device then that
>particular device should be logoff and deleted from activity list.
>5. The only remain thing is that signout to a particular device.
>6. How to do signout to a particular device from his activity list.
>
>   For example, User has 2 devices and He/She login from 2 devices with one
> account. In his account activity it will show 2 devices how to signout
> another device from his account activity. In python and django
>
> Thank You in advance
> ~ Salima
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMSz6bkQhOy8bA%3D1XgUZ6%2BXryhu0cf%3Dr%2BXGJ5UVNPZdxL6n90g%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/CAMeub5NYyroSTb8xzxcpPJ__bBehX77ZpULfBiUKAOhoAaUwFA%40mail.gmail.com.


Account activity How to logout a particular device to logout.

2020-09-14 Thread Salima Begum
Hi all,
By using python and django.


   1. User Login with one account in different devices.
   2. If he login into another device we sent user to email. Saying that
   New device login.
   3. After we show user in his/her account activity page With that account
   how many devices are login.
   4. Then if user clicks on sign-out to a particular device then that
   particular device should be logoff and deleted from activity list.
   5. The only remain thing is that signout to a particular device.
   6. How to do signout to a particular device from his activity list.

  For example, User has 2 devices and He/She login from 2 devices with one
account. In his account activity it will show 2 devices how to signout
another device from his account activity. In python and django

Thank You in advance
~ Salima

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMSz6bkQhOy8bA%3D1XgUZ6%2BXryhu0cf%3Dr%2BXGJ5UVNPZdxL6n90g%40mail.gmail.com.


Re: A beginner question

2020-09-14 Thread Annick Sakoua
Hi ,

Here is the documentation link, follow every steps of the tutorial and it 
gonna be fine.

https://docs.djangoproject.com/en/3.1/

All the best :)

Le dimanche 13 septembre 2020 à 13:17:37 UTC+1, neginha...@gmail.com a 
écrit :

> Hi, I'm a beginner, just now I installed Django, how can I use it??

-- 
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/47a4a68d-cb76-475a-b337-69f0bda7n%40googlegroups.com.