Django mysql db issue

2020-02-21 Thread Perceval Maturure
Dear all

Is there anyone experiencing the below with python3.7 Django 2.2

django.db.utils.OperationalError: (1074, "Column length too big for column 
'url' (max = 16383); use BLOB or TEXT instead")

-- 
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/5F0F1C12-C0D9-4B3E-8659-2048103658D2%40gmail.com.


Re: Channels, daphne, and asgiref, oh my!

2020-02-21 Thread Andrew Godwin
Hi Larry,

Your problem is the Python version - 3.5 is somewhat old (but most
importantly, was still a very rough release for asyncio) and isn't
supported by any current release of asgiref/channels for that reason. If
you are able to upgrade that, I very much recommend it.

Andrew

On Sat, Feb 22, 2020 at 2:52 AM Aldian Fazrihady  wrote:

> I have these working module combinations, but my Python is 3.6.9:
> asgiref==2.2.0
> channels==2.0.2
> channels_redis==2.3.0
> daphne==2.1.0
> Django==2.2.4
> django-redis==4.10.0
> redis==3.3.6
> Twisted[tls,http2]
> uwsgi==2.0.18
> websockets==6.0
>
> On Sat, Feb 22, 2020 at 3:25 AM Larry Martell 
> wrote:
>
>> I am in a bit of version hell. Not fun on a Friday afternoon.
>>
>> Django 2.0.4, python 3.5.2
>>
>> Trying to get channels, websockets, daphne, and asgiref working.
>>
>> When I installed the latest channels it did not work with my version
>> of mysqlclient and some googling led me to install 2.0 of channels.
>> That worked fine with the dev server, and then I wanted to deploy my
>> app in prod. In prod we use nginx/uwsgi so I was going to replace
>> uwsgi with daphne. When I tried to run daphne I got:
>>
>> ImportError: No module named 'asgiref.compatibility'
>>
>> Googling that I was led to upgrade asgiref to the latest version.
>> After I did that I got:
>>
>> AttributeError: module 'asyncio.coroutines' has no attribute
>> '_is_coroutine'
>>
>> Have not been able to get past this one.
>>
>> Anyone have any thoughts? Would upgrading django and python fix these
>> issues? I am planning on doing that soon, but I was not planning on
>> doing that now. Don't want to upgrade now and then find I still have
>> issues. Can I get all this to work with my current versions and
>> upgrade later?
>>
>> TIA!
>> Larry
>>
>> --
>> 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/CACwCsY5SQzRG-7EuEM8rZvOfQor5bBOjt%3DBV1Qsbn9%2BBhMx12g%40mail.gmail.com
>> .
>>
>
>
> --
> Regards,
>
> Aldian Fazrihady
> http://aldianfazrihady.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/CAN7EoAbSAVUT%3D8sg1o-0oczCfjfRhtGwrMDE31YBt9N%2Bm96YmA%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/CAFwN1up5WAkwAVrasG%2BgG6ia8JSru1sMjJnckiCP8kbsVK-JiA%40mail.gmail.com.


Re: Channels, daphne, and asgiref, oh my!

2020-02-21 Thread Aldian Fazrihady
I have these working module combinations, but my Python is 3.6.9:
asgiref==2.2.0
channels==2.0.2
channels_redis==2.3.0
daphne==2.1.0
Django==2.2.4
django-redis==4.10.0
redis==3.3.6
Twisted[tls,http2]
uwsgi==2.0.18
websockets==6.0

On Sat, Feb 22, 2020 at 3:25 AM Larry Martell 
wrote:

> I am in a bit of version hell. Not fun on a Friday afternoon.
>
> Django 2.0.4, python 3.5.2
>
> Trying to get channels, websockets, daphne, and asgiref working.
>
> When I installed the latest channels it did not work with my version
> of mysqlclient and some googling led me to install 2.0 of channels.
> That worked fine with the dev server, and then I wanted to deploy my
> app in prod. In prod we use nginx/uwsgi so I was going to replace
> uwsgi with daphne. When I tried to run daphne I got:
>
> ImportError: No module named 'asgiref.compatibility'
>
> Googling that I was led to upgrade asgiref to the latest version.
> After I did that I got:
>
> AttributeError: module 'asyncio.coroutines' has no attribute
> '_is_coroutine'
>
> Have not been able to get past this one.
>
> Anyone have any thoughts? Would upgrading django and python fix these
> issues? I am planning on doing that soon, but I was not planning on
> doing that now. Don't want to upgrade now and then find I still have
> issues. Can I get all this to work with my current versions and
> upgrade later?
>
> TIA!
> Larry
>
> --
> 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/CACwCsY5SQzRG-7EuEM8rZvOfQor5bBOjt%3DBV1Qsbn9%2BBhMx12g%40mail.gmail.com
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAbSAVUT%3D8sg1o-0oczCfjfRhtGwrMDE31YBt9N%2Bm96YmA%40mail.gmail.com.


Re: Why can't Nginx find Django's static files?

2020-02-21 Thread Stephen J. Butler
The way production servers are setup with Django uses this kind of request
workflow:

client /myapp1 --> nginx:8080 ---(proxy)---> gunicorn:8000 (runs python)
client /myapp2 --> nginx:8080 ---(proxy)---> gunicorn:8000 (runs python)
client /myapp3 --> nginx:8080 ---(proxy)---> gunicorn:8000 (runs python)
client /static/somefile1.css ---> nginx:8080 (reads from the filesystem)
client /static/somefile2.css ---> nginx:8080 (reads from the filesystem)

Notice how everything first goes to nginx, and then your nginx either
proxies/forwards the request to gunicorn for the python code, or it serves
up the static file itself. That's what we want to do. gunicorn is very good
at running dynamic python code but it's very bad at serving up static
files. nginx is very good at serving static files but can't run python
code. See how they work together?

Here's another way to think about it. Take a look sometime at the number of
requests a browser makes to a simple Django website that maybe has 10
images on it, 5 CSS files, and 5 JS files. The initial request fetches
dynamic content and the python code, but then there are 20+ (!!) other
requests that fetch all the static things.

So in that case, only 5% of your requests need to run in gunicorn and the
rest of them should be handled by nginx directly. If you did the bad thing
and just let gunicorn handle it all then you'd need to provision x20 the
resources for gunicorn to make your site have good response times under
load! That's because you'd be handling x20 the connections just to serve
static files.

Therefore, every good sysadmin puts gunicorn behind nginx or apache or some
other proxy technology. It says "Let the frontend server (nginx, apache,
CloudFront, CDN, etc) do the easy task of serving up files from /static,
and send everything else to the backend server (gunicorn) for the hard part
of generating dynamic content."

