Re: Django + WSGI: no HTTP_COOKIE in environ

2018-07-19 Thread need_some_help
Sorry for the delayed response. Yes, I understand that a cookie must be 
set/sent to the browser after the first request, and that generally you 
must send the cookie headers alone as I've had trouble on other platforms 
trying to send them along with other things. That being said, I need to 
cover the basics.

I first need to make sure I am accessing them correctly. This is as simple 
as it gets I imagine:

view.py:

def index(environ, start_response, request):
if not 'HTTP_COOKIE' in environ:
response = HttpResponse("hello")
response.set_cookie('user_agreement', 'cookie text', 
domain='.mysite.com')
return response
else:
print environ['HTTP_COOKIE']

The webpage just prints 'hello' and never reaches the else not matter how 
many times I refresh the page. There are no cookies in the browser ever 
either.

Am I missing some middleware? I remember some answers to cookie problems 
related to the order of their middleware configurations. Here's mine:

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

-- 
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/06b0a007-09fd-4476-b100-ac0a504ee297%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


authenticate issues with custom backends in 2.1rc1

2018-07-19 Thread DirkBo
After updating from 2.0.7 to 2.1rc1 when i 
call django.contrib.auth.authenticate(), my custom authentication Backends 
are now completely ignored, only django.contrib.auth.backends.ModelBackend 
is used.

Is this happening for someone else or did i miss some changes? 

-- 
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/4c70a073-aa04-48d8-b47f-dd4cf515db76%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to create dynamic form field? Django 2.0

2018-07-19 Thread Django Lover


Here is the image of the form what is need when user click on "Add New Tax 
" two input (Tax name and Value ) should generate dynamically and with all 
field of the 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/d323c889-020f-46a0-9e14-b8bb26c9abdb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: API for writing a new database backend

2018-07-19 Thread C. Kirby
I haven't worked on DB backends, but I'm pretty sure you want to implement 
everything in db/backends/base

https://github.com/django/django/tree/master/django/db/backends/base

Also here is a page with some info and links to talks and concepts about 
writing a backend (slightly out of date, but should have most of the info 
you need)

https://reinout.vanrees.org/weblog/2016/11/04/database-backends.html

On Wednesday, July 18, 2018 at 5:32:09 PM UTC-4, Nuno wrote:
>
> Hi,
> I'm starting to write a new database backend for a non-relational 
> database, but I can't find any API specification that I should follow.
> Such API or any related documentation exists?
>
> Thank you,
> Nuno
>
>

-- 
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/3f06814e-ff02-448d-8557-b947f1b1abaa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to create dynamic form field? Django 2.0

2018-07-19 Thread C. Kirby
https://docs.djangoproject.com/en/2.0/topics/forms/formsets/ to allow for 
multiple instances of the same form type. Then you will need some 
javascript to handle showing additional instances of the form when the 
button is clicked

On Thursday, July 19, 2018 at 9:29:51 AM UTC-4, Django Lover wrote:
>
> Here is the image of the form what is need when user click on "Add New Tax 
> " two input (Tax name and Value ) should generate dynamically and with all 
> field of the 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/c8ae0b6c-957c-4cae-83b1-b7e46916d797%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to create dynamic form field? Django 2.0

2018-07-19 Thread Django Lover
This is hard for me understand can you please give some code. I am new in 
Django. PLEASE HELP ME

On Thursday, July 19, 2018 at 7:26:29 PM UTC+5:30, C. Kirby wrote:
>
> https://docs.djangoproject.com/en/2.0/topics/forms/formsets/ to allow for 
> multiple instances of the same form type. Then you will need some 
> javascript to handle showing additional instances of the form when the 
> button is clicked
>
> On Thursday, July 19, 2018 at 9:29:51 AM UTC-4, Django Lover wrote:
>>
>> Here is the image of the form what is need when user click on "Add New 
>> Tax " two input (Tax name and Value ) should generate dynamically and with 
>> all field of the 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/734e4c1c-ec9c-4627-93c8-5d2e692c9447%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Channels] How to write tests with database access?

2018-07-19 Thread Neraste

Hello Django users,

