Download attachments plain text encoding 'ANSI'

2020-07-16 Thread Marchi
Hi,

I hope the encoding type of the download plintext file is ANSI, not UTF-8.

View.py

...
with open(file_path + filename, 'r', encoding='cp949') as fd:
# This plain text file from inside the server is an ANSI (cp949) 
encoded file.
response = HttpResponse(fd) 
response['Content-Type'] = "text/plain" 
response['Content -Disposition'] = "attachment; filename=%s" % filename 

return response
...

When text file is downloaded from chromium-based browser, it is downloaded 
as autf-8 encoding text file.

How can I modify the web server(views.py) to download as an ANSI (CP949) 
encoded text file?

Best Regards



-- 
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/b17c36e8-6f0e-46b1-936d-520cd24b0c2dn%40googlegroups.com.


Re: How to save images posted by application users

2020-07-16 Thread Exactly musty
I also had the same problem long time ago I remember i felt like hanging 
myself,here is what I did, i deleted the media folder,created by django, try 
this if it will 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/c3d661dd-7cf3-4ff7-9332-422687927a29o%40googlegroups.com.


Re: How to save images posted by application users

2020-07-16 Thread Ram
Hi Mottaz,

Thank you for your suggestion. We already tried a model with ImageField but
not luck yet. Here is our code snippet

image = models.ImageField(upload_to='media',
> null=True, blank=True) image2 = models.ImageField(upload_to='media',
> null=True, blank=True) image3 = models.ImageField(upload_to='media',
> null=True, blank=True)
>

settings.py has the related settings

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
> STATIC_URL = '/static/'
>
> MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
> MEDIA_URL = '/media/'
>
> and also we have urls patterns like this in urls.py

>
> from django.contrib.staticfiles.urls import static
>> from django.contrib.staticfiles.urls import staticfiles_urlpatterns
>> 
>> 
>>
> if settings.DEBUG is True:
>  urlpatterns += static(settings.MEDIA_URL,
> document_root=settings.MEDIA_ROOT)
>

 ran the following commands after the above changes

1. makemigrations
2. migrate
3. collectstatic
4. runserver

Then we posted an Ad in front end of the application with images and we
getting this error and images did not show up in front end,

>
> Not Found: /media/jpg1.jpg
>>>
>> [17/Jul/2020 10:27:27] "GET /media/bluejpg.jpg HTTP/1.1" 404 1816
>> [17/Jul/2020 10:27:27] "GET /media/jpg1.jpg HTTP/1.1" 404 1807
>>
> [17/Jul/2020 10:27:27] "GET /static/css/images/notice.png HTTP/1.1" 404
> 1689
>

 Thanks,
~Ram


On Thu, Jul 16, 2020 at 1:18 AM Mottaz Hegaze  wrote:

> You need a model with ImageField or FileField
>
> On Thu, 16 Jul 2020, 7:07 am Ram,  wrote:
>
>> Hi,
>>
>> We need to save images posted by our application users and the images
>> will be displayed in application UI once they are saved successfully. We
>> are trying with these parameters in our settings.py but they are not
>> working and our OS platform is Windows 10 OS. We know file paths are
>> different in Windows OS when compared to non Windows OS platforms. Did
>> anyone use Window OS in this community and able to save image successfully?
>>
>> STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
>>> STATIC_URL = '/static/'
>>>
>>>
>>> MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
>>> MEDIA_URL = '/media/'
>>>
>>>
>> Another challenge that we have is  that the above question is related to
>> development, becase we use Windows laptop for our application evelopment,
>> but once the code is integrated we need to deploy the code in our hosting
>> server that is running with Linux OS. So we are not sure how to handle the
>> case of multi OS platforms?
>>
>> I'm sure many people could have resolved this in their applications. I
>> appreciate if you can share suitabe recommendations?
>>
>> Best regards
>>
>>
>> --
>> 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/CA%2BOi5F095b3_rr2qv02qrneLKs%2BySO1AjXedUv%3D653LY3cfDnw%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/CAHV4E-cqB-S5xtKVQA1QyMCqoyZ0F6OHT%3DOPM034-iJ4OnmBEg%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/CA%2BOi5F0WofNvcTr8DrOAEv7UY_XJ6sU90LqcGfD6hdBmMFbjqQ%40mail.gmail.com.


Please help I want to list down all the users with the sharewith from the frontend in backend I used Many to Many field and also my data is not getting into database

2020-07-16 Thread mick
views.py
def notesadd(request):
form = NoteForm(request.POST or None)
if form.is_valid():
form.save()
form=NoteForm()
context = {
'form': form
}
print('submitted')
   
return render(request, 'notes.html', context)



models.py
class Notes(models.Model):
sharewith = models.ManyToManyField(User, blank=True, null=True)
subject = models.CharField(max_length=10, null=True)
uploadingdate = models.DateTimeField(null=True)
notesfile = models.FileField(null=True)
description = models.TextField(max_length=50,null=True)
   
def __str__(self):
  return self.sharewith.user.username

forms.py

class NoteForm(forms.ModelForm):
class Meta:
model=Notes
fields = [
'sharewith' ,
'subject',
'uploadingdate',
   'notesfile',
'description' ]

notes.html

 {% extends 'navigation.html' %}

 {% block body %}


  {% csrf_token %}

 
  
 

  
Subject:

{{note.subject}}
  

  


  
Description:

  
  

  
Choose Notes:

  

  





Share With

  {{form.username}}
 

  
  Submit

 

 
 {% endblock  %}



admin.py
from django.contrib import admin

from .models import Notes

admin.site.register(Notes)


-- 
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/c669fa9c-a4ec-45ed-8409-abe85ce5982do%40googlegroups.com.


Re: How to provide background image via url() in django

2020-07-16 Thread Sujata Aghor
I set background image like below in the style tag of the html page. It
works !


   body{
background: url({% static 'users/img/bg/name_of _image.png'%})
no-repeat center center fixed;
-webkit-background-size:cover;
-moz--background-size:cover;
-o--background-size:cover;
background-size: cover;
   }




On Fri, Jul 17, 2020 at 4:38 AM sunday honesty 
wrote:

> Hi django users, pls help me with this:
>
> In case we supply background image via the url() function as
> background-image: url("some_path/image.png")
>
> How do we do this in django static files?
> I tried
>
> url("{% static 'some_path/image.png' %}")
>
> but it didn't work, how do I do this pls?
>
> --
> 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/c711150b-910c-4cbb-9823-48e0657fe352o%40googlegroups.com
> .
>


-- 

Thanks & Regards!
Sujata S. Aghor

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


Re: How to provide background image via url() in django

2020-07-16 Thread Exactly musty
i encounter alot shit when adding static to a url background images,django 
templates can be shitty sometimes,because sometimes it wont pick up due to 
some spacing ,its very annoying,here is what i do either i write the same 
code by myself again beneath it but mostly it always worked by copying 
another url background image then i edit it,let me explain, in your 
templates you must have another url background images you have added static 
to and it worked just copy it beneath your main problem then edit it after 
editing delete the problem and restart your dev server

On Friday, July 17, 2020 at 12:08:11 AM UTC+1, sunday honesty wrote:
>
> Hi django users, pls help me with this:
>
> In case we supply background image via the url() function as 
> background-image: url("some_path/image.png")
>
> How do we do this in django static files?
> I tried 
>
> url("{% static 'some_path/image.png' %}")
>
> but it didn't work, how do I do this pls?
>
>

-- 
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/b9c5147a-d924-4600-aa3f-256fe6e48620o%40googlegroups.com.


Re: How to provide background image via url() in django

2020-07-16 Thread Desh Deepak
Try it

url(" static 'some_path/image.png' ")

On Fri, 17 Jul 2020, 4:38 am sunday honesty, 
wrote:

> Hi django users, pls help me with this:
>
> In case we supply background image via the url() function as
> background-image: url("some_path/image.png")
>
> How do we do this in django static files?
> I tried
>
> url("{% static 'some_path/image.png' %}")
>
> but it didn't work, how do I do this pls?
>
> --
> 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/c711150b-910c-4cbb-9823-48e0657fe352o%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/CAJ0m4xjEH01K4x83%2BbaRkfn7BCPeFzL%3DurCjVu3AfoPyJBeK6w%40mail.gmail.com.


How to provide background image via url() in django

2020-07-16 Thread sunday honesty
Hi django users, pls help me with this:

In case we supply background image via the url() function as 
background-image: url("some_path/image.png")

How do we do this in django static files?
I tried 

url("{% static 'some_path/image.png' %}")

but it didn't work, how do I do this pls?

-- 
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/c711150b-910c-4cbb-9823-48e0657fe352o%40googlegroups.com.


Re: ModuleNotFoundError: No module named 'django'

