Django Aggregate(annotate, count) is working differently.

2020-06-17 Thread Himanshu Pharawal
models.py
class Intrest(models.Model):
 user = models.ForeignKey(User, related_name='intrests', on_delete=models.
CASCADE)
 keyword = models.CharField(max_length=100)

class SponsoredBook(models.Model):
 title = models.CharField(max_length=20)

class Keyword(models.Model):
 sponsored_book = models.ForeignKey(SponsoredBook, related_name='keywords', 
on_delete=models.CASCADE)
 title = models.CharField(max_length=50, unique=True)


views.py
def get(self, request):
 user = User.objects.filter(id=3).prefetch_related('intrests')
 sub = Subquery(user[0].intrests.annotate(key=Lower('keyword')).values('key'
))
 sponsored_books = models.SponsoredBook.objects.annotate(tit=Lower(
'keywords__title')).filter(tit__in=sub).annotate(points=Count('id')).
order_by('points')[:6]
 all_sponsored_books = models.SponsoredBook.objects.all()[:6]
 for sponsored_book in sponsored_books:
 print(sponsored_book.__dict__)
 print()

Case explained
There are two interests stored in db for user(id=3) names as

   1. python
   2. programming

And three sponsored books stored in db with their correspond interests 
named as 

   1. Test1 - Interests(ptyhon, programming)
   2. Test2 - Interests(python, A)
   3. Test3 - Interests(B, C)

Problem
For the above database, models and views it shows Test1 book two times and 
Test2 book one time but expectation was to having Test1 one time and Test2 
also one time only the order should be affect but here query set is able to 
group by books with there id and give them points on the basis of 
there repetition repetition.

*Let me know if you need for more information on the same.*

-- 
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/bc724ec0-99ad-4180-919e-f036a051b8a6o%40googlegroups.com.


why in views we use def(functions) and model we use class, why not we use def(fuction) in models and class in views

2020-06-17 Thread yashwanth balanagu
why in views we use def(functions) and model we use class, why not we use 
def(fuction) in models and class in views

-- 
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/4e4b1e4b-1a59-43d9-8835-4992e986f943o%40googlegroups.com.


Re: Django Saving a form with Imagefield on shared host

2020-06-17 Thread MUGOYA DIHFAHSIH
@Mangla, essentially what i want to do is to serve uploaded images on a
shared host through the media directory in my project root. I have deployed
the web app the static files such as css and images are working fine, but
when i try to submit a form that has imagefield into the database, it
throws 404 error. I know it has to deal with the Aoache web server and the
mod_wsgi but how?

On Wed, 17 Jun 2020 at 10:06, Vishesh Mangla 
wrote:

> One thing that can be done is to save the image as a base64 string in the
> database.
> https://stackoverflow.com/questions/3715493/encoding-an-image-file-with-base64
>
>
>
> Sent from Mail  for
> Windows 10
>
>
>
> *From: *MUGOYA DIHFAHSIH 
> *Sent: *14 June 2020 19:15
> *To: *Django users 
> *Subject: *Django Saving a form with Imagefield on shared host
>
>
>
> I am working on django project and now i have deployed it with Namecheap
>
> When i submit a form that does not have an ImageField, the form submits
> successfully on the shared host
>
> but when i submit a form with one of the fields ImageField, it raises 404
> error.
>
> but on the localhost, the forms work perfectly.
>
> what can i do to submit such forms on a shared host.
>
> Thanks.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b79bb9b5-46b4-43eb-9ea5-3eaab14336ddo%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/3F4C1D42-FB11-49A2-8A6E-BF990EE847AD%40hxcore.ol
> 
> .
>

-- 
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/CAP%3DJD9wV4_Pbd%3DK2EoH6VNbHKr_7ca%2BErCfQcc7xpwWfqmEzTw%40mail.gmail.com.


Re: Want to learn web crawling using Python