Now, you setup your nginx and gunicorn properly as far as I can tell. The
only bad thing you did was talk to gunicorn directly instead of going
through the nginx proxy like you should have.

On Fri, Feb 21, 2020 at 11:49 AM Robert F. 
wrote:

>
>
> On Thursday, February 20, 2020 at 8:52:31 AM UTC-8, Stephen J. Butler
> wrote:
>>
>> Django only serves up static files itself when run using runserver. This
>> is meant for development and not production use. When you run it through
>> gunicorn the Django framework won't serve up static files. That's why you
>> connections to :8000 (gunicorn directly, bypassing nginx) don't work right.
>>
>> For running in production/gunicorn you need to run "collectstatic" after
>> changes, and connect to nginx (probably port 80/443) so that the
>> "location/alias" block works as intended and you get your static files.
>>
>>
>>> I understand what you're saying but I don't understand specifically what
>>> it is that I'm doing wrong.  Should I not start Gunicorn with ":8000"?  Do
>>> I need to modify my Nginx configuration file?  I don't quite see how all of
>>> these pieces work together and which piece (or pieces) are wrong.  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/f1cd8e78-17ae-47c0-91e8-732a52c9%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/CAD4ANxWga%2BXA4N%2BYTBxG9spDLUpXdcK3g9o0s2C54tdfpFZrGQ%40mail.gmail.com.


Channels, daphne, and asgiref, oh my!

2020-02-21 Thread Larry Martell
I am in a bit of version hell. Not fun on a Friday afternoon.

Django 2.0.4, python 3.5.2

Trying to get channels, websockets, daphne, and asgiref working.

When I installed the latest channels it did not work with my version
of mysqlclient and some googling led me to install 2.0 of channels.
That worked fine with the dev server, and then I wanted to deploy my
app in prod. In prod we use nginx/uwsgi so I was going to replace
uwsgi with daphne. When I tried to run daphne I got:

ImportError: No module named 'asgiref.compatibility'

Googling that I was led to upgrade asgiref to the latest version.
After I did that I got:

AttributeError: module 'asyncio.coroutines' has no attribute '_is_coroutine'

Have not been able to get past this one.

Anyone have any thoughts? Would upgrading django and python fix these
issues? I am planning on doing that soon, but I was not planning on
doing that now. Don't want to upgrade now and then find I still have
issues. Can I get all this to work with my current versions and
upgrade later?

TIA!
Larry

-- 
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/CACwCsY5SQzRG-7EuEM8rZvOfQor5bBOjt%3DBV1Qsbn9%2BBhMx12g%40mail.gmail.com.


Django program development tutorials

2020-02-21 Thread Joshua Kayode
Join our group for an indepth discussion on django projects

https://chat.whatsapp.com/IgJcwnZR9sr1Jatc5jnSx9

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


Re: Whatsap group for best practices

2020-02-21 Thread Joshua Kayode
Weekly django project development...

https://chat.whatsapp.com/IgJcwnZR9sr1Jatc5jnSx9

On Tue, Feb 18, 2020, 7:03 PM Infinity Programmer <
infinityprogramme...@gmail.com> wrote:

> Join expert's Python developer whatsapp group
>
> Follow this link to join my WhatsApp group:
> https://chat.whatsapp.com/HHN5GoV27mM4TXKcqPf0ES
>
>
> Follow this link to join my WhatsApp group:
> https://chat.whatsapp.com/HHN5GoV27mM4TXKcqPf0ES
>
>
> Follow this link to join my WhatsApp group:
> https://chat.whatsapp.com/HHN5GoV27mM4TXKcqPf0ES
>
> --
> 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/1181cff8-32b1-471f-96d4-5425bf009696%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/CAEL9fCEues0J3xcz9CXnmb9KrXMHncA_89KRiXCuarNJs2Yn7Q%40mail.gmail.com.


Re: Why can't Nginx find Django's static files?

2020-02-21 Thread אורי
If it's a development server and not production, you can add something like
this to your urls.py:

from django.conf import settings as django_settings
from django.conf.urls.static import static

...

if (django_settings.DEBUG):
urlpatterns = static(prefix=django_settings.MEDIA_URL,
document_root=django_settings.MEDIA_ROOT) + urlpatterns
אורי
u...@speedy.net


On Thu, Feb 20, 2020 at 6:36 PM Robert F.  wrote:

> I'm trying to understand how static files are served up by Django using a
> project I've created on my Mac using Django 3, Gunicorn, and Nginx.  The
> website serves up templates correctly except that the templates can't see
> my CSS stylesheet.  When I go to a page, for example ```
> 127.0.0.1:8000/app1/```  and view the
> source, I see this in my HTML template:
>
> 
>
> If I click on the href link, I get a page "Not Found" at the address ```
> http://127.0.0.1:8000/static/css/main.css```
> .  This seems like it should
> be the correct link but the template can't see the main.css stylesheet as I
> would expect.
>
> Here are the relevant files in my 'mysite' project located in
> /Users/me/projects/django/django-staticfiles:
>
> ├── app1
> │   ├── templates
> │   │   └── app1
> │   │   └── index.html
> ├── mysite
> │   ├── settings.py
> │   └── wsgi.py
> ├── static
> │   └── css
> │   └── main.css
> ├── static-final
> │   ├── admin
> │   │   ├── css
> │   │   ├── fonts
> │   │   ├── img
> │   │   └── js
> │   └── css
> │   └── main.css
>
> Here are the relevant settings:
>
> # mysite/settings.py
> ...
> DEBUG = False
> ALLOWED_HOSTS = ['127.0.0.1', ]
> ...
> INSTALLED_APPS = [
> 'django.contrib.staticfiles',
> 'app1',
> ]
> ...
> STATIC_URL = '/static/'
> STATICFILES_DIRS = (
> os.path.join(BASE_DIR, 'static'),
> )
> STATIC_ROOT = os.path.join(BASE_DIR, 'static-final/')
> ...
>
> I installed Gunicorn into my virtual environment and run it with this
> command:
>
> gunicorn --bind 0.0.0.0:8000 mysite.wsgi
>
> I installed Nginx using Homebrew.  Here is the part of nginx.conf that
> includes my Nginx settings:
>
> # /usr/local/etc/nginx.conf
> ...
> http {
> ...
> server {
> listen  8080;
> server_name localhost;
> }
> ...
> include server/*;
> }
>
> Here is my Nginx configuration:
>
> # /usr/local/etc/nginx/servers/django-staticfiles
> server {
> listen 80;
> server_name 127.0.0.1;
>
> location / {
> proxy_pass http://127.0.0.1:8000;
> }
>
> location /static/ {
> alias /Users/me/projects/django/django-staticfiles/static-final/;
> }
> }
>
> I should add that when I stop Gunicorn and start Django's development
> server with DEBUG = True, the app1 template accesses the main.css file
> correctly.  It just can't see it when I'm running Gunicorn and Nginx.  I
> realize that I don't have a real need to run Gunicorn/Nginx on my Mac, but
> I've just set it up so I can compare and contrast how Django manages static
> files in development versus production.
>
> --
> 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/75f129a6-2dbf-47cc-b4ea-08008b30b047%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/CABD5YeEiYOvgNXBPX6aNTAwvqP6NWAX4HdvPDbHurY4h5R%2BMHQ%40mail.gmail.com.


Re: Why can't Nginx find Django's static files?

2020-02-21 Thread Robert F.


On Thursday, February 20, 2020 at 8:52:31 AM UTC-8, Stephen J. Butler wrote:
>
> Django only serves up static files itself when run using runserver. This 
> is meant for development and not production use. When you run it through 
> gunicorn the Django framework won't serve up static files. That's why you 
> connections to :8000 (gunicorn directly, bypassing nginx) don't work right.
>
> For running in production/gunicorn you need to run "collectstatic" after 
> changes, and connect to nginx (probably port 80/443) so that the 
> "location/alias" block works as intended and you get your static files.
>
>
>> I understand what you're saying but I don't understand specifically what 
>> it is that I'm doing wrong.  Should I not start Gunicorn with ":8000"?  Do 
>> I need to modify my Nginx configuration file?  I don't quite see how all of 
>> these pieces work together and which piece (or pieces) are wrong.  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/f1cd8e78-17ae-47c0-91e8-732a52c9%40googlegroups.com.


Re: Why can't Nginx find Django's static files?

2020-02-21 Thread Robert F.
Thanks but I'm not interested in using Whitenoise.

On Friday, February 21, 2020 at 6:22:40 AM UTC-8, Jody Fitzpatrick wrote:
>
> Take a look at whitenoise for django, this should help you. 
>
> On Thursday, February 20, 2020 at 11:35:51 AM UTC-5, Robert F. wrote:
>>
>> I'm trying to understand how static files are served up by Django using a 
>> project I've created on my Mac using Django 3, Gunicorn, and Nginx.  The 
>> website serves up templates correctly except that the templates can't see 
>> my CSS stylesheet.  When I go to a page, for example ```
>> 127.0.0.1:8000/app1/```  and view the 
>> source, I see this in my HTML template:
>>
>> 
>>
>> If I click on the href link, I get a page "Not Found" at the address ```
>> http://127.0.0.1:8000/static/css/main.css``` 
>> .  This seems like it should 
>> be the correct link but the template can't see the main.css stylesheet as I 
>> would expect.
>>
>> Here are the relevant files in my 'mysite' project located in 
>> /Users/me/projects/django/django-staticfiles:
>>
>> ├── app1
>> │   ├── templates
>> │   │   └── app1
>> │   │   └── index.html
>> ├── mysite
>> │   ├── settings.py
>> │   └── wsgi.py
>> ├── static
>> │   └── css
>> │   └── main.css
>> ├── static-final
>> │   ├── admin
>> │   │   ├── css
>> │   │   ├── fonts
>> │   │   ├── img
>> │   │   └── js
>> │   └── css
>> │   └── main.css
>>
>> Here are the relevant settings:
>>
>> # mysite/settings.py
>> ...
>> DEBUG = False
>> ALLOWED_HOSTS = ['127.0.0.1', ]
>> ...
>> INSTALLED_APPS = [
>> 'django.contrib.staticfiles',
>> 'app1',
>> ]
>> ...
>> STATIC_URL = '/static/'
>> STATICFILES_DIRS = (
>> os.path.join(BASE_DIR, 'static'),
>> )
>> STATIC_ROOT = os.path.join(BASE_DIR, 'static-final/')
>> ...
>>
>> I installed Gunicorn into my virtual environment and run it with this 
>> command:
>>
>> gunicorn --bind 0.0.0.0:8000 mysite.wsgi
>>
>> I installed Nginx using Homebrew.  Here is the part of nginx.conf that 
>> includes my Nginx settings:
>>
>> # /usr/local/etc/nginx.conf
>> ...
>> http {
>> ...
>> server {
>> listen  8080;
>> server_name localhost;
>> }
>> ...
>> include server/*;
>> }
>>
>> Here is my Nginx configuration:
>>
>> # /usr/local/etc/nginx/servers/django-staticfiles
>> server {
>> listen 80;
>> server_name 127.0.0.1;
>>
>> location / {
>> proxy_pass http://127.0.0.1:8000;
>> }
>>
>> location /static/ {
>> alias /Users/me/projects/django/django-staticfiles/static-final/;
>> }
>> }
>>
>> I should add that when I stop Gunicorn and start Django's development 
>> server with DEBUG = True, the app1 template accesses the main.css file 
>> correctly.  It just can't see it when I'm running Gunicorn and Nginx.  I 
>> realize that I don't have a real need to run Gunicorn/Nginx on my Mac, but 
>> I've just set it up so I can compare and contrast how Django manages static 
>> files in development versus production.
>>
>>

-- 
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/64a79357-c5db-4da6-8320-4b19d5fa51d1%40googlegroups.com.


Re: Python Django Training

2020-02-21 Thread shailendra singh
When will training start?

On Fri, Feb 21, 2020 at 7:13 PM Bharati Nilam 
wrote:

> Hi,
> I also from Hyderabad and I'm also interested in the training. please tell
> me how to join?
>
> Regards,
> Bharati
>
> On Thu, 20 Feb, 2020, 6:19 PM Thiagu Palaniappan, <
> thiagarajan@gmail.com> wrote:
>
>> I'm also interested. Please add me in the group.
>>
>>
>> Thanks & Regards,
>> Thiagu
>>
>> On Mon, Feb 17, 2020 at 12:41 AM Akshay Raul 
>> wrote:
>>
>>> I am interested also. Please let me know the details.
>>>
>>> On Sat 1 Feb, 2020, 2:42 PM Srikanth K,  wrote:
>>>
 Hi,

 I am from Hyderabad. I am Python Developer by Profession. I am eager
 take up any Python , Django Training (online Preferrable or Weekends).
 Members who require can contact me or share me  there idea.

 Regards,
 Srikanth.K

 --
 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/CACPyz-gXb7wo9E0Uhs_pnxF9X52uA10__Fq1xt4trjXUaN3ehQ%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/CAEd%2Bv%3D0gE2dEMXKJ0Nm8FcH2ZxUPAdQspkQKB%2Bg5pZbSc_uZnQ%40mail.gmail.com
>>> 
>>> .
>>>
>>
>>
>> --
>>
>> Thanks & Regards,
>>
>> *Thiagu Palaniappan*
>>
>> M +91 (0) 9994318799
>>
>> *DXC Technology*
>> 8th Floor, Tower 1 B DLF IT Park, 1/124 - Shivaji Garden, Nandambakkam
>> post, Ramapuram, Chennai - 600 089.
>>
>> dxc.technology  / Twitter
>>  / Facebook
>>  / LinkedIn
>> 
>>
>> --
>> 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/CAK%3DQXNMzH-iL6BQ3_vfrvTpeY%2BSe5%3DbZm9h5wPW_Dw%2BM2BsvQg%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/CAPGVBeOgomb94NXAm347QqGcJ%3D3MzxULU7eQnY-M56EbC2D9vg%40mail.gmail.com
> 
> .
>


-- 
*Thanks & Regards,*
Shailendra Singh

-- 
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/CAOOJk%3DVvjRZ70Pt8p753qckCvRgkXkw1c9-bOofH8svc3cA28g%40mail.gmail.com.


Re: Why can't Nginx find Django's static files?

2020-02-21 Thread Aldian Fazrihady
When you are using Nginx, it is assumed you are trying to make a production
environment.
On production environments you don't want your backend code execution to be
slowed down by something like serving people downloading static images.
On production environments, Django will focus on its purpose, which is to
handle application code logic.

Static files handling should be delegated to other server such as Nginx.
The static file folder will be referenced directly by Nginx.
Most of static files, such as images are so irrelevant to your backend
application logic so that they can be cached on the browser.


On Thu, Feb 20, 2020 at 11:36 PM Robert F. 
wrote:

> I'm trying to understand how static files are served up by Django using a
> project I've created on my Mac using Django 3, Gunicorn, and Nginx.  The
> website serves up templates correctly except that the templates can't see
> my CSS stylesheet.  When I go to a page, for example ```
> 127.0.0.1:8000/app1/```  and view the
> source, I see this in my HTML template:
>
> 
>
> If I click on the href link, I get a page "Not Found" at the address ```
> http://127.0.0.1:8000/static/css/main.css```
> .  This seems like it should
> be the correct link but the template can't see the main.css stylesheet as I
> would expect.
>
> Here are the relevant files in my 'mysite' project located in
> /Users/me/projects/django/django-staticfiles:
>
> ├── app1
> │   ├── templates
> │   │   └── app1
> │   │   └── index.html
> ├── mysite
> │   ├── settings.py
> │   └── wsgi.py
> ├── static
> │   └── css
> │   └── main.css
> ├── static-final
> │   ├── admin
> │   │   ├── css
> │   │   ├── fonts
> │   │   ├── img
> │   │   └── js
> │   └── css
> │   └── main.css
>
> Here are the relevant settings:
>
> # mysite/settings.py
> ...
> DEBUG = False
> ALLOWED_HOSTS = ['127.0.0.1', ]
> ...
> INSTALLED_APPS = [
> 'django.contrib.staticfiles',
> 'app1',
> ]
> ...
> STATIC_URL = '/static/'
> STATICFILES_DIRS = (
> os.path.join(BASE_DIR, 'static'),
> )
> STATIC_ROOT = os.path.join(BASE_DIR, 'static-final/')
> ...
>
> I installed Gunicorn into my virtual environment and run it with this
> command:
>
> gunicorn --bind 0.0.0.0:8000 mysite.wsgi
>
> I installed Nginx using Homebrew.  Here is the part of nginx.conf that
> includes my Nginx settings:
>
> # /usr/local/etc/nginx.conf
> ...
> http {
> ...
> server {
> listen  8080;
> server_name localhost;
> }
> ...
> include server/*;
> }
>
> Here is my Nginx configuration:
>
> # /usr/local/etc/nginx/servers/django-staticfiles
> server {
> listen 80;
> server_name 127.0.0.1;
>
> location / {
> proxy_pass http://127.0.0.1:8000;
> }
>
> location /static/ {
> alias /Users/me/projects/django/django-staticfiles/static-final/;
> }
> }
>
> I should add that when I stop Gunicorn and start Django's development
> server with DEBUG = True, the app1 template accesses the main.css file
> correctly.  It just can't see it when I'm running Gunicorn and Nginx.  I
> realize that I don't have a real need to run Gunicorn/Nginx on my Mac, but
> I've just set it up so I can compare and contrast how Django manages static
> files in development versus production.
>
> --
> 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/75f129a6-2dbf-47cc-b4ea-08008b30b047%40googlegroups.com
> 
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAbn3p8AcQoz3yygaqmdKz-X4Z84fZQrQcVh3Pm0eENkmA%40mail.gmail.com.


Re: Bulk SMS website using django

2020-02-21 Thread Isaac Imafidon
Thanks alot for your support. I have visited Twilo website, and see their
packages its very good. Thanks alot i think i will go with Twilo.

On Fri, 21 Feb 2020 at 15:20, Jody Fitzpatrick <
jody.lee.fitzpatr...@gmail.com> wrote:

> Hi, look at Twilio. They seem to be a great choice, cost is going to vary
> - just charge extra per message on top of what they charge. Building out
> this service on your own will be difficult without the help of a third
> party to send the messages.
>
> --
> 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/cdcfc982-6504-4eee-917d-b2414c6a89d7%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/CADzUEaibv%3DAmjz08%2B%3DeM2agmfWZt2kqSP0BD-e%2BSQcdEkqPTDw%40mail.gmail.com.


Re: Why can't Nginx find Django's static files?

2020-02-21 Thread Jody Fitzpatrick
Take a look at whitenoise for django, this should help you. 

On Thursday, February 20, 2020 at 11:35:51 AM UTC-5, Robert F. wrote:
>
> I'm trying to understand how static files are served up by Django using a 
> project I've created on my Mac using Django 3, Gunicorn, and Nginx.  The 
> website serves up templates correctly except that the templates can't see 
> my CSS stylesheet.  When I go to a page, for example ```
> 127.0.0.1:8000/app1/```  and view the 
> source, I see this in my HTML template:
>
> 
>
> If I click on the href link, I get a page "Not Found" at the address ```
> http://127.0.0.1:8000/static/css/main.css``` 
> .  This seems like it should 
> be the correct link but the template can't see the main.css stylesheet as I 
> would expect.
>
> Here are the relevant files in my 'mysite' project located in 
> /Users/me/projects/django/django-staticfiles:
>
> ├── app1
> │   ├── templates
> │   │   └── app1
> │   │   └── index.html
> ├── mysite
> │   ├── settings.py
> │   └── wsgi.py
> ├── static
> │   └── css
> │   └── main.css
> ├── static-final
> │   ├── admin
> │   │   ├── css
> │   │   ├── fonts
> │   │   ├── img
> │   │   └── js
> │   └── css
> │   └── main.css
>
> Here are the relevant settings:
>
> # mysite/settings.py
> ...
> DEBUG = False
> ALLOWED_HOSTS = ['127.0.0.1', ]
> ...
> INSTALLED_APPS = [
> 'django.contrib.staticfiles',
> 'app1',
> ]
> ...
> STATIC_URL = '/static/'
> STATICFILES_DIRS = (
> os.path.join(BASE_DIR, 'static'),
> )
> STATIC_ROOT = os.path.join(BASE_DIR, 'static-final/')
> ...
>
> I installed Gunicorn into my virtual environment and run it with this 
> command:
>
> gunicorn --bind 0.0.0.0:8000 mysite.wsgi
>
> I installed Nginx using Homebrew.  Here is the part of nginx.conf that 
> includes my Nginx settings:
>
> # /usr/local/etc/nginx.conf
> ...
> http {
> ...
> server {
> listen  8080;
> server_name localhost;
> }
> ...
> include server/*;
> }
>
> Here is my Nginx configuration:
>
> # /usr/local/etc/nginx/servers/django-staticfiles
> server {
> listen 80;
> server_name 127.0.0.1;
>
> location / {
> proxy_pass http://127.0.0.1:8000;
> }
>
> location /static/ {
> alias /Users/me/projects/django/django-staticfiles/static-final/;
> }
> }
>
> I should add that when I stop Gunicorn and start Django's development 
> server with DEBUG = True, the app1 template accesses the main.css file 
> correctly.  It just can't see it when I'm running Gunicorn and Nginx.  I 
> realize that I don't have a real need to run Gunicorn/Nginx on my Mac, but 
> I've just set it up so I can compare and contrast how Django manages static 
> files in development versus production.
>
>

-- 
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/68197136-3dfb-47ab-913c-f5cf01f742c6%40googlegroups.com.


Re: Bulk SMS website using django

2020-02-21 Thread Isaac Imafidon
What is the country code ? I tried to send whatsapp message but the number 
is not identified, because no country code is included. Can you please 
repost the number with the country code ?
 

On Friday, 21 February 2020 14:26:08 UTC+1, Jani Eric wrote:
>
> Hello. Text me on this number: 03351931286 .this is my what's app no
>
> On Fri, Feb 21, 2020, 12:52 PM Isaac Imafidon  > wrote:
>
>> I have a project to develop a bulk sms website using django, but i have 
>> not develop this kind of website before. Also the client want to be able to 
>> have users that log in and buy credit that they will use to send sms to any 
>> part of the world. Also i don't know any recommended company to buy the 
>> reseller at an affordable price that will make my client be able to make 
>> profit from he's business. I really need you guys support on this, also if 
>> anyone have develop this kind of website before and just brief me on how to 
>> go about it.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/1707833a-44c2-43f9-8f66-c7fca1a2540d%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/f91eba88-b4a9-44f3-b59d-69576ab8ccc5%40googlegroups.com.


Re: Django i18n_patterns default language

2020-02-21 Thread Aldian Fazrihady
A web browser has language preference setting. When a request made to your
Django server,  your browser reads its language preferences and it put it
in the request "Accept-Language" header.
Django will check if the request URL has language prefix in it. If it
doesn't it will add language prefix to the same URL and make web browser to
redirect to that new URL.

You can see the flow using web browser developer tool.

On Fri, Feb 21, 2020 at 8:43 PM Szocs Arnold 
wrote:

> I am using i18n_patterns to change the language prefix in url. It s
> working fine ones the language cookie is set. The problem is that it's
> adding /en/ when I trying to access a page without the language code in
> private window, even though my preferred language is not en (the default
> one set in settings.LANGUAGE_CODE). The Django documentation says that how
> django discovers language prefference:
>
> Django documentation says it will use the following to choose the language:
>
> First, it looks for the language prefix in the requested URL.Failing that,
>> it looks for the LANGUAGE_SESSION_KEY key in the current user’s
>> session.Failing that, it looks for a cookie. The name of the cookie used is
>> set by the LANGUAGE_COOKIE_NAME setting. (The default name is
>> django_language.) Failing that, it looks at the Accept-Language HTTP
>> header. This header is sent by your browser and tells the server which
>> language(s) you prefer, in order by priority. Django tries each language in
>> the header until it finds one with available translations. Failing that, it
>> uses the global LANGUAGE_CODE setting.
>>
>
> So the reason why I get /en/ prefix in my url, when there is no any cookie
> set is because of the Accept-Language HTTP header. How can i solve that if
> somebody visits my site for the first time when there is no cookie, the
> i18n to go to the final step to get the language from the global
> LANGUAGE_CODE?
>
>
> --
> 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/5586da94-87bb-4879-b227-f8e29ce3e635%40googlegroups.com
> 
> .
>


-- 
Regards,

Aldian Fazrihady
http://aldianfazrihady.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/CAN7EoAbU5kUTc0UrX0etqp_s8bC4zK0L-wHpYNuoUB585DM7Og%40mail.gmail.com.


wkhtmltopdf on Amazon ElasticBeanstalk - ModuleNotFoundError: No module named 'main'

2020-02-21 Thread Abdulrasheed Ibrahim
Hello everyone, I need a hand a here.

I have an app that uses wkhtmltopdf for generating pdf files, it works
perfectly on my development environment.

I now deployed the project on amazon eb and it doesn't work, below is the
stacktrace:

Traceback (most recent call last):
  File "/usr/lib64/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
  File "/usr/lib64/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
  File
"/opt/python/run/venv/local/lib/python3.6/site-packages/django/utils/autoreload.py",
line 53, in wrapper
fn(*args, **kwargs)
  File
"/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
line 109, in inner_run
autoreload.raise_last_exception()
  File
"/opt/python/run/venv/local/lib/python3.6/site-packages/django/utils/autoreload.py",
line 76, in raise_last_exception
raise _exception[1]
  File
"/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/management/__init__.py",
line 357, in execute
autoreload.check_errors(django.setup)()
  File
"/opt/python/run/venv/local/lib/python3.6/site-packages/django/utils/autoreload.py",
line 53, in wrapper
fn(*args, **kwargs)
  File
"/opt/python/run/venv/local/lib/python3.6/site-packages/django/__init__.py",
line 24, in setup
apps.populate(settings.INSTALLED_APPS)
  File
"/opt/python/run/venv/local/lib/python3.6/site-packages/django/apps/registry.py",
line 91, in populate
app_config = AppConfig.create(entry)
  File
"/opt/python/run/venv/local/lib/python3.6/site-packages/django/apps/config.py",
line 90, in create
module = import_module(entry)
  File "/opt/python/run/venv/lib64/python3.6/importlib/__init__.py", line
126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 994, in _gcd_import
  File "", line 971, in _find_and_load
  File "", line 955, in _find_and_load_unlocked
  File "", line 665, in _load_unlocked
  File "", line 678, in exec_module
  File "", line 219, in
_call_with_frames_removed
  File
"/opt/python/run/venv/local/lib/python3.6/dist-packages/wkhtmltopdf/__init__.py",
line 1, in 

*from main import WKhtmlToPdf, wkhtmltopdfModuleNotFoundError: No
module named 'main'*

*Any help *would be appreciated.
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/CAPXBATR4US-pFWKUaW5x38gG7Fu2smwaEQkfCWJm%2BFDR%3Dh%2BT8Q%40mail.gmail.com.


Re: Python Django Training

2020-02-21 Thread Emmanuel klutse
Hello, I’m also interested. Please add me to the list.
Thanks

On Fri, 21 Feb 2020 at 1:52 PM, Irfan Khan  wrote:

> Hi
> How you conducting the sessions and please add me into the group
>
> On Sat, 1 Feb 2020 at 7:12 PM, Srikanth K  wrote:
>
>> Hi,
>>
>> I am from Hyderabad. I am Python Developer by Profession. I am eager take
>> up any Python , Django Training (online Preferrable or Weekends). Members
>> who require can contact me or share me  there idea.
>>
>> Regards,
>> Srikanth.K
>>
>> --
>> 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/CACPyz-gXb7wo9E0Uhs_pnxF9X52uA10__Fq1xt4trjXUaN3ehQ%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/CALKGVio8O2efruksWSwh3H_Vo0viO5LBQ%2BK1HTi-rBsoeuHeLA%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/CAAw18mBn1BVJYdFWxahQrknUpxOT%2BprcOA4NJsxRHNoNdP5mhg%40mail.gmail.com.


Re: Python Django Training

2020-02-21 Thread Irfan Khan
Hi
How you conducting the sessions and please add me into the group

On Sat, 1 Feb 2020 at 7:12 PM, Srikanth K  wrote:

> Hi,
>
> I am from Hyderabad. I am Python Developer by Profession. I am eager take
> up any Python , Django Training (online Preferrable or Weekends). Members
> who require can contact me or share me  there idea.
>
> Regards,
> Srikanth.K
>
> --
> 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/CACPyz-gXb7wo9E0Uhs_pnxF9X52uA10__Fq1xt4trjXUaN3ehQ%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/CALKGVio8O2efruksWSwh3H_Vo0viO5LBQ%2BK1HTi-rBsoeuHeLA%40mail.gmail.com.


Re: Python Django Training

2020-02-21 Thread Isaac Ndutumo
Hello, I am interested in learning Python with you.  Add me

On Fri, Feb 21, 2020 at 4:42 PM Bharati Nilam 
wrote:

> Hi,
> I also from Hyderabad and I'm also interested in the training. please tell
> me how to join?
>
> Regards,
> Bharati
>
> On Thu, 20 Feb, 2020, 6:19 PM Thiagu Palaniappan, <
> thiagarajan@gmail.com> wrote:
>
>> I'm also interested. Please add me in the group.
>>
>>
>> Thanks & Regards,
>> Thiagu
>>
>> On Mon, Feb 17, 2020 at 12:41 AM Akshay Raul 
>> wrote:
>>
>>> I am interested also. Please let me know the details.
>>>
>>> On Sat 1 Feb, 2020, 2:42 PM Srikanth K,  wrote:
>>>
 Hi,

 I am from Hyderabad. I am Python Developer by Profession. I am eager
 take up any Python , Django Training (online Preferrable or Weekends).
 Members who require can contact me or share me  there idea.

 Regards,
 Srikanth.K

 --
 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/CACPyz-gXb7wo9E0Uhs_pnxF9X52uA10__Fq1xt4trjXUaN3ehQ%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/CAEd%2Bv%3D0gE2dEMXKJ0Nm8FcH2ZxUPAdQspkQKB%2Bg5pZbSc_uZnQ%40mail.gmail.com
>>> 
>>> .
>>>
>>
>>
>> --
>>
>> Thanks & Regards,
>>
>> *Thiagu Palaniappan*
>>
>> M +91 (0) 9994318799
>>
>> *DXC Technology*
>> 8th Floor, Tower 1 B DLF IT Park, 1/124 - Shivaji Garden, Nandambakkam
>> post, Ramapuram, Chennai - 600 089.
>>
>> dxc.technology  / Twitter
>>  / Facebook
>>  / LinkedIn
>> 
>>
>> --
>> 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/CAK%3DQXNMzH-iL6BQ3_vfrvTpeY%2BSe5%3DbZm9h5wPW_Dw%2BM2BsvQg%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/CAPGVBeOgomb94NXAm347QqGcJ%3D3MzxULU7eQnY-M56EbC2D9vg%40mail.gmail.com
> 
> .
>


-- 
Kind Regards
Isaac

-- 
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/CAMje%2B21OuhTCJiBWZsxCf_%2BQddy97f8piyi2oxSY265g6JY6xQ%40mail.gmail.com.


Django 3 get_absolute_url and routing to multiple views

2020-02-21 Thread Raúl Beristáin
Hi guys,

Apologies in advance for what I know is a confusing question.
I am upgrading a site to django 3 but the old version didn't use URLs the 
canonical way (it didn't use slugs or indexes, it was hard coded). 
I'm trying to do it properly and of course half of it is broken :/

*Summary*: I want to have two different class-based views that do different 
things each over instances *of the same model*.


I have one Model called "*Tool*" and two class-based views: *ToolView* and 
*AdvancedToolView* that do different things with instances of that model


   - *Tool* is a model that contains a bunch of text.
   - *ToolView* is a generic view that only implements GET and displays 
   model instances based on parameter tool_name. It works.
   - *AdvancedToolView* is a subclass of ToolView that implements POST. It 
   *used* to work with my hardcoded urls, *but now I can't resolve it*.


My urls.py

urlpatterns += [ 
path(
"section//advanced-tool/",
views.AdvancedToolView.as_view(tool_name="Advanced Tool"),  #this is 
not resolving
name="Advanced_tool",
),
# this works
path("section///", views.ToolView.as_view(), 
name="tools"),
]


The idea is:  .../advanced-tool/ goes to view AdvancedToolView, any other 
slug goes to ToolView.

I think at least one problem is that I override *get_absolute_url* in 
*model.**Tool*:

class Tool(models.Model):
   name = models.CharField(...)
   slug = models.SlugField(...)  # slug is the slugyfied version of name
   payload = ...

   def get_absolute_url(self):
   return reverse("shed:tools", kwargs={"section_name": 
Section.objects.filter(...), "tool_name": self.slug})

On my site, these work: 
/shed/section/Main/current-problems/
/shed/section/Main/order-summary/

But this one errors with "No Tool matches the given query." -- 
/shed/section/Main/advanced-tool/

What is the correct way to dispatch /advanced-tool/ to 
*view.AdvancedToolView*  ???

-- 
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/c80d23f0-4af2-4ed2-8e7c-c155503f93b2%40googlegroups.com.


Re: Python Django Training

2020-02-21 Thread Devendra Gohare

>
> intrested!

Please add me.;) 

-- 
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/229adc79-b9c0-4546-af8c-191627814701%40googlegroups.com.


Re: Python Django Training

2020-02-21 Thread Bharati Nilam
Hi,
I also from Hyderabad and I'm also interested in the training. please tell
me how to join?

Regards,
Bharati

On Thu, 20 Feb, 2020, 6:19 PM Thiagu Palaniappan, 
wrote:

> I'm also interested. Please add me in the group.
>
>
> Thanks & Regards,
> Thiagu
>
> On Mon, Feb 17, 2020 at 12:41 AM Akshay Raul 
> wrote:
>
>> I am interested also. Please let me know the details.
>>
>> On Sat 1 Feb, 2020, 2:42 PM Srikanth K,  wrote:
>>
>>> Hi,
>>>
>>> I am from Hyderabad. I am Python Developer by Profession. I am eager
>>> take up any Python , Django Training (online Preferrable or Weekends).
>>> Members who require can contact me or share me  there idea.
>>>
>>> Regards,
>>> Srikanth.K
>>>
>>> --
>>> 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/CACPyz-gXb7wo9E0Uhs_pnxF9X52uA10__Fq1xt4trjXUaN3ehQ%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/CAEd%2Bv%3D0gE2dEMXKJ0Nm8FcH2ZxUPAdQspkQKB%2Bg5pZbSc_uZnQ%40mail.gmail.com
>> 
>> .
>>
>
>
> --
>
> Thanks & Regards,
>
> *Thiagu Palaniappan*
>
> M +91 (0) 9994318799
>
> *DXC Technology*
> 8th Floor, Tower 1 B DLF IT Park, 1/124 - Shivaji Garden, Nandambakkam
> post, Ramapuram, Chennai - 600 089.
>
> dxc.technology  / Twitter
>  / Facebook
>  / LinkedIn
> 
>
> --
> 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/CAK%3DQXNMzH-iL6BQ3_vfrvTpeY%2BSe5%3DbZm9h5wPW_Dw%2BM2BsvQg%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/CAPGVBeOgomb94NXAm347QqGcJ%3D3MzxULU7eQnY-M56EbC2D9vg%40mail.gmail.com.


Django i18n_patterns default language

2020-02-21 Thread Szocs Arnold
I am using i18n_patterns to change the language prefix in url. It s working 
fine ones the language cookie is set. The problem is that it's adding /en/ 
when I trying to access a page without the language code in private window, 
even though my preferred language is not en (the default one set in 
settings.LANGUAGE_CODE). The Django documentation says that how django 
discovers language prefference:

Django documentation says it will use the following to choose the language:

First, it looks for the language prefix in the requested URL.Failing that, 
> it looks for the LANGUAGE_SESSION_KEY key in the current user’s 
> session.Failing that, it looks for a cookie. The name of the cookie used is 
> set by the LANGUAGE_COOKIE_NAME setting. (The default name is 
> django_language.) Failing that, it looks at the Accept-Language HTTP 
> header. This header is sent by your browser and tells the server which 
> language(s) you prefer, in order by priority. Django tries each language in 
> the header until it finds one with available translations. Failing that, it 
> uses the global LANGUAGE_CODE setting.
>

So the reason why I get /en/ prefix in my url, when there is no any cookie 
set is because of the Accept-Language HTTP header. How can i solve that if 
somebody visits my site for the first time when there is no cookie, the 
i18n to go to the final step to get the language from the global 
LANGUAGE_CODE?
 

-- 
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/5586da94-87bb-4879-b227-f8e29ce3e635%40googlegroups.com.


Re: Bulk SMS website using django

2020-02-21 Thread Jani Eric
Hello. Text me on this number: 03351931286 .this is my what's app no

On Fri, Feb 21, 2020, 12:52 PM Isaac Imafidon 
wrote:

> I have a project to develop a bulk sms website using django, but i have
> not develop this kind of website before. Also the client want to be able to
> have users that log in and buy credit that they will use to send sms to any
> part of the world. Also i don't know any recommended company to buy the
> reseller at an affordable price that will make my client be able to make
> profit from he's business. I really need you guys support on this, also if
> anyone have develop this kind of website before and just brief me on how to
> go about it.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1707833a-44c2-43f9-8f66-c7fca1a2540d%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/CAEh2BEDWrEEWFkCmue40Yk51gr35Ed_ce29F0Z4RJ%2BgezG742Q%40mail.gmail.com.


Re: Object of type date is not JSON serializable

2020-02-21 Thread DHRUVA
But I haven't used the JSON .I am just using datefield in forms and models.

On Fri, 21 Feb, 2020, 6:47 PM Derek,  wrote:

> https://code-maven.com/serialize-datetime-object-as-json-in-python
>
>
> On Thursday, 20 February 2020 22:12:11 UTC+2, mick wrote:
>>
>> TypeError at /addForm4
>>
>> Object of type date is not JSON serializable
>>
>> Request Method: POST
>> Request URL: http://127.0.0.1:8000/addForm4
>> Django Version: 3.0.1
>> Exception Type: TypeError
>> Exception Value:
>>
>> Object of type date is not JSON serializable
>>
>> Exception Location: 
>> C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\Lib\json\encoder.py
>> in default, line 179
>> Python Executable: C:\Users\Administrator\Scripts\python.exe
>>
> --
> 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/77f62353-4e00-4808-a7e1-4e7f29899c6f%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/CANvoF%2B9_2veFMJCd%3Dt4bKot6pYPgh62fVL9dOoUZzpJne01PVQ%40mail.gmail.com.


Re: Object of type date is not JSON serializable

2020-02-21 Thread Derek
https://code-maven.com/serialize-datetime-object-as-json-in-python


On Thursday, 20 February 2020 22:12:11 UTC+2, mick wrote:
>
> TypeError at /addForm4
>
> Object of type date is not JSON serializable
>
> Request Method: POST
> Request URL: http://127.0.0.1:8000/addForm4
> Django Version: 3.0.1
> Exception Type: TypeError
> Exception Value: 
>
> Object of type date is not JSON serializable
>
> Exception Location: 
> C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\Lib\json\encoder.py
>  
> in default, line 179
> Python Executable: C:\Users\Administrator\Scripts\python.exe
>

-- 
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/77f62353-4e00-4808-a7e1-4e7f29899c6f%40googlegroups.com.


Re: understanding urls, forms, and HTTP ERROR 405

2020-02-21 Thread onlinejudge95
On Fri, Feb 21, 2020 at 2:24 AM Phil Kauffman 
wrote:

> So something like this?
>
Yes if you are using method based views. You can still do the same using
class-based views by referring to the following
https://stackoverflow.com/questions/15622354/django-listview-with-post-method


> def site(request, site_id):
> site = get_object_or_404(Site.name, pk=site_id)
>
> def sitesubmit(request):
> #site=get_object_or_404(Site, pk=site_id)
> form = SelectSite()
> if request.method == 'POST':
> form = SelectSite(request.POST)
> if form.is_valid():
> instance = form.save(commit=False)
> instance.name = site.site_id
> instance.save()
> else:
> form = SelectSite()
> return render(request, 'app/home.html', {'form': form})
>
> I'm just learning this stuff. If you can think of any posts or examples
> please let me know.
>
> On Thursday, February 20, 2020 at 1:16:07 PM UTC-5, OnlineJudge95 wrote:
>
>>
>>
>> On Thu, Feb 20, 2020 at 11:38 PM Phil Kauffman 
>> wrote:
>>
>>> Hello,
>>>
>>> Newbie in need of a little shove. It seems I need to review the purpose
>>> of the urls.py file. At present I am getting an HTTP Error 405 with the
>>> following:
>>>
>> HTTP 405 error code states the the HTTP method is not allowed on the
>> endpoint (https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405)
>>
>>>
>>> urls.py:
>>> path('', views.show_site, name = 'home'),
>>> path('site-view', views.List.as_view(), name='site-view')
>>>
>>> views.py
>>> class List(ListView):
>>> def get_queryset(self, *args, **kwargs):
>>> return Profile.objects.filter(sitename_id=self.kwargs['pk'])
>>>
>> You need to define the post() method yourself,
>>
>>>
>>> def show_site(request):
>>> form = SelectSite()
>>> if request.method == 'POST':
>>> form = SelectSite(request.POST)
>>> if form.is_valid():
>>> pass
>>> else:
>>> form = SelectSite()
>>> return render(request, 'app/home.html', {'form': form})
>>>
>>> home.html
>>> {% extends 'app\base.html' %}
>>>
>>> {% block title %}Site Home{% endblock %}
>>> {% block content %}
>>> This Form is Terrible
>>> {% csrf_token %}
>>>  {{form}} 
>>> 
>>> 
>>> {% endblock %}
>>>
>>> Any guidance would be greatly appreciated.
>>>
>>> Thank You
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/10be0e68-da3f-42cd-a095-96d6d2a5617f%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/ba1394b9-1fde-442e-9d4d-e67e32b2f694%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/CAD%3DM5eQvbc--tMz%2BgnjW%3DydudFxivOajJoz6MgDDRHKCmRxAuA%40mail.gmail.com.


Re: Bulk SMS website using django

2020-02-21 Thread Aniket Jain
Hello,
I have an experience in making this type of website. If you want I can help
you with this.
Please let me know
My skype id
aniket.d.mehta

On Fri, 21 Feb, 2020, 1:21 PM Isaac Imafidon, 
wrote:

> I have a project to develop a bulk sms website using django, but i have
> not develop this kind of website before. Also the client want to be able to
> have users that log in and buy credit that they will use to send sms to any
> part of the world. Also i don't know any recommended company to buy the
> reseller at an affordable price that will make my client be able to make
> profit from he's business. I really need you guys support on this, also if
> anyone have develop this kind of website before and just brief me on how to
> go about it.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1707833a-44c2-43f9-8f66-c7fca1a2540d%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/CADV%2BovJ3329sE_pVhQexsawrKhghhzhe0wUd_mEOHF%2BtZ6rOTg%40mail.gmail.com.