2020-07-16 Thread Exactly musty
Are you sure you are in your virtual environment, if not make sure you 
activate your env then install all requirements before you migrations or 
runserver




On Thursday, July 16, 2020 at 7:50:11 PM UTC+1, harshith kumar pedarla 
wrote:
>
> I'm getting this error
>
>  Traceback (most recent call last):
>   File "C:/Users/lenovo/Desktop/Django Projects/telusko/telusko/urls.py", 
> line 16, in 
> from django.contrib import admin
>
> *ModuleNotFoundError: No module named 'django'*
>
> could someone please help in resolving this error in pycharm in Django in 
> virtual env
>
>

-- 
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/b3eb952c-0dd8-4729-9028-cfddbdc5cbb4o%40googlegroups.com.


ModuleNotFoundError: No module named 'django'

2020-07-16 Thread harshith kumar pedarla
I'm getting this error

 Traceback (most recent call last):
  File "C:/Users/lenovo/Desktop/Django Projects/telusko/telusko/urls.py", 
line 16, in 
from django.contrib import admin

*ModuleNotFoundError: No module named 'django'*

could someone please help in resolving this error in pycharm in Django in 
virtual env

-- 
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/3339ef62-a70f-41c5-9eca-e9eb794c489bo%40googlegroups.com.


Re: Two factor authentication using OTP

2020-07-16 Thread carlos
https://github.com/django-otp/django-otp-yubikey

On Thu, Jul 16, 2020 at 7:50 AM Kasper Laudrup 
wrote:

> Hi o1bigtenor,
>
> On 16/07/2020 15.18, o1bigtenor wrote:
> >
> > As a person who has very very very terrible wireless phone reception
> > where I live I would hope that there is some other method that can be
> > used to help with two factor authentication without using the bloody
> > useless cell phone.
> > It seems that the programming community thinks that everyone has
> > absolutely wonderful reception so that the use of a SMS text is a
> > wonderful idea.
> > There must be a better option that doesn't need to use of a cell phone.
> > (I hope and if not one should be found!)
> >
> > Please rethink your proposed plan sir!
> >
>
> In addition to that, it might be worth considering that accessing the
> web site from the same phone as the one receiving the one-time password
> defeats the whole purpose of two factor authentication if an attacker
> has control over the phone.
>
> Key cards with pregenerated one time codes or something like YubiKey:
>
> https://en.wikipedia.org/wiki/YubiKey
>
> seems like a much better option.
>
> 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/9357377a-13c6-c4bc-7328-70179ce99d15%40stacktrace.dk
> .
>


-- 
att.
Carlos Rocha

-- 
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/CAM-7rO0WWhR41rdY9mKuLtErKP-uWgvfR%2BE21WWr7-%2BWQ5iFDg%40mail.gmail.com.


Re: Two factor authentication using OTP

2020-07-16 Thread Kasper Laudrup

Hi o1bigtenor,

On 16/07/2020 15.18, o1bigtenor wrote:


As a person who has very very very terrible wireless phone reception 
where I live I would hope that there is some other method that can be 
used to help with two factor authentication without using the bloody 
useless cell phone.
It seems that the programming community thinks that everyone has 
absolutely wonderful reception so that the use of a SMS text is a 
wonderful idea.
There must be a better option that doesn't need to use of a cell phone. 
(I hope and if not one should be found!)


Please rethink your proposed plan sir!



In addition to that, it might be worth considering that accessing the 
web site from the same phone as the one receiving the one-time password 
defeats the whole purpose of two factor authentication if an attacker 
has control over the phone.


Key cards with pregenerated one time codes or something like YubiKey:

https://en.wikipedia.org/wiki/YubiKey

seems like a much better option.

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/9357377a-13c6-c4bc-7328-70179ce99d15%40stacktrace.dk.


Re: Two factor authentication using OTP

2020-07-16 Thread o1bigtenor
On Thu, Jul 16, 2020 at 6:52 AM Issa Kehinde  wrote:

> Hello everyone!
>
>  How can I implement a two factor authentication for my django web app?
> After a user login with his/her credential (i.e. username and password), I
> want  an OTP to be send to the user's phone number . The user will  enter
> the OTP to gain final access to the web application.
>
> As a person who has very very very terrible wireless phone reception where
I live I would hope that there is some other method that can be used to
help with two factor authentication without using the bloody useless cell
phone.
It seems that the programming community thinks that everyone has absolutely
wonderful reception so that the use of a SMS text is a wonderful idea.
There must be a better option that doesn't need to use of a cell phone. (I
hope and if not one should be found!)

