Re: Disable count admin

2019-06-13 Thread Michele Gatti
Thansk

Il giorno sab 8 giu 2019 alle ore 09:03 Derek  ha
scritto:

> Can you use:
>
>
> https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#django.contrib.admin.ModelAdmin.show_full_result_count
>
>
> On Monday, 3 June 2019 14:48:23 UTC+2, Michele Gatti wrote:
>>
>> Hi i need to disable paginato on django admin with not managed model.
>> Is possible?
>>
> --
> 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/IlnElmFeICY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/565da33a-3b81-4055-8677-d856f2591154%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKwk%3DN3ooVHg8qKDegXiNmtovsKVwGTKaq4hLDL11GM0kTCjPw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How can I send an outlook mail from angular using django

2019-06-13 Thread Andréas Kühne
Hi,

You cannot send outlook email via django at all. Django runs on a server
that hasn't access to the clients email application.

However - what you can do is use the standard a tag with a "mailto:"; link.
This should open the clients email program (whatever that is) and send an
email from there.
You can see some information about the this solution here:
http://blog.clickdimensions.com/pre-fill-an-email-created-via-mailto-link/

Best regards,

Andréas


Den tors 13 juni 2019 kl 03:19 skrev Taylor Hughes-Scott <
cooly792...@gmail.com>:

> I'm not so sure about sending outlook email through django. However i do
> know django has a basic email sending built in have you had a look at that?
> https://docs.djangoproject.com/en/2.2/topics/email/
>
> On Thu., 13 Jun. 2019, 10:41 am Sai Aravind, 
> wrote:
>
>> How can I send an outlook mail from angular using django can u please
>> provide a y document for this
>>
>> --
>> 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 post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/711f3310-0b89-400e-adff-4aaf61e51cff%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAAOisOJQGg05hZw98PQTHnbWVSfQQ9NERFccSm8ERJOqn5YirQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK4qSCf7Jn9NSDxN2HPy8w9t6_f9jS9GBLOhkXFMis2wE2oBtg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Confused with deleted migrations

2019-06-13 Thread Andréas Kühne
Hi Mohammed,

You need to make sure that all migrations that you do in development also
can be run on the production machine - the migrations should be version
controlled and checked in. Then you can run migrate when deploying new code
and all migrations should just work. This is how I do it at least.

It seems as though you have different migrations on the server and
development machine? I think that adds complexity that you really don't
want.

And it doesn't matter if you have mysql on the production server and sqlite
locally. The database settings should differ but the migrations are (more
or less) database agnostic, so you should be able to run the same
migrations (as long as you don't use specific database fields).

Regards,

Andréas


Den ons 12 juni 2019 kl 20:27 skrev Mohammad Etemaddar <
mohammad.etemad...@gmail.com>:

> Hey folks
> After uploading the app to the server, I got problems by local migrations
> in development. So deleted the migrations and local sqlite db (Server uses
> MySQL).
> After more development, uploaded the whole project to the server and
> overwrite the files. And typed migrate on server. I don't know what
> happened to the database. Some new tables seems to be created (or not). I
> got really confused with this situation. It is much confusing to get backup
> from server's data and then restore them back.
> What is your opinion?
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d050785c-3924-40cb-8c9c-2b878dda4ad5%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK4qSCcHqiW%2BScQ3TBJ3-OCaESu9MXj01J%3D3GFeWKfjZrnaFCA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: parse xml from url to database

2019-06-13 Thread Nuno Vieira


quarta-feira, 12 de Junho de 2019 às 17:22:01 UTC+1, Nuno Vieira escreveu:
>
> Hi there.
>
> I´m having some problems on parsing a real estate xml to database.
> The user profile have url field to import properties automatically from 
> xml feed (url). The user can insert mannually or automatically, if the user 
> insert the url feed then it should be able to get the objects and save them 
> to mysql database automatically.
> The function is not working and i do not know why, gives no error but 
> don´t populate the database.
>
> Models.py:
> class Listing(models.Model):
> '''Create table listing in db '''
> realtor = models.ForeignKey(User, on_delete=models.CASCADE)
> title = models.CharField(max_length=200)
> address = models.CharField(max_length=200)
> city = models.CharField(max_length=100)
> state = models.CharField(max_length=100)
> zipcode = models.CharField(max_length=20)
> longitude = models.DecimalField(max_digits=9, decimal_places=6,default=0)
> latitude = models.DecimalField(max_digits=9, decimal_places=6, default=0)
> description = models.TextField(blank=True)
> price = models.IntegerField()
> bedrooms = models.IntegerField()
> bathrooms = models.DecimalField(max_digits=2, decimal_places=1)
> garage = models.IntegerField(default=0)
> sqmt = models.IntegerField(blank=True)
> lot_size = models.DecimalField(max_digits=5, decimal_places=1,blank=True)
> On_Processing = 'On Processing'
> AMais = 'A+'
> A = 'A'
> B = 'B'
> BMenos = 'B-'
> C = 'C'
> D = 'D'
> E = 'E'
> F = 'F'
> ENERGY_RATE_CHOICES = [
> (On_Processing, 'On Processing'),
> (AMais, 'A+'),
> (A, 'A'),
> (B, 'B'),
> (BMenos, 'B-'),
> (C, 'C'),
> (D, 'D'),
> (E, 'E'),
> (F, 'F'),
> ]
> energy_rate = models.CharField(
> max_length=12,
> choices=ENERGY_RATE_CHOICES,
> default=On_Processing,
> )
> photo_main = models.ImageField(upload_to='photos/%Y/%m/%d/', default=
> 'default.jpg')
> photo_main_url = models.URLField(blank = True)
> is_published = models.BooleanField(default=True)
> list_date = models.DateTimeField(default=datetime.now, blank=True)
> video_url = models.CharField(max_length=100, blank=True) 
> virtual_tour = models.URLField(blank=True)
> visit_num = models.PositiveIntegerField(default=0)
>
> def __str__(self):
> return self.title
>
> def get_absolute_url(self):
> return reverse('listing-detail', kwargs={'pk': self.pk})
>
> Function on xml_parse.py:
> ...
> import xml.etree.ElementTree as ET
> import requests
> from users.models import Profile
>
>
> def xml_parse(self):
> prof_list = Profile.objects.all()
> for prof in prof_list:
> if prof.xml_ky is not None:
> url = xml_ky
> response = request.get(url)
> with open('xml/%s' % self.id + '/feed.xml', 'wb') as file:
> file.write(response.content)
>
> tree = ET.parse('xml/%s' % self.id + '/feed.xml')
> root = tree.getroot()
> for props in root.iter('property'): 
> listing, created = Listing.object.create(
> title = props.find('type').text + ' ' + props.find('town').text,
> address = props.find('location_detail').text,
> city = props.find('town').text, 
> state = props.find('province').text,
> zipcode = props.find('zipcode').text,
> loc = props.find('location'),
> longitude = loc.find('longitude').text,
> latitude = loc.find('latitude').text,
> desc = props.find('desc'),
> description = desc.find('en').text, 
> price = props.find('price').text, 
> bedrooms = props.find('beds').text,
> bathrooms = props.find('baths').text,
> garage = props.find('garage').text, 
> area = props.find('surface_area'),
> sqmt = area.find('built').text,
> energy_rate = props.find('energy_rate').text,
> realtor = self.request.user,
> img = props.find('images'),
> image = img.get('id=1'), 
> image_url = image.find('url').text,
> photo_main_url = image_url,
> video_url = props.find('video_url').text,
> virtual_tour = props.find('virtual_tour').text,
> )
> if created:
> return listing.save()
>
>
>
> If you could help me and point me in the right direction it would be great.
>
> Thanks and sorry for the black background!
>


Thanks for the reply.


 XML Example:



  
3
  

2150
2018-06-27 11:18:37
BC10002
1599900
EUR
sale
0
0
0

6000

Villa

37.134720
-8.020436

optional location detail
Loulé
Algarve
Portugal
5
5
1


http://bc-villas.com/wp-content/uploads/2018/05/001-DJI_0243.jpg


http://bc-villas.com/wp-content/uploads/2018/05/001b-IMG_3891.jpg


http://bc-villas.com/wp-content/uploads/2018/05/001c-IMG_3878.jpg


http://bc-villas.com/wp-content/uploads/2018/05/002-DJI_0233.jpg


http://bc-villas.com/wp-content/uploads/2018/05/003-DJI_0221.jpg






http://bc-villas.com/property/private-modern-5-bedrooms-villa/


This truly stunning  Private modern 5 bedrooms villa.
Set in 6,000m2 accessed by two security gates.
Located just below the old market town of Loule and only 8 minute drive to 
Vilasol and Vilamoura and everything you will need for luxury living .
10 minutes drive of the villa you will find championship golf courses, 
numerous restaurants, golden beaches, sports and leisure facilities. The 
f

Why "WebsocketDemultiplexer" is not available in 2.x series of Django Channels

2019-06-13 Thread Sajith Samarathunga
Why "WebsocketDemultiplexer" is not available in 2.x series the latest of 
Django Channels but only available on 1.x series of Django Channels. Is 
there any security or performance related reason for removing  
"WebsocketDemultiplexer". In 2.x documentation the topics "generics" 
and "WebSocket Multiplexing" is also not available. documentation for 1.x 
and 2.x the latest are following.Any reason for removing those things from 
the latest framework

https://channels.readthedocs.io/en/1.x/generics.html

https://channels.readthedocs.io/en/latest/



-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6555f95d-55ae-495c-bd88-f862b5c8c6e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Why "Generic Consumers" are removed from Djang Channels Latest Release

2019-06-13 Thread Sajith Samarathunga
Is there and reason for removing "Generic Consumers" which includes 
"WebsocketDemultiplexer". is there any security related reason or 
performance related reason behinf removing these from lated relase of 
django channels. documentation for both 2.x the latest and 1.x are 
following.


https://channels.readthedocs.io/en/latest/

https://channels.readthedocs.io/en/1.x/generics.html#websocket-multiplexing

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/838d5090-9e90-4838-923f-c159d30178a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: parse xml from url to database

2019-06-13 Thread Nuno Vieira
Hi Ewen,

thanks for the reply.
I have extended user model with a profile model and a new field (xml_ky). 
The goal is to verify each user profile and if they have an xml url on 
field xml_ky, than populate the database with the properties located on 
that url.

Thanks for your help.

quinta-feira, 13 de Junho de 2019 às 00:04:33 UTC+1, Ewen Le Bihan escreveu:
>
> Hi, where does prof.xml_ky comes from ?
>
> Le mercredi 12 juin 2019 18:22:01 UTC+2, Nuno Vieira a écrit :
>>
>> Hi there.
>>
>> I´m having some problems on parsing a real estate xml to database.
>> The user profile have url field to import properties automatically from 
>> xml feed (url). The user can insert mannually or automatically, if the user 
>> insert the url feed then it should be able to get the objects and save them 
>> to mysql database automatically.
>> The function is not working and i do not know why, gives no error but 
>> don´t populate the database.
>>
>> Models.py:
>> class Listing(models.Model):
>> '''Create table listing in db '''
>> realtor = models.ForeignKey(User, on_delete=models.CASCADE)
>> title = models.CharField(max_length=200)
>> address = models.CharField(max_length=200)
>> city = models.CharField(max_length=100)
>> state = models.CharField(max_length=100)
>> zipcode = models.CharField(max_length=20)
>> longitude = models.DecimalField(max_digits=9, decimal_places=6,default=0)
>> latitude = models.DecimalField(max_digits=9, decimal_places=6, default=0)
>> description = models.TextField(blank=True)
>> price = models.IntegerField()
>> bedrooms = models.IntegerField()
>> bathrooms = models.DecimalField(max_digits=2, decimal_places=1)
>> garage = models.IntegerField(default=0)
>> sqmt = models.IntegerField(blank=True)
>> lot_size = models.DecimalField(max_digits=5, decimal_places=1,blank=True)
>> On_Processing = 'On Processing'
>> AMais = 'A+'
>> A = 'A'
>> B = 'B'
>> BMenos = 'B-'
>> C = 'C'
>> D = 'D'
>> E = 'E'
>> F = 'F'
>> ENERGY_RATE_CHOICES = [
>> (On_Processing, 'On Processing'),
>> (AMais, 'A+'),
>> (A, 'A'),
>> (B, 'B'),
>> (BMenos, 'B-'),
>> (C, 'C'),
>> (D, 'D'),
>> (E, 'E'),
>> (F, 'F'),
>> ]
>> energy_rate = models.CharField(
>> max_length=12,
>> choices=ENERGY_RATE_CHOICES,
>> default=On_Processing,
>> )
>> photo_main = models.ImageField(upload_to='photos/%Y/%m/%d/', default=
>> 'default.jpg')
>> photo_main_url = models.URLField(blank = True)
>> is_published = models.BooleanField(default=True)
>> list_date = models.DateTimeField(default=datetime.now, blank=True)
>> video_url = models.CharField(max_length=100, blank=True) 
>> virtual_tour = models.URLField(blank=True)
>> visit_num = models.PositiveIntegerField(default=0)
>>
>> def __str__(self):
>> return self.title
>>
>> def get_absolute_url(self):
>> return reverse('listing-detail', kwargs={'pk': self.pk})
>>
>> Function on xml_parse.py:
>> ...
>> import xml.etree.ElementTree as ET
>> import requests
>> from users.models import Profile
>>
>>
>> def xml_parse(self):
>> prof_list = Profile.objects.all()
>> for prof in prof_list:
>> if prof.xml_ky is not None:
>> url = xml_ky
>> response = request.get(url)
>> with open('xml/%s' % self.id + '/feed.xml', 'wb') as file:
>> file.write(response.content)
>>
>> tree = ET.parse('xml/%s' % self.id + '/feed.xml')
>> root = tree.getroot()
>> for props in root.iter('property'): 
>> listing, created = Listing.object.create(
>> title = props.find('type').text + ' ' + props.find('town').text,
>> address = props.find('location_detail').text,
>> city = props.find('town').text, 
>> state = props.find('province').text,
>> zipcode = props.find('zipcode').text,
>> loc = props.find('location'),
>> longitude = loc.find('longitude').text,
>> latitude = loc.find('latitude').text,
>> desc = props.find('desc'),
>> description = desc.find('en').text, 
>> price = props.find('price').text, 
>> bedrooms = props.find('beds').text,
>> bathrooms = props.find('baths').text,
>> garage = props.find('garage').text, 
>> area = props.find('surface_area'),
>> sqmt = area.find('built').text,
>> energy_rate = props.find('energy_rate').text,
>> realtor = self.request.user,
>> img = props.find('images'),
>> image = img.get('id=1'), 
>> image_url = image.find('url').text,
>> photo_main_url = image_url,
>> video_url = props.find('video_url').text,
>> virtual_tour = props.find('virtual_tour').text,
>> )
>> if created:
>> return listing.save()
>>
>>
>>
>> If you could help me and point me in the right direction it would be 
>> great.
>>
>> Thanks and sorry for the black background!
>>
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/795d6c1e-c64b-4c2c-93f6-be

Re: my file uploads missing/deleted

2019-06-13 Thread omar ahmed
i followed the steps
when i typed 
python manage.py test [--settings=test_settings]
i found this error 
ModuleNotFoundError: No module named '[--settings=test_settings]'
and when i tried to open my site (club page that has image) i foun this 
error

No module named 'StringIO'

i searched at Google but no similar issues

On Thursday, June 13, 2019 at 1:03:10 AM UTC+2, James Farris wrote:
>
> This python package may be a better choice for you, since I assume you 
> want all user generated content (images) to be stored in Dropbox. 
>
> This has pretty good documentation. 
> https://pypi.org/project/django-dropbox-storage/
>
> If you use this package, remove the sample code I sent
>
>
> On Wed, Jun 12, 2019 at 3:53 PM omar ahmed  > wrote:
>
>> i added this function at the end of views.py file 
>> def connect_to_dropbox():
>> dbx = dropbox.Dropbox(‘your access token)
>> dbx.users_get_current_account()
>> and i put given access token from dropbox
>> then what about call
>> do you mean in any view function that will show page included images add  
>> connect_to_dropbox()
>> and what about 
>>
>> for entry in dbx.files_list_folder('').entries:
>> print(entry.name)
>>
>>
>>
>> On Thursday, June 13, 2019 at 12:38:11 AM UTC+2, James Farris wrote:
>>>
>>> You would add this code to the views.py file, which is where the 
>>> business logic goes. 
>>>
>>> https://docs.djangoproject.com/en/2.2/topics/http/views/
>>>
>>> Likely would add a class with properties and methods or a definition (a 
>>> function) like below:
>>>
>>> For example in your apps views.py file:
>>>
>>> def connect_to_dropbox():
>>> dbx = dropbox.Dropbox(‘your access token)
>>> dbx.users_get_current_account()
>>>
>>> # this stuff likely would go in a separate function
>>> for entry in dbx.files_list_folder(‘’).entries:
>>> print(entry.name)
>>>
>>>
>>> At some point in your code you would call the function:
>>> connect_to_dropbox()
>>>
>>> On Wed, Jun 12, 2019 at 3:10 PM omar ahmed  wrote:
>>>
 i opened the documentation for django-storages ... and i installed 
 Dropbox in my environment and i created my app folder  but i didn't 
 complete docs .
 somethings not clear ... like :
 Link an account 

 dbx = dropbox.Dropbox('YOUR_ACCESS_TOKEN')

 dbx.users_get_current_account()
 Try some API requests

 for entry in dbx.files_list_folder('').entries:
 print(entry.name)

 where should i write these commands ?
 thanks

 On Wednesday, June 12, 2019 at 1:13:11 AM UTC+2, James Farris wrote:
>
> You might try the docs from Dropbox
> https://www.dropbox.com/developers/documentation/python#overview
>
> You can checkout this project for ideas
> https://github.com/singingwolfboy/django-with-dropbox
>
> and here is documentation for django-storages
> https://django-storages.readthedocs.io/en/latest/backends/dropbox.html
>
>
>
> On Tue, Jun 11, 2019 at 2:17 PM omar ahmed  wrote:
>
>> yes James you are right i need to upload images using the Django 
>> admin, ... how can i use Dropbox for this issue ? 
>> i need a good tutorial
>>
>> On Tuesday, June 11, 2019 at 6:14:10 PM UTC+2, James Farris wrote:
>>>
>>> He is saying these aren’t static files. It sounds like he uploads 
>>> them using the Django admin, which of course is like an end user on a 
>>> client uploading files to the media directory. 
>>>
>>> Since that is the case it sounds like the Dropbox option is the 
>>> best. Documentation was provided earlier. So being that it seems like 
>>> he 
>>> read through the documentation, my question is where is he stuck in the 
>>> Dropbox implementation?
>>
>> -- 
>> 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/8O8BS7DhF30/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, send an email to 
>> django...@googlegroups.com.
>> To post to this group, send email to django...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/3d50f417-cceb-4141-9b6d-9d2f5d0feee4%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> -- 
 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/8O8BS7DhF30/unsubscribe.
 To unsubscribe from this group 

Re: my file uploads missing/deleted

2019-06-13 Thread James Farris
That means it wasn’t installed or it wasn’t added to your settings.py file in 
the installed apps section 

Sent from my mobile device

> On Jun 13, 2019, at 7:07 AM, omar ahmed  wrote:
> 
> i followed the steps
> when i typed 
> python manage.py test [--settings=test_settings]
> i found this error 
> ModuleNotFoundError: No module named '[--settings=test_settings]'
> and when i tried to open my site (club page that has image) i foun this error
> No module named 'StringIO'
> i searched at Google but no similar issues
> 
>> On Thursday, June 13, 2019 at 1:03:10 AM UTC+2, James Farris wrote:
>> This python package may be a better choice for you, since I assume you want 
>> all user generated content (images) to be stored in Dropbox. 
>> 
>> This has pretty good documentation. 
>> https://pypi.org/project/django-dropbox-storage/
>> 
>> If you use this package, remove the sample code I sent
>> 
>> 
>>> On Wed, Jun 12, 2019 at 3:53 PM omar ahmed  wrote:
>>> i added this function at the end of views.py file 
>>> def connect_to_dropbox():
>>> dbx = dropbox.Dropbox(‘your access token)
>>> dbx.users_get_current_account()
>>> and i put given access token from dropbox
>>> then what about call
>>> do you mean in any view function that will show page included images add  
>>> connect_to_dropbox()
>>> and what about 
>>> for entry in dbx.files_list_folder('').entries:
>>> print(entry.name)
>>> 
>>> 
>>> 
 On Thursday, June 13, 2019 at 12:38:11 AM UTC+2, James Farris wrote:
 You would add this code to the views.py file, which is where the business 
 logic goes. 
 
 https://docs.djangoproject.com/en/2.2/topics/http/views/
 
 Likely would add a class with properties and methods or a definition (a 
 function) like below:
 
 For example in your apps views.py file:
 
 def connect_to_dropbox():
 dbx = dropbox.Dropbox(‘your access token)
 dbx.users_get_current_account()
 
 # this stuff likely would go in a separate function
 for entry in dbx.files_list_folder(‘’).entries:
 print(entry.name)
 
 
 At some point in your code you would call the function:
 connect_to_dropbox()
 
> On Wed, Jun 12, 2019 at 3:10 PM omar ahmed  wrote:
> i opened the documentation for django-storages ... and i installed 
> Dropbox in my environment and i created my app folder  but i didn't 
> complete docs .
> somethings not clear ... like :
> Link an account 
> dbx = dropbox.Dropbox('YOUR_ACCESS_TOKEN')
> dbx.users_get_current_account()
> Try some API requests
> 
> for entry in dbx.files_list_folder('').entries:
> print(entry.name)
> where should i write these commands ?
> thanks
> 
> 
>> On Wednesday, June 12, 2019 at 1:13:11 AM UTC+2, James Farris wrote:
>> You might try the docs from Dropbox
>> https://www.dropbox.com/developers/documentation/python#overview
>> 
>> You can checkout this project for ideas
>> https://github.com/singingwolfboy/django-with-dropbox
>> 
>> and here is documentation for django-storages
>> https://django-storages.readthedocs.io/en/latest/backends/dropbox.html
>> 
>> 
>> 
>>> On Tue, Jun 11, 2019 at 2:17 PM omar ahmed  wrote:
>>> yes James you are right i need to upload images using the Django 
>>> admin, ... how can i use Dropbox for this issue ? 
>>> i need a good tutorial
>>> 
 On Tuesday, June 11, 2019 at 6:14:10 PM UTC+2, James Farris wrote:
 He is saying these aren’t static files. It sounds like he uploads them 
 using the Django admin, which of course is like an end user on a 
 client uploading files to the media directory. 
 
 Since that is the case it sounds like the Dropbox option is the best. 
 Documentation was provided earlier. So being that it seems like he 
 read through the documentation, my question is where is he stuck in 
 the Dropbox implementation?
> 
>>> -- 
>>> 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/8O8BS7DhF30/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to 
>>> django...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/3d50f417-cceb-4141-9b6d-9d2f5d0feee4%40googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
> 
> -- 
> You received this message because you are subscribed to a topic in the 
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit 

Re: my file uploads missing/deleted

2019-06-13 Thread omar ahmed
i added django_dropbox_storage in installed apps in settings.py
what should i add else ?
thanks
On Thursday, June 13, 2019 at 4:43:23 PM UTC+2, James Farris wrote:
>
> That means it wasn’t installed or it wasn’t added to your settings.py file 
> in the installed apps section 
>
> Sent from my mobile device
>
> On Jun 13, 2019, at 7:07 AM, omar ahmed > 
> wrote:
>
> i followed the steps
> when i typed 
> python manage.py test [--settings=test_settings]
> i found this error 
> ModuleNotFoundError: No module named '[--settings=test_settings]'
> and when i tried to open my site (club page that has image) i foun this 
> error
>
> No module named 'StringIO'
>
> i searched at Google but no similar issues
>
> On Thursday, June 13, 2019 at 1:03:10 AM UTC+2, James Farris wrote:
>>
>> This python package may be a better choice for you, since I assume you 
>> want all user generated content (images) to be stored in Dropbox. 
>>
>> This has pretty good documentation. 
>> https://pypi.org/project/django-dropbox-storage/
>>
>> If you use this package, remove the sample code I sent
>>
>>
>> On Wed, Jun 12, 2019 at 3:53 PM omar ahmed  wrote:
>>
>>> i added this function at the end of views.py file 
>>> def connect_to_dropbox():
>>> dbx = dropbox.Dropbox(‘your access token)
>>> dbx.users_get_current_account()
>>> and i put given access token from dropbox
>>> then what about call
>>> do you mean in any view function that will show page included images 
>>> add  
>>> connect_to_dropbox()
>>> and what about 
>>>
>>> for entry in dbx.files_list_folder('').entries:
>>> print(entry.name)
>>>
>>>
>>>
>>> On Thursday, June 13, 2019 at 12:38:11 AM UTC+2, James Farris wrote:

 You would add this code to the views.py file, which is where the 
 business logic goes. 

 https://docs.djangoproject.com/en/2.2/topics/http/views/

 Likely would add a class with properties and methods or a definition (a 
 function) like below:

 For example in your apps views.py file:

 def connect_to_dropbox():
 dbx = dropbox.Dropbox(‘your access token)
 dbx.users_get_current_account()

 # this stuff likely would go in a separate function
 for entry in dbx.files_list_folder(‘’).entries:
 print(entry.name)


 At some point in your code you would call the function:
 connect_to_dropbox()

 On Wed, Jun 12, 2019 at 3:10 PM omar ahmed  wrote:

> i opened the documentation for django-storages ... and i installed 
> Dropbox in my environment and i created my app folder  but i didn't 
> complete docs .
> somethings not clear ... like :
> Link an account 
>
> dbx = dropbox.Dropbox('YOUR_ACCESS_TOKEN')
>
> dbx.users_get_current_account()
> Try some API requests
>
> for entry in dbx.files_list_folder('').entries:
> print(entry.name)
>
> where should i write these commands ?
> thanks
>
> On Wednesday, June 12, 2019 at 1:13:11 AM UTC+2, James Farris wrote:
>>
>> You might try the docs from Dropbox
>> https://www.dropbox.com/developers/documentation/python#overview
>>
>> You can checkout this project for ideas
>> https://github.com/singingwolfboy/django-with-dropbox
>>
>> and here is documentation for django-storages
>> https://django-storages.readthedocs.io/en/latest/backends/dropbox.html
>>
>>
>>
>> On Tue, Jun 11, 2019 at 2:17 PM omar ahmed  
>> wrote:
>>
>>> yes James you are right i need to upload images using the Django 
>>> admin, ... how can i use Dropbox for this issue ? 
>>> i need a good tutorial
>>>
>>> On Tuesday, June 11, 2019 at 6:14:10 PM UTC+2, James Farris wrote:

 He is saying these aren’t static files. It sounds like he uploads 
 them using the Django admin, which of course is like an end user on a 
 client uploading files to the media directory. 

 Since that is the case it sounds like the Dropbox option is the 
 best. Documentation was provided earlier. So being that it seems like 
 he 
 read through the documentation, my question is where is he stuck in 
 the 
 Dropbox implementation?
>>>
>>> -- 
>>> 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/8O8BS7DhF30/unsubscribe
>>> .
>>> To unsubscribe from this group and all its topics, send an email to 
>>> django...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/3d50f417-cceb-4141-9b6d-9d2f5d0feee4%40googlegroups.com
>

Re: my file uploads missing/deleted

2019-06-13 Thread omar ahmed
and this was Traceback
Environment:


Request Method: GET
Request URL: https://arena3.herokuapp.com/8/clubpage/

Django Version: 2.2.1
Python Version: 3.6.8
Installed Applications:
['core.apps.CoreConfig',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django_social_share',
 'django_dropbox_storage']
Installed Middleware:
('whitenoise.middleware.WhiteNoiseMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'whitenoise.middleware.WhiteNoiseMiddleware',
 '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 /app/templates/base.html, error at line 10
   No module named 'StringIO'
   1 : {% load static %}
   2 : 
   3 : 
   4 : 
   5 : https://fonts.googleapis.com/css?family=Bitter"; 
rel="stylesheet">
   6 : https://fonts.googleapis.com/css?family=Merriweather"; 
rel="stylesheet">
   7 : 
   8 : 
   9 : {% block title %}{% endblock %}
   10 : https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"; 
integr ity="sha384-ggOyR0i 
XCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" 
crossorigin="anonymous">
   11 : 
   12 : 
   13 : 
   14 : 
   15 : 
   16 :
   17 :  
   18 :   {% if user.is_authenticated %}
   19 :logged in as {{ user.username }}
   20 :  {% endif %}


Traceback:

File 
"/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py" 
in _resolve_lookup
  829. current = current[bit]

During handling of the above exception ('ImageFieldFile' object is not 
subscriptable), another exception occurred:

File 
"/app/.heroku/python/lib/python3.6/site-packages/django_dropbox_storage/storage.py"
 
in 
  6. from cStringIO import StringIO

During handling of the above exception (No module named 'cStringIO'), 
another exception occurred:

File 
"/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py"
 
in inner
  34. response = get_response(request)

File 
"/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py" 
in _get_response
  115. response = self.process_exception_by_middleware(e, 
request)

File 
"/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py" 
in _get_response
  113. response = wrapped_callback(request, *callback_args, 
**callback_kwargs)

File "/app/core/views.py" in clubpage
  86. return render(request, 'core/clubpage.html', {'club':club, 
'news':news})

File "/app/.heroku/python/lib/python3.6/site-packages/django/shortcuts.py" 
in render
  36. content = loader.render_to_string(template_name, context, 
request, using=using)

File 
"/app/.heroku/python/lib/python3.6/site-packages/django/template/loader.py" 
in render_to_string
  62. return template.render(context, request)

File 
"/app/.heroku/python/lib/python3.6/site-packages/django/template/backends/django.py"
 
in render
  61. return self.template.render(context)

File 
"/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py" 
in render
  171. return self._render(context)

File 
"/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py" 
in _render
  163. return self.nodelist.render(context)

File 
"/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py" 
in render
  937. bit = node.render_annotated(context)

File 
"/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py" 
in render_annotated
  904. return self.render(context)

File 
"/app/.heroku/python/lib/python3.6/site-packages/django/template/loader_tags.py"
 
in render
  150. return compiled_parent._render(context)

File 
"/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py" 
in _render
  163. return self.nodelist.render(context)

File 
"/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py" 
in render
  937. bit = node.render_annotated(context)

File 
"/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py" 
in render_annotated
  904. return self.render(context)

File 
"/app/.heroku/python/lib/python3.6/site-packages/django/template/loader_tags.py"
 
in render
  62. result = block.nodelist.render(context)

File 
"/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py" 
in render
  937. bit = node.render_annotated(context)

File 
"/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py" 
in render_annotated
 

Re: my file uploads missing/deleted

2019-06-13 Thread James Farris
When you run the server does it give you any errors?

On Thu, Jun 13, 2019 at 8:12 AM omar ahmed  wrote:

> i added django_dropbox_storage in installed apps in settings.py
> what should i add else ?
> thanks
> On Thursday, June 13, 2019 at 4:43:23 PM UTC+2, James Farris wrote:
>>
>> That means it wasn’t installed or it wasn’t added to your settings.py
>> file in the installed apps section
>>
>> Sent from my mobile device
>>
>> On Jun 13, 2019, at 7:07 AM, omar ahmed  wrote:
>>
>> i followed the steps
>> when i typed
>> python manage.py test [--settings=test_settings]
>> i found this error
>> ModuleNotFoundError: No module named '[--settings=test_settings]'
>> and when i tried to open my site (club page that has image) i foun this
>> error
>>
>> No module named 'StringIO'
>>
>> i searched at Google but no similar issues
>>
>> On Thursday, June 13, 2019 at 1:03:10 AM UTC+2, James Farris wrote:
>>>
>>> This python package may be a better choice for you, since I assume you
>>> want all user generated content (images) to be stored in Dropbox.
>>>
>>> This has pretty good documentation.
>>> https://pypi.org/project/django-dropbox-storage/
>>>
>>> If you use this package, remove the sample code I sent
>>>
>>>
>>> On Wed, Jun 12, 2019 at 3:53 PM omar ahmed  wrote:
>>>
 i added this function at the end of views.py file
 def connect_to_dropbox():
 dbx = dropbox.Dropbox(‘your access token)
 dbx.users_get_current_account()
 and i put given access token from dropbox
 then what about call
 do you mean in any view function that will show page included images
 add
 connect_to_dropbox()
 and what about

 for entry in dbx.files_list_folder('').entries:
 print(entry.name)



 On Thursday, June 13, 2019 at 12:38:11 AM UTC+2, James Farris wrote:
>
> You would add this code to the views.py file, which is where the
> business logic goes.
>
> https://docs.djangoproject.com/en/2.2/topics/http/views/
>
> Likely would add a class with properties and methods or a definition
> (a function) like below:
>
> For example in your apps views.py file:
>
> def connect_to_dropbox():
> dbx = dropbox.Dropbox(‘your access token)
> dbx.users_get_current_account()
>
> # this stuff likely would go in a separate function
> for entry in dbx.files_list_folder(‘’).entries:
> print(entry.name)
>
>
> At some point in your code you would call the function:
> connect_to_dropbox()
>
> On Wed, Jun 12, 2019 at 3:10 PM omar ahmed  wrote:
>
>> i opened the documentation for django-storages ... and i installed
>> Dropbox in my environment and i created my app folder  but i didn't
>> complete docs .
>> somethings not clear ... like :
>> Link an account
>>
>> dbx = dropbox.Dropbox('YOUR_ACCESS_TOKEN')
>>
>> dbx.users_get_current_account()
>> Try some API requests
>>
>> for entry in dbx.files_list_folder('').entries:
>> print(entry.name)
>>
>> where should i write these commands ?
>> thanks
>>
>> On Wednesday, June 12, 2019 at 1:13:11 AM UTC+2, James Farris wrote:
>>>
>>> You might try the docs from Dropbox
>>> https://www.dropbox.com/developers/documentation/python#overview
>>>
>>> You can checkout this project for ideas
>>> https://github.com/singingwolfboy/django-with-dropbox
>>>
>>> and here is documentation for django-storages
>>>
>>> https://django-storages.readthedocs.io/en/latest/backends/dropbox.html
>>>
>>>
>>>
>>> On Tue, Jun 11, 2019 at 2:17 PM omar ahmed 
>>> wrote:
>>>
 yes James you are right i need to upload images using the
 Django admin, ... how can i use Dropbox for this issue ?
 i need a good tutorial

 On Tuesday, June 11, 2019 at 6:14:10 PM UTC+2, James Farris wrote:
>
> He is saying these aren’t static files. It sounds like he uploads
> them using the Django admin, which of course is like an end user on a
> client uploading files to the media directory.
>
> Since that is the case it sounds like the Dropbox option is the
> best. Documentation was provided earlier. So being that it seems like 
> he
> read through the documentation, my question is where is he stuck in 
> the
> Dropbox implementation?

 --
 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/8O8BS7DhF30/unsubscribe
 .
 To unsubscribe from this group and all its topics, send an email to
 django...@googlegroups.com.
 To post to this group, send email to django...@googlegroups.com.
 Visit t

Re: my file uploads missing/deleted

2019-06-13 Thread James Farris
A quick google search took me here

https://stackoverflow.com/questions/11914472/stringio-in-python3


On Thu, Jun 13, 2019 at 8:23 AM omar ahmed  wrote:

> and this was Traceback
> Environment:
>
>
> Request Method: GET
> Request URL: https://arena3.herokuapp.com/8/clubpage/
>
> Django Version: 2.2.1
> Python Version: 3.6.8
> Installed Applications:
> ['core.apps.CoreConfig',
>  'django.contrib.admin',
>  'django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.messages',
>  'django.contrib.staticfiles',
>  'django_social_share',
>  'django_dropbox_storage']
> Installed Middleware:
> ('whitenoise.middleware.WhiteNoiseMiddleware',
>  'django.middleware.security.SecurityMiddleware',
>  'whitenoise.middleware.WhiteNoiseMiddleware',
>  '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 /app/templates/base.html, error at line 10
>No module named 'StringIO'
>1 : {% load static %}
>2 :
>3 :
>4 : 
>5 : https://fonts.googleapis.com/css?family=Bitter";
> rel="stylesheet">
>6 : https://fonts.googleapis.com/css?family=Merriweather";
> rel="stylesheet">
>7 : 
>8 : 
>9 : {% block title %}{% endblock %}
>10 : https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css";
> integr ity="sha384-ggOyR0i
> XCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
> crossorigin="anonymous">
>11 : 
>12 : 
>13 : 
>14 : 
>15 :
>16 :
>17 :
>18 :   {% if user.is_authenticated %}
>19 :logged in as {{ user.username }}
>20 :  {% endif %}
>
>
> Traceback:
>
> File
> "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py"
> in _resolve_lookup
>   829. current = current[bit]
>
> During handling of the above exception ('ImageFieldFile' object is not
> subscriptable), another exception occurred:
>
> File
> "/app/.heroku/python/lib/python3.6/site-packages/django_dropbox_storage/storage.py"
> in 
>   6. from cStringIO import StringIO
>
> During handling of the above exception (No module named 'cStringIO'),
> another exception occurred:
>
> File
> "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py"
> in inner
>   34. response = get_response(request)
>
> File
> "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py"
> in _get_response
>   115. response = self.process_exception_by_middleware(e,
> request)
>
> File
> "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py"
> in _get_response
>   113. response = wrapped_callback(request,
> *callback_args, **callback_kwargs)
>
> File "/app/core/views.py" in clubpage
>   86. return render(request, 'core/clubpage.html', {'club':club,
> 'news':news})
>
> File "/app/.heroku/python/lib/python3.6/site-packages/django/shortcuts.py"
> in render
>   36. content = loader.render_to_string(template_name, context,
> request, using=using)
>
> File
> "/app/.heroku/python/lib/python3.6/site-packages/django/template/loader.py"
> in render_to_string
>   62. return template.render(context, request)
>
> File
> "/app/.heroku/python/lib/python3.6/site-packages/django/template/backends/django.py"
> in render
>   61. return self.template.render(context)
>
> File
> "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py"
> in render
>   171. return self._render(context)
>
> File
> "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py"
> in _render
>   163. return self.nodelist.render(context)
>
> File
> "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py"
> in render
>   937. bit = node.render_annotated(context)
>
> File
> "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py"
> in render_annotated
>   904. return self.render(context)
>
> File
> "/app/.heroku/python/lib/python3.6/site-packages/django/template/loader_tags.py"
> in render
>   150. return compiled_parent._render(context)
>
> File
> "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py"
> in _render
>   163. return self.nodelist.render(context)
>
> File
> "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py"
> in render
>   937. bit = node.render_annotated(context)
>
> File
> "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py"
> in render_annotated
>   904. return self.render(context)
>
> File
> "/app/.heroku/python/lib

Re: my file uploads missing/deleted

2019-06-13 Thread Joe Reitman
Omar, 

You should not be configuring views for Dropbox. DJANGO-STORAGES does all 
the back end coding for you.

Follow these steps from DJANGO-STORAGES documentation after removing the 
code changes you made to views. I'm assuming your using pip.

1. pip install django-storages
2. pip install dropbox
3. In your settings.py set these variables
DEFAULT_FILE_STORAGE = 'storages.backends.dropbox.DropBoxStorage'
DROPBOX_OAUTH2_TOKEN = your token from dropbox
DROPBOX_ROOT_PATH = your root path to store media
FROM THE DROPBOX DOCUMENTATION TUTORIAL YOU ONLY NEED TO REGISTER YOUR APP 
AND GENERATE YOUR OAUTH2 TOKEN. DISREGARD THE 'LINK YOUR ACCOUNT'. DJANGO 
STORAGES DOES THAT FOR YOU.

4. pip install django-imagekit and add it to your settings.py 'installed 
apps' -read the docs  on 
this one

Now you need to have an imagefield in your model and config your admin.py 
as I explained earlier. 
I highly recommend creating an app to do this functionality. Call it 
something like 'logo upload'. Django best practices says an app does one 
thing and does it well.


On Friday, June 7, 2019 at 6:32:21 PM UTC-5, omar ahmed wrote:
>
> hii ..
> i deployed my first django app on Heroku https://arena3.herokuapp.com/
> but my media files ( like club logo ) disappear or deleted ... 
> i found this article on Heroku 
> https://help.heroku.com/K1PPS2WM/why-are-my-file-uploads-missing-deleted  
> that means The Heroku filesystem is ephermal and i should use aws but it's 
> not free ?
> is there any solution ?
> how can i use Heroku postgres (addons) to upload my files permanently .. 
> thanks in advance
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7fa4e41b-1f34-47e6-a481-c8026910cdcb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django.contrib.gis for Windows 10

2019-06-13 Thread Thanasis
Hello. 
I want to use the GeoDjango application. I begun with the tutorial GIS 
Tutorial . 
I installed properly the PostgreSQL and PostGis for Windows 10. In 
addition, I follow the steps and I installed the OSGeo4W 
 in 
order to get the geospartial libraries. I foolowed the steps in order to 
create the environment variables GDA L_DATA and PROJ_LIB. So, I continued 
with the tutorial 
https://docs.djangoproject.com/en/2.2/ref/contrib/gis/tutorial/#use-ogrinfo-to-examine-spatial-data
 which 
this command works properly. I make a geographic model and try to make a 
migration in the database. Although, I get a big traceback 

Traceback (most recent call last):
  File "manage.py", line 21, in 
main()
  File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
  File 
"C:\Users\examples\vent\lib\site-packages\django\core\management\__init__.py"
, line 381, in execute_from_command_line
utility.execute()
  File 
"C:\Users\examples\vent\lib\site-packages\django\core\management\__init__.py"
, line 357, in execute
django.setup()
  File "C:\Users\examples\vent\lib\site-packages\django\__init__.py", line 
24, in setup
apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\examples\vent\lib\site-packages\django\apps\registry.py", 
line 122, in populate
app_config.ready()
  File 
"C:\Users\examples\vent\lib\site-packages\django\contrib\admin\apps.py", 
line 24, in ready
self.module.autodiscover()
  File 
"C:\Users\examples\vent\lib\site-packages\django\contrib\admin\__init__.py", 
line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
  File 
"C:\Users\examples\vent\lib\site-packages\django\utils\module_loading.py", 
line 47, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
  File "C:\Users\examples\vent\lib\importlib\__init__.py", line 127, in 
import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 1006, in _gcd_import
  File "", line 983, in _find_and_load
  File "", line 967, in _find_and_load_unlocked
  File "", line 677, in _load_unlocked
  File "", line 728, in exec_module
  File "", line 219, in 
_call_with_frames_removed
  File 
"C:\Users\examples\vent\lib\site-packages\django\contrib\gis\admin\__init__.py"
, line 5, in 
from django.contrib.gis.admin.options import GeoModelAdmin, OSMGeoAdmin
  File 
"C:\Users\examples\vent\lib\site-packages\django\contrib\gis\admin\options.py"
, line 2, in 
from django.contrib.gis.admin.widgets import OpenLayersWidget
  File 
"C:\Users\examples\vent\lib\site-packages\django\contrib\gis\admin\widgets.py"
, line 3, in 
from django.contrib.gis.gdal import GDALException
  File 
"C:\Users\examples\vent\lib\site-packages\django\contrib\gis\gdal\__init__.py"
, line 28, in 
from django.contrib.gis.gdal.datasource import DataSource
  File 
"C:\Users\examples\vent\lib\site-packages\django\contrib\gis\gdal\datasource.py"
, line 39, in 
from django.contrib.gis.gdal.driver import Driver
  File 
"C:\Users\examples\vent\lib\site-packages\django\contrib\gis\gdal\driver.py"
, line 5, in 
from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as 
rcapi
  File 
"C:\Users\examples\vent\lib\site-packages\django\contrib\gis\gdal\prototypes\ds.py"
, line 9, in 
from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
  File "C:\Users\examples\
vent\lib\site-packages\django\contrib\gis\gdal\libgdal.py", line 47, in 

lgdal = CDLL(lib_path)
  File "c:\program files (x86)\python37-32\Lib\ctypes\__init__.py", line 356
, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 applicationEnter code here
...


-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b30c87ac-00d0-4966-a43a-c60533ccec49%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django.contrib.gis for Windows 10

2019-06-13 Thread Chetan Ganji
Hey,

I had a similar issue with one of the projects I was working on.

GDAL was not working properly in windows 10, it was not getting detected
for some reason.
I never figured out why and how to fix that.

I ended up using Ubuntu to fix the issue. It worked like a charm!


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


On Thu, Jun 13, 2019 at 11:54 PM Thanasis  wrote:

> Hello.
> I want to use the GeoDjango application. I begun with the tutorial GIS
> Tutorial .
> I installed properly the PostgreSQL and PostGis for Windows 10. In
> addition, I follow the steps and I installed the OSGeo4W
> 
> in order to get the geospartial libraries. I foolowed the steps in order to
> create the environment variables GDA L_DATA and PROJ_LIB. So, I continued
> with the tutorial
> https://docs.djangoproject.com/en/2.2/ref/contrib/gis/tutorial/#use-ogrinfo-to-examine-spatial-data
>  which
> this command works properly. I make a geographic model and try to make a
> migration in the database. Although, I get a big traceback
>
> Traceback (most recent call last):
>   File "manage.py", line 21, in 
> main()
>   File "manage.py", line 17, in main
> execute_from_command_line(sys.argv)
>   File
> "C:\Users\examples\vent\lib\site-packages\django\core\management\__init__.py"
> , line 381, in execute_from_command_line
> utility.execute()
>   File
> "C:\Users\examples\vent\lib\site-packages\django\core\management\__init__.py"
> , line 357, in execute
> django.setup()
>   File "C:\Users\examples\vent\lib\site-packages\django\__init__.py",
> line 24, in setup
> apps.populate(settings.INSTALLED_APPS)
>   File "C:\Users\examples\vent\lib\site-packages\django\apps\registry.py",
> line 122, in populate
> app_config.ready()
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\admin\apps.py",
> line 24, in ready
> self.module.autodiscover()
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\admin\__init__.py"
> , line 26, in autodiscover
> autodiscover_modules('admin', register_to=site)
>   File
> "C:\Users\examples\vent\lib\site-packages\django\utils\module_loading.py",
> line 47, in autodiscover_modules
> import_module('%s.%s' % (app_config.name, module_to_search))
>   File "C:\Users\examples\vent\lib\importlib\__init__.py", line 127, in
> import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 1006, in _gcd_import
>   File "", line 983, in _find_and_load
>   File "", line 967, in
> _find_and_load_unlocked
>   File "", line 677, in _load_unlocked
>   File "", line 728, in exec_module
>   File "", line 219, in
> _call_with_frames_removed
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\gis\admin\__init__.py"
> , line 5, in 
> from django.contrib.gis.admin.options import GeoModelAdmin,
> OSMGeoAdmin
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\gis\admin\options.py"
> , line 2, in 
> from django.contrib.gis.admin.widgets import OpenLayersWidget
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\gis\admin\widgets.py"
> , line 3, in 
> from django.contrib.gis.gdal import GDALException
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\gis\gdal\__init__.py"
> , line 28, in 
> from django.contrib.gis.gdal.datasource import DataSource
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\gis\gdal\datasource.py"
> , line 39, in 
> from django.contrib.gis.gdal.driver import Driver
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\gis\gdal\driver.py"
> , line 5, in 
> from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as
> rcapi
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\gis\gdal\prototypes\ds.py"
> , line 9, in 
> from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
>   File "C:\Users\examples\
> vent\lib\site-packages\django\contrib\gis\gdal\libgdal.py", line 47, in
> 
> lgdal = CDLL(lib_path)
>   File "c:\program files (x86)\python37-32\Lib\ctypes\__init__.py", line
> 356, in __init__
> self._handle = _dlopen(self._name, mode)
> OSError: [WinError 193] %1 is not a valid Win32 applicationEnter code here
> ...
>
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b30c87ac-00d0-4966-a43a-c60533ccec49%40googlegroups.com
> 

Re: my file uploads missing/deleted

2019-06-13 Thread omar ahmed
i did first and second steps
but what about 
DROPBOX_OAUTH2_TOKEN = your token from dropbox
did you mean Generate access token ??
DROPBOX_ROOT_PATH = your root path to store media
did you mean link to Dropbox app folder ?
thanks
On Thursday, June 13, 2019 at 6:15:02 PM UTC+2, Joe Reitman wrote:
>
> Omar, 
>
> You should not be configuring views for Dropbox. DJANGO-STORAGES does all 
> the back end coding for you.
>
> Follow these steps from DJANGO-STORAGES documentation after removing the 
> code changes you made to views. I'm assuming your using pip.
>
> 1. pip install django-storages
> 2. pip install dropbox
> 3. In your settings.py set these variables
> DEFAULT_FILE_STORAGE = 'storages.backends.dropbox.DropBoxStorage'
> DROPBOX_OAUTH2_TOKEN = your token from dropbox
> DROPBOX_ROOT_PATH = your root path to store media
> FROM THE DROPBOX DOCUMENTATION TUTORIAL YOU ONLY NEED TO REGISTER YOUR APP 
> AND GENERATE YOUR OAUTH2 TOKEN. DISREGARD THE 'LINK YOUR ACCOUNT'. DJANGO 
> STORAGES DOES THAT FOR YOU.
>
> 4. pip install django-imagekit and add it to your settings.py 'installed 
> apps' -read the docs  
> on this one
>
> Now you need to have an imagefield in your model and config your admin.py 
> as I explained earlier. 
> I highly recommend creating an app to do this functionality. Call it 
> something like 'logo upload'. Django best practices says an app does one 
> thing and does it well.
>
>
> On Friday, June 7, 2019 at 6:32:21 PM UTC-5, omar ahmed wrote:
>>
>> hii ..
>> i deployed my first django app on Heroku https://arena3.herokuapp.com/
>> but my media files ( like club logo ) disappear or deleted ... 
>> i found this article on Heroku 
>> https://help.heroku.com/K1PPS2WM/why-are-my-file-uploads-missing-deleted  
>>
>> that means The Heroku filesystem is ephermal and i should use aws but 
>> it's not free ?
>> is there any solution ?
>> how can i use Heroku postgres (addons) to upload my files permanently .. 
>> thanks in advance
>>
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/729a3c5a-ad59-4386-8ac0-1772fa36c583%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django/apache/ubuntu server18.04 openssl not found after package upgrade / libssl.so.1.1: version `OPENSSL_1_1_1' not found

2019-06-13 Thread Volker
Two days ago my django app which runs on an Ubuntu 18.04.2 LTS server with 
apache and mod_wsgi in an venv with Python 3.6 throws an exception after 
https login - as it seems - after a package upgrade.
To my understanding libssl/openssl is causing the error. The error message 
below states that openssl_1_1_1 is not found. Though it seems to be 
installed.

Could you guys give me a pointer? Please let me know if I need to provide 
additional information.

Thanks and cheers!



Two days ago following packages where upgraded:
=
libelf1:amd64 0.170-0.4 => 0.170-0.4ubuntu0.1
libglib2.0-0:amd64 2.56.4-0ubuntu0.18.04.2 => 2.56.4-0ubuntu0.18.04.3
libglib2.0-data:all 2.56.4-0ubuntu0.18.04.2 => 2.56.4-0ubuntu0.18.04.3
libnss-systemd:amd64 237-3ubuntu10.21 => 237-3ubuntu10.22
libpam-systemd:amd64 237-3ubuntu10.21 => 237-3ubuntu10.22
libpython3.6-minimal:amd64 3.6.7-1~18.04 => 3.6.8-1~18.04.1
libpython3.6-stdlib:amd64 3.6.7-1~18.04 => 3.6.8-1~18.04.1
libpython3.6:amd64 3.6.7-1~18.04 => 3.6.8-1~18.04.1
libssl1.1:amd64 1.1.0g-2ubuntu4.3 => 1.1.1-1ubuntu2.1~18.04.1
libsystemd0:amd64 237-3ubuntu10.21 => 237-3ubuntu10.22
libudev1:amd64 237-3ubuntu10.21 => 237-3ubuntu10.22
openssl:amd64 1.1.0g-2ubuntu4.3 => 1.1.1-1ubuntu2.1~18.04.1
python3-cryptography:amd64 2.1.4-1ubuntu1.2 => 2.1.4-1ubuntu1.3
python3-distutils:all 3.6.7-1~18.04 => 3.6.8-1~18.04
python3-gdbm:amd64 3.6.7-1~18.04 => 3.6.8-1~18.04
python3-lib2to3:all 3.6.7-1~18.04 => 3.6.8-1~18.04
python3.6-minimal:amd64 3.6.7-1~18.04 => 3.6.8-1~18.04.1
python3.6-venv:amd64 3.6.7-1~18.04 => 3.6.8-1~18.04.1
python3.6:amd64 3.6.7-1~18.04 => 3.6.8-1~18.04.1
systemd-sysv:amd64 237-3ubuntu10.21 => 237-3ubuntu10.22
systemd:amd64 237-3ubuntu10.21 => 237-3ubuntu10.22
udev:amd64 237-3ubuntu10.21 => 237-3ubuntu10.22

Login Implementation

Im using djangos login views:
settings.py:
LOGIN_URL = '/accounts/login/'
urls.py:
path('accounts/', include('django.contrib.auth.urls')),

Error after Login Page of application / and django admin:

"Internal Server Error
The server encountered an internal error or misconfiguration and was unable 
to complete your request."

Error in Apache Log
==
[Thu Jun 13 18:58:10.555937 2019] [wsgi:error] [pid 1274:tid 
140451378087680] [client 77.8.21.189:48212] mod_wsgi (pid=1274): Request 
data read error when proxying data to daemon process: Connection reset by 
peer.
[Thu Jun 13 20:46:51.186545 2019] [wsgi:error] [pid 1274:tid 
140451252197120] [client 217.18.178.226:61510] Truncated or oversized 
response headers received from daemon process 'fotobau.ourdomain.de': 
/srv/fotobau/djangoprojekt/wsgi.py, referer: 
https://www.fotobau.ourdomain/accounts/login/

Unfortunately I failed to obtain a core dump till now.

Though right now I suspect the problem occurs when django tries to receive 
the https/encrypted user and password. I suspect this because I got another 
error message!

Another Error in Django Log

Here I got a new error message: The first one ('Exception' is not JSON 
serializable) is fairly common - though I didn´t manage to fix it till now, 
it never really bothered.
Though after the package upgrade it raises a new error message (which will 
raise itself again for 3 times) below - the one with "ImportError: 
/usr/lib/x86_64-linux-gnu/libssl.so.1.1: version `OPENSSL_1_1_1":

ERROR 2019-06-12 19:57:17,638 log 505 Internal Server Error: 
/restservice/v1/fotos/
Traceback (most recent call last):
  File 
"/home/eidle/.virtualenvs/fotobau/lib/python3.6/site-packages/django/core/handlers/exception.py",
 
line 34, in inner
response = get_response(request)
  File 
"/home/eidle/.virtualenvs/fotobau/lib/python3.6/site-packages/django/core/handlers/base.py",
 
line 156, in _get_response
response = self.process_exception_by_middleware(e, request)
  File 
"/home/eidle/.virtualenvs/fotobau/lib/python3.6/site-packages/django/core/handlers/base.py",
 
line 154, in _get_response
response = response.render()
  File 
"/home/eidle/.virtualenvs/fotobau/lib/python3.6/site-packages/django/template/response.py",
 
line 106, in render
self.content = self.rendered_content
  File 
"/home/eidle/.virtualenvs/fotobau/lib/python3.6/site-packages/rest_framework/response.py",
 
line 72, in rendered_content
ret = renderer.render(self.data, accepted_media_type, context)
  File 
"/home/eidle/.virtualenvs/fotobau/lib/python3.6/site-packages/rest_framework/renderers.py",
 
line 107, in render
allow_nan=not self.strict, separators=separators
  File 
"/home/eidle/.virtualenvs/fotobau/lib/python3.6/site-packages/rest_framework/utils/json.py",
 
line 28, in dumps
return json.dumps(*args, **kwargs)
  File "/usr/lib/python3.6/json/__init__.py", line 238, in dumps
**kw).encode(obj)
  File "/usr/lib/python3.6/json/encoder.py", line 199, in enco

Create View not saving form data to database

2019-06-13 Thread curtly critchlow
CreateView class not saving data to database. When I hit submit, the html 
the page only refreshes. l'm not getting any errors so I have no idea what 
i'm doing wrong. Does CreateView automatically takes care of many to many 
relationships? here is my code below, I've been trying to solve this 
problem 2 days now.


   1. Models.py 
   2.  
   3. from django.db import models
   4. from django.utils import timezone
   5. from django.urls import reverse_lazy, reverse
   6. 
   7. # Create your models here.
   8. 
   9. class Requisition(models.Model):
   10.# constants
   11.FROZEN = 'Frozen'
   12.CHILLED = 'Chilled/Cold Pack'
   13.DRYICE = 'Dry Ice'
   14.ROOMTEMP = 'Room Temperature'
   15.TRANSPORT_CHOICE = 
   [(FROZEN,FROZEN),(CHILLED,CHILLED),(DRYICE,DRYICE),(ROOMTEMP,ROOMTEMP)]
   16.
   17.EMAIL = 'email'
   18.HARDCOPY = 'Hardcopy Pickup'
   19.BOTH = 'Email & Hardcopy Pickup'
   20.RECEIPT_CHOICE = [(EMAIL,EMAIL), (HARDCOPY,HARDCOPY), (BOTH,BOTH)]
   21. 
   22. 
   23. ACUTE = 'Acute'
   24.CHRONIC = 'Chronic'
   25.SYMPTOMS_CHOICE = [(ACUTE,ACUTE,), (CHRONIC,CHRONIC)]
   26. 
   27. #columns
   28.accession_number = models.CharField(max_length=254, unique=True, 
   help_text='format: VSLXXX-XXX')
   29.customer = models.ForeignKey('general.Customer', 
   on_delete=models.CASCADE, related_name='requisition')
   30.
   31.# Veterinary Officer Info
   32.veterinary_officer = models.CharField(max_length=50, blank=True)
   33.address = models.CharField(max_length=50, blank=True)
   34.contact_number = models.CharField(max_length=13, blank=True, 
   help_text="number format example: +592 XXX ") 
   35. email_address = models.EmailField(max_length=50, blank=True)
   36. 
   37. # General sample info
   38.
   39.collected_by = models.CharField(max_length=50)
   40.time_of_collection = models.DateTimeField()
   41.
   42. 
   43. method_of_transport = models.CharField(max_length=50, 
   choices=TRANSPORT_CHOICE)
   44.result_transmission = models.CharField(max_length=50, 
   choices=RECEIPT_CHOICE)
   45. 
   46. #pathology
   47.reason_for_request = 
   models.ManyToManyField('ReasonForRequest',related_name='requisition', 
   blank=True)
   48.illness_date = models.DateField('Date of onset of illness', 
   blank=True, null=True)
   49.illness_duration = models.CharField('Duration of illness', 
   max_length=254, blank=True)
   50.symptoms = models.CharField(max_length=50, 
   choices=SYMPTOMS_CHOICE, blank=True)
   51.fever = models.BooleanField('Presence of Fever', blank=True, 
   null=True)
   52.body_temp = models.PositiveSmallIntegerField('Max body 
   Temperature (C)', blank=True, null=True)
   53.fever_duration = models.CharField('Duration of 
   Fever',max_length=50, blank=True)
   54.signs = models.ManyToManyField('Signs', 
   related_name='requisition', blank=True)
   55.vaccination_status = models.CharField(max_length=50, blank=True)
   56.vaccination_date = models.DateField('Date of Vaccination', 
   blank=True, null=True)
   57.treatments = models.TextField('Previous/Current Treatments', 
   blank=True)
   58.exposed = models.ManyToManyField('Exposed', 
   related_name='requisition', through='ExposureHistory', blank=True)
   59.
   60.comments = models.TextField(blank=True)
   61.recieved_by = models.ForeignKey('auth.User', 
   on_delete=models.CASCADE)
   62.submitted_by = models.CharField(max_length=254, help_text='if 
   multiple persons separate names using "&" exampe: John Doe   & 
   Jane Doe')
   63.date_of_submission = models.DateTimeField(auto_now_add=True)
   64. 
   65. def __str__(self):
   66.return self.accession_number 
   67.  
   68.def get_absolute_url(self):
   69.return reverse("laboratory:requisition_details", 
   kwargs={'pk':self.pk})
   70.
   71. forms.py
   72. 
   73. from django.forms import ModelForm
   74. from general.models import Customer
   75. from laboratory.models import Requisition
   76. from bootstrap_datepicker_plus import DatePickerInput, 
   DateTimePickerInput
   77. 
   78. class RequisitionForm(ModelForm):
   79.class Meta:
   80.model = Requisition
   81.fields = '__all__'
   82.widgets = {
   83.'illness_date': DatePickerInput,
   84.'vaccination_date': DatePickerInput,
   85.'date_of_submission': DateTimePickerInput,
   86.}
   87. views.py
   88. from django.contrib.auth.mixins import LoginRequiredMixin
   89. from django.urls import reverse_lazy, reverse
   90. from django.shortcuts import render
   91. from django.views.generic import TemplateView, CreateView, 
   DetailView, ListView, UpdateView, DeleteView
   92. from general.models import Customer
   93. from laboratory.models import Requisition, Sample
   94. from laboratory.for

libssl.so.1.1 / OPENSSL_1_1_1 not found after upgrade (ubuntu server 18.04 / apache / mod_wsgi)

2019-06-13 Thread Volker
Two days ago my django app which runs on an Ubuntu 18.04.2 LTS server with 
apache 2.4 (from repo9 and mod_wsgi in an venv with Python 3.6 throws an 
exception after https login - as it seems - after a package upgrade.
To my understanding libssl/openssl is causing the error. The error message 
below states that openssl_1_1_1 is not found. Though it seems to be 
installed.

Could you guys give me a pointer? Please let me know if I need to provide 
additional information.

Thanks and cheers!



Two days ago following packages where upgraded:
=
libelf1:amd64 0.170-0.4 => 0.170-0.4ubuntu0.1
libglib2.0-0:amd64 2.56.4-0ubuntu0.18.04.2 => 2.56.4-0ubuntu0.18.04.3
libglib2.0-data:all 2.56.4-0ubuntu0.18.04.2 => 2.56.4-0ubuntu0.18.04.3
libnss-systemd:amd64 237-3ubuntu10.21 => 237-3ubuntu10.22
libpam-systemd:amd64 237-3ubuntu10.21 => 237-3ubuntu10.22
libpython3.6-minimal:amd64 3.6.7-1~18.04 => 3.6.8-1~18.04.1
libpython3.6-stdlib:amd64 3.6.7-1~18.04 => 3.6.8-1~18.04.1
libpython3.6:amd64 3.6.7-1~18.04 => 3.6.8-1~18.04.1
libssl1.1:amd64 1.1.0g-2ubuntu4.3 => 1.1.1-1ubuntu2.1~18.04.1
libsystemd0:amd64 237-3ubuntu10.21 => 237-3ubuntu10.22
libudev1:amd64 237-3ubuntu10.21 => 237-3ubuntu10.22
openssl:amd64 1.1.0g-2ubuntu4.3 => 1.1.1-1ubuntu2.1~18.04.1
python3-cryptography:amd64 2.1.4-1ubuntu1.2 => 2.1.4-1ubuntu1.3
python3-distutils:all 3.6.7-1~18.04 => 3.6.8-1~18.04
python3-gdbm:amd64 3.6.7-1~18.04 => 3.6.8-1~18.04
python3-lib2to3:all 3.6.7-1~18.04 => 3.6.8-1~18.04
python3.6-minimal:amd64 3.6.7-1~18.04 => 3.6.8-1~18.04.1
python3.6-venv:amd64 3.6.7-1~18.04 => 3.6.8-1~18.04.1
python3.6:amd64 3.6.7-1~18.04 => 3.6.8-1~18.04.1
systemd-sysv:amd64 237-3ubuntu10.21 => 237-3ubuntu10.22
systemd:amd64 237-3ubuntu10.21 => 237-3ubuntu10.22
udev:amd64 237-3ubuntu10.21 => 237-3ubuntu10.22

Login Implementation

Im using djangos login views:
settings.py:
LOGIN_URL = '/accounts/login/'
urls.py:
path('accounts/', include('django.contrib.auth.urls')),

Error after Login Page of application / and django admin:

"Internal Server Error
The server encountered an internal error or misconfiguration and was unable 
to complete your request."

Error in Apache Log
==
[Thu Jun 13 18:58:10.555937 2019] [wsgi:error] [pid 1274:tid 
140451378087680] [client 77.8.21.189:48212] mod_wsgi (pid=1274): Request 
data read error when proxying data to daemon process: Connection reset by 
peer.
[Thu Jun 13 20:46:51.186545 2019] [wsgi:error] [pid 1274:tid 
140451252197120] [client 217.18.178.226:61510] Truncated or oversized 
response headers received from daemon process 'fotobau.ourdomain.de': 
/srv/fotobau/djangoprojekt/wsgi.py, referer: 
https://www.fotobau.ourdomain/accounts/login/

Unfortunately I failed to obtain a core dump till now.

Though right now I suspect the problem occurs when django tries to receive 
the https/encrypted user and password. I suspect this because I got another 
error message!

Another Error in Django Log

Here I got a new error message: The first one ('Exception' is not JSON 
serializable) is fairly common - though I didn´t manage to fix it till now, 
it never really bothered.
Though after the package upgrade it raises a new error message (which will 
raise itself again for 3 times) below - the one with "ImportError: 
/usr/lib/x86_64-linux-gnu/libssl.so.1.1: version `OPENSSL_1_1_1":

ERROR 2019-06-12 19:57:17,638 log 505 Internal Server Error: 
/restservice/v1/fotos/
Traceback (most recent call last):
  File 
"/home/eidle/.virtualenvs/fotobau/lib/python3.6/site-packages/django/core/handlers/exception.py",
 
line 34, in inner
response = get_response(request)
  File 
"/home/eidle/.virtualenvs/fotobau/lib/python3.6/site-packages/django/core/handlers/base.py",
 
line 156, in _get_response
response = self.process_exception_by_middleware(e, request)
  File 
"/home/eidle/.virtualenvs/fotobau/lib/python3.6/site-packages/django/core/handlers/base.py",
 
line 154, in _get_response
response = response.render()
  File 
"/home/eidle/.virtualenvs/fotobau/lib/python3.6/site-packages/django/template/response.py",
 
line 106, in render
self.content = self.rendered_content
  File 
"/home/eidle/.virtualenvs/fotobau/lib/python3.6/site-packages/rest_framework/response.py",
 
line 72, in rendered_content
ret = renderer.render(self.data, accepted_media_type, context)
  File 
"/home/eidle/.virtualenvs/fotobau/lib/python3.6/site-packages/rest_framework/renderers.py",
 
line 107, in render
allow_nan=not self.strict, separators=separators
  File 
"/home/eidle/.virtualenvs/fotobau/lib/python3.6/site-packages/rest_framework/utils/json.py",
 
line 28, in dumps
return json.dumps(*args, **kwargs)
  File "/usr/lib/python3.6/json/__init__.py", line 238, in dumps
**kw).encode(obj)
  File "/usr/lib/python3.6/json/encoder.py", l