The code I shared is where the problem is. Here is the output once again from the server logs. It is evident that the second request is running into the first and appending the responses.
The text in BOLD 'Entered Search' is the entry point for each request. I suspect a problem with looping qList or appending 'p'.
Entered Search
<QueryDict: {u'project': [u'project1'], u'app': [u'app'], u'sdtime': [u'2016-05-30 00:00:00 UTC'], u'days': [u'0'], u'edtime': [u'2016-05-30 00:02:00 UTC']}>
Hello, I am X
Hello, I am Y
Hello, I am A
Entered Search
<QueryDict: {u'project': [u'project1'], u'app': [u'app'], u'sdtime': [u'2016-05-30 00:00:00 UTC'], u'days': [u'0'], u'edtime': [u'2016-05-30 00:02:00 UTC']}>
Hello, I am X
Hello, I am B
Hello, I am Y
[30/May/2016 22:00:35] "GET /search/?project=project1&app=app&days=0&sdtime=2016-05-30+00%3A00%3A00+UTC&edtime=2016-05-30+00%3A02%3A00+UTC HTTP/1.1" 200 893
Hello, I am A
Hello, I am B
[30/May/2016 22:00:58] "GET /search/?project=project1&app=app&days=0&sdtime=2016-05-30+00%3A00%3A00+UTC&edtime=2016-05-30+00%3A02%3A00+UTC HTTP/1.1" 200 1475
On Monday, May 30, 2016 at 9:32:47 PM UTC-4, Stephen Butler wrote:
<QueryDict: {u'project': [u'project1'], u'app': [u'app'], u'sdtime': [u'2016-05-30 00:00:00 UTC'], u'days': [u'0'], u'edtime': [u'2016-05-30 00:02:00 UTC']}>
Hello, I am X
Hello, I am Y
Hello, I am A
Entered Search
<QueryDict: {u'project': [u'project1'], u'app': [u'app'], u'sdtime': [u'2016-05-30 00:00:00 UTC'], u'days': [u'0'], u'edtime': [u'2016-05-30 00:02:00 UTC']}>
Hello, I am X
Hello, I am B
Hello, I am Y
[30/May/2016 22:00:35] "GET /search/?project=project1&app=app&days=0&sdtime=2016-05-30+00%3A00%3A00+UTC&edtime=2016-05-30+00%3A02%3A00+UTC HTTP/1.1" 200 893
Hello, I am A
Hello, I am B
[30/May/2016 22:00:58] "GET /search/?project=project1&app=app&days=0&sdtime=2016-05-30+00%3A00%3A00+UTC&edtime=2016-05-30+00%3A02%3A00+UTC HTTP/1.1" 200 1475
On Monday, May 30, 2016 at 9:32:47 PM UTC-4, Stephen Butler wrote:
I don't see anything in your pasted code that would cause that in the browser. Have you provided us a complete example that exhibits that behavior? Reduce your project down to the smallest set of code that exhibits the problem and then upload it somewhere we can see it.On Mon, May 30, 2016 at 8:13 PM, cr katz <crka...@gmail.com> wrote:--Single request from the user gives the correct output as below. Please see the appended response further below when a user submits 2 requests from 2 different browsers on the same dev machine.I don't want the users to see appended responses, rather, each request must return response as intended with in the request context.Hello, I am A
Hello, I am X
Hello, I am B
Hello, I am Y
Appended response when user submits 2 requests simultaneously from 2 diff browsers:Hello, I am A
Hello, I am X
Hello, I am B
Hello, I am Y
Hello, I am A
Hello, I am B
On Monday, May 30, 2016 at 6:52:12 PM UTC-4, Stephen Butler wrote:What's your actual output vs. what's your desired output?Also, the RequestContext is meant for the render() function. If you just want to access request.GET then you can do it directly (request is passed in as the first parameter to your view func). You also don't need to pre-assign qList and cd, as long as they are assigned before they are accessed you are OK.On Mon, May 30, 2016 at 5:18 PM, cr katz <crka...@gmail.com> wrote:Hello James,Here below is my code:qList in the code below, actually take a list of functions and uses the parameters received thru the request, processes and appends the response to 'p'. In this code, I eliminated those functions and hardcoded with a list of strings.def search(request):
p = []
cd = {}
qList=[]
request_context = RequestContext(request)
if request_context.request.GET:
form = SearchForm(request_context.request.GET)
# print form
if form.is_valid():
cd = request_context.request.GET
projectId = cd['project']
app = cd['app']
if cd['days'] != '0':
daysAgo = '-' + cd['days']
else:
daysAgo = cd['days']
sdtime = cd['sdtime']
edtime = cd['edtime']
qList = ["Hello, I am X", "Hello, I am Y", "Hello, I am A", "Hello, I am B"]
for func in qList:
print func
t.sleep(10)
p.append(func)
context = {'query_output': p, 'id_project': projectId,
'app': app, 'pOutput': p}
return render(request, 'temp.html', context)
else:
form = SearchForm()
return render_to_response('search_form.html' , {'form': form})
Thankscrkatz
On Monday, May 30, 2016 at 2:10:17 AM UTC-4, James Schneider wrote:
On May 29, 2016 4:23 PM, "cr katz" <crka...@gmail.com> wrote:
>
> Hello,
> I am new to django. I developed a web application using form based views. When I submit a single web request from the dev env, the response is returned correctly. When submit 2 simultaneously from 2 browsers, I see appended responses for each request.
>
> How can I process requests independently?That would certainly be odd behavior, although I'm not exactly sure what you mean. Can you post the output that you're seeing and the view in question?
-James
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.--
You received this message because you are subscribed to the Google Groups "Django users" group.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/04067a15- .d2cd-48d9-810c-8abe5760278c% 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...@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/7be9a742- .26dc-4a85-b6c1-2ab6def4696f% 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+unsubscribe@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/2851f295-6f8f-4ad3-b1d1-8768532b3fac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment