Re: Channels, Websockets and 'Backpressure'

2016-12-01 Thread Andrew Godwin
On Thu, Dec 1, 2016 at 1:03 PM, Hank Sims  wrote:

> You set it in the channel layer configuration in Django, like this:
>> https://github.com/django/asgi_redis/#usage
>>
>
> Ah, thank you. Sorry I missed that.
>
>
>> How would you propose this worked? The only alternative to closing the
>> socket is to buffer the messages in memory and retry sending them, at which
>> point you might have the case where the client thinks they have a working
>> connection but it's not actually delivered anything for 30 seconds. Hard
>> failure is preferable in distributed systems in my experience; trying to
>> solve the problem with soft failure and retry just makes problems even more
>> difficult to detect and debug.
>>
>
> I guess the "hard failure" I would prefer in this case -- though maybe not
> all cases -- is simply discarding new outbound messages when their queue is
> full. Or else some sort of mechanism from within my consumers.py that
> would allow me to forgo writing to a channel if its queue is full.
>

You already get this - trying to send to an outbound channel when it is
full will raise the ChannelFull exception. What you're seeing is the
inbound channel filling up, and the ASGI spec says that websocket protocol
servers should drop the connection if they can't send an incoming message
from a socket.

Andrew

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFwN1uprDQYKu3AR7J%3DVTksY-C9%2Bnbn2iZP_e0%3DAFX2eqsfG4Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How does django pass data through post?

2016-12-01 Thread Jordan W
Daniel, you nailed it! I didn't have the name specified. Adding that makes 
it propagate through!

On Monday, November 28, 2016 at 6:34:19 PM UTC-6, Jordan W wrote:
>
> Hi,
>
> I have been working on a small project for myself and some friends, and I 
> seem to have hit a hitch in getting it to work as expected.
>
> In my detail view, I have a small simple form:
> 
> {% csrf_token %}
>Prepare
> 
>
>
> My main list view and detail view are class based views, with me 
> attempting to use a FBV for prepare because it seems simpler to understand. 
> I've put a breakpoint in the "action" view, and tried to inspect the 
> request and see data from clicking the button come through, but I don't see 
> it. I am clearly missing something about how django sends POST data. I have 
> tried adding the following in bold to see how to get the data through, as 
> well as adding *args, **kwargs, as well as positional and named keyword 
> arguments to my "action" FBV:
>
> http://obj.id> }}" objid="{{ obj.id  }}"*>
> {% csrf_token %}
> *{{obj.id }}*
> *http://obj.id>}}" />*
>Prepare
> 
>
> If anyone can explain what I'm missing, it'd be greatly appreciated!
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d75827d7-99b8-4f1e-bd4e-dff5dc000b52%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANNOUNCE] Django bugfix releases issued: 1.10.4, 1.9.12, and 1.8.17

2016-12-01 Thread Tim Graham
Details are available on the Django project weblog:

https://www.djangoproject.com/weblog/2016/dec/01/bugfix-releases/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/82c03e9c-71a1-4784-94bb-d52dab8805a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Channels, Websockets and 'Backpressure'

2016-12-01 Thread Hank Sims
>
> You set it in the channel layer configuration in Django, like this:
> https://github.com/django/asgi_redis/#usage
>

Ah, thank you. Sorry I missed that.


> How would you propose this worked? The only alternative to closing the
> socket is to buffer the messages in memory and retry sending them, at which
> point you might have the case where the client thinks they have a working
> connection but it's not actually delivered anything for 30 seconds. Hard
> failure is preferable in distributed systems in my experience; trying to
> solve the problem with soft failure and retry just makes problems even more
> difficult to detect and debug.
>

I guess the "hard failure" I would prefer in this case -- though maybe not
all cases -- is simply discarding new outbound messages when their queue is
full. Or else some sort of mechanism from within my consumers.py that would
allow me to forgo writing to a channel if its queue is full.

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


Re: Channels, Websockets and 'Backpressure'

2016-12-01 Thread Andrew Godwin
On Thu, Dec 1, 2016 at 12:48 PM, Hank Sims  wrote:

> Thanks, Andrew. A few follow-up questions:
>
> 1. How would one go about increasing the default maximum queue size? I saw
> some reference to this when I was researching the problem yesterday, but I
> couldn't find the setting that would change it.
>

You set it in the channel layer configuration in Django, like this:
https://github.com/django/asgi_redis/#usage


>
> 2. Shouldn't there be a way to resolve the backpressure by draining the
> queue before allowing new messages to be written to it? It seems like
> cutting the connection between client and server would exacerbate the
> problem, rather than remedying it. In my particular case, it wouldn't be
> that big if a block of messages were skipped. But closing the socket when
> maximum queue size is reached seems to cause a cascade of problems.
>

How would you propose this worked? The only alternative to closing the
socket is to buffer the messages in memory and retry sending them, at which
point you might have the case where the client thinks they have a working
connection but it's not actually delivered anything for 30 seconds. Hard
failure is preferable in distributed systems in my experience; trying to
solve the problem with soft failure and retry just makes problems even more
difficult to detect and debug.

Andrew


>
> On Thursday, December 1, 2016 at 12:34:22 PM UTC-8, Andrew Godwin wrote:
>>
>> "Backpressure" is designed exactly for what you describe, which is when
>> clients are making requests of the server faster than you can handle them.
>> Each channel has a maximum capacity of messages (100 by default), beyond
>> which trying to add a new one results in an error.
>>
>> Webservers, when they see this, return an error to the client to try and
>> resolve the overload situation. If they didn't, then the server would clog
>> up trying to buffer all the pending requests. It's like returning a 503
>> error on a webpage when a server is overloaded.
>>
>> To solve the situation, just provision more workers so the channel is
>> drained as fast as messages are put onto it.
>>
>> If you want to monitor the size of channels to anticipate this stuff,
>> there's a plan for an API in ASGI that would let you do that but it's not
>> in place yet. You may look at the length of the Redis lists directly in the
>> meantime if you wish (there's one list per channel).
>>
>> Andrew
>>
>>
>>
>> On Thu, Dec 1, 2016 at 11:26 AM, hank...@gmail.com 
>> wrote:
>>
>>> Can someone help me understand the concept of websocket “backpressure”
>>> in a Django Channels project? What is it? How do diagnose it? At what level
>>> of the stack does it occur? How do I cure it? The docs are a little hazy on
>>> this.
>>>
>>>
>>> I wired up a quick Channels project for my mid-sized website. Before
>>> deploying the project, I load-tested it with thor
>>>  and started scaling up. When I
>>> reached two Daphne processes and four worker processes, it seemed like I
>>> had enough power behind the project to handle the load on my site. It was
>>> able to handle 2000 simultaneous websocket connections without errors,
>>> according to thor. That should have been more than enough.
>>>
>>>
>>> I deployed, and everything went fine for a while. After a bit, though,
>>> the websockets got slow and the server started to drop connections.
>>> Eventually the whole project stalled out. I looked through the Daphne logs
>>> and found a flurry of lines like this:
>>>
>>>
>>> 2016-12-01 14:35:14,513 WARNING WebSocket force closed for
 websocket.send!QbxCqPhvyxVt due to receive backpressure
>>>
>>>
>>> I restarted all the server and worker processes to no effect. I was able
>>> to put the project back online by manually deleting all the “asgi:*” keys
>>> in Redis. But then, after a while, the backpressure built up and everything
>>> crashed again.
>>>
>>>
>>> The problem, I suppose, has something to do with the high frequency of
>>> messages that were to be passed via websocket in this particular project. A
>>> click triggers a message in each direction, and people were encouraged to
>>> click rapidly. So I probably have to throttle this, or else launch more
>>> workers and/or servers.
>>>
>>>
>>> But I'd like to know what, specifically, triggers these “backpressure”
>>> disconnections, and where I might look to monitor them /before/ errors
>>> start to occur. In one of the Redis queues, I suppose? If so, which one(s)
>>> – inbound or outbound? I suppose my idea, here, is that I might be able to
>>> automatically scale up if the queues start to fill up.
>>>
>>>
>>> Thank you in advance. Fun project!
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to 

Re: Channels, Websockets and 'Backpressure'

2016-12-01 Thread Hank Sims
Thanks, Andrew. A few follow-up questions:

1. How would one go about increasing the default maximum queue size? I saw 
some reference to this when I was researching the problem yesterday, but I 
couldn't find the setting that would change it. 

2. Shouldn't there be a way to resolve the backpressure by draining the 
queue before allowing new messages to be written to it? It seems like 
cutting the connection between client and server would exacerbate the 
problem, rather than remedying it. In my particular case, it wouldn't be 
that big if a block of messages were skipped. But closing the socket when 
maximum queue size is reached seems to cause a cascade of problems.

Thanks for your response, and even more thanks for your work on this 
project.



On Thursday, December 1, 2016 at 12:34:22 PM UTC-8, Andrew Godwin wrote:
>
> "Backpressure" is designed exactly for what you describe, which is when 
> clients are making requests of the server faster than you can handle them. 
> Each channel has a maximum capacity of messages (100 by default), beyond 
> which trying to add a new one results in an error.
>
> Webservers, when they see this, return an error to the client to try and 
> resolve the overload situation. If they didn't, then the server would clog 
> up trying to buffer all the pending requests. It's like returning a 503 
> error on a webpage when a server is overloaded.
>
> To solve the situation, just provision more workers so the channel is 
> drained as fast as messages are put onto it.
>
> If you want to monitor the size of channels to anticipate this stuff, 
> there's a plan for an API in ASGI that would let you do that but it's not 
> in place yet. You may look at the length of the Redis lists directly in the 
> meantime if you wish (there's one list per channel).
>
> Andrew
>
>
>
> On Thu, Dec 1, 2016 at 11:26 AM, hank...@gmail.com  <
> hank...@gmail.com > wrote:
>
>> Can someone help me understand the concept of websocket “backpressure” in 
>> a Django Channels project? What is it? How do diagnose it? At what level of 
>> the stack does it occur? How do I cure it? The docs are a little hazy on 
>> this.
>>
>>
>> I wired up a quick Channels project for my mid-sized website. Before 
>> deploying the project, I load-tested it with thor 
>>  and started scaling up. When I 
>> reached two Daphne processes and four worker processes, it seemed like I 
>> had enough power behind the project to handle the load on my site. It was 
>> able to handle 2000 simultaneous websocket connections without errors, 
>> according to thor. That should have been more than enough.
>>
>>
>> I deployed, and everything went fine for a while. After a bit, though, 
>> the websockets got slow and the server started to drop connections. 
>> Eventually the whole project stalled out. I looked through the Daphne logs 
>> and found a flurry of lines like this:
>>
>>
>> 2016-12-01 14:35:14,513 WARNING WebSocket force closed for 
>>> websocket.send!QbxCqPhvyxVt due to receive backpressure
>>
>>
>> I restarted all the server and worker processes to no effect. I was able 
>> to put the project back online by manually deleting all the “asgi:*” keys 
>> in Redis. But then, after a while, the backpressure built up and everything 
>> crashed again.
>>
>>
>> The problem, I suppose, has something to do with the high frequency of 
>> messages that were to be passed via websocket in this particular project. A 
>> click triggers a message in each direction, and people were encouraged to 
>> click rapidly. So I probably have to throttle this, or else launch more 
>> workers and/or servers.
>>
>>
>> But I'd like to know what, specifically, triggers these “backpressure” 
>> disconnections, and where I might look to monitor them /before/ errors 
>> start to occur. In one of the Redis queues, I suppose? If so, which one(s) 
>> – inbound or outbound? I suppose my idea, here, is that I might be able to 
>> automatically scale up if the queues start to fill up.
>>
>>
>> Thank you in advance. Fun project!
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/79eb8c4d-0223-4320-8295-c936ebc4a68f%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an 

Re: Channels, Websockets and 'Backpressure'

2016-12-01 Thread Andrew Godwin
"Backpressure" is designed exactly for what you describe, which is when
clients are making requests of the server faster than you can handle them.
Each channel has a maximum capacity of messages (100 by default), beyond
which trying to add a new one results in an error.

Webservers, when they see this, return an error to the client to try and
resolve the overload situation. If they didn't, then the server would clog
up trying to buffer all the pending requests. It's like returning a 503
error on a webpage when a server is overloaded.

To solve the situation, just provision more workers so the channel is
drained as fast as messages are put onto it.

If you want to monitor the size of channels to anticipate this stuff,
there's a plan for an API in ASGI that would let you do that but it's not
in place yet. You may look at the length of the Redis lists directly in the
meantime if you wish (there's one list per channel).

Andrew



On Thu, Dec 1, 2016 at 11:26 AM, hanks...@gmail.com 
wrote:

> Can someone help me understand the concept of websocket “backpressure” in
> a Django Channels project? What is it? How do diagnose it? At what level of
> the stack does it occur? How do I cure it? The docs are a little hazy on
> this.
>
>
> I wired up a quick Channels project for my mid-sized website. Before
> deploying the project, I load-tested it with thor
>  and started scaling up. When I
> reached two Daphne processes and four worker processes, it seemed like I
> had enough power behind the project to handle the load on my site. It was
> able to handle 2000 simultaneous websocket connections without errors,
> according to thor. That should have been more than enough.
>
>
> I deployed, and everything went fine for a while. After a bit, though, the
> websockets got slow and the server started to drop connections. Eventually
> the whole project stalled out. I looked through the Daphne logs and found a
> flurry of lines like this:
>
>
> 2016-12-01 14:35:14,513 WARNING WebSocket force closed for
>> websocket.send!QbxCqPhvyxVt due to receive backpressure
>
>
> I restarted all the server and worker processes to no effect. I was able
> to put the project back online by manually deleting all the “asgi:*” keys
> in Redis. But then, after a while, the backpressure built up and everything
> crashed again.
>
>
> The problem, I suppose, has something to do with the high frequency of
> messages that were to be passed via websocket in this particular project. A
> click triggers a message in each direction, and people were encouraged to
> click rapidly. So I probably have to throttle this, or else launch more
> workers and/or servers.
>
>
> But I'd like to know what, specifically, triggers these “backpressure”
> disconnections, and where I might look to monitor them /before/ errors
> start to occur. In one of the Redis queues, I suppose? If so, which one(s)
> – inbound or outbound? I suppose my idea, here, is that I might be able to
> automatically scale up if the queues start to fill up.
>
>
> Thank you in advance. Fun project!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/79eb8c4d-0223-4320-8295-c936ebc4a68f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Questions about templates from a novice - Question #1

2016-12-01 Thread Dan Tagg
Hi Jim,

I would really recommend looking at https://ccbv.co.uk/projects/Django/1.9/

There are diagrams to show the hierarchy of inheritance and mixins, plus
all the properties and methods are there to see and explore.

The place to start is the dispatch method, as_view is called first but you
can backtrack to that later. Have a look, you'll see dispatch gets the
request's method tries to call a method with that name if it is a valid
HTTP method and returns a HTTP 405 if either the method is not defined.

Dan



On Thursday, 1 December 2016, jim_anderson  wrote:

> Hi,
>
> A few intro words first. I am an experienced programmer and worked on a
> few python projects for maybe 3 years around 2000. Most of my other
> programming has been in c, c++, and java - maybe too many years. My current
> project is a web based project using Python 3.5.2 and Django 1.9.7. I have
> gotten to the point where I'm feeling pretty comfortable with python again,
> but I'm still getting a handle on django, so I'll classify myself as being
> intermediate in my python knowledge and mid-novice with django. I am
> writing a bit of code for the project and in parallel, I am experimenting
> with a django project that I call 'testDjangoProject' (I'm not too
> original). My current objective in the test project is to get a working
> template environment and a working knowledge so that I can write and
> templates, template tags and template filters.
>
> I have a few questions, but I'm going enter each question as a separate
> thread in this group.
>
> So, question number 1:
>
> I have created a view class that is derived from generic.ListView, which
> inherits from a few other classes both directly and indirectly. My class,
> called TagView, overrides 2 methods get_query_set() and get(). I basically
> did this to mimic what I saw in some tutorials. When I run my test case,
> the get() method is called. There are a number of other derived methods
> that could also have been overriden. What are the deciding factors that
> django uses to determine which view class method to call?
>
> BTW, my 'tag' model has 2 entries in a sqlite3 db.
>
> Jim Anderson
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/ms
> gid/django-users/ce1e5ebf-725f-4c44-8a91-2e742061c764%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Channels, Websockets and 'Backpressure'

2016-12-01 Thread hanks...@gmail.com
 

Can someone help me understand the concept of websocket “backpressure” in a 
Django Channels project? What is it? How do diagnose it? At what level of 
the stack does it occur? How do I cure it? The docs are a little hazy on 
this.


I wired up a quick Channels project for my mid-sized website. Before 
deploying the project, I load-tested it with thor 
 and started scaling up. When I reached 
two Daphne processes and four worker processes, it seemed like I had enough 
power behind the project to handle the load on my site. It was able to 
handle 2000 simultaneous websocket connections without errors, according to 
thor. That should have been more than enough.


I deployed, and everything went fine for a while. After a bit, though, the 
websockets got slow and the server started to drop connections. Eventually 
the whole project stalled out. I looked through the Daphne logs and found a 
flurry of lines like this:


2016-12-01 14:35:14,513 WARNING WebSocket force closed for 
> websocket.send!QbxCqPhvyxVt due to receive backpressure


I restarted all the server and worker processes to no effect. I was able to 
put the project back online by manually deleting all the “asgi:*” keys in 
Redis. But then, after a while, the backpressure built up and everything 
crashed again.


The problem, I suppose, has something to do with the high frequency of 
messages that were to be passed via websocket in this particular project. A 
click triggers a message in each direction, and people were encouraged to 
click rapidly. So I probably have to throttle this, or else launch more 
workers and/or servers.


But I'd like to know what, specifically, triggers these “backpressure” 
disconnections, and where I might look to monitor them /before/ errors 
start to occur. In one of the Redis queues, I suppose? If so, which one(s) 
– inbound or outbound? I suppose my idea, here, is that I might be able to 
automatically scale up if the queues start to fill up.


Thank you in advance. Fun project!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/79eb8c4d-0223-4320-8295-c936ebc4a68f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Questions about templates from a novice - Question #1

2016-12-01 Thread jim_anderson
Hi, 

A few intro words first. I am an experienced programmer and worked on a few 
python projects for maybe 3 years around 2000. Most of my other programming 
has been in c, c++, and java - maybe too many years. My current project is 
a web based project using Python 3.5.2 and Django 1.9.7. I have gotten to 
the point where I'm feeling pretty comfortable with python again, but I'm 
still getting a handle on django, so I'll classify myself as being 
intermediate in my python knowledge and mid-novice with django. I am 
writing a bit of code for the project and in parallel, I am experimenting 
with a django project that I call 'testDjangoProject' (I'm not too 
original). My current objective in the test project is to get a working 
template environment and a working knowledge so that I can write and 
templates, template tags and template filters. 

I have a few questions, but I'm going enter each question as a separate 
thread in this group. 

So, question number 1: 

I have created a view class that is derived from generic.ListView, which 
inherits from a few other classes both directly and indirectly. My class, 
called TagView, overrides 2 methods get_query_set() and get(). I basically 
did this to mimic what I saw in some tutorials. When I run my test case, 
the get() method is called. There are a number of other derived methods 
that could also have been overriden. What are the deciding factors that 
django uses to determine which view class method to call? 

BTW, my 'tag' model has 2 entries in a sqlite3 db. 

Jim Anderson 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ce1e5ebf-725f-4c44-8a91-2e742061c764%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: wsgiref - When does the complexity of question require posting to the Developers or other forums?

2016-12-01 Thread Daniel Roseman
On Thursday, 1 December 2016 13:16:07 UTC, NoviceSortOf wrote:
>
>
>
> Hi All,
>
> After hours of looking for solutions, here on Stackoverflow, GitHub, 
> Django site and other forums,
> and seeing that at least 2 other posts related to what per web chatter 
> appears to be a known
> bug in Django and the WSGI package, I'm wondering where to turn for useful 
> advice
> regarding what appears to be a common problem without a common answer.
>
> Below is detail of a wsgiref issue that gets considerable discussion 
> online with
> no answer to the question being posted here or elsewhere.
>
> * Should I attempt posting this question in the Developers Conf?
> * Are there other forums that might be of help?
>
> Please advise 
>
>
>
> Details of well known Wsgiref bug/issue follow.
>
>
> ***
> After porting my project to the new development area...
> When running... 
>  python manage.py runserver 0.0.0.0:8000
>
> And then loading a page on a browser I get the following.
>
>
> 
>   File "/usr/lib64/python2.7/wsgiref/simple_server.py", line 33, in close
>self.status.split(' ',1)[0], self.bytes_sent
>AttributeError: 'NoneType' object has no attribute 'split'
>
> 
>
> This problem points to the wsgi component of the install packages.
>
> Researching the web various solutions are posted, including ...
>
> --
> * Commenting out line 33 in simple_server.py and see if any missing
>packages are reported.
>(I've tried this and no packages are reported as missing)
>
> REF.:  https://groups.google.com/forum/#!topic/django-users/Cps4kHh0_-0
>
> ---
>
> ---
> * A Django bug report, with code that does not match the version I 
> currently
>   am using. It recommends modifications to file  
>   django/core/handlers /exception.py 
>   which does not exist on the release currently installed.
>
> REF.: 
> https://github.com/django/django/commit/742ea51413b3aab07c6afbfd1d52c1908ffcb510
>
> 
> * A Django modification that makes perfect sense and partially matches the 
> revision of django/core/handlers/base.py on my installed system.
>
> REF.: 
> https://github.com/django/django/commit/2f615b10e6330d27dccbd770a4628200044acf70
>
> -
>
> Still though I continue to get 'NoneType' object has no attribute 'render' 
> or
> other errors related to NoneType assigned as NoneType object when it should
> be a request response object.
>
> *** What to do?
>
> * This appears to be a bug noted in Django, Github and Stackoverflow 
> communities,
>   with Wsgi related to various versions of Django and Python 
>   
>   _Is there any logical way of resolving the NonType error, by settings.py 
> or other
>Django config options?
>   
>   _Would placing my app as the home page on this development server rather 
> than 
>relying on the python manage.py runserver possibly resolve this problem?
>   
>   _Is there an alternative to Wsgi that would possibly eliminate the 
> problem?
>   
>
> Any ideas or suggestions appreciated.
>
>

It seems pretty unlikely that there is a fundamental bug in Django which 
means it cannot serve pages via WSGI; I would imagine that that would have 
been noticed by others, including the core developers, before now.

So it is almost certain that the bug is in your code, which you have not 
shown. You also need to show the full traceback.
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d32d891e-2f72-4a2f-b9d4-a158a295293e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: GeoDjango with Docker

2016-12-01 Thread Tadeo C
Wow! Your posts looks amazingly detailed and comprehensive. I'm going to 
follow them careful. I can use Ubuntu for the meanwhile, no problem. Thank 
you very much for sharing this worthy material!

On Thursday, December 1, 2016 at 12:52:52 PM UTC-3, hunter...@gmail.com 
wrote:
>
> Hi Tadeo, I've recently gone through this exercise myself, and documented 
> my progress in three posts:
>
> https://geoanalytic.github.io/a-production-ready-web-mapping-toolkit-part-1/
>
> https://geoanalytic.github.io/a-production-ready-web-mapping-toolkit-part-2/
>
> https://geoanalytic.github.io/a-production-ready-web-mapping-toolkit-part-3/
>
> It's based on Ubuntu but you should be able to move it to Alpine without 
> too much effort.
> Dave
>
> On Wednesday, November 30, 2016 at 10:02:59 AM UTC-7, Tadeo C wrote:
>>
>> Hi, I'm starting a project with GeoDjango and I want to use Docker 
>> containers to build the stack (GeoDjango, Nginx, Postgis) preferably Alpine 
>> base images.
>> Does anyone has successful done this before? Where can I find a useful 
>> docker-compose.yml or a tested and working updated image?
>> Thanks a lot,
>> Tadeo
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4ad9eecc-20a0-44b9-b4d2-6aa327dc46b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Initial data with migrations vs fixtures

2016-12-01 Thread Tim Graham
Calling loaddata in a migration will work until you modify the model's 
fields. You can read more on Trac: 
https://code.djangoproject.com/ticket/24778

On Thursday, December 1, 2016 at 12:09:49 PM UTC-5, Tom Evans wrote:
>
> Hi all 
>
> We're moving a project over to the latest release (well, we're at 1.7 
> now, but that's the end goal anyway) and replacing South migrations 
> with Django migrations. 
>
> It looks like that fixtures are no longer thought of as the correct 
> way of providing initial data. Is this because Run{SQL,Python} can 
> have "reverse" instructions included, or is it some other reason? I 
> couldn't see anything pertinent in the docs. 
>
> Given that we have an existing project and fixture files, is it very 
> bad and wrong to simply have a data migration that runs loaddata on 
> our required fixtures? It would not be reversible, but it would be 
> massively simpler. 
>
> Cheers 
>
> Tom 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d24855cb-4640-4cbd-849e-03d05058debe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: GeoDjango + PostGIS Docker Stack

2016-12-01 Thread Tadeo C
I'm sorry I reposted this question because I could not find the previous 
one. Thanks for the answers!

On Thursday, December 1, 2016 at 2:41:06 PM UTC-3, Tadeo C wrote:
>
> Hi, I'm trying to setup a stack of Docker containers (GeoDjango + PostGIS 
> + Nginx) to develop a GeoDjango application, preferably Alpine based.
> I can't find a docker-compose.yml fille nor images that allows me to get 
> the three containers up and running.
> Does anyone has experience with this? Where can I find an up-to-date 
> docker-compose.yml that covers this stack.
> Thank you very much!
> Tadeo Carrier
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1a8a80e1-a562-428a-a429-90401539ec20%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


GeoDjango + PostGIS Docker Stack

2016-12-01 Thread Tadeo C
Hi, I'm trying to setup a stack of Docker containers (GeoDjango + PostGIS + 
Nginx) to develop a GeoDjango application, preferably Alpine based.
I can't find a docker-compose.yml fille nor images that allows me to get 
the three containers up and running.
Does anyone has experience with this? Where can I find an up-to-date 
docker-compose.yml that covers this stack.
Thank you very much!
Tadeo Carrier

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d252e15b-5aeb-464a-8a24-32d107c7fa16%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


inline parent value

2016-12-01 Thread Roberto Russi
hi, I have 3 models:

class Orders(models.Model):
brand = models.ForeignKey(
Brands,
verbose_name = "Brand",
null=True,
blank=True,
related_name="ord_brand"
)
dateord = models.DateField("Date")
numbord = models.CharField("Number",
max_length=20,
unique_for_year="dateord", 
)

class OrderRows(models.Model):
order = models.ForeignKey(
Orders,
verbose_name = "Order",
)
product = models.ForeignKey(
Products,
verbose_name = "Product",
)
price = models.DecimalField("Price",
max_digits = 11,
decimal_places=2,
)

class Products(models.Model):
brand = models.ForeignKey(
Brands,
verbose_name = "Brand",
)
code = models.CharField("Code",
max_length=25, 
)
descr = models.CharField("Description",
max_length=50, 
)

In my admin.py I have a ModelForm for Orders and an Inline for OrderRow.
In the Inline I need filter product queryset for records where 
brand=orders.brand.

How can I do 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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3f1d5cc5-6485-4f90-b626-929dc6d0e353%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Inline master

2016-12-01 Thread Roberto Russi
I have 3 models:

class Products(models.Model):
brand = models.ForeignKey(
Brands,
verbose_name = "Brand",
)
code = models.CharField("Code",
max_length=25, 
)
descr = models.CharField("Description",
max_length=50, 
)

class Orders(models.Model):
brand = models.ForeignKey(
Brands,
verbose_name = "Brand",
null=True,
blank=True,
related_name="ord_brand"
)
ord_date = models.DateField("Date")
ord_numb = models.CharField("Number",
max_length=20,
unique_for_year="ord_date", 
)

class OrderRows(models.Model):
order = models.ForeignKey(
Orders,
verbose_name = "Order",
)
product = models.ForeignKey(
Products,
verbose_name = "Product",
)
price = models.DecimalField("Price",
max_digits = 11,
decimal_places=2,
)

In my Admins.py I have a ModelAdmin for Orders whit a Inline for OrderRows.

How can I filter the product queryset in OrderRows where brand=orders.brand?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f54aaba0-bb94-421a-8902-00c6a9f594dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Initial data with migrations vs fixtures

2016-12-01 Thread 'Tom Evans' via Django users
Hi all

We're moving a project over to the latest release (well, we're at 1.7
now, but that's the end goal anyway) and replacing South migrations
with Django migrations.

It looks like that fixtures are no longer thought of as the correct
way of providing initial data. Is this because Run{SQL,Python} can
have "reverse" instructions included, or is it some other reason? I
couldn't see anything pertinent in the docs.

Given that we have an existing project and fixture files, is it very
bad and wrong to simply have a data migration that runs loaddata on
our required fixtures? It would not be reversible, but it would be
massively simpler.

Cheers

Tom

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


Re: GeoDjango with Docker

2016-12-01 Thread Dan Tagg
Cookie cutter is pretty awesome. Don't know whether it works with GeoDjango
though.
https://github.com/pydanny/cookiecutter-django

Dan


On 1 December 2016 at 13:32, hunter.cur...@gmail.com <
hunter.cur...@gmail.com> wrote:

> Hi Tadeo, I've recently gone through this exercise myself, and documented
> my progress in three posts:
> https://geoanalytic.github.io/a-production-ready-web-
> mapping-toolkit-part-1/
> https://geoanalytic.github.io/a-production-ready-web-
> mapping-toolkit-part-2/
> https://geoanalytic.github.io/a-production-ready-web-
> mapping-toolkit-part-3/
>
> It's based on Ubuntu but you should be able to move it to Alpine without
> too much effort.
> Dave
>
> On Wednesday, November 30, 2016 at 10:02:59 AM UTC-7, Tadeo C wrote:
>>
>> Hi, I'm starting a project with GeoDjango and I want to use Docker
>> containers to build the stack (GeoDjango, Nginx, Postgis) preferably Alpine
>> base images.
>> Does anyone has successful done this before? Where can I find a useful
>> docker-compose.yml or a tested and working updated image?
>> Thanks a lot,
>> Tadeo
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/3f10a892-c65d-4f5e-96ce-cca55295c33f%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wildman and Herring Limited, Registered Office: Sir Robert Peel House, 178
Bishopsgate, London, United Kingdom, EC2M 4NJ, Company no: 05766374

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPZHCY4X9%3Dg2O4PQfex7fd4f%2BbUR3Ckyh7akHKOesd%2BZ-tgQKg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: GeoDjango with Docker

2016-12-01 Thread hunter.cur...@gmail.com
Hi Tadeo, I've recently gone through this exercise myself, and documented 
my progress in three posts:
https://geoanalytic.github.io/a-production-ready-web-mapping-toolkit-part-1/
https://geoanalytic.github.io/a-production-ready-web-mapping-toolkit-part-2/
https://geoanalytic.github.io/a-production-ready-web-mapping-toolkit-part-3/

It's based on Ubuntu but you should be able to move it to Alpine without 
too much effort.
Dave

On Wednesday, November 30, 2016 at 10:02:59 AM UTC-7, Tadeo C wrote:
>
> Hi, I'm starting a project with GeoDjango and I want to use Docker 
> containers to build the stack (GeoDjango, Nginx, Postgis) preferably Alpine 
> base images.
> Does anyone has successful done this before? Where can I find a useful 
> docker-compose.yml or a tested and working updated image?
> Thanks a lot,
> Tadeo
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3f10a892-c65d-4f5e-96ce-cca55295c33f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: makemigrations generates new migration when nothing has changed

2016-12-01 Thread Bruno A.
I've seen that happening when calling a callable as one of the keyword 
argument rather than passing the callable itself. Typical example:

class TimeFramedModel(models.Model):
created = models.DateTimeField(default=timezone.now*()*)

Instead of:

class TimeFramedModel(models.Model):
created = models.DateTimeField(default=timezone.now)

As Mike pointed out, in the case of a ForeignKey it might be with choices 
maybe?


On Wednesday, 30 November 2016 17:02:59 UTC, Francis Fisher wrote:
>
> Any idea why makemigrations would fail to recognise that a migration has 
> already been generated?
>
> makemigrations.py is a script which calls makemigrations with appropriate 
> django settings. If I run this once, it will generate the initial 
> migration, but every time I run it subsequently, it will regenerate a 
> migration even though nothing has changed in the model. This is with django 
> 1.10.3 and postgres. The field sk that is constantly regenerated is a 
> foreign key relation to an unmanaged database, but I have referred to this 
> in a different app with no bother.
>
> I am using django 1.10.3.
>
> I found a post in this group that had a similar issue with instantiating a 
> class in the model that was missing an implementation for __eq__ but that 
> doesn't apply in this case as I don't instantiate any class in the model 
> file.
>
> Is there any common mistake that leads to this outcome?
>
> --
>
> user@testenv:~/eit/testproj$ ./makemigrations.py 
> Migrations for 'sk':
>   testproj/sk/migrations/0001_initial.py:
> - Create model SKM
> user@testenv:~/eit/testproj$ ./makemigrations.py 
> Migrations for 'sk':
>   testproj/sk/migrations/0002_auto_20161130_1643.py:
> - Alter field s on skm
> user@testenv:~/eit/testproj$ 
> user@testenv:~/eit/testproj$ ./makemigrations.py 
> Migrations for 'sk':
>   testproj/sk/migrations/0003_auto_20161130_1643.py:
> - Alter field s on skm
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/507878c8-a82a-4134-95f3-420699283347%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: GeoDjango with Docker

2016-12-01 Thread Jani Tiainen

Hi,

Basically what you need is to pick base distro you want to use. 
Installing PostGIS package usually brings in all the spatial libs Django 
expects so you're covered by that part. The rest is just putting Django 
served from your container.


So there is not much stuff involved.


On 30.11.2016 17:39, Tadeo C wrote:
Hi, I'm starting a project with GeoDjango and I want to use Docker 
containers to build the stack (GeoDjango, Nginx, Postgis) preferably 
Alpine base images.
Does anyone has successful done this before? Where can I find a useful 
docker-compose.yml or a tested and working updated image?

Thanks a lot,
Tadeo
--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to django-users+unsubscr...@googlegroups.com 
.
To post to this group, send email to django-users@googlegroups.com 
.

Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7c0649e1-e2d8-4e56-9930-14e2f95135ef%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
Jani Tiainen

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/185f35a1-9203-bce3-faa3-0a3c69020913%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: GeoDjango with Docker

2016-12-01 Thread Reza Shalbafzadeh
Hi Tadeo 

GeoDjango is very similar to Django and you can modify existing Django 
dockerfiles to build your own images
have a look at this links 
realpython django docker example 

postgis django  dockerfile (outdated) 

geodjango postgis dockerfile (outdated) 

you can modify and build  them 

PS:




*make sure you really need docker for achieve your goal managing docker 
images and creating them could be a headache and in many cases using docker 
is a overkill ex : for provisioning servers you can use puppet instead * 
Best Regards
Reza

On Wednesday, November 30, 2016 at 8:32:59 PM UTC+3:30, Tadeo C wrote:
>
> Hi, I'm starting a project with GeoDjango and I want to use Docker 
> containers to build the stack (GeoDjango, Nginx, Postgis) preferably Alpine 
> base images.
> Does anyone has successful done this before? Where can I find a useful 
> docker-compose.yml or a tested and working updated image?
> Thanks a lot,
> Tadeo
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bf6c4020-2358-44e3-b6e9-5a34c389b1a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django runserver, the header doesn't contain connection:keep-alive

2016-12-01 Thread 韦然

Thanks. I will try other production servers.

在 2016年12月1日星期四 UTC+8下午9:32:09,emepe写道:
>
> On Thursday, December 1, 2016 at 6:42:38 AM UTC-3, 韦然 wrote:
>>
>> Dear all,
>>
>> The current header is:
>>
>> HTTP/1.0 200 OK
>>
>> Date: Thu, 01 Dec 2016 08:33:29 GMT
>>
>> Server: WSGIServer/0.1 Python/2.7.12
>>
>> X-Frame-Options: SAMEORIGIN
>>
>> Content-Type: text/xml
>>
>>
>>
> The docs states clearly that runserver is not for production, just for 
> developing.  For a light webserver you could use nginx + gunicorn. The are 
> several tutorials for this.
>
> mikelpierre
> http://flickrock.com/mikelpierre 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3f188b59-31ac-424a-ab84-5dde13266d62%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django runserver, the header doesn't contain connection:keep-alive

2016-12-01 Thread emepe
On Thursday, December 1, 2016 at 6:42:38 AM UTC-3, 韦然 wrote:
>
> Dear all,
>
> The current header is:
>
> HTTP/1.0 200 OK
>
> Date: Thu, 01 Dec 2016 08:33:29 GMT
>
> Server: WSGIServer/0.1 Python/2.7.12
>
> X-Frame-Options: SAMEORIGIN
>
> Content-Type: text/xml
>
>
>
The docs states clearly that runserver is not for production, just for 
developing.  For a light webserver you could use nginx + gunicorn. The are 
several tutorials for this.

mikelpierre
http://flickrock.com/mikelpierre 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4d2054f6-3531-4d2e-992a-8978b0d79992%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


wsgiref - When does the complexity of question require posting to the Developers or other forums?

2016-12-01 Thread NoviceSortOf


Hi All,

After hours of looking for solutions, here on Stackoverflow, GitHub, Django 
site and other forums,
and seeing that at least 2 other posts related to what per web chatter 
appears to be a known
bug in Django and the WSGI package, I'm wondering where to turn for useful 
advice
regarding what appears to be a common problem without a common answer.

Below is detail of a wsgiref issue that gets considerable discussion online 
with
no answer to the question being posted here or elsewhere.

* Should I attempt posting this question in the Developers Conf?
* Are there other forums that might be of help?

Please advise 



Details of well known Wsgiref bug/issue follow.

***
After porting my project to the new development area...
When running... 
 python manage.py runserver 0.0.0.0:8000

And then loading a page on a browser I get the following.


  File "/usr/lib64/python2.7/wsgiref/simple_server.py", line 33, in close
   self.status.split(' ',1)[0], self.bytes_sent
   AttributeError: 'NoneType' object has no attribute 'split'


This problem points to the wsgi component of the install packages.

Researching the web various solutions are posted, including ...
--
* Commenting out line 33 in simple_server.py and see if any missing
   packages are reported.
   (I've tried this and no packages are reported as missing)

REF.:  https://groups.google.com/forum/#!topic/django-users/Cps4kHh0_-0
---
---
* A Django bug report, with code that does not match the version I currently
  am using. It recommends modifications to file  
  django/core/handlers /exception.py 
  which does not exist on the release currently installed.

REF.: 
https://github.com/django/django/commit/742ea51413b3aab07c6afbfd1d52c1908ffcb510

* A Django modification that makes perfect sense and partially matches the 
revision of django/core/handlers/base.py on my installed system.

REF.: 
https://github.com/django/django/commit/2f615b10e6330d27dccbd770a4628200044acf70
-

Still though I continue to get 'NoneType' object has no attribute 'render' 
or
other errors related to NoneType assigned as NoneType object when it should
be a request response object.

*** What to do?

* This appears to be a bug noted in Django, Github and Stackoverflow 
communities,
  with Wsgi related to various versions of Django and Python 
  
  _Is there any logical way of resolving the NonType error, by settings.py 
or other
   Django config options?
  
  _Would placing my app as the home page on this development server rather 
than 
   relying on the python manage.py runserver possibly resolve this problem?
  
  _Is there an alternative to Wsgi that would possibly eliminate the 
problem?
  

Any ideas or suggestions appreciated.

  
  

  


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4be17192-d031-4692-85fe-2ef3a0913e72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django runserver, the header doesn't contain connection:keep-alive

2016-12-01 Thread Avraham Serour
Don't use runserver fur production, use nginx with uwsgi

On Dec 1, 2016 11:42 AM, "韦然"  wrote:

> Dear all,
>
> The current header is:
>
> HTTP/1.0 200 OK
>
> Date: Thu, 01 Dec 2016 08:33:29 GMT
>
> Server: WSGIServer/0.1 Python/2.7.12
>
> X-Frame-Options: SAMEORIGIN
>
> Content-Type: text/xml
>
>
>
> And the process code is :
>
>
> from django.shortcuts import render
>
> from django.http import HttpResponse
>
> import xml.etree.ElementTree as ET
>
> import re
>
> # Create your views here.
>
> from .forms import AddForm
>
>
> ns = {'SOAP-ENV':'http://schemas.xmlsoap.org/soap/envelope/', \
>
>   'SOAP-ENC':'http://schemas.xmlsoap.org/soap/encoding/', \
>
>   'xsi':'http://www.w3.org/2001/XMLSchema-instance', \
>
>   'xsd':'http://www.w3.org/2001/XMLSchema','cwmp':'urn:
> dslforum-org:cwmp-1-0'}
>
> def index(request):
>
> if request.method == 'POST':
>
> #print('===START===')
>
> #print(request.body)
>
> root = ET.fromstring(request.body)
>
>
> #print('===END===')
>
> body = root.find('SOAP-ENV:Body', ns)
>
> inform = body.find('cwmp:Inform', ns)
>
> header = root.find('SOAP-ENV:Header', ns)
>
> idObj = header.find('cwmp:ID', ns)
>
> #print idObj.text
>
> #s = request.session()
>
> #print s
>
> return render(request, 'tools/cwmpInformResponse.html',
> {'cwmpID': idObj.text},content_type='text/xml')
>
> else:
>
> form = AddForm()
>
> return render(request, 'tools/index.html', {'form': form})
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/dc133975-8bf2-48fc-b32b-5868874f687e%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Django runserver, the header doesn't contain connection:keep-alive

2016-12-01 Thread 韦然
Dear all,

The current header is:

HTTP/1.0 200 OK

Date: Thu, 01 Dec 2016 08:33:29 GMT

Server: WSGIServer/0.1 Python/2.7.12

X-Frame-Options: SAMEORIGIN

Content-Type: text/xml



And the process code is :


from django.shortcuts import render

from django.http import HttpResponse

import xml.etree.ElementTree as ET

import re

# Create your views here.

from .forms import AddForm


ns = {'SOAP-ENV':'http://schemas.xmlsoap.org/soap/envelope/', \

  'SOAP-ENC':'http://schemas.xmlsoap.org/soap/encoding/', \

  'xsi':'http://www.w3.org/2001/XMLSchema-instance', \

  
'xsd':'http://www.w3.org/2001/XMLSchema','cwmp':'urn:dslforum-org:cwmp-1-0'}

def index(request):

if request.method == 'POST':

#print('===START===')

#print(request.body)

root = ET.fromstring(request.body)


#print('===END===')

body = root.find('SOAP-ENV:Body', ns)

inform = body.find('cwmp:Inform', ns)

header = root.find('SOAP-ENV:Header', ns)

idObj = header.find('cwmp:ID', ns)

#print idObj.text

#s = request.session()

#print s

return render(request, 'tools/cwmpInformResponse.html', {'cwmpID': 
idObj.text},content_type='text/xml')

else:

form = AddForm()

return render(request, 'tools/index.html', {'form': form})

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dc133975-8bf2-48fc-b32b-5868874f687e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.