This sounds like a pretty newbish question, but I am struggling on how 
to write tests for Django-channels 2 websocket consumers that access the 
database. I am not familiar with pytest and asynchronous programming 
(the bread and butter of Channels testing), so while I caught up with 
pytest, I am still a bit lost between `async` and `await`.


Using Django/Django-REST, when I test a view method which modifies a 
database object for a given request, here is what I usually do:


1. Assert the initial state of the object ;
2. Use the test client to send the request ;
3. Assert the outcome of the request ;
4. Assert the final state of the object, which should be different.

All of this synchronously. With Channels, I thought I could do the same 
for a consumer method which modifies a database object on a given event:


1. Assert the initial state of the object ;
2. Use the test communicator to send the event ;
3. Assert the final state of the object, which should have changed.

All of this asynchronously, as stated in the documentation 
, but 
this is a synchronous test scenario! Obviously, it does not work, as 
step 2. is executed with `await` and step 3. is achieved before step 2. 
finishes. I tried to execute step 2. synchronously using `async_to_sync` 
but it does not work (I can give details).


I am missing something, how can I test such a consumer method? Is this 
possible? The documentation does not give any hint on this…


Help would be much appreciated!

Cheers,

--
Neraste

--
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/c22c1afb-ff85-5af9-66f6-a94cdc77a545%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to create dynamic form field? Django 2.0

2018-07-19 Thread mottaz hejaze
this is not a django stuff , this is frontend .. you can use jquery or
angularjs ..to hundle click event on the button and create the two fields
...

this website cant be done with django templates.. you need djangorest
framework with frontend javascript library

the django template way , you create a button that links to a separate form
.. the user enters tax name and value ,then submit , if he want to add more
, he will repeat the process

On Thu, 19 Jul 2018, 16:18 Django Lover,  wrote:

> This is hard for me understand can you please give some code. I am new in
> Django. PLEASE HELP ME
>
> On Thursday, July 19, 2018 at 7:26:29 PM UTC+5:30, C. Kirby wrote:
>>
>> https://docs.djangoproject.com/en/2.0/topics/forms/formsets/ to allow
>> for multiple instances of the same form type. Then you will need some
>> javascript to handle showing additional instances of the form when the
>> button is clicked
>>
>> On Thursday, July 19, 2018 at 9:29:51 AM UTC-4, Django Lover wrote:
>>>
>>> Here is the image of the form what is need when user click on "Add New
>>> Tax " two input (Tax name and Value ) should generate dynamically and with
>>> all field of the 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/734e4c1c-ec9c-4627-93c8-5d2e692c9447%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/CAHV4E-d7NucCNcumUoVSQa2wsQa4fuR9mHCzEteiLyxWg%3DSGkw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to create dynamic form field? Django 2.0

2018-07-19 Thread Sunil Kothiyal
Thank you for responding. Please can you tell me how i can save it  if i
will generate multiple form field using frontend javascript.

On Thu, Jul 19, 2018, 9:23 PM mottaz hejaze  wrote:

> this is not a django stuff , this is frontend .. you can use jquery or
> angularjs ..to hundle click event on the button and create the two fields
> ...
>
> this website cant be done with django templates.. you need djangorest
> framework with frontend javascript library
>
> the django template way , you create a button that links to a separate
> form .. the user enters tax name and value ,then submit , if he want to add
> more , he will repeat the process
>
> On Thu, 19 Jul 2018, 16:18 Django Lover,  wrote:
>
>> This is hard for me understand can you please give some code. I am new in
>> Django. PLEASE HELP ME
>>
>> On Thursday, July 19, 2018 at 7:26:29 PM UTC+5:30, C. Kirby wrote:
>>>
>>> https://docs.djangoproject.com/en/2.0/topics/forms/formsets/ to allow
>>> for multiple instances of the same form type. Then you will need some
>>> javascript to handle showing additional instances of the form when the
>>> button is clicked
>>>
>>> On Thursday, July 19, 2018 at 9:29:51 AM UTC-4, Django Lover wrote:

 Here is the image of the form what is need when user click on "Add New
 Tax " two input (Tax name and Value ) should generate dynamically and with
 all field of the 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/734e4c1c-ec9c-4627-93c8-5d2e692c9447%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/GOBFMJqL20Y/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHV4E-d7NucCNcumUoVSQa2wsQa4fuR9mHCzEteiLyxWg%3DSGkw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Is there any way to disable dispatching of signals?