Please rethink your proposed plan sir!

-- 
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/CAPpdf5_6g58H0uwz%2BpPdQCaf-BdJejJnAkAp2mQsO6_nSUzzmA%40mail.gmail.com.


Re: Two factor authentication using OTP

2020-07-16 Thread Kasper Laudrup

Hi Issa,

On 16/07/2020 11.36, Issa Kehinde wrote:

Hello everyone!

  How can I implement a two factor authentication for my django web app?
After a user login with his/her credential (i.e. username and password), 
I want  an OTP to be send to the user's phone number . The user will  
enter  the OTP to gain final access to the web application.




Have you tried looking at look at this?

https://github.com/django-otp

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/1c8c6bbe-c427-62db-0f45-ca44fb0785e4%40stacktrace.dk.


Joining 4 tables on 2 columns

2020-07-16 Thread Omar aboul makarem
class Company(models.Model):
id = models.UUIDField(primary_key = True, default = uuid.uuid4, editable = 
False)
name = models.CharField(_('Name'), max_length=64)


class Approval(models.Model):
 id = models.UUIDField(primary_key = True, default = uuid.uuid4, editable = 
False)
company = models.ForeignKey(Company, related_name=("approval_company"), 
on_delete=models.CASCADE, verbose_name = _('Company'))   
procedure = models.ForeignKey('Procedure', 
related_name=("approval_procedure"), on_delete=models.CASCADE, verbose_name = 
_('Procedure')) 


  
class Procedure(models.Model):
id = models.UUIDField(primary_key = True, default = uuid.uuid4, editable = 
False)
name = models.CharField(_('Name'), max_length=255)



class Price(models.Model):

id = models.UUIDField(primary_key = True, default = uuid.uuid4, editable = 
False)
company = models.ForeignKey('Company', related_name=("price_company"), 
on_delete=models.CASCADE, verbose_name = _('Insurance Company')) 
procedure = models.ForeignKey('Procedure', 
related_name=("price_procedure"), on_delete=models.CASCADE, verbose_name = 
_('Procedure'))   
price = models.IntegerField(_('Price'), )



I have these models, i want to make a queryset that can get me the prices of 
approvals that have been created and aggregate(sum('price'))

I cant find the django way to do it, i know the postgresql raw sql which is 


select main_price.price from main_approval  inner join main_price on 
main_approval.procedure_id = main_price.procedure_id and 
main_approval.company_id = main_price.company_id ;


Keeping in mind that main is my app name


How can i translate that sql in a django way

-- 
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/218172f0-d96e-4cab-b8c5-085b7ccc7d95o%40googlegroups.com.


Two factor authentication using OTP

2020-07-16 Thread Issa Kehinde
Hello everyone!

 How can I implement a two factor authentication for my django web app?
After a user login with his/her credential (i.e. username and password), I 
want  an OTP to be send to the user's phone number . The user will  enter  
the OTP to gain final access to the web application.  





-- 
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/00799d0b-5f0b-40be-a696-238991a2d965o%40googlegroups.com.


Re: How to save images posted by application users

2020-07-16 Thread Mottaz Hegaze
You need a model with ImageField or FileField

On Thu, 16 Jul 2020, 7:07 am Ram,  wrote:

> Hi,
>
> We need to save images posted by our application users and the images will
> be displayed in application UI once they are saved successfully. We are
> trying with these parameters in our settings.py but they are not working
> and our OS platform is Windows 10 OS. We know file paths are different in
> Windows OS when compared to non Windows OS platforms. Did anyone use Window
> OS in this community and able to save image successfully?
>
> STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
>> STATIC_URL = '/static/'
>>
>>
>> MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
>> MEDIA_URL = '/media/'
>>
>>
> Another challenge that we have is  that the above question is related to
> development, becase we use Windows laptop for our application evelopment,
> but once the code is integrated we need to deploy the code in our hosting
> server that is running with Linux OS. So we are not sure how to handle the
> case of multi OS platforms?
>
> I'm sure many people could have resolved this in their applications. I
> appreciate if you can share suitabe recommendations?
>
> Best regards
>
>
> --
> 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/CA%2BOi5F095b3_rr2qv02qrneLKs%2BySO1AjXedUv%3D653LY3cfDnw%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/CAHV4E-cqB-S5xtKVQA1QyMCqoyZ0F6OHT%3DOPM034-iJ4OnmBEg%40mail.gmail.com.