2020-06-17 Thread Anish Chapagain
I would recommend some books example:
https://www.packtpub.com/big-data-and-business-intelligence/hands-web-scraping-python

On Wed, 17 Jun 2020 at 20:50, Spring-dot  wrote:

> Hey!! I want to learn web crawling using Python from scratch. Please
> Someone help!!!
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8d4b570d-f945-49f2-93cf-c9d08083199fo%40googlegroups.com
> 
> .
>


-- 
Regards,
Anish C.

-- 
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/CANE3pV8pEb6RVOBM1%3D0cR6B-mDk60vN-XrTn8QDrktXm0M83jg%40mail.gmail.com.


Re: Want to learn web crawling using Python

2020-06-17 Thread upendra kushwaha
Scrapy https://scrapy.org/ will be good starting point

On Wed, Jun 17, 2020 at 8:34 PM Spring-dot  wrote:

> Hey!! I want to learn web crawling using Python from scratch. Please
> Someone help!!!
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8d4b570d-f945-49f2-93cf-c9d08083199fo%40googlegroups.com
> 
> .
>


-- 
Regards,
Upendra Pratap Kushwaha
Mob: +919643886908

-- 
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/CAHvKYXVu_4MdCrJAEoQOWwqZo-h0ioNsRptUcZOfz3%3DOyCXWJQ%40mail.gmail.com.


Re: Django forms

2020-06-17 Thread chaitanya orakala
Hi Obed,
You can use django model forms, where modelform will access your fields in
model and you play with it using widgets.
Hope this helps.
Thank  You

On Tue, Jun 16, 2020 at 5:25 PM Obed Balogun  wrote:

> Please im trying to create a playlist app such that the user enters songs
> in a playlist creation page and this is added to a playlist model. I want
> to know the best way to collect this data from the user. Im stuck at what
> possible way to collect this data in the form page and then display each
> song as an iterable within a playlist.
>
> --
> 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/3b14cdd4-d502-4381-8734-6fc1fe438959o%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/CAPcTzRYjNNCaw-0Np3dwe82Y_DeM4%2BwkY1gVMgXGJqPcx8rXQQ%40mail.gmail.com.


GSoD 2020

2020-06-17 Thread Spring-dot
What are the project ideas for contributing to Django for GSoD, 2020? 
Anyone who can guide me in this? Please Help!!
Thanks!

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


Re: Work in django!!

2020-06-17 Thread Luqman Lawal
ok

On Wed, Jun 17, 2020, 05:41 carlos  wrote:

> geodjango!
>
> On Tue, Jun 16, 2020 at 10:35 PM RANGA BHARATH JINKA <
> bharathjink...@gmail.com> wrote:
>
>> Hi, You can use the folium package.
>>
>> On Wed, Jun 17, 2020 at 9:28 AM meera gangani 
>> wrote:
>>
>>> Hello ,
>>>
>>>I want to work with maps in django, which libraries i installed!
>>>
>>> Thank to you in advance
>>> -Meera
>>>
>>>
>>> --
>>> 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/CANaPPPKCrrTbdUNC-JDujx7wn05kp%3Dd5xXbu-qKYsGH%2BGO00YQ%40mail.gmail.com
>>> 
>>> .
>>>
>>
>>
>> --
>> Thanks and Regards
>>
>> J. Ranga Bharath
>> cell: 9110334114
>>
>> --
>> 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/CAK5m3158B8nSkjKRrY1KGZ7p3G2MY%2Be-Pkv9kqYDXBbZ3BV-8A%40mail.gmail.com
>> 
>> .
>>
>
>
> --
> 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-7rO3fxcZND0GozLpR%2BO-4d_YQXDN6kRQ4v%3DfzcmVVDEbwtQ%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/CAHj0e%2BSbf7d3_zRWKGOKRWhgbTrSez2_nBKiABifqAz0Q%2BRGDQ%40mail.gmail.com.


Re: someone to help in this please

2020-06-17 Thread Peter Kirieny
fortunately am in windows, once again thanks
I'll let you know the proceeds

On Wed, 17 Jun 2020 at 15:23, Kasper Laudrup  wrote:

> Hi Peter,
>
> On 17/06/2020 14.04, Peter Kirieny wrote:
> > yea, I installed it with OSGEO4W
> >
>
> So I assume you are on Windows?
>
> It would have been quite useful if you had written that in your initial
> question.
>
> I'm not very experienced on that platform, but the installer you used
> has most likely installed a library somewhere, I assume in "Program
> Files" or whatever it's called on Windows these days.
>
> Try to figure out where the installer put the GDAL library which is
> probably a file ending with either ".lib" or ".dll" and set your
> GDAL_LIBRARY_PATH to that folder in your settings.
>
> Hope that helps.
>
> 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/f68cf720-4fe2-cf15-687b-0ecda634b41f%40stacktrace.dk
> .
>

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


Re: someone to help in this please

2020-06-17 Thread Peter Kirieny
Thanks to all, let me try and hope you won't mind me coming back in case of
anything
'AM NEW'

On Wed, 17 Jun 2020 at 16:07, Richard Balwane 
wrote:

> -> Do a .whl installation - In the environment!
> Download  "GDAL-3.0.4-cp37-cp37m-win_amd64.whl", if using Python 3.7 on
> Windows 64-bit
> Say...
> Command(env activated, path to the file):
> python.exe -m pip install
> "C:\\Users\\Mossad\\Downloads\\GDAL-3.0.4-cp37-cp37m-win_amd64.whl"
>
>  ->  Include 'gdal300'  in
> env\Lib\site-packages\django\contrib\gis\gdal\libgdal.py file for this
> GDAL-3.0.4 .whl installation
> (There is a list of these .dlls for nt users)
>   Set:
> 1. GDAL_LIBRARY_PATH in settings.py:
>   import os
>   GDAL_LIBRARY_PATH = os.path.join(
> PROJECT_DIR, r"env\\Lib\\site-packages\\osgeo\\gdal300.dll"
> )
>
> 2.  GDAL_DRIVER_PATH = os.path.join(
> PROJECT_DIR,
> r"env\\Lib\site-packages\\osgeo\\gdalplugins\\ogr_FileGDB.dll"
> )
>
> And, you are good to go.
>
> Praise be to The Almighty God.
>
>
>
> *Richard Dick Balwane*
>
> *Mobiles:+256 755 442248, *
>
> *+256 781 493558.*
> *Twiter:   @RBalwane*
> *WhatsApp:   **+256 755 442248*
>
>
> *Balwane Holding Inc.*
>
>
>
>
> On Tue, 16 Jun 2020 at 18:11, Peter Kirieny 
> wrote:
>
>> am using Geodjango with postgresql db and i get this error while trying
>> to run the server;
>> raise ImproperlyConfigured(
>> django.core.exceptions.ImproperlyConfigured: Could not find the GDAL
>> library (tried "gdal204", "gdal203", "gdal202", "gdal201", "gdal20"). Is
>> GDAL installed? If it i
>> s, try setting GDAL_LIBRARY_PATH in your settings.
>>
>> the libraries are installed just don't know  how to set the paths
>> 'am new in programming'
>>
>> --
>> 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/CAL8t8eof1jY3wwUa9Fj_owAK8WEoVpZSFnOCFrQsmD_w3Yy%3Dfg%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/CAAjYwK9JRdX%3DyUtrkeV6jxJsDtHKS-NfP30buww2NbkHjPwLjQ%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/CAL8t8epdQ%3Dv0DSX5z%2BNeovrpQ3gb-uy3uhYTOCGt7FLRfyOZRw%40mail.gmail.com.


Want to learn web crawling using Python

2020-06-17 Thread Spring-dot
Hey!! I want to learn web crawling using Python from scratch. Please 
Someone help!!! 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8d4b570d-f945-49f2-93cf-c9d08083199fo%40googlegroups.com.


Re: how to make docker image of your django app

2020-06-17 Thread onlinejudge95
On Wed, Jun 17, 2020 at 7:28 PM Jason Turner  wrote:

>
> https://testdriven.io/blog/dockerizing-django-with-postgres-gunicorn-and-nginx/
>
> Also, Will Vincent's book "Django for Professionals" is a good resource.
>
> On Wed, Jun 17, 2020, 8:51 AM Anirudh choudhary <
> anirudhchoudary...@gmail.com> wrote:
>
>> I Want to make make a docker image of my Django app using PostgreSQL and
>> unicorn. but I can't find any good tutorial for reference
>> please share my link to if you know any good tutorial
>>
> The first philosophy of docker is to run a single service in a container,
which would translate to you running 2 containers.

   1. Django container having all your Django code
   2. DB container having your DB

Now you can(i would say must) leverage *docker-compose* for local
development. It's somewhat easy to learn, just follow along with the
official docs .

> My Dockerfile now is like
>> FROM python:3.6
>> ENV PYTHONUNBUFFERED 1
>> RUN mkdir /app
>> WORKDIR /app
>> COPY requirements.txt /app/requirements.txt
>> RUN pip install -r requirements.txt
>> RUN apt install postgresql-client
>> RUN mkdir postgresqlcode
>> COPY /private_key/client-cert.pem /private_key/client-cert.pem
>> COPY /private_key/client-cert.pem /private_key/client-cert.pem
>> COPY /private_key/client-cert.pem /private_key/client-cert.pem
>> RUN psql "sslmode=verify-ca sslrootcert=\server-ca.pem \
>> sslcert=client-cert.pem sslkey=\client-key.pem \
>> hostaddr=hostaddress \
>> port=port \
>> user=postgres dbname=postgres"
>> COPY . /code/
>>
>>
>> I know I have to make Django-compose.yml file and I ha
>>
>>
>>
>>
>>
>>
>>
>> --
>> 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/CAL8_rkEBoEuAC7N9XCgDsakOVSsGtM1EM_3bZc9azOL3jPhDjw%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/CADoyC14A%3Df_c7FGt8RQqacpYKMuQAkj-QmGA49Hmzr08EaorLw%40mail.gmail.com
> 
> .
>


-- 
Thanks,
Mayank Pathak

-- 
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/CAD%3DM5eQcWT7OvuU-cGASF8_fLdgfmoxWGxQRU%2BX09gucSBhn_Q%40mail.gmail.com.


Re: how to make docker image of your django app

2020-06-17 Thread Jason Turner
https://testdriven.io/blog/dockerizing-django-with-postgres-gunicorn-and-nginx/

Also, Will Vincent's book "Django for Professionals" is a good resource.

On Wed, Jun 17, 2020, 8:51 AM Anirudh choudhary <
anirudhchoudary...@gmail.com> wrote:

> I Want to make make a docker image of my Django app using PostgreSQL and
> unicorn. but I can't find any good tutorial for reference
> please share my link to if you know any good tutorial
>
> My Dockerfile now is like
> FROM python:3.6
> ENV PYTHONUNBUFFERED 1
> RUN mkdir /app
> WORKDIR /app
> COPY requirements.txt /app/requirements.txt
> RUN pip install -r requirements.txt
> RUN apt install postgresql-client
> RUN mkdir postgresqlcode
> COPY /private_key/client-cert.pem /private_key/client-cert.pem
> COPY /private_key/client-cert.pem /private_key/client-cert.pem
> COPY /private_key/client-cert.pem /private_key/client-cert.pem
> RUN psql "sslmode=verify-ca sslrootcert=\server-ca.pem \
> sslcert=client-cert.pem sslkey=\client-key.pem \
> hostaddr=hostaddress \
> port=port \
> user=postgres dbname=postgres"
> COPY . /code/
>
>
> I know I have to make Django-compose.yml file and I ha
>
>
>
>
>
>
>
> --
> 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/CAL8_rkEBoEuAC7N9XCgDsakOVSsGtM1EM_3bZc9azOL3jPhDjw%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/CADoyC14A%3Df_c7FGt8RQqacpYKMuQAkj-QmGA49Hmzr08EaorLw%40mail.gmail.com.


how to make docker image of your django app

2020-06-17 Thread Anirudh choudhary
I Want to make make a docker image of my Django app using PostgreSQL and
unicorn. but I can't find any good tutorial for reference
please share my link to if you know any good tutorial

My Dockerfile now is like
FROM python:3.6
ENV PYTHONUNBUFFERED 1
RUN mkdir /app
WORKDIR /app
COPY requirements.txt /app/requirements.txt
RUN pip install -r requirements.txt
RUN apt install postgresql-client
RUN mkdir postgresqlcode
COPY /private_key/client-cert.pem /private_key/client-cert.pem
COPY /private_key/client-cert.pem /private_key/client-cert.pem
COPY /private_key/client-cert.pem /private_key/client-cert.pem
RUN psql "sslmode=verify-ca sslrootcert=\server-ca.pem \
sslcert=client-cert.pem sslkey=\client-key.pem \
hostaddr=hostaddress \
port=port \
user=postgres dbname=postgres"
COPY . /code/


I know I have to make Django-compose.yml file and I ha

-- 
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/CAL8_rkEBoEuAC7N9XCgDsakOVSsGtM1EM_3bZc9azOL3jPhDjw%40mail.gmail.com.


Re: someone to help in this please

2020-06-17 Thread Richard Balwane
-> Do a .whl installation - In the environment!
Download  "GDAL-3.0.4-cp37-cp37m-win_amd64.whl", if using Python 3.7 on
Windows 64-bit
Say...
Command(env activated, path to the file):
python.exe -m pip install
"C:\\Users\\Mossad\\Downloads\\GDAL-3.0.4-cp37-cp37m-win_amd64.whl"

 ->  Include 'gdal300'  in
env\Lib\site-packages\django\contrib\gis\gdal\libgdal.py file for this
GDAL-3.0.4 .whl installation
(There is a list of these .dlls for nt users)
  Set:
1. GDAL_LIBRARY_PATH in settings.py:
  import os
  GDAL_LIBRARY_PATH = os.path.join(
PROJECT_DIR, r"env\\Lib\\site-packages\\osgeo\\gdal300.dll"
)

2.  GDAL_DRIVER_PATH = os.path.join(
PROJECT_DIR,
r"env\\Lib\site-packages\\osgeo\\gdalplugins\\ogr_FileGDB.dll"
)

And, you are good to go.

Praise be to The Almighty God.



*Richard Dick Balwane*

*Mobiles:+256 755 442248, *

*+256 781 493558.*
*Twiter:   @RBalwane*
*WhatsApp:   **+256 755 442248*


*Balwane Holding Inc.*




On Tue, 16 Jun 2020 at 18:11, Peter Kirieny  wrote:

> am using Geodjango with postgresql db and i get this error while trying to
> run the server;
> raise ImproperlyConfigured(
> django.core.exceptions.ImproperlyConfigured: Could not find the GDAL
> library (tried "gdal204", "gdal203", "gdal202", "gdal201", "gdal20"). Is
> GDAL installed? If it i
> s, try setting GDAL_LIBRARY_PATH in your settings.
>
> the libraries are installed just don't know  how to set the paths
> 'am new in programming'
>
> --
> 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/CAL8t8eof1jY3wwUa9Fj_owAK8WEoVpZSFnOCFrQsmD_w3Yy%3Dfg%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/CAAjYwK9JRdX%3DyUtrkeV6jxJsDtHKS-NfP30buww2NbkHjPwLjQ%40mail.gmail.com.


Re: someone to help in this please

2020-06-17 Thread Kasper Laudrup

Hi Peter,

On 17/06/2020 14.04, Peter Kirieny wrote:

yea, I installed it with OSGEO4W



So I assume you are on Windows?

It would have been quite useful if you had written that in your initial 
question.


I'm not very experienced on that platform, but the installer you used 
has most likely installed a library somewhere, I assume in "Program 
Files" or whatever it's called on Windows these days.


Try to figure out where the installer put the GDAL library which is 
probably a file ending with either ".lib" or ".dll" and set your 
GDAL_LIBRARY_PATH to that folder in your settings.


Hope that helps.

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/f68cf720-4fe2-cf15-687b-0ecda634b41f%40stacktrace.dk.


Re: someone to help in this please

2020-06-17 Thread Peter Kirieny
yea, I installed it with OSGEO4W

On Tue, 16 Jun 2020 at 18:14, Budi Hermansyah 
wrote:

> Did you already install gdal n friends?
>
>
> https://docs.djangoproject.com/en/3.0/ref/contrib/gis/install/geolibs/
>
>
>
> On Tue, 16 Jun 2020 at 22.12 Peter Kirieny  wrote:
>
>> am using Geodjango with postgresql db and i get this error while trying
>> to run the server;
>> raise ImproperlyConfigured(
>> django.core.exceptions.ImproperlyConfigured: Could not find the GDAL
>> library (tried "gdal204", "gdal203", "gdal202", "gdal201", "gdal20"). Is
>> GDAL installed? If it i
>> s, try setting GDAL_LIBRARY_PATH in your settings.
>>
>> the libraries are installed just don't know  how to set the paths
>> 'am new in programming'
>>
>> --
>> 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/CAL8t8eof1jY3wwUa9Fj_owAK8WEoVpZSFnOCFrQsmD_w3Yy%3Dfg%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/CAHGmjWWFFha3%3DqU_%2BYf60Vvz5bhuCA6G9-raXasbA89GSB_Yyw%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/CAL8t8eoWwwtWC%3DHk9b1JNy%3D8ODxUwmx7TLfxDL%3Dc81TxxFyOeQ%40mail.gmail.com.


Django channels handshake response headers are missing

2020-06-17 Thread Albertas Gimbutas
Hi,

  I am trying to add WebSocket `permessage-deflate` extension support to my 
django channels consumer. As I know if a WebSocket server supports an 
extension (which was provided in the request headers), the server has to 
include the extension headers in the handshake response. Which I was not 
able to do.

  The default accept() method implementation of AsyncWebsocketConsumer does 
not have headers parameter: 
https://github.com/django/channels/blob/master/channels/generic/websocket.py#L184
  However, the asgiref specification states that websocket.accept message 
can have "headers" section: 
https://asgi.readthedocs.io/en/latest/specs/www.html#accept-send-event
  So when a client initiates WebSocket connection with 
"Sec-WebSocket-Extensions: permessage-deflate" headers, I use this code to 
accept the connection:

class MyConsumer(AsyncWebsocketConsumer):
  async def connect(self):
await self.base_send({
"type": "websocket.accept",
"subprotocol": None,
"headers": [
(b'sec-websocket-extensions', b'permessage-deflate')
]
})

  Connection gets upgraded to WS protocol, however the client does not 
receive the Sec-Websocket-Extensions headers and does not expect messages 
to be compressed. For example I am providing request/response headers.
  Request headers:
GET ws://localhost:8080/ws/my_route/ HTTP/1.1
Host: localhost:8080
Connection: Upgrade
Pragma: no-cache
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, 
like Gecko) Chrome/83.0.4103.97 Safari/537.36
Upgrade: websocket
Origin: http://localhost:8200
Sec-WebSocket-Version: 13
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Sec-WebSocket-Key: XX==
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits

  Response headers:
HTTP/1.1 101 Switching Protocols
Server: Daphne
Upgrade: WebSocket
Connection: Upgrade
Sec-WebSocket-Accept: XXX=

  This behaviour is observed when using manage.py runserver on RedHat7 
linux and newest Chrome/Firefox browsers. Main package from my pip freeze 
are:
aiohttp==3.6.2
aioredis==1.2.0
asgiref==3.2.9
async-timeout==3.0.1
asyncio==3.4.3
billiard==3.6.0.0
channels==2.4.0
channels-redis==2.4.0
daphne==2.3.0
Django==2.2
django-cors-headers==2.3.0
django-crequest==2018.5.11
gunicorn==19.9.0
pika==0.12.0
redis==3.2.1
tornado==5.1
Twisted==18.9.0
txaio==18.8.1
urllib3==1.24.1

  I am not sure whether its a bug, or am I doing something wrong?

Best regards,
Albertas
  

-- 
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/8e346f91-ed71-4ce0-97bb-d83a72f4409fo%40googlegroups.com.


Re: Sybase X Django

2020-06-17 Thread Henri GERARDIN
I made a change in my sql.ini and now i get this mistake : 
[SAP][ASE ODBC Driver][Adaptive Server Enterprise]Function 'SYSDATETIME' 
not found. If this is a SQLJ function or SQL function, use sp_help to check 
whether the object exists 
Le mercredi 17 juin 2020 à 11:55:51 UTC+2, Henri GERARDIN a écrit :

> Hello everybody, 
>
> I am trying to connect my Django project with a sybase database but i 
> always get this mistake : Cannot locate reference to the DB server 
> specified in DSURL. Here is my connection String :
>
>  'apidata': {
>
>  'ENGINE': "sql_server.pyodbc",
>  'HOST': "dsp_adt_django",
>  'USER': "",
>  'PASSWORD': "",
>  'NAME': "APIDATA",
>  'PORT': 4600,
>  'OPTIONS': {
> 'driver': 'Adaptive Server Enterprise',
> 'isolation_level':'READ UNCOMMITTED',
> }
> }
>
> Please Help !!
>

-- 
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/190c5f86-476c-4915-967f-6be54193bfc3n%40googlegroups.com.


Disable temporary nested serializer

2020-06-17 Thread plusmen...@gmail.com
Hello everyone! I'm new in Django. 
I have a serializer with nested serializer like this: 

  Project Serializer with nested customer serializer 
###

class ProjectSerializer(serializers.ModelSerializer):
id = serializers.IntegerField(required=False) 
customer = CustomerSerializer(required=True)

class Meta: 
model = Project
fields = '__all__'

def __init__(self, customer_serializer_included=True, *args, **kwargs):
super(ProjectSerializer, self).__init__(*args, **kwargs)
self.customer = 
CustomerSerializer(required=customer_serializer_included)

### BillingActivitySerializer that uses Project serializer (without 
nested serializer) ###

class BillingActivitySerializer(serializers.ModelSerializer):
 id = serializers.IntegerField(required=False) 
 project = ProjectSerializer(required=True, 
customer_serializer_included = False)

The problem is that everytime i use the project serializer, also nested 
serializer are used too. I'd like to exclude the nested serializer. I've 
try to do this in the __init__ but Django gives always a 400 Bad request

Response: {
  "project": {
"customer": [
  "This field is required."
]
  }
}



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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0ddcb9ea-8fe1-4391-a268-10fe41d8c95dn%40googlegroups.com.


Sybase X Django

2020-06-17 Thread Henri GERARDIN
Hello everybody, 

I am trying to connect my Django project with a sybase database but i 
always get this mistake : Cannot locate reference to the DB server 
specified in DSURL. Here is my connection String :

 'apidata': {

 'ENGINE': "sql_server.pyodbc",
 'HOST': "dsp_adt_django",
 'USER': "",
 'PASSWORD': "",
 'NAME': "APIDATA",
 'PORT': 4600,
 'OPTIONS': {
'driver': 'Adaptive Server Enterprise',
'isolation_level':'READ UNCOMMITTED',
}
}

Please Help !!

-- 
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/f2fa6157-7878-4b44-a64d-b2ee5cc9abc3n%40googlegroups.com.


Django channels handshake headers are ignored

2020-06-17 Thread Albertas Gimbutas
Hi,

  I want to add WebSocket extension support to my Django channels consumer 
class. As I know a list of accepted extensions should be included in the 
headers of the handshake response of the consumer. I tried adding the 
response headers, however browser does not get them. I am not sure whether 
its a bug, or I have done something wrong.

  As specified in the asgiref documentation: "websocket.accept" message can 
have "headers" section 
https://asgi.readthedocs.io/en/latest/specs/www.html#accept-send-event
  In my AsyncJsonWebsocketConsumer class I am accepting the connection with 
this code:

await self.base_send({
  "type": "websocket.accept",
  "subprotocol": None,
  "headers": [(b'sec-websocket-extensions', b'permessage-deflate')]
})

  since the original accept() method implementation does not have headers 
parameter 
https://github.com/django/channels/blob/507cb54fcb36df63282dd19653ea743036e7d63c/channels/generic/websocket.py#L184

  With this implementation latest Chrome/Firefox does not receive 
"Sec-WebSocket-Extensions: permessage-deflate" headeres in the handshake 
response. For example, I provide request and response headers:

  The request headers are:

GET ws://localhost:8080/ws/my_route/ HTTP/1.1
Host: localhost:8080
Connection: Upgrade
Pragma: no-cache
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, 
like Gecko) Chrome/83.0.4103.97 Safari/537.36
Upgrade: websocket
Origin: http://localhost:8200
Sec-WebSocket-Version: 13
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Sec-WebSocket-Key: XX==
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits


  The response headers are:

HTTP/1.1 101 Switching Protocols
Server: Daphne
Upgrade: WebSocket
Connection: Upgrade
Sec-WebSocket-Accept: XXX=



  I am using manage.py runserver command. Major packages of my pip freeze 
are:

aiohttp==3.6.2
aioredis==1.2.0
asgiref==3.2.9
async-timeout==3.0.1
asyncio==3.4.3
billiard==3.6.0.0
channels==2.4.0
channels-redis==2.4.0
daphne==2.3.0
Django==2.2
django-cors-headers==2.3.0
django-crequest==2018.5.11
gunicorn==19.9.0
pika==0.12.0
redis==3.2.1
tornado==5.1
Twisted==18.9.0
txaio==18.8.1
urllib3==1.24.1


Maybe you could advice me how to find the reason why the response 
headers are ignored? Should I report this as a bug to channels/asgiref?

Best regards,
Albertas

-- 
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/00693eea-809b-495e-a0a7-b70792065d15o%40googlegroups.com.


Re: Django Saving a form with Imagefield on shared host

2020-06-17 Thread Kelvin Sajere
If you indeed have your media folder where it’s supposed to be, then make
sure in your settings file, you have specified that folder as your root
folder for media. I don’t see your code, so this might be difficult to
determine on my end.
-- 
KeLLs

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


RE: Django Saving a form with Imagefield on shared host

2020-06-17 Thread Vishesh Mangla
One thing that can be done is to save the image as a base64 string in the database. https://stackoverflow.com/questions/3715493/encoding-an-image-file-with-base64 Sent from Mail for Windows 10 From: MUGOYA DIHFAHSIHSent: 14 June 2020 19:15To: Django usersSubject: Django Saving a form with Imagefield on shared host I am working on django project and now i have deployed it with NamecheapWhen i submit a form that does not have an ImageField, the form submits successfully on the shared hostbut when i submit a form with one of the fields ImageField, it raises 404 error.but on the localhost, the forms work perfectly.what can i do to submit such forms on a shared host.Thanks. -- You received this message because you are subscribed to the Google Groups "Django users" group.To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com.To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b79bb9b5-46b4-43eb-9ea5-3eaab14336ddo%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/3F4C1D42-FB11-49A2-8A6E-BF990EE847AD%40hxcore.ol.