2018-07-19 Thread lorinkoz
Is there any way to disable dispatching of signals?
If not, I truly truly think there should be a way to do it :)

Possible use cases:
- Prevent signals being called recursively because the signal code 
dispatched the same signal.
- Disable for scripts or management commands
- Just bypass the signals on specific actions.

-- 
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/3fd1f97e-177c-4241-b7bf-9ac74abb82a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Tutorial: "NoReverseMatch" Error

2018-07-19 Thread roflcopterpaul
Hello, everyone! I have run into a problem I cannot figure out. I have 
spent days searching online and trying different things in my code, but I 
cannot figure out where this problem is stemming from. I would truly 
appreciate any insights.

Admittedly, I am scrub enough that I'm not even sure of all the code I 
should include, so if I should include anything else, please let me know!

NoReverseMatch at /polls/1/vote/
>
> Reverse for 'results' with arguments '(1,)' not found. 1 pattern(s) tried: 
> ['polls\\/\\
> Request Method: POST
> Request URL: http://127.0.0.1:8000/polls/1/vote/
> Django Version: 2.0.6
> Exception Type: NoReverseMatch
> Exception Value: 
>
> Reverse for 'results' with arguments '(1,)' not found. 1 pattern(s) tried: 
> ['polls\\/\\
> Exception Location: 
> C:\Users\pwalker\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py
>  
> in _reverse_with_prefix, line 636
> Python Executable: 
> C:\Users\pwalker\AppData\Local\Programs\Python\Python36-32\python.exe
> Python Version: 3.6.4
> Python Path: 
>
> ['C:\\Users\\pwalker\\Coding\\Python-Practice\\Gaining_Agreement\\GA_site',
>  
> 'C:\\Users\\pwalker\\AppData\\Local\\Programs\\Python\\Python36-32\\python36.zip',
>  'C:\\Users\\pwalker\\AppData\\Local\\Programs\\Python\\Python36-32\\DLLs',
>  'C:\\Users\\pwalker\\AppData\\Local\\Programs\\Python\\Python36-32\\lib',
>  'C:\\Users\\pwalker\\AppData\\Local\\Programs\\Python\\Python36-32',
>  
> 'C:\\Users\\pwalker\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages']
>
>
 views.py
...

def vote(request, question_id):
question = get_object_or_404(Question, pk=question_id)
try:
selected_choice = question.choice_set.get(pk=request.POST['choice'])
except (KeyError, Choice.DoesNotExist):
# Redisplay the question voting formself.
return render(request, 'polls/detail.html', {'question': question, 
'error_message': "You didn't select a choice.", })
else:
selected_choice.votes += 1
selected_choice.save()
# Always return an HttpResponseRedirect after successfully dealing 
with POST data.
# This prevents data from being posted twice if a user hits the 
Back buttonself.
return HttpResponseRedirect(reverse('polls:results', 
args=(question.id,)))

urls.py
urlpatterns = [
# ex: /polls/
path('', views.IndexView.as_view(), name='index'),
# ex: /polls/5/
# the 'name' value as called by the {% url %} template tag
path('/', views.DetailView.as_view(), name='detail'),
# ex: /polls/5/results/
path('/vote/', views.vote, name='vote'),
]

templates/polls/results.html  - This is the page it *should* be redirecting 
to after I click to vote, but that is when it takes me to the error screen.
{{ question.question_text }}


{% for choice in question.choice_set.all %}
  {{ choice.choice_text }} -- {{ choice.votes }} vote{{ 
choice.votes|pluralize }}
{% endfor %}


Vote again?


Thank you very much for any help!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To 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/38f2f492-86a3-47e6-9652-cf9a8e858ad6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Tutorial: "NoReverseMatch" Error

2018-07-19 Thread Dylan Reinhold
You are missing the > in the path
path('/results/', views.ResultsView.as_view(), name='results'),

On Thu, Jul 19, 2018 at 11:18 AM, roflcopterpaul 
wrote:

> Hello, everyone! I have run into a problem I cannot figure out. I have
> spent days searching online and trying different things in my code, but I
> cannot figure out where this problem is stemming from. I would truly
> appreciate any insights.
>
> Admittedly, I am scrub enough that I'm not even sure of all the code I
> should include, so if I should include anything else, please let me know!
>
> NoReverseMatch at /polls/1/vote/
>>
>> Reverse for 'results' with arguments '(1,)' not found. 1 pattern(s) tried: 
>> ['polls\\/\\>
>> Request Method: POST
>> Request URL: http://127.0.0.1:8000/polls/1/vote/
>> Django Version: 2.0.6
>> Exception Type: NoReverseMatch
>> Exception Value:
>>
>> Reverse for 'results' with arguments '(1,)' not found. 1 pattern(s) tried: 
>> ['polls\\/\\>
>> Exception Location: C:\Users\pwalker\AppData\Local\Programs\Python\
>> Python36-32\lib\site-packages\django\urls\resolvers.py in
>> _reverse_with_prefix, line 636
>> Python Executable: C:\Users\pwalker\AppData\Local\Programs\Python\
>> Python36-32\python.exe
>> Python Version: 3.6.4
>> Python Path:
>>
>> ['C:\\Users\\pwalker\\Coding\\Python-Practice\\Gaining_Agreement\\GA_site',
>>  
>> 'C:\\Users\\pwalker\\AppData\\Local\\Programs\\Python\\Python36-32\\python36.zip',
>>  'C:\\Users\\pwalker\\AppData\\Local\\Programs\\Python\\Python36-32\\DLLs',
>>  'C:\\Users\\pwalker\\AppData\\Local\\Programs\\Python\\Python36-32\\lib',
>>  'C:\\Users\\pwalker\\AppData\\Local\\Programs\\Python\\Python36-32',
>>  
>> 'C:\\Users\\pwalker\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages']
>>
>>
>  views.py
> ...
>
> def vote(request, question_id):
> question = get_object_or_404(Question, pk=question_id)
> try:
> selected_choice = question.choice_set.get(pk=
> request.POST['choice'])
> except (KeyError, Choice.DoesNotExist):
> # Redisplay the question voting formself.
> return render(request, 'polls/detail.html', {'question': question,
> 'error_message': "You didn't select a choice.", })
> else:
> selected_choice.votes += 1
> selected_choice.save()
> # Always return an HttpResponseRedirect after successfully dealing
> with POST data.
> # This prevents data from being posted twice if a user hits
> the Back buttonself.
> return HttpResponseRedirect(reverse('polls:results', args=(
> question.id,)))
>
> urls.py
> urlpatterns = [
> # ex: /polls/
> path('', views.IndexView.as_view(), name='index'),
> # ex: /polls/5/
> # the 'name' value as called by the {% url %} template tag
> path('/', views.DetailView.as_view(), name='detail'),
> # ex: /polls/5/results/
> path(' # ex: /polls/5/vote/
> path('/vote/', views.vote, name='vote'),
> ]
>
> templates/polls/results.html  - This is the page it *should* be
> redirecting to after I click to vote, but that is when it takes me to the
> error screen.
> {{ question.question_text }}
>
> 
> {% for choice in question.choice_set.all %}
>   {{ choice.choice_text }} -- {{ choice.votes }} vote{{
> choice.votes|pluralize }}
> {% endfor %}
> 
>
> Vote again?
>
>
> Thank you very much for any help!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To 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/38f2f492-86a3-47e6-9652-cf9a8e858ad6%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/CAHtg44BU4iM0%3Dy0EqaToAm6Y1jnRt14uCG9sL_6gJsEjwWy_sg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


RE: Django Tutorial: "NoReverseMatch" Error

2018-07-19 Thread Matthew Pava
It looks like you have a typo:

urlpatterns = [
# ex: /polls/
path('', views.IndexView.as_view(), name='index'),
# ex: /polls/5/
# the 'name' value as called by the {% url %} template tag
path('/', views.DetailView.as_view(), name='detail'),
# ex: /polls/5/results/
path('/vote/', views.vote, name='vote'),
]

The red line should probably have this path:
/results/


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of roflcopterpaul
Sent: Thursday, July 19, 2018 1:18 PM
To: Django users
Subject: Django Tutorial: "NoReverseMatch" Error

Hello, everyone! I have run into a problem I cannot figure out. I have spent 
days searching online and trying different things in my code, but I cannot 
figure out where this problem is stemming from. I would truly appreciate any 
insights.

Admittedly, I am scrub enough that I'm not even sure of all the code I should 
include, so if I should include anything else, please let me know!

NoReverseMatch at /polls/1/vote/

Reverse for 'results' with arguments '(1,)' not found. 1 pattern(s) tried: 
['polls\\/\\http://127.0.0.1:8000/polls/1/vote/

Django Version:

2.0.6

Exception Type:

NoReverseMatch

Exception Value:


Reverse for 'results' with arguments '(1,)' not found. 1 pattern(s) tried: 
['polls\\/\\/', views.DetailView.as_view(), name='detail'),
# ex: /polls/5/results/
path('/vote/', views.vote, name='vote'),
]

templates/polls/results.html  - This is the page it *should* be redirecting to 
after I click to vote, but that is when it takes me to the error screen.
{{ question.question_text }}


{% for choice in question.choice_set.all %}
  {{ choice.choice_text }} -- {{ choice.votes }} vote{{ 
choice.votes|pluralize }}
{% endfor %}


Vote again?


Thank you very much for any help!
--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com.
To 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/38f2f492-86a3-47e6-9652-cf9a8e858ad6%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/668d07e3dacb45ecb71559ea4979631c%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Re: Django Tutorial: "NoReverseMatch" Error

2018-07-19 Thread roflcopterpaul
Yeah, I just discovered that after posting this. I'm ashamed to admit that
single error had me baffled for days.

Thank you so much for the quick reply!

On Thu, Jul 19, 2018, 11:35 AM Dylan Reinhold  wrote:

> You are missing the > in the path
> path(' Should be
> path('/results/', views.ResultsView.as_view(), name='results'),
>
> On Thu, Jul 19, 2018 at 11:18 AM, roflcopterpaul  > wrote:
>
>> Hello, everyone! I have run into a problem I cannot figure out. I have
>> spent days searching online and trying different things in my code, but I
>> cannot figure out where this problem is stemming from. I would truly
>> appreciate any insights.
>>
>> Admittedly, I am scrub enough that I'm not even sure of all the code I
>> should include, so if I should include anything else, please let me know!
>>
>> NoReverseMatch at /polls/1/vote/
>>>
>>> Reverse for 'results' with arguments '(1,)' not found. 1 pattern(s) tried: 
>>> ['polls\\/\\>>
>>> Request Method: POST
>>> Request URL: http://127.0.0.1:8000/polls/1/vote/
>>> Django Version: 2.0.6
>>> Exception Type: NoReverseMatch
>>> Exception Value:
>>>
>>> Reverse for 'results' with arguments '(1,)' not found. 1 pattern(s) tried: 
>>> ['polls\\/\\>>
>>> Exception Location: 
>>> C:\Users\pwalker\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py
>>> in _reverse_with_prefix, line 636
>>> Python Executable:
>>> C:\Users\pwalker\AppData\Local\Programs\Python\Python36-32\python.exe
>>> Python Version: 3.6.4
>>> Python Path:
>>>
>>> ['C:\\Users\\pwalker\\Coding\\Python-Practice\\Gaining_Agreement\\GA_site',
>>>  
>>> 'C:\\Users\\pwalker\\AppData\\Local\\Programs\\Python\\Python36-32\\python36.zip',
>>>  'C:\\Users\\pwalker\\AppData\\Local\\Programs\\Python\\Python36-32\\DLLs',
>>>  'C:\\Users\\pwalker\\AppData\\Local\\Programs\\Python\\Python36-32\\lib',
>>>  'C:\\Users\\pwalker\\AppData\\Local\\Programs\\Python\\Python36-32',
>>>  
>>> 'C:\\Users\\pwalker\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages']
>>>
>>>
>>  views.py
>> ...
>>
>> def vote(request, question_id):
>> question = get_object_or_404(Question, pk=question_id)
>> try:
>> selected_choice =
>> question.choice_set.get(pk=request.POST['choice'])
>> except (KeyError, Choice.DoesNotExist):
>> # Redisplay the question voting formself.
>> return render(request, 'polls/detail.html', {'question':
>> question, 'error_message': "You didn't select a choice.", })
>> else:
>> selected_choice.votes += 1
>> selected_choice.save()
>> # Always return an HttpResponseRedirect after successfully
>> dealing with POST data.
>> # This prevents data from being posted twice if a user hits
>> the Back buttonself.
>> return HttpResponseRedirect(reverse('polls:results', args=(
>> question.id,)))
>>
>> urls.py
>> urlpatterns = [
>> # ex: /polls/
>> path('', views.IndexView.as_view(), name='index'),
>> # ex: /polls/5/
>> # the 'name' value as called by the {% url %} template tag
>> path('/', views.DetailView.as_view(), name='detail'),
>> # ex: /polls/5/results/
>> path('> # ex: /polls/5/vote/
>> path('/vote/', views.vote, name='vote'),
>> ]
>>
>> templates/polls/results.html  - This is the page it *should* be
>> redirecting to after I click to vote, but that is when it takes me to the
>> error screen.
>> {{ question.question_text }}
>>
>> 
>> {% for choice in question.choice_set.all %}
>>   {{ choice.choice_text }} -- {{ choice.votes }} vote{{
>> choice.votes|pluralize }}
>> {% endfor %}
>> 
>>
>> Vote again?
>>
>>
>> Thank you very much for any help!
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To 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/38f2f492-86a3-47e6-9652-cf9a8e858ad6%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/haz9iF_HDpc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHtg44BU4iM0%3Dy0Eqa

Re: authenticate issues with custom backends in 2.1rc1

2018-07-19 Thread Tim Graham
Do you have deprecation warnings with Django 2.0.x? 
https://docs.djangoproject.com/en/dev/howto/upgrade-version/#resolving-deprecation-warnings

>From the 2.1 release notes: "The authenticate() method of authentication 
backends requires request as the first positional argument."

>From the 1.11 release notes: "authenticate() now passes a request argument 
to the authenticate() method of authentication backends. Support for 
methods that don’t accept request as the first positional argument will be 
removed in Django 2.1."

On Thursday, July 19, 2018 at 7:08:39 AM UTC-4, DirkBo wrote:
>
> After updating from 2.0.7 to 2.1rc1 when i 
> call django.contrib.auth.authenticate(), my custom authentication Backends 
> are now completely ignored, only django.contrib.auth.backends.ModelBackend 
> is used.
>
> Is this happening for someone else or did i miss some changes? 
>

-- 
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/8136222c-d6a1-420a-b49d-5405ab67f977%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to check if server is running in ASGI or in WSGI mode?

2018-07-19 Thread Rafis Ganeev
We are running same django project in WSGI mode for handling HTTP requests 
and in ASGI mode for handling WebSockets. For WSGI mode we are using 
**gunicorn3** server:

gunicorn3 --pythonpath . -b 0.0.0.0:8000 chat_bot.wsgi:application

For ASGI mode we are using **daphne** server:

daphne --root-path . -b 0.0.0.0 -p 8001 chat_bot.asgi:application

How to programatically detect which mode currently is running 
**GUnicorn+WSGI** or **Daphne+ASGI**?

-- 
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/4ec22aa6-e69e-4cb6-8463-d3a9eef4728e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is there any way to disable dispatching of signals?

2018-07-19 Thread Jason
deciding whether to act or not is really part of the signal handler, to be 
honest.

-- 
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/966d4c2a-5738-4b38-b7d4-5990852a0a00%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Tutorial: "NoReverseMatch" Error

2018-07-19 Thread Melvyn Sopacua
On donderdag 19 juli 2018 20:39:15 CEST roflcopterpaul wrote:
> Yeah, I just discovered that after posting this. I'm ashamed to admit that
> single error had me baffled for days.

No shame needed, because at some point you read over and over it and read the 
same wrong thing as right in your brain. There's two tricks to it:
a) put the lines from the example below/above your line and compare above with 
below. Obviously this only works when you have an example and works better if 
you added or missed a letter.
b) ask sooner. A different set of eyes connected to a fresh brain makes  a 
world of difference. In fact, a lot of times just composing the mail can solve 
a problem as you put the code into a different setting and your brain has to 
process it again. Especially if you paste it as plain text without all the 
formatting of an IDE/editor.

-- 
Melvyn Sopacua

-- 
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/2626313.Z6rRR89q5h%40fritzbook.
For more options, visit https://groups.google.com/d/optout.


Re: Is there any way to disable dispatching of signals?

2018-07-19 Thread Melvyn Sopacua
On donderdag 19 juli 2018 18:22:46 CEST lorin...@gmail.com wrote:
> Is there any way to disable dispatching of signals?
> If not, I truly truly think there should be a way to do it :)
> 
> Possible use cases:
> - Prevent signals being called recursively because the signal code
> dispatched the same signal.

Subscribe to the signal with dispatch_uid[1].

> - Disable for scripts or management commands
> - Just bypass the signals on specific actions.

As Jason implies: both tasks of the observer, not the dispatcher. If a 
dispatcher does not 
call all registered observers as part of the API contract, you have no way to 
debug it (given 
that a signal dispatcher should be a black box to you) or at best you'd have 2 
places where 
things can go wrong instead of just one.

You thought up some use cases, but given the tone of your mail you mybe spent 
some 
time trying to shoehorn some code into a signal/observer pattern? Perhaps it's 
not the 
right fit for your problem.
-- 
Melvyn Sopacua


[1] 
https://docs.djangoproject.com/en/2.0/topics/signals/#preventing-duplicate-signals

-- 
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/6325556.ifQiiisRDa%40fritzbook.
For more options, visit https://groups.google.com/d/optout.


Re: How to create dynamic form field? Django 2.0

2018-07-19 Thread Melvyn Sopacua
On donderdag 19 juli 2018 16:18:07 CEST Django Lover wrote:
> This is hard for me understand can you please give some code. I am new in
> Django. PLEASE HELP ME

If you're new to Django don't try to do this and learn more about Django first. 
You don't have the knowledge to break down your problem into the right 
components, which for a Django developer up to the task would be very simple 
(as shown by the replies).
Walk before your run.
-- 
Melvyn Sopacua

-- 
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/3559019.g1zy2VpXjY%40fritzbook.
For more options, visit https://groups.google.com/d/optout.


Re: How to create dynamic form field? Django 2.0

2018-07-19 Thread Django Lover
@Melvyn Sopacua Can you please give me simple solution of this problem?

On Friday, July 20, 2018 at 11:15:06 AM UTC+5:30, Melvyn Sopacua wrote:
>
> On donderdag 19 juli 2018 16:18:07 CEST Django Lover wrote: 
> > This is hard for me understand can you please give some code. I am new 
> in 
> > Django. PLEASE HELP ME 
>
> If you're new to Django don't try to do this and learn more about Django 
> first. 
> You don't have the knowledge to break down your problem into the right 
> components, which for a Django developer up to the task would be very 
> simple 
> (as shown by the replies). 
> Walk before your run. 
> -- 
> Melvyn Sopacua 
>

-- 
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/add2bc6a-9684-4930-b1ac-3c51c1209d8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Tutorial: "NoReverseMatch" Error

2018-07-19 Thread roflcopterpaul
I truly appreciate the suggestions, Melvyn. Thanks so much!

On Thu, Jul 19, 2018, 10:28 PM Melvyn Sopacua  wrote:

> On donderdag 19 juli 2018 20:39:15 CEST roflcopterpaul wrote:
> > Yeah, I just discovered that after posting this. I'm ashamed to admit
> that
> > single error had me baffled for days.
>
> No shame needed, because at some point you read over and over it and read
> the
> same wrong thing as right in your brain. There's two tricks to it:
> a) put the lines from the example below/above your line and compare above
> with
> below. Obviously this only works when you have an example and works better
> if
> you added or missed a letter.
> b) ask sooner. A different set of eyes connected to a fresh brain makes  a
> world of difference. In fact, a lot of times just composing the mail can
> solve
> a problem as you put the code into a different setting and your brain has
> to
> process it again. Especially if you paste it as plain text without all the
> formatting of an IDE/editor.
>
> --
> Melvyn Sopacua
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/haz9iF_HDpc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2626313.Z6rRR89q5h%40fritzbook
> .
> 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/CAGNGjWNB_fVfWChKpdtGkY_V%3D4gBUdzo6ZsYVYHFR88EZ%2Bwnfg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.