Re: NoReverseMatch error message - Please help

2020-03-31 Thread victor awakan
Sometimes the error can be from your url.py or even views.py and also make
sure no typo. Check each on e of the above carefully. Hopefully you might
see the bug.

Cheers

On Tue 31. Mar 2020 at 18.06, Jeff Waters  wrote:

> Thanks Ryan.
>
> I've just tried that, but I still get an error message.
>
> By the way, is it definitely .id and not _id? I've seen both, and Django
> docs says: 'Behind the scenes, Django appends "_id" to the field name to
> create its database column name, which makes me wonder if it might be _id.
>
> Incidentally, I've also tried amending the relevant URL path to
> path('add_comment/', views.add_comment, name='add_comment')
> - with underscore and with a dot before the id - but that doesn't work.
>
> Jeff
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4473f031-abfa-428a-8804-debaf5a41c93%40googlegroups.com
> .
>

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


Re: NoReverseMatch error message - Please help

2020-03-31 Thread Jeff Waters
Thanks Ryan.

I've just tried that, but I still get an error message. 

By the way, is it definitely .id and not _id? I've seen both, and Django docs 
says: 'Behind the scenes, Django appends "_id" to the field name to create its 
database column name, which makes me wonder if it might be _id.

Incidentally, I've also tried amending the relevant URL path to 
path('add_comment/', views.add_comment, name='add_comment') - 
with underscore and with a dot before the id - but that doesn't work.

Jeff



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


Re: NoReverseMatch error message - Please help

2020-03-31 Thread Ryan Nowakowski

Based on the rest of your template from the github link, looks like:

{% url 'nowandthen:add_comment' image.id %}

...should instead be:

{% url 'nowandthen:add_comment' p.image.id %}

On 3/31/20 7:08 AM, Jeff Waters wrote:

I am putting together a website which has a photo gallery where users can add 
comments. When I go to the photo gallery page, I get the following error 
message:

NoReverseMatch at /photo_feed/ Reverse for 'add_comment' with arguments '('',)' 
not found. 1 pattern(s) tried: ['add_comment/$']

The code for the relevant part of the HTML document is as follows:

 comments
 {% if not comments %}
 No comments
 {% endif %}
 {% for x in comment %}
 
 
 Comment by {{ x.user }}
 
 {{ x.created_on }}
 
 
 {{ x.body | linebreaks }}
 
 {% endfor %}
 
 
 {% if new_comment %}
 Your comment has been posted.
 {% else %}
 Leave a comment
 
 {{ comment_form.as_p }}
 {% csrf_token %}
 Submit
 {% endif %}
The URLs.py entry for add_comment is path('add_comment/', 
views.add_comment, name='add_comment'). Removing the int: image_id doesn't fix the 
problem.

When I go into admin, no ids appear to have been generated for the photos. 
Could it be that the problem is that there are missing IDs? If so, how do I fix 
this?

The repository URL is https://github.com/EmilyQuimby/my_now_and_then.

Thank you.



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


Re: NoReverseMatch error message - Please help

2020-03-31 Thread Kasper Laudrup

Hi Jeff,

On 31/03/2020 14.08, Jeff Waters wrote:

I am putting together a website which has a photo gallery where users can add 
comments. When I go to the photo gallery page, I get the following error 
message:

NoReverseMatch at /photo_feed/ Reverse for 'add_comment' with arguments '('',)' 
not found. 1 pattern(s) tried: ['add_comment/$']



Trailing slashes are part of the path, so "/foobar/" is not the same as 
"/foobar".


Hopefully that should give you a hint to what is most likely the cause 
of your problem.


Kind regards,

Kasper Laudrup

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/860f1f56-b008-f38b-3b01-8ff985f5d88f%40stacktrace.dk.


NoReverseMatch error message - Please help

2020-03-31 Thread Jeff Waters
I am putting together a website which has a photo gallery where users can add 
comments. When I go to the photo gallery page, I get the following error 
message:

NoReverseMatch at /photo_feed/ Reverse for 'add_comment' with arguments '('',)' 
not found. 1 pattern(s) tried: ['add_comment/$']

The code for the relevant part of the HTML document is as follows:

comments
{% if not comments %}
No comments
{% endif %}
{% for x in comment %}


Comment by {{ x.user }}

{{ x.created_on }}


{{ x.body | linebreaks }}

{% endfor %}


{% if new_comment %}
Your comment has been posted.
{% else %}
Leave a comment

{{ comment_form.as_p }}
{% csrf_token %}
Submit
{% endif %}
The URLs.py entry for add_comment is path('add_comment/', 
views.add_comment, name='add_comment'). Removing the int: image_id doesn't fix 
the problem.

When I go into admin, no ids appear to have been generated for the photos. 
Could it be that the problem is that there are missing IDs? If so, how do I fix 
this?

The repository URL is https://github.com/EmilyQuimby/my_now_and_then.

Thank you.

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


Re: NoReverseMatch() error while learning Python

2020-02-19 Thread Jorge Gimeno
On Wed, Feb 19, 2020 at 4:47 AM DamnGeniuses' Squad <
andhikaravelen...@gmail.com> wrote:

> NoReverseMatch at /polls/1/
>
> Reverse for 'vote' with arguments '('',)' not found. 1 pattern(s) tried: 
> ['polls/(?P[0-9]+)/vote/$']
>
> Request Method: GET
> Request URL: http://127.0.0.1:8000/polls/1/
> Django Version: 3.0.3
> Exception Type: NoReverseMatch
> Exception Value:
>
> Reverse for 'vote' with arguments '('',)' not found. 1 pattern(s) tried: 
> ['polls/(?P[0-9]+)/vote/$']
>
> Exception Location: 
> C:\Users\Andhika\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py
> in _reverse_with_prefix, line 677
> Python Executable:
> C:\Users\Andhika\AppData\Local\Programs\Python\Python38\python.exe
> Python Version: 3.8.1
> Python Path:
>
> ['E:\\TestingKetiga-2\\mysite',
>  
> 'C:\\Users\\Andhika\\AppData\\Local\\Programs\\Python\\Python38\\python38.zip',
>  'C:\\Users\\Andhika\\AppData\\Local\\Programs\\Python\\Python38\\DLLs',
>  'C:\\Users\\Andhika\\AppData\\Local\\Programs\\Python\\Python38\\lib',
>  'C:\\Users\\Andhika\\AppData\\Local\\Programs\\Python\\Python38',
>  'C:\\Users\\Andhika\\AppData\\Roaming\\Python\\Python38\\site-packages',
>  
> 'C:\\Users\\Andhika\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages']
>
> Server time: Wed, 19 Feb 2020 09:56:21 +
> Error during template rendering
>
> In template E:\TestingKetiga-2\mysite\polls\templates\polls\detail.html,
> error at line *5*
> Reverse for 'vote' with arguments '('',)' not found. 1 pattern(s) tried:
> ['polls/(?P[0-9]+)/vote/$']
> 1 {{ question.question_text }}
> 2
> 3 {% if error_message %}{{ error_message }}{%
> endif %}
> 4
> 5 
> 6 {% csrf_token %}
> 7 {% for choice in question.choice_set.all %}
> 8  value="{{ choice.id }}">
> 9 {{ choice.choice_text
> }}
> 10 {% endfor %}
> 11 
> 12 
> Please help me fix this , i want to learn more about Django , but i
> already searching for 3 hours but got no solution yet
> Thankyouu
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b5374455-e259-4ac7-b16d-2b55c8dd6924%40googlegroups.com
> 
> .
>

Would you be able to show us your polls/urls.py and your mysite/urls.py
please?

-Jorge

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


NoReverseMatch() error while learning Python

2020-02-19 Thread DamnGeniuses' Squad
NoReverseMatch at /polls/1/

Reverse for 'vote' with arguments '('',)' not found. 1 pattern(s) tried: 
['polls/(?P[0-9]+)/vote/$']

Request Method: GET
Request URL: http://127.0.0.1:8000/polls/1/
Django Version: 3.0.3
Exception Type: NoReverseMatch
Exception Value: 

Reverse for 'vote' with arguments '('',)' not found. 1 pattern(s) tried: 
['polls/(?P[0-9]+)/vote/$']

Exception Location: 
C:\Users\Andhika\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py
 
in _reverse_with_prefix, line 677
Python Executable: 
C:\Users\Andhika\AppData\Local\Programs\Python\Python38\python.exe
Python Version: 3.8.1
Python Path: 

['E:\\TestingKetiga-2\\mysite',
 'C:\\Users\\Andhika\\AppData\\Local\\Programs\\Python\\Python38\\python38.zip',
 'C:\\Users\\Andhika\\AppData\\Local\\Programs\\Python\\Python38\\DLLs',
 'C:\\Users\\Andhika\\AppData\\Local\\Programs\\Python\\Python38\\lib',
 'C:\\Users\\Andhika\\AppData\\Local\\Programs\\Python\\Python38',
 'C:\\Users\\Andhika\\AppData\\Roaming\\Python\\Python38\\site-packages',
 
'C:\\Users\\Andhika\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages']

Server time: Wed, 19 Feb 2020 09:56:21 +
Error during template rendering

In template E:\TestingKetiga-2\mysite\polls\templates\polls\detail.html, 
error at line *5*
Reverse for 'vote' with arguments '('',)' not found. 1 pattern(s) tried: 
['polls/(?P[0-9]+)/vote/$']
1 {{ question.question_text }} 
2 
3 {% if error_message %}{{ error_message }}{% endif 
%} 
4 
5  
6 {% csrf_token %} 
7 {% for choice in question.choice_set.all %} 
8  
9 {{ choice.choice_text 
}} 
10 {% endfor %} 
11  
12  
Please help me fix this , i want to learn more about Django , but i already 
searching for 3 hours but got no solution yet
Thankyouu

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


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.


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: 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: 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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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<https://groups.google.com/d/msgid/django-users/38f2f492-86a3-47e6-9652-cf9a8e858ad6%40googlegroups.com?utm_medium=email&utm_source=footer>.
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 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.


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: NoReverseMatch error raise when adding a new entry in django admin

2018-02-12 Thread Julio Biason
Hi Weifeng,

I think the problem is here:

django.urls.exceptions.NoReverseMatch: Reverse for
'nmm_tokenservice_userprofile_change' with arguments '('',)' not found. 1
pattern(s) tried: ['admin/nmm_tokenservice\\/userprofile\\/(?P.+
)\\/change\\/$']

By all the Django is saying, you're trying to reverse the URL for
`mm_tokenservice_userprofile_change` passing an empty string as args; but
your regex por it requres an `object_id` that must have at least 1
character (that's what `.+` means). So, because you're passing no
parameters, it can't resolve the URL properly.

You *need* to pass the object_id, as per your URL specification, on your
reverse.

Hope that helps.

On Mon, Feb 12, 2018 at 1:20 AM, Weifeng Pan  wrote:

> I got this wired issue. who can help.
>
> Python 3.6
> Django Latest 2.0.2
>
> following are stack trace---
> Internal Server Error: /admin/nmm_tokenservice/userprofile/add/ Traceback
> (most recent call last): File "C:\Python36\lib\site-
> packages\django\core\handlers\exception.py", line 35, in inner response =
> get_response(request) File "C:\Python36\lib\site-
> packages\django\core\handlers\base.py", line 128, in _get_response
> response = self.process_exception_by_middleware(e, request) File
> "C:\Python36\lib\site-packages\django\core\handlers\base.py", line 126,
> in _get_response response = wrapped_callback(request, *callback_args,
> **callback_kwargs) File "C:\Python36\lib\site-
> packages\django\contrib\admin\options.py", line 574, in wrapper return
> self.admin_site.admin_view(view)(*args, **kwargs) File
> "C:\Python36\lib\site-packages\django\utils\decorators.py", line 142, in
> _wrapped_view response = view_func(request, *args, **kwargs) File
> "C:\Python36\lib\site-packages\django\views\decorators\cache.py", line
> 44, in _wrapped_view_func response = view_func(request, *args, **kwargs)
> File "C:\Python36\lib\site-packages\django\contrib\admin\sites.py", line
> 223, in inner return view(request, *args, **kwargs) File
> "C:\Python36\lib\site-packages\django\contrib\admin\options.py", line
> 1553, in add_view return self.changeform_view(request, None, form_url,
> extra_context) File 
> "C:\Python36\lib\site-packages\django\utils\decorators.py",
> line 62, in _wrapper return bound_func(*args, **kwargs) File
> "C:\Python36\lib\site-packages\django\utils\decorators.py", line 142, in
> _wrapped_view response = view_func(request, *args, **kwargs) File
> "C:\Python36\lib\site-packages\django\utils\decorators.py", line 58, in
> bound_func return func.__get__(self, type(self))(*args2, **kwargs2) File
> "C:\Python36\lib\site-packages\django\contrib\admin\options.py", line
> 1450, in changeform_view return self._changeform_view(request, object_id,
> form_url, extra_context) File "C:\Python36\lib\site-
> packages\django\contrib\admin\options.py", line 1495, in _changeform_view
> return self.response_add(request, new_object) File "C:\Python36\lib\site-
> packages\django\contrib\admin\options.py", line 1098, in response_add
> current_app=self.admin_site.name, File 
> "C:\Python36\lib\site-packages\django\urls\base.py",
> line 88, in reverse return iri_to_uri(resolver._reverse_with_prefix(view,
> prefix, *args, **kwargs)) File 
> "C:\Python36\lib\site-packages\django\urls\resolvers.py",
> line 632, in _reverse_with_prefix raise NoReverseMatch(msg)
> django.urls.exceptions.NoReverseMatch: Reverse for
> 'nmm_tokenservice_userprofile_change' with arguments '('',)' not found. 1
> pattern(s) tried: ['admin/nmm_tokenservice\\/
> userprofile\\/(?P.+)\\/change\\/$']
>
> * here is my model---*
> class UserProfile(models.Model):
> #base information
> user = models.OneToOneField(User, on_delete=models.deletion.CASCADE,
> verbose_name='系统账户', related_name='profile')
> uid = UIDField(verbose_name='用户ID', primary_key=True, editable=False, null
> =False, blank=False)
> imuid = UIDField(verbose_name='IM用户ID', editable=False, null=True, blank=
> True)
> nickname = models.CharField(verbose_name='昵称', max_length=20, null=True,
> blank=True, db_index=True)
> tel = models.CharField(verbose_name='手机号码', max_length=20, null=True,
> blank=False)
> #status and level
> status = models.CharField(verbose_name='状态', max_length=20, null=False,
> blank=False, default=USER_STATUS[0][0], choices=USER_STATUS)
> level = models.PositiveIntegerField(verbose_name='级别', null=False, blank=
> False, default=1, db_index=True)
> #org information
> city = CityCodeField(verbose_name='城市', null=True, blank=False)
> org = CodeField(verbose_name='学校或组织机构代码', null=True, blank=True, db_index=
> True)
> textbookcode = LabelCodeField(verbose_name='教材(标签代码)', help_text='请填写标签代码',
> null=True, blank=True, db_index=True)
> gradecode = LabelCodeField(verbose_name='年级/级别(标签代码)', help_text='请填写标签代码',
> null=True, blank=True, db_index=True)
> #role
> role = UserRoleField(verbose_name='角色', null=False, blank=False, 
> choices=UserRole_CHOICES,
> default=UserRole.user.name)
> ### teacher specific

Re: NoReverseMatch error raise when adding a new entry in django admin

2018-02-12 Thread Etienne Robillard

Hi Weifeng,

plz show us your urls.py...

Etienne


Le 2018-02-11 à 22:20, Weifeng Pan a écrit :

I got this wired issue. who can help.
Python 3.6
Django Latest 2.0.2
following are stack trace---
Internal Server Error: /admin/nmm_tokenservice/userprofile/add/ 
Traceback (most recent call last): File 
"C:\Python36\lib\site-packages\django\core\handlers\exception.py", 
line 35, in inner response = get_response(request) File 
"C:\Python36\lib\site-packages\django\core\handlers\base.py", line 
128, in _get_response response = 
self.process_exception_by_middleware(e, request) File 
"C:\Python36\lib\site-packages\django\core\handlers\base.py", line 
126, in _get_response response = wrapped_callback(request, 
*callback_args, **callback_kwargs) File 
"C:\Python36\lib\site-packages\django\contrib\admin\options.py", line 
574, in wrapper return self.admin_site.admin_view(view)(*args, 
**kwargs) File 
"C:\Python36\lib\site-packages\django\utils\decorators.py", line 142, 
in _wrapped_view response = view_func(request, *args, **kwargs) File 
"C:\Python36\lib\site-packages\django\views\decorators\cache.py", line 
44, in _wrapped_view_func response = view_func(request, *args, 
**kwargs) File 
"C:\Python36\lib\site-packages\django\contrib\admin\sites.py", line 
223, in inner return view(request, *args, **kwargs) File 
"C:\Python36\lib\site-packages\django\contrib\admin\options.py", line 
1553, in add_view return self.changeform_view(request, None, form_url, 
extra_context) File 
"C:\Python36\lib\site-packages\django\utils\decorators.py", line 62, 
in _wrapper return bound_func(*args, **kwargs) File 
"C:\Python36\lib\site-packages\django\utils\decorators.py", line 142, 
in _wrapped_view response = view_func(request, *args, **kwargs) File 
"C:\Python36\lib\site-packages\django\utils\decorators.py", line 58, 
in bound_func return func.__get__(self, type(self))(*args2, **kwargs2) 
File "C:\Python36\lib\site-packages\django\contrib\admin\options.py", 
line 1450, in changeform_view return self._changeform_view(request, 
object_id, form_url, extra_context) File 
"C:\Python36\lib\site-packages\django\contrib\admin\options.py", line 
1495, in _changeform_view return self.response_add(request, 
new_object) File 
"C:\Python36\lib\site-packages\django\contrib\admin\options.py", line 
1098, in response_add current_app=self.admin_site.name, File 
"C:\Python36\lib\site-packages\django\urls\base.py", line 88, in 
reverse return iri_to_uri(resolver._reverse_with_prefix(view, prefix, 
*args, **kwargs)) File 
"C:\Python36\lib\site-packages\django\urls\resolvers.py", line 632, in 
_reverse_with_prefix raise NoReverseMatch(msg) 
django.urls.exceptions.NoReverseMatch: Reverse for 
'nmm_tokenservice_userprofile_change' with arguments '('',)' not 
found. 1 pattern(s) tried: 
['admin/nmm_tokenservice\\/userprofile\\/(?P.+)\\/change\\/$']

* here is my model---*
class UserProfile(models.Model):
#base information
user = models.OneToOneField(User, on_delete=models.deletion.CASCADE, 
verbose_name='系统账户', related_name='profile')
uid = UIDField(verbose_name='用户ID', primary_key=True, editable=False, 
null=False, blank=False)
imuid = UIDField(verbose_name='IM用户ID', editable=False, null=True, 
blank=True)
nickname = models.CharField(verbose_name='昵称', max_length=20, 
null=True, blank=True, db_index=True)
tel = models.CharField(verbose_name='手机号码', max_length=20, null=True, 
blank=False)

#status and level
status = models.CharField(verbose_name='状态', max_length=20, 
null=False, blank=False, default=USER_STATUS[0][0], choices=USER_STATUS)
level = models.PositiveIntegerField(verbose_name='级别', null=False, 
blank=False, default=1, db_index=True)

#org information
city = CityCodeField(verbose_name='城市', null=True, blank=False)
org = CodeField(verbose_name='学校或组织机构代码', null=True, blank=True, 
db_index=True)
textbookcode = LabelCodeField(verbose_name='教材(标签代码)', 
help_text='请填写标签代码', null=True, blank=True, db_index=True)
gradecode = LabelCodeField(verbose_name='年级/级别(标签代码)', 
help_text='请填写标签代码', null=True, blank=True, db_index=True)

#role
role = UserRoleField(verbose_name='角色', null=False, blank=False, 
choices=UserRole_CHOICES, default=UserRole.user.name)

### teacher specific attributes ###
synopsis = models.TextField(verbose_name='个人简介', max_length=500, 
null=True, blank=True)
workhistory = models.TextField(verbose_name='工作经历', max_length=500, 
null=True, blank=True)
cert = models.TextField(verbose_name='荣誉证书', max_length=500, 
null=True, blank=True)
labels = models.CharField(verbose_name='个人标签', max_length=100, 
null=True, blank=True)
scope = models.CharField(verbose_name='出题范围', 
help_text='老师的出题范围,仅对老师角色有效', max_length=100, null=True, 
blank=True)
title = models.PositiveIntegerField(verbose_name='头衔级别', null=False, 
blank=False, default=1, db_index=True)

### promotion and relation ###
promotioncode = PromotionCodeField(verbose_name='推荐码', 
help_text='用于推荐其他用户或者老师', null=True, blank=True)
broker_pr

NoReverseMatch error raise when adding a new entry in django admin

2018-02-11 Thread Weifeng Pan
I got this wired issue. who can help.

Python 3.6
Django Latest 2.0.2

following are stack trace---
Internal Server Error: /admin/nmm_tokenservice/userprofile/add/ Traceback 
(most recent call last): File 
"C:\Python36\lib\site-packages\django\core\handlers\exception.py", line 35, 
in inner response = get_response(request) File 
"C:\Python36\lib\site-packages\django\core\handlers\base.py", line 128, in 
_get_response response = self.process_exception_by_middleware(e, request) 
File "C:\Python36\lib\site-packages\django\core\handlers\base.py", line 
126, in _get_response response = wrapped_callback(request, *callback_args, 
**callback_kwargs) File 
"C:\Python36\lib\site-packages\django\contrib\admin\options.py", line 574, 
in wrapper return self.admin_site.admin_view(view)(*args, **kwargs) File 
"C:\Python36\lib\site-packages\django\utils\decorators.py", line 142, in 
_wrapped_view response = view_func(request, *args, **kwargs) File 
"C:\Python36\lib\site-packages\django\views\decorators\cache.py", line 44, 
in _wrapped_view_func response = view_func(request, *args, **kwargs) File 
"C:\Python36\lib\site-packages\django\contrib\admin\sites.py", line 223, in 
inner return view(request, *args, **kwargs) File 
"C:\Python36\lib\site-packages\django\contrib\admin\options.py", line 1553, 
in add_view return self.changeform_view(request, None, form_url, 
extra_context) File 
"C:\Python36\lib\site-packages\django\utils\decorators.py", line 62, in 
_wrapper return bound_func(*args, **kwargs) File 
"C:\Python36\lib\site-packages\django\utils\decorators.py", line 142, in 
_wrapped_view response = view_func(request, *args, **kwargs) File 
"C:\Python36\lib\site-packages\django\utils\decorators.py", line 58, in 
bound_func return func.__get__(self, type(self))(*args2, **kwargs2) File 
"C:\Python36\lib\site-packages\django\contrib\admin\options.py", line 1450, 
in changeform_view return self._changeform_view(request, object_id, 
form_url, extra_context) File 
"C:\Python36\lib\site-packages\django\contrib\admin\options.py", line 1495, 
in _changeform_view return self.response_add(request, new_object) File 
"C:\Python36\lib\site-packages\django\contrib\admin\options.py", line 1098, 
in response_add current_app=self.admin_site.name, File 
"C:\Python36\lib\site-packages\django\urls\base.py", line 88, in reverse 
return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, 
**kwargs)) File "C:\Python36\lib\site-packages\django\urls\resolvers.py", 
line 632, in _reverse_with_prefix raise NoReverseMatch(msg) 
django.urls.exceptions.NoReverseMatch: Reverse for 
'nmm_tokenservice_userprofile_change' with arguments '('',)' not found. 1 
pattern(s) tried: 
['admin/nmm_tokenservice\\/userprofile\\/(?P.+)\\/change\\/$']

* here is my model---*
class UserProfile(models.Model):
#base information
user = models.OneToOneField(User, on_delete=models.deletion.CASCADE, 
verbose_name='系统账户', related_name='profile')
uid = UIDField(verbose_name='用户ID', primary_key=True, editable=False, null=
False, blank=False)
imuid = UIDField(verbose_name='IM用户ID', editable=False, null=True, blank=
True)
nickname = models.CharField(verbose_name='昵称', max_length=20, null=True, 
blank=True, db_index=True)
tel = models.CharField(verbose_name='手机号码', max_length=20, null=True, blank=
False)
#status and level
status = models.CharField(verbose_name='状态', max_length=20, null=False, 
blank=False, default=USER_STATUS[0][0], choices=USER_STATUS)
level = models.PositiveIntegerField(verbose_name='级别', null=False, blank=
False, default=1, db_index=True)
#org information
city = CityCodeField(verbose_name='城市', null=True, blank=False)
org = CodeField(verbose_name='学校或组织机构代码', null=True, blank=True, db_index=
True)
textbookcode = LabelCodeField(verbose_name='教材(标签代码)', help_text='请填写标签代码', 
null=True, blank=True, db_index=True)
gradecode = LabelCodeField(verbose_name='年级/级别(标签代码)', help_text='请填写标签代码', 
null=True, blank=True, db_index=True)
#role
role = UserRoleField(verbose_name='角色', null=False, blank=False, 
choices=UserRole_CHOICES, 
default=UserRole.user.name)
### teacher specific attributes ###
synopsis = models.TextField(verbose_name='个人简介', max_length=500, null=True, 
blank=True)
workhistory = models.TextField(verbose_name='工作经历', max_length=500, null=
True, blank=True)
cert = models.TextField(verbose_name='荣誉证书', max_length=500, null=True, 
blank=True)
labels = models.CharField(verbose_name='个人标签', max_length=100, null=True, 
blank=True)
scope = models.CharField(verbose_name='出题范围', help_text='老师的出题范围,仅对老师角色有效', 
max_length=100, null=True, blank=True)
title = models.PositiveIntegerField(verbose_name='头衔级别', null=False, blank=
False, default=1, db_index=True)
### promotion and relation ###
promotioncode = PromotionCodeField(verbose_name='推荐码', help_text=
'用于推荐其他用户或者老师', null=True, blank=True)
broker_promote = UIDField(verbose_name='推荐者用户ID', null=True, blank=True, 
db_index=True)
broker_firstserve = UIDFiel

Re: NoReverseMatch Error using Django + Haystack + Elasticsearch

2016-10-15 Thread Aline C. R. Souza
Thank you for your time, Constantine. 

I gave up on following this path. 

I threw away everything that I did on this matter, and I followed the steps 
of this link: http://django-haystack.readthedocs.io/en/v2.5.0/tutorial.html

It took me some time to understand, but now it is working fine.

Thank you.

Em sábado, 15 de outubro de 2016 04:43:21 UTC-3, Constantine Covtushenko 
escreveu:
>
> Hi Aline,
>
> I did not use Haystack but I am using ElastickSearch.
> I carefully read you post on StackOverflow and see that search form 
> returns author of the post without `pk` key defined.
>
> Did you check what is returned by ElastickSearch?
> May be your SearchForm returns exactly what Elastick stores in its index? 
> I mean that post returned by SearchForm not the same as Post model? It can 
> be dictionary or something?
>
> Sorry I do not have time to build test app to check my idea.
>
> You can easily set up a break point and check what are the posts inside 
> your `post_search` view function.
>
> Regards,
> Constantine C.
>
> On Sat, Oct 15, 2016 at 12:48 AM, Aline C. R. Souza  > wrote:
>
>> Hello everybody,
>>
>> I am having a issue using Django + Haystack + Elasticsearch to perform a 
>> website search.
>>
>> I made a question on StackOverflow, but I had no satisfatory answer.
>>
>> The problem is in this line:
>>
>> by {{ post.author 
>> }}
>>
>> post.author.pk works well when called by several views, but it is not 
>> resolved when called by the search.
>>
>> There is another way to get the pk of the author of the post?
>>
>> The link of the StackOverflow question: 
>> http://stackoverflow.com/questions/40033039/noreversematch-error-using-haystack-elasticsearch
>>
>> Can someone help me? Please explain in details, because I am new in 
>> Django, and in haystack, elasticsearch...
>>
>>
>> -- 
>> 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/fb151afb-35a8-4ac4-a9e4-69f4419568c1%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/fb151afb-35a8-4ac4-a9e4-69f4419568c1%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> 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/63bae927-7d3c-4b5e-9355-a15937520e67%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NoReverseMatch Error using Django + Haystack + Elasticsearch

2016-10-15 Thread Constantine Covtushenko
Hi Aline,

I did not use Haystack but I am using ElastickSearch.
I carefully read you post on StackOverflow and see that search form returns
author of the post without `pk` key defined.

Did you check what is returned by ElastickSearch?
May be your SearchForm returns exactly what Elastick stores in its index? I
mean that post returned by SearchForm not the same as Post model? It can be
dictionary or something?

Sorry I do not have time to build test app to check my idea.

You can easily set up a break point and check what are the posts inside
your `post_search` view function.

Regards,
Constantine C.

On Sat, Oct 15, 2016 at 12:48 AM, Aline C. R. Souza 
wrote:

> Hello everybody,
>
> I am having a issue using Django + Haystack + Elasticsearch to perform a
> website search.
>
> I made a question on StackOverflow, but I had no satisfatory answer.
>
> The problem is in this line:
>
> by {{ post.author
> }}
>
> post.author.pk works well when called by several views, but it is not
> resolved when called by the search.
>
> There is another way to get the pk of the author of the post?
>
> The link of the StackOverflow question: http:/
> /stackoverflow.com/questions/40033039/noreversematch-error-
> using-haystack-elasticsearch
>
> Can someone help me? Please explain in details, because I am new in
> Django, and in haystack, elasticsearch...
>
>
> --
> 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/fb151afb-35a8-4ac4-a9e4-69f4419568c1%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/fb151afb-35a8-4ac4-a9e4-69f4419568c1%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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/CAK52boUrkqTgVTjcDqrFqoDeH0nO56HiSJ9HKvncu9bP%3DDF_Eg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


NoReverseMatch Error using Django + Haystack + Elasticsearch

2016-10-14 Thread Aline C. R. Souza
Hello everybody,

I am having a issue using Django + Haystack + Elasticsearch to perform a 
website search.

I made a question on StackOverflow, but I had no satisfatory answer.

The problem is in this line:

by {{ post.author 
}}

post.author.pk works well when called by several views, but it is not 
resolved when called by the search.

There is another way to get the pk of the author of the post?

The link of the StackOverflow question: 
http://stackoverflow.com/questions/40033039/noreversematch-error-using-haystack-elasticsearch

Can someone help me? Please explain in details, because I am new in Django, 
and in haystack, elasticsearch...


-- 
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/fb151afb-35a8-4ac4-a9e4-69f4419568c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NoReverseMatch error in django 1.8

2015-09-27 Thread Gergely Polonkai
Hello,

the bookp route requires a user and a book_id parameter. Unless you supply
that, your {% url %} tag won't match.

Best,
Gergely
On 27 Sep 2015 12:49, "hossein"  wrote:

> this is my views and url.py
> as long as use  tag in my template show error
>
> url
>
> urlpatterns = [
> url(r'^bookee/$', views.index, name='index'),
> url(r'^bookee/user/(?P[a-z0-9-._@+]\w+)/$', views.uprofile, 
> name='userprofile'),
> url(r'^bookee/user/(?P[a-z0-9-._@+]\w+)/book/(?P\d)/$', 
> views.bookprof, name='bookp'),
> 
> url(r'^bookee/user/(?P[a-z0-9-._@+]\w+)/publisher/(?P\d)/$', 
> views.publishprof, name='publishep'),
> ]
>
>
>
> view
>
> def uprofile(request, user):
> usr = User.objects.get(username=user)
> book = Book.objects.filter(user=usr)
> return render(request, 'u/uprof.html', {'usr': usr, 'book': book})
>
> def bookprof(request, user, bookid):
> usr = User.objects.get(username=user)
> bookid = Book.objects.get(id=bookid)
> # bookd = Book.objects.filter(id=bookid)
> return render(request, 'u/uprof.html', {'usr':usr,'bookid': bookid})
>
> def publishprof(request, user, publishid):
> usr = User.objects.get(username=user)
> pubid = Publisher.objects.get(id=publishid)
> publisher = Publisher.objects.filter(id=pubid)
> return render(request, 'u/uprof.html', {'usr':usr,'publisher': publisher})
>
> template
>
> 
> 
> list of books
> 
> 
>
> NoReverseMatch at /bookee/user/admin/
> Reverse for 'bookp' with arguments '()' and keyword arguments '{}' not found. 
> 1 pattern(s) tried: 
> ['bookee/user/(?P[a-z0-9-._@+]\\w+)/book/(?P\\d)/$']
>
>
> thanks for your 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a9092ae0-ff31-467c-ab25-e8418d82270d%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACczBUJeMpAy%2Bqm6c0_Z5c3ihTcdT3eGnEnZD8fUMaFHq93DRw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


NoReverseMatch error in django 1.8

2015-09-27 Thread hossein
this is my views and url.py
as long as use  tag in my template show error

url

urlpatterns = [
url(r'^bookee/$', views.index, name='index'),
url(r'^bookee/user/(?P[a-z0-9-._@+]\w+)/$', views.uprofile, 
name='userprofile'),
url(r'^bookee/user/(?P[a-z0-9-._@+]\w+)/book/(?P\d)/$', 
views.bookprof, name='bookp'),

url(r'^bookee/user/(?P[a-z0-9-._@+]\w+)/publisher/(?P\d)/$', 
views.publishprof, name='publishep'),
]

 

view

def uprofile(request, user):
usr = User.objects.get(username=user)
book = Book.objects.filter(user=usr)
return render(request, 'u/uprof.html', {'usr': usr, 'book': book})

def bookprof(request, user, bookid):
usr = User.objects.get(username=user)
bookid = Book.objects.get(id=bookid)
# bookd = Book.objects.filter(id=bookid)
return render(request, 'u/uprof.html', {'usr':usr,'bookid': bookid})

def publishprof(request, user, publishid):
usr = User.objects.get(username=user)
pubid = Publisher.objects.get(id=publishid)
publisher = Publisher.objects.filter(id=pubid)
return render(request, 'u/uprof.html', {'usr':usr,'publisher': publisher})

template



list of books



NoReverseMatch at /bookee/user/admin/
Reverse for 'bookp' with arguments '()' and keyword arguments '{}' not found. 1 
pattern(s) tried: 
['bookee/user/(?P[a-z0-9-._@+]\\w+)/book/(?P\\d)/$']


thanks for your 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a9092ae0-ff31-467c-ab25-e8418d82270d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NoReverseMatch error

2014-10-19 Thread Daniel Grace
You were right Vijay.  I worked this out.  I needed to set type and state 
via the context as follows:

def get_context_data(self, **kwargs):
context = super(TestFlow, self).get_context_data(**kwargs)
context.update({'type': self.kwargs['type'], 'state': 
self.kwargs['state']})
return context

... then reference type and state in the url template tag:


-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ea14bda3-1e09-471f-bb2a-aacbc74e8b48%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NoReverseMatch error

2014-10-18 Thread Vijay Khemlani
I think you need to pass the "type" and "state" values in the {% url ... %}
tag

https://docs.djangoproject.com/en/1.7/ref/templates/builtins/#url

On Sat, Oct 18, 2014 at 6:06 PM, Daniel Grace  wrote:

> Hi,
> I get the following error on one of my view forms:
> Request Method: GET
> Request URL: http://127.0.0.1:8000/test/test_type_1/test_state_1/
> Django Version: 1.7
> Exception Type: NoReverseMatch
> Exception Value:
> Reverse for 'create-flow-params' with arguments '()' and keyword arguments
> '{}' not found. 1 pattern(s) tried:
> ['test/(?P\\w+)/(?P\\w+)/$']
>
> The url for this view is as follows:
> url(r'^test/(?P\w+)/(?P\w+)/$',
> login_required(views.TestFlow.as_view(success_url="/")),
> name='create-flow-params'),
>
> The html line which the error refers to is as follows:
> 
>
> I'm doing something wrong.  Any ideas?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/eb878a55-d514-4a6e-b234-8e368c07dfb3%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALn3ei2h5PG5E05cpX0zPQ5d1GvTneP_%3Dat58vy%2BJMGiyCw_Eg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


NoReverseMatch error

2014-10-18 Thread Daniel Grace
Hi,
I get the following error on one of my view forms:
Request Method: GET
Request URL: http://127.0.0.1:8000/test/test_type_1/test_state_1/
Django Version: 1.7
Exception Type: NoReverseMatch
Exception Value: 
Reverse for 'create-flow-params' with arguments '()' and keyword arguments 
'{}' not found. 1 pattern(s) tried: 
['test/(?P\\w+)/(?P\\w+)/$']

The url for this view is as follows:
url(r'^test/(?P\w+)/(?P\w+)/$', 
login_required(views.TestFlow.as_view(success_url="/")), 
name='create-flow-params'),

The html line which the error refers to is as follows:


I'm doing something wrong.  Any ideas?

Thanks

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


NoReverseMatch error: Reverse for 'lebay_view_user_profile' with arguments '('',)' and keyword arguments '{}' not found.

2014-07-04 Thread Niccolò Lancellotti
Hi guys, i'm new in this group. I'm trying to upgrade a django project i 
found on internet, called 'little ebay', from django 1.2 to 1.5. It is a 
very simple project, there are only few files.
i'm going to append them... please help me, i'm going ma with that.

i'm appending only two of the various templates, the two templates involved 
in the error

Thank you all.

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3104a0c9-e35b-48c3-b9d0-433f28c2a481%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
{% extends "base.html" %}

{% load uni_form_tags %}

{% block title %}View User{% endblock %}

{% block content %}
{% ifequal user request.user.user %}
This is you!
{% endifequal %}
{{ user.first_name }} {{ user.last_name }}
{% ifequal user request.user.user %}
Edit Profile
{% endifequal %} 
Email: {{ user.email }}
Address Line 1: {{ user.address_line_1 }}
{% if user.address_line_2 %}
Address Line 2: {{ user.address_line_2 }}
{% endif %}
City: {{ user.city }}
State: {{ user.state }}
Zip: {{ user.zipcode }}
Phone: {{ user.phone }}
{% endblock %}
import datetime
from decimal import Decimal

from django import forms
from django.conf import settings
from django.contrib.auth import authenticate
from django.core.urlresolvers import reverse
from django.db.models import Q
from django.forms.util import ValidationError
from django.contrib.admin import widgets as adminwidgets
from django.contrib.localflavor.us.forms import USPhoneNumberField, USZipCodeField

from lebay.apps.lebay.models import User, Seller, Item, AuctionEvent, Bid, Sales
from lebay.apps.lebay.constants import AUCTION_ITEM_STATUS_RUNNING

class UserLoginForm(forms.Form):
username = forms.CharField(label=u'User Name')
password = forms.CharField(label=u'Password', widget=forms.PasswordInput(render_value=False))

def clean(self):
cleaned_data = self.cleaned_data
username = cleaned_data.get('username', '')
password = cleaned_data.get('password', '')
user = authenticate(username=username, password=password)
if user is not None:
if not user.is_active:
raise ValidationError('This account is disable. Please constact the webmaster.') 
else:
raise ValidationError('Wrong username and or password. Try again.') 

return cleaned_data

def get_user(self):
username = self.cleaned_data.get('username', '')
password = self.cleaned_data.get('password', '')
user = authenticate(username=username, password=password)

return user

class AuctionSearchForm(forms.Form):
query = forms.CharField(max_length=200, required=False, label='')

def search(self):
cleaned_data = self.cleaned_data
cleaned_query = cleaned_data.get('query', '') 
if cleaned_query:
matching_auctions = AuctionEvent.objects.get_current_auctions().filter(Q(item__title__icontains=cleaned_query) | Q(item__description__icontains=cleaned_query))
else:
matching_auctions = AuctionEvent.objects.get_current_auctions()

return matching_auctions

class UserRegistrationForm(forms.ModelForm):
password = forms.CharField(label=u'Password', widget=forms.PasswordInput(render_value=False))
retyped_password = forms.CharField(label=u'Retype Password', widget=forms.PasswordInput(render_value=False))
zipcode = USZipCodeField()
phone = USPhoneNumberField()

def __init__(self, *args, **kwargs):
super(forms.ModelForm, self).__init__(*args, **kwargs)
self.fields.keyOrder = [
'username',
'first_name',
'last_name',
'email',
'password',
'retyped_password',
'address_line_1',
'address_line_2',
'city',
'state',
'zipcode',
'phone']

class Meta:
model = User
fields = ['username', 'first_name', 'last_name', 'email', 'password', 'address_line_1', 'address_line_2', 'city', 'state', 'zipcode', 'phone']

def clean(self):
cleaned_data = self.cleaned_data
password = cleaned_data.get('password', '')
retyped_password = cleaned_data.get('retyped_password', '')

if password != retyped_password:
raise ValidationError('Password and retyped password didn\'t match.')

return cleaned_data

def save(self, force_insert=False, force_update=False, commit=True, 

Re: NoReverseMatch error when following Django Tutorial

2014-06-22 Thread Jerry Wu
It works!  Thank you very much!

On Sunday, June 22, 2014 7:54:41 PM UTC+8, Noxxan wrote:
>
> Hi
> It looks like you have in polls/views.py whitespace in reverse function 
> ("polls: results"), try without it ('polls:results").
>
> On Sunday, June 22, 2014 10:53:12 AM UTC+2, Jerry Wu wrote:
>>
>> Dear every one,
>>
>> I am new to Python and Django and am following the Tutorial to start my 
>> first site. But I am getting an error of NoReverseMatch error when vote. It 
>> should be redirected but error below happened.
>>
>> NoReverseMatch at /polls/1/vote/
>>
>> Reverse for ' results' with arguments '(1,)' and keyword arguments '{}' not 
>> found. 0 pattern(s) tried: []
>>
>> Request Method:POSTRequest URL:http://localhost:8000/polls/1/vote/Django 
>> Version:1.6.5Exception Type:NoReverseMatchException Value:
>>
>> Reverse for ' results' with arguments '(1,)' and keyword arguments '{}' not 
>> found. 0 pattern(s) tried: []
>>
>> Exception 
>> Location:/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py
>>  
>> in _reverse_with_prefix, line 452Python Executable:
>> /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/PythonPython
>>  
>> Version:2.7.6Python Path:
>>
>> ['/Users/wctjerry/Dropbox/code/django/mysite',
>>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
>>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
>>  
>> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
>>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
>>  
>> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
>>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
>>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
>>  
>> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
>>  
>> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages',
>>  '/Library/Python/2.7/site-packages']
>>
>> Server time:Sun, 22 Jun 2014 08:38:56 +
>>
>>
>>
>> I am sure I finished namespace part in the end of Tutorial Part 3. And I 
>> checked code in Tutorial Part 4 
>> <https://docs.djangoproject.com/en/1.6/intro/tutorial04/>  again and 
>> again, seeming all the same. Here is my code, could any one give me some 
>> thoughts?
>>
>> Thanks.
>>
>> mysite/urls: http://pastebin.com/8armrsXC
>> polls/urls: http://pastebin.com/Tn1uFXi4
>> polls/views: http://pastebin.com/jhnnidQr
>> index.html: http://pastebin.com/S1XhmsBb
>> detail.html: http://pastebin.com/GTsV3D7D
>> results.html: http://pastebin.com/BtSf5teF
>>
>>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b73287f6-ea28-4c47-910b-93ab423708c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NoReverseMatch error when following Django Tutorial

2014-06-22 Thread Noxxan
Hi
It looks like you have in polls/views.py whitespace in reverse function 
("polls: results"), try without it ('polls:results").

On Sunday, June 22, 2014 10:53:12 AM UTC+2, Jerry Wu wrote:
>
> Dear every one,
>
> I am new to Python and Django and am following the Tutorial to start my 
> first site. But I am getting an error of NoReverseMatch error when vote. It 
> should be redirected but error below happened.
>
> NoReverseMatch at /polls/1/vote/
>
> Reverse for ' results' with arguments '(1,)' and keyword arguments '{}' not 
> found. 0 pattern(s) tried: []
>
> Request Method:POSTRequest URL:http://localhost:8000/polls/1/vote/Django 
> Version:1.6.5Exception Type:NoReverseMatchException Value:
>
> Reverse for ' results' with arguments '(1,)' and keyword arguments '{}' not 
> found. 0 pattern(s) tried: []
>
> Exception 
> Location:/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py
>  
> in _reverse_with_prefix, line 452Python Executable:
> /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/PythonPython
>  
> Version:2.7.6Python Path:
>
> ['/Users/wctjerry/Dropbox/code/django/mysite',
>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
>  
> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
>  
> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
>  
> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
>  
> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages',
>  '/Library/Python/2.7/site-packages']
>
> Server time:Sun, 22 Jun 2014 08:38:56 +
>
>
>
> I am sure I finished namespace part in the end of Tutorial Part 3. And I 
> checked code in Tutorial Part 4 
> <https://docs.djangoproject.com/en/1.6/intro/tutorial04/>  again and 
> again, seeming all the same. Here is my code, could any one give me some 
> thoughts?
>
> Thanks.
>
> mysite/urls: http://pastebin.com/8armrsXC
> polls/urls: http://pastebin.com/Tn1uFXi4
> polls/views: http://pastebin.com/jhnnidQr
> index.html: http://pastebin.com/S1XhmsBb
> detail.html: http://pastebin.com/GTsV3D7D
> results.html: http://pastebin.com/BtSf5teF
>
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/90503181-35b6-4cca-ac2b-5cd54b006435%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


NoReverseMatch error when following Django Tutorial

2014-06-22 Thread Jerry Wu
Dear every one,

I am new to Python and Django and am following the Tutorial to start my 
first site. But I am getting an error of NoReverseMatch error when vote. It 
should be redirected but error below happened.

NoReverseMatch at /polls/1/vote/

Reverse for ' results' with arguments '(1,)' and keyword arguments '{}' not 
found. 0 pattern(s) tried: []

Request Method:POSTRequest URL:http://localhost:8000/polls/1/vote/Django 
Version:1.6.5Exception Type:NoReverseMatchException Value:

Reverse for ' results' with arguments '(1,)' and keyword arguments '{}' not 
found. 0 pattern(s) tried: []

Exception 
Location:/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py
 
in _reverse_with_prefix, line 452Python Executable:
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/PythonPython
 
Version:2.7.6Python Path:

['/Users/wctjerry/Dropbox/code/django/mysite',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
 
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
 
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages',
 '/Library/Python/2.7/site-packages']

Server time:Sun, 22 Jun 2014 08:38:56 +



I am sure I finished namespace part in the end of Tutorial Part 3. And I 
checked code in Tutorial Part 4 
<https://docs.djangoproject.com/en/1.6/intro/tutorial04/>  again and again, 
seeming all the same. Here is my code, could any one give me some thoughts?

Thanks.

mysite/urls: http://pastebin.com/8armrsXC
polls/urls: http://pastebin.com/Tn1uFXi4
polls/views: http://pastebin.com/jhnnidQr
index.html: http://pastebin.com/S1XhmsBb
detail.html: http://pastebin.com/GTsV3D7D
results.html: http://pastebin.com/BtSf5teF

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f772a98a-7691-4c79-86de-87e950487719%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NoReverseMatch error on redirect

2014-01-14 Thread Brad Rice
I figured it out. I had a namespaced url so it needed:

return HttpResponseRedirect(reverse('requestform:registrant_add', 
kwargs={'app_id': obj.id}))

On Monday, January 13, 2014 12:22:59 PM UTC-5, Brad Rice wrote:
>
> I have a mulit-page form I am building. I get the start page to enter the 
> data for the application, validate and save. When I try using reverse to 
> move to the next page I get this error:
>
> NoReverseMatch at /requestform/start/Reverse for 'registrant_add' with 
> arguments '()' and keyword arguments '{'app_id': 11}' not found.
>
> I have this url in my urls.py
>
> url(r'^step1/(?P\d+)/$, RegistrantCreate.as_view(), 
> name="registrant_add"),
>
> I am trying to call the view this way:
>
> class ApplicationCreate(CreateView):
> model = Application
> form_class = ApplicationForm
> slug_field = 'created_by'
> template_name = 'requestform/start_form.html'
>
> @method_decorator(login_required)
> def dispatch(self, *args, **kwargs):
> return super(ApplicationCreate, self).dispatch(*args, **kwargs)
>
>
> def form_valid(self, form):
> obj = form.save(commit=False)
> obj.created_by = self.request.user
> obj.created = datetime.datetime.today()
> obj.modified = datetime.datetime.today()
> obj.save()
> return HttpResponseRedirect(reverse('registrant_add', 
> kwargs={'app_id': obj.id}))
>
> Why doesn't django recognize the named url 'registrant_add' and redirect 
> to 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c8908fe0-1b86-4dcb-a977-cb4a6c999186%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


NoReverseMatch error on redirect

2014-01-13 Thread Brad Rice
I have a mulit-page form I am building. I get the start page to enter the 
data for the application, validate and save. When I try using reverse to 
move to the next page I get this error:

NoReverseMatch at /requestform/start/Reverse for 'registrant_add' with 
arguments '()' and keyword arguments '{'app_id': 11}' not found.

I have this url in my urls.py

url(r'^step1/(?P\d+)/$, RegistrantCreate.as_view(), 
name="registrant_add"),

I am trying to call the view this way:

class ApplicationCreate(CreateView):
model = Application
form_class = ApplicationForm
slug_field = 'created_by'
template_name = 'requestform/start_form.html'

@method_decorator(login_required)
def dispatch(self, *args, **kwargs):
return super(ApplicationCreate, self).dispatch(*args, **kwargs)


def form_valid(self, form):
obj = form.save(commit=False)
obj.created_by = self.request.user
obj.created = datetime.datetime.today()
obj.modified = datetime.datetime.today()
obj.save()
return HttpResponseRedirect(reverse('registrant_add', 
kwargs={'app_id': obj.id}))

Why doesn't django recognize the named url 'registrant_add' and redirect to 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a7a2ad99-0be5-4aa8-8c1f-05fc3e0b85c0%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Yet Another NoReverseMatch Error

2013-05-13 Thread Tom Evans
On Mon, May 13, 2013 at 3:34 PM, Neil Chaudhuri  wrote:
> Oh sorry I wasn't clear. The first time I typed the patterns function call 
> out. So in other words, the %s was in there all along. I just misrepresented 
> it in my question. Things are failing even with the correct call and have 
> been all along.
>
> Could you provide more details about how I can double-check the urlconf and 
> follow the includes down?
>
> Thanks.
>

So, the url conf hierarchy starts with whatever is specified in
settings.ROOT_URLCONF. This urlconf includes other urlconfs, trace the
includes down from the top level and verify that this urlconf that
your url is being defined in is actually included in the project.

A simple way of doing this is ensuring that the view is available (and
runs) if you directly go to that url.

This is not necessarily meant to find anything, it is just verifying
that everything is actually set up as you think it is.

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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Yet Another NoReverseMatch Error

2013-05-13 Thread Neil Chaudhuri
Oh sorry I wasn't clear. The first time I typed the patterns function call out. 
So in other words, the %s was in there all along. I just misrepresented it in 
my question. Things are failing even with the correct call and have been all 
along.

Could you provide more details about how I can double-check the urlconf and 
follow the includes down? 

Thanks.


On May 13, 2013, at 10:31 AM, Tom Evans  wrote:

> On Mon, May 13, 2013 at 3:19 PM, Neil Chaudhuri  wrote:
>> Good catch. That was a typo. Let me cut and paste directly:
>> 
>> urlpatterns = patterns("apps.popular_keywords.views",
>>   url("^%skeyword/(?P.*)%s$" % _slashes, 
>> "matching_items_list", name="matching_items")
>> )
>> 
>> Perhaps I should try some of your coffee.
>> 
>> Thanks.
> 
> Does that make it work or does it still fail to reverse? I'm running
> out of trouble shooting ideas - double check that the urlconf is
> actually being used - start at the project level urlconf, and follow
> the includes down.
> 
> Cheers
> 
> Tom
> 
> -- 
> 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/y_G3Zirkn7s/unsubscribe?hl=en.
> 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 http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> 

-- 
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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Yet Another NoReverseMatch Error

2013-05-13 Thread Tom Evans
On Mon, May 13, 2013 at 3:19 PM, Neil Chaudhuri  wrote:
> Good catch. That was a typo. Let me cut and paste directly:
>
> urlpatterns = patterns("apps.popular_keywords.views",
>url("^%skeyword/(?P.*)%s$" % _slashes, 
> "matching_items_list", name="matching_items")
> )
>
> Perhaps I should try some of your coffee.
>
> Thanks.

Does that make it work or does it still fail to reverse? I'm running
out of trouble shooting ideas - double check that the urlconf is
actually being used - start at the project level urlconf, and follow
the includes down.

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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Yet Another NoReverseMatch Error

2013-05-13 Thread Neil Chaudhuri
Good catch. That was a typo. Let me cut and paste directly:

urlpatterns = patterns("apps.popular_keywords.views",
   url("^%skeyword/(?P.*)%s$" % _slashes, 
"matching_items_list", name="matching_items")
)

Perhaps I should try some of your coffee.

Thanks.


On May 13, 2013, at 10:17 AM, Tom Evans  wrote:

> On Sun, May 12, 2013 at 9:08 AM,   wrote:
>> I have an app within my project called popular_keywords.
>> 
>> Within urls.py I have this:
>> 
>> urlpatterns = patterns("apps.popular_keywords.views",
>>   url("^%keyword/(?P.*)%s$" % _slashes,
>> "matching_items_list", name="matching_items")
>> )
> 
> I hadn't had my coffee when I first saw this. This isn't a valid string 
> format:
> 
>  "^%keyword/(?P.*)%s$"
> 
> Probably just missing a 's' from the first format specifier, eg '^%skeyword…'.
> 
> Does it work correctly if you fix the format string?
> 
> Cheers
> 
> Tom
> 
> -- 
> 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/y_G3Zirkn7s/unsubscribe?hl=en.
> 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 http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> 

-- 
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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Yet Another NoReverseMatch Error

2013-05-13 Thread Tom Evans
On Sun, May 12, 2013 at 9:08 AM,   wrote:
> I have an app within my project called popular_keywords.
>
> Within urls.py I have this:
>
> urlpatterns = patterns("apps.popular_keywords.views",
>url("^%keyword/(?P.*)%s$" % _slashes,
> "matching_items_list", name="matching_items")
> )

I hadn't had my coffee when I first saw this. This isn't a valid string format:

  "^%keyword/(?P.*)%s$"

Probably just missing a 's' from the first format specifier, eg '^%skeyword…'.

Does it work correctly if you fix the format string?

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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Yet Another NoReverseMatch Error

2013-05-13 Thread Neil Chaudhuri
Here is slashes:

_slashes = (
"/" if settings.BLOG_SLUG else "",
"/" if settings.APPEND_SLASH else "",
)

Thanks.


On May 13, 2013, at 4:28 AM, Tom Evans  wrote:

> On Sun, May 12, 2013 at 9:08 AM,   wrote:
>> I have an app within my project called popular_keywords.
>> 
>> Within urls.py I have this:
>> 
>> urlpatterns = patterns("apps.popular_keywords.views",
>>   url("^%keyword/(?P.*)%s$" % _slashes,
>> "matching_items_list", name="matching_items")
>> )
>> 
> 
> What is the contents of _slashes?
> 
> 
> Cheers
> 
> Tom
> 
> -- 
> 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/y_G3Zirkn7s/unsubscribe?hl=en.
> 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 http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> 

-- 
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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Yet Another NoReverseMatch Error

2013-05-13 Thread Tom Evans
On Sun, May 12, 2013 at 9:08 AM,   wrote:
> I have an app within my project called popular_keywords.
>
> Within urls.py I have this:
>
> urlpatterns = patterns("apps.popular_keywords.views",
>url("^%keyword/(?P.*)%s$" % _slashes,
> "matching_items_list", name="matching_items")
> )
>

What is the contents of _slashes?


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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Yet Another NoReverseMatch Error

2013-05-12 Thread neil
I have an app within my project called popular_keywords. 

Within *urls.py* I have this:

*urlpatterns = patterns("apps.popular_keywords.views",*
*   url("^%keyword/(?P.*)%s$" % _slashes, 
"matching_items_list", **name="matching_items")*
*)*


Within *views.py* I have this function:

*def matching_items_list(request, keyword=None, 
template="popular_keywords/keyword_matched_list.html")*



In my template I have this:

**
*
*
*
*
The problem is when I view my page I find this:


*NoReverseMatch at /*

*Reverse for 'matching_items' with arguments '()' and keyword arguments 
'{u'keyword': 'Cake'}' not found.*

*
*

I thought I had my bases covered, but as a Django noob, I would appreciate help 
on whatever silly thing I missed. Please let me know if I need to provide more 
information.


Thanks.






-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: NoReverseMatch Error

2012-08-25 Thread Karen Tracey
On Sat, Aug 25, 2012 at 1:28 AM, Syam Palakurthy
wrote:

> Hi, Can you please elaborate on how to use this block in the template
> code?  I've tried adding this into my details template code in various
> places and cannot get it to successfully work.  Also, any
> suggestions/examples you could point me to would be much appreciated.
>
>
Sorry, it's {% load url from future %}, not import. Brain misfired and put
Python word in place of Django template language.

See the forward compatibility note here:
https://docs.djangoproject.com/en/1.3/ref/templates/builtins/#url

Karen
-- 
http://tracey.org/kmt/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: NoReverseMatch Error

2012-08-24 Thread Syam Palakurthy
Hi, Can you please elaborate on how to use this block in the template code? 
 I've tried adding this into my details template code in various places and 
cannot get it to successfully work.  Also, any suggestions/examples you 
could point me to would be much appreciated.

{{ poll.question }}

{% if error_message %}{{ error_message }}{% endif %}


{% import url from future %}


{% csrf_token %}
{% for choice in poll.choice_set.all %}


{{ choice.choice_text 
}}
{% endfor %}



Thanks,
Syam

On Wednesday, August 15, 2012 4:53:23 AM UTC-7, Karen Tracey wrote:
>
> On Tue, Aug 14, 2012 at 10:46 AM, Serge G. Spaolonzi 
> 
> > wrote:
>
>> Try removing the quotes from 'polls.views.vote':
>>
>> 
>>
>>
>>
> Note that will work for 1.4 but it's doing things the old way, and that 
> will break in 1.5. Much better to add {% import url from future %} and have 
> code that will continue to work with the next release of Django. Removing 
> the quotes is not the best approach at this time.
>  
> Karen
> -- 
> http://tracey.org/kmt/
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/La3h_D5OnOQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: NoReverseMatch Error

2012-08-15 Thread Karen Tracey
On Tue, Aug 14, 2012 at 10:46 AM, Serge G. Spaolonzi wrote:

> Try removing the quotes from 'polls.views.vote':
>
> 
>
>
>
Note that will work for 1.4 but it's doing things the old way, and that
will break in 1.5. Much better to add {% import url from future %} and have
code that will continue to work with the next release of Django. Removing
the quotes is not the best approach at this time.

Karen
-- 
http://tracey.org/kmt/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: NoReverseMatch Error

2012-08-14 Thread Serge G. Spaolonzi
Try removing the quotes from 'polls.views.vote':



Regards

-- 
Serge G. Spaolonzi
Cobalys Systems
http://www.cobalys.com


On Mon, Aug 13, 2012 at 11:46 PM, Syam Palakurthy
wrote:

> Hi - I could not find any explanation that fixed the problem, until I ran
> across this person's abridged Django tutorial:
> http://tony.abou-assaleh.net/web-development/stripped-down-django-tutorial
>
> It's basically a line in the details template, which should be:
>
> 
>
>
> Instead of:
>
> 
>
>
> I'm not sure why this fixed the issue, but it did for me.  I'd love an
> explanation if anyone has one.
>
> Thanks,
> Syam
>
> On Thursday, June 9, 2011 12:28:30 AM UTC-7, bh.hoseini wrote:
>>
>> hi there,
>> this is my views.py that doesn't have any problem:
>>
>> from django.shortcuts import get_object_or_404, render_to_response
>> from django.core.urlresolvers import reverse
>> .
>> .
>> .
>> return HttpResponseRedirect(reverse('**polls.views.results',
>> args=(p.id,)))
>>
>> def results(request, poll_id):
>> p = get_object_or_404(Poll, pk=poll_id)
>> return render_to_response('(...)/**polls/results.html', {'poll': p})
>> --**--**
>> --**--
>> but when i edit my urls.py like this:
>>
>> #...
>> urlpatterns = patterns('',
>> (r'^$',
>> ListView.as_view(
>> queryset=Poll.objects.order_**by('-pub_date')[:5],
>> context_object_name='latest_**poll_list',
>> template_name='(...)polls/**index.html')),
>> (r'^(?P\d+)/$',
>> DetailView.as_view(
>> model=Poll,
>> template_name='(...)polls/**detail.html')),
>> url(r'^(?P\d+)/results/$',
>> DetailView.as_view(
>> model=Poll,
>> template_name='(...)polls/**results.html'),
>> name='poll_results'),
>> (r'^(?P\d+)/vote/$', 'polls.views.vote'),
>> --**--**
>> --**
>> and open my browser with the link (http://localhost:8000/polls/**
>> id=1/vote ), I'd face this error:
>> can anybody help please?
>>
>> Reverse for 'polls.views.results' with arguments '(id=1,)' and keyword 
>> arguments '{}' not found.
>>
>> can anybody help?
>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/2MW2j_RVlfYJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: NoReverseMatch Error

2012-08-13 Thread Karen Tracey
On Mon, Aug 13, 2012 at 10:46 PM, Syam Palakurthy
wrote:

> Hi - I could not find any explanation that fixed the problem, until I ran
> across this person's abridged Django tutorial:
> http://tony.abou-assaleh.net/web-development/stripped-down-django-tutorial
>
> It's basically a line in the details template, which should be:
>
> 
>
>
> Instead of:
>
> 
>
>
> I'm not sure why this fixed the issue, but it did for me.  I'd love an
> explanation if anyone has one.
>
>
This is not a typo in the tutorial. The {% url %} variant is a faily recent
update to the current  development level of the online docs. It was added
in order to show in the tutorial best practices: url reversal by name
rather than hard-coding url paths in the template. However, it uses the {%
url %} tag syntax that is correct for the upcoming Django release, 1.5. In
order for that syntax (specifically, the quotes around polls.views.vote) to
work in the 1.4 released version, the template would also have to include
{% import url from future %}. This "from future" import is not necessary in
the current development level of code, so was not included when this change
to demonstrate how to use {% url %} was added to the tutorial development
level. However it seems that many many many people are running through the
development-level doc with the 1.4- released level code, so perhaps we
should add a note here (or more prominently elsewhere) to please be sure
you run through the online version of the tutorial that matches the level
of code you are running.

Karen

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: NoReverseMatch Error

2012-08-13 Thread Syam Palakurthy
Hi - I could not find any explanation that fixed the problem, until I ran 
across this person's abridged Django 
tutorial: 
http://tony.abou-assaleh.net/web-development/stripped-down-django-tutorial

It's basically a line in the details template, which should be:




Instead of:




I'm not sure why this fixed the issue, but it did for me.  I'd love an 
explanation if anyone has one.

Thanks,
Syam

On Thursday, June 9, 2011 12:28:30 AM UTC-7, bh.hoseini wrote:
>
> hi there,
> this is my views.py that doesn't have any problem:
>  
> from django.shortcuts import get_object_or_404, render_to_response
> from django.core.urlresolvers import reverse
> .
> .
> .
> return HttpResponseRedirect(reverse('polls.views.results', args=(
> p.id,)))
>
> def results(request, poll_id):
> p = get_object_or_404(Poll, pk=poll_id)
> return render_to_response('(...)/polls/results.html', {'poll': p})
>
> 
> but when i edit my urls.py like this:
>
> #...
> urlpatterns = patterns('',
> (r'^$',
> ListView.as_view(
> queryset=Poll.objects.order_by('-pub_date')[:5],
> context_object_name='latest_poll_list',
> template_name='(...)polls/index.html')),
> (r'^(?P\d+)/$',
> DetailView.as_view(
> model=Poll,
> template_name='(...)polls/detail.html')),
> url(r'^(?P\d+)/results/$',
> DetailView.as_view(
> model=Poll,
> template_name='(...)polls/results.html'),
> name='poll_results'),
> (r'^(?P\d+)/vote/$', 'polls.views.vote'),
>
> --
> and open my browser with the link (http://localhost:8000/polls/id=1/vote), 
> I'd face this error: can anybody help please?
>
> Reverse for 'polls.views.results' with arguments '(id=1,)' and keyword 
> arguments '{}' not found.
>
> can anybody help?
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/2MW2j_RVlfYJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



NoReverseMatch error and serializers

2012-05-20 Thread .
Hello,

I have two local repos. The only difference between them is their DBs.
I'm trying to copy some tables from one DB to another via XML-RPC and
serializers.
I call my XML-RPC method from the shell. It returns a str
(serializer). Then I'm trying to deserialize that string:

for x in serializers.deserialize("xml", mydata):
  x.save()

But I get a NoReverseMatch error.

I've already checked my URLconf. Patterns look fine.
I've also read that it can be connected with encoding (if you're using
MySQL). But I'm using SQLite.

How to get rid of this error?


Regards

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



recent 1.3.1 upgrade - admin panel throwing NoReverseMatch error now

2011-10-18 Thread Nick Nachefski
Hello,



I've recently upgraded to 1.3.1 and am getting a NoReverseMatch exception with 
piston when attempting to view my admin panel.  Has anyone else seen this with 
1.3.1?



Here is the relevant url.py config for my piston:



blah_resource = Resource(handler=BLAH)

urlpatterns = patterns('',

   url(r'^status$', blah_resource, { 'emitter_format': 'json' }),

   )





Traceback (most recent call last):



  File "/usr/lib/python2.6/dist-packages/django/core/handlers/base.py", line 
111, in get_response

response = callback(request, *callback_args, **callback_kwargs)



  File "/usr/lib/python2.6/dist-packages/django/contrib/admin/sites.py", line 
209, in wrapper

return self.admin_view(view, cacheable)(*args, **kwargs)



  File "/usr/lib/python2.6/dist-packages/django/utils/decorators.py", line 91, 
in _wrapped_view

response = view_func(request, *args, **kwargs)



  File "/usr/lib/python2.6/dist-packages/django/views/decorators/cache.py", 
line 88, in _wrapped_view_func

response = view_func(request, *args, **kwargs)



  File "/usr/lib/python2.6/dist-packages/django/contrib/admin/sites.py", line 
192, in inner

return view(request, *args, **kwargs)



  File "/usr/lib/python2.6/dist-packages/django/views/decorators/cache.py", 
line 88, in _wrapped_view_func

response = view_func(request, *args, **kwargs)



  File "/usr/lib/python2.6/dist-packages/django/contrib/admin/sites.py", line 
345, in index

'admin_url': reverse('admin:%s_%s_changelist' % info, 
current_app=self.name),



  File "/usr/lib/python2.6/dist-packages/django/core/urlresolvers.py", line 
473, in reverse

(prefix, resolver.reverse(view, *args, **kwargs)))



  File "/usr/lib/python2.6/dist-packages/django/core/urlresolvers.py", line 
392, in reverse

"arguments '%s' not found." % (lookup_view_s, args, kwargs))



NoReverseMatch: Reverse for 'piston_token_changelist' with arguments '()' and 
keyword arguments '{}' not found.


Any help would be greatly appreciated.


Note: This email is for the confidential use of the named addressee(s) only and 
may contain proprietary, confidential or privileged information. If you are not 
the intended recipient, you are hereby notified that any review, dissemination 
or copying of this email is strictly prohibited, and to please notify the 
sender immediately and destroy this email and any attachments. Email 
transmission cannot be guaranteed to be secure or error-free. Jump Trading, 
therefore, does not make any guarantees as to the completeness or accuracy of 
this email or any attachments. This email is for informational purposes only 
and does not constitute a recommendation, offer, request or solicitation of any 
kind to buy, sell, subscribe, redeem or perform any type of transaction of a 
financial product.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: NoReverseMatch Error

2011-06-09 Thread krzysiekpl
Hi,

Look at this:

https://docs.djangoproject.com/en/dev/topics/http/urls/#reverse

`viewname` is incorrect in your app you must use 'poll_results'
instead of 'polls.views.results'


Krzysztof Hoffmann


On 9 Cze, 09:28, bahare hoseini  wrote:
> hi there,
> this is my views.py that doesn't have any problem:
>
> from django.shortcuts import get_object_or_404, render_to_response
> from django.core.urlresolvers import reverse
> .
> .
> .
>         return HttpResponseRedirect(reverse('polls.views.results', args=(
> p.id,)))
>
> def results(request, poll_id):
>     p = get_object_or_404(Poll, pk=poll_id)
>     return render_to_response('(...)/polls/results.html', {'poll': p})
> --- 
> -
> but when i edit my urls.py like this:
>
> #...
> urlpatterns = patterns('',
>     (r'^$',
>         ListView.as_view(
>             queryset=Poll.objects.order_by('-pub_date')[:5],
>             context_object_name='latest_poll_list',
>             template_name='(...)polls/index.html')),
>     (r'^(?P\d+)/$',
>         DetailView.as_view(
>             model=Poll,
>             template_name='(...)polls/detail.html')),
>     url(r'^(?P\d+)/results/$',
>         DetailView.as_view(
>             model=Poll,
>             template_name='(...)polls/results.html'),
>         name='poll_results'),
>     (r'^(?P\d+)/vote/$', 'polls.views.vote'),
> --- 
> ---
> and open my browser with the link (http://localhost:8000/polls/id=1/vote),
> I'd face this error: can anybody help please?
>
> Reverse for 'polls.views.results' with arguments '(id=1,)' and keyword
> arguments '{}' not found.
>
> can anybody help?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



NoReverseMatch Error

2011-06-09 Thread bahare hoseini
hi there,
this is my views.py that doesn't have any problem:

from django.shortcuts import get_object_or_404, render_to_response
from django.core.urlresolvers import reverse
.
.
.
return HttpResponseRedirect(reverse('polls.views.results', args=(
p.id,)))

def results(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
return render_to_response('(...)/polls/results.html', {'poll': p})

but when i edit my urls.py like this:

#...
urlpatterns = patterns('',
(r'^$',
ListView.as_view(
queryset=Poll.objects.order_by('-pub_date')[:5],
context_object_name='latest_poll_list',
template_name='(...)polls/index.html')),
(r'^(?P\d+)/$',
DetailView.as_view(
model=Poll,
template_name='(...)polls/detail.html')),
url(r'^(?P\d+)/results/$',
DetailView.as_view(
model=Poll,
template_name='(...)polls/results.html'),
name='poll_results'),
(r'^(?P\d+)/vote/$', 'polls.views.vote'),
--
and open my browser with the link (http://localhost:8000/polls/id=1/vote),
I'd face this error: can anybody help please?

Reverse for 'polls.views.results' with arguments '(id=1,)' and keyword
arguments '{}' not found.

can anybody help?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: NoReverseMatch error when attempting to spawn an intermediate window from an admin action

2010-08-19 Thread Guy
I realize that I must have hit reply to author earlier.   But thank
you again (and more publicly) for the help.  This definitely gets me
started.
Guy

On Aug 19, 5:25 am, Daniel Roseman  wrote:
> On Aug 19, 9:16 am, Guy  wrote:
>
>
>
> > I am having trouble with learning to use httpresponseredirect and
> > reverse.
> > I am trying to generate an admin action on a selection of a list of
> > items. The purpose is to generate an intermediate window that can be
> > used to select a new
> > status for all the objects,
>
> > The admin action shows up in the pulldown menu on /admin/items/item.
> > However, once clicked, I get the following error: NoReverseMatch at /
> > admin/items/item/
>
> > Any advice would be greatly appreciated, I have been pounding me head
> > for a day or so on this.  I am certainly a novice, so this is likely
> > to be a very newbie misunderstanding.
>
> > Many thanks,
> > Guy
>
> > #myproject/app/admin.py
>
> > class ItemAdmin(admin.ModelAdmin):
>
> >     fieldsets = ( #... )
>
> >     #set up management command
> >     def change_status(self, request, queryset):
> >         """call intermediary window to present admin with option to
> > update
> >         the status for a batch of items. Basically it seems
> > inefficient to
> >         make several 'admin actions' on the regular item list page,
> > (one
> >         for each status type). Seems more logical to select change
> > status from
> >         the admin action dropdown, and then have an intermediate
> > window ask
> >         what the status should be"""
>
> >         return HttpResponseRedirect(reverse("change-item-status",
> > kwargs = {'queryset': queryset, 'request': request,}))
>
> >     change_status.short_description = "change status of items in
> > batch"
> >     actions = ['change_status']
>
> > #myproject/urls.py
> > from django.conf import settings
> > from django.conf.urls.defaults import *
> > from django.contrib import admin
>
> > admin.autodiscover()
>
> > urlpatterns = patterns('',
> >     url(r'^admin/items/item/changestatus/$',
> >         'myapp.items.admin_views.changeitemstatus', kwargs = {},
> >         name="change-item-status")
> >         )
>
> > #myproject/app/admin_views.py
> > def changeitemstatus(request,**kwargs):
> >     """intermediary window to present admin with option to update the
> > status
> >     and apply any notes to a batch of items"""
> >     template_name='admin/items/changeitemstatus.html'
> >     context = RequestContext(request,
> >                                 {'items': kwargs['queryset'],
> >                                'choices': item.status_choices})
>
> >     return render(template_name, context)
>
> There seem to be a few confusions here. The arguments to a view are
> those elements that are passed in the URL itself and extracted via the
> urlconf regex. It is possible to insert extra arguments into the call
> to the view by hard-coding them in the urlconf, as I think you are
> trying to do with your `kwargs = {}`, but then there is no way of
> specifying these dynamically - because the urlconf is matched against
> the URL.
>
> Next, what HttpResponseRedirect does - as the name implies - is send a
> response to the browser, with an HTTP status code telling the browser
> to request another URL, plus a Location header telling it what that
> URL should be. So, again, any dynamic arguments you pass in (eg via
> reverse) have to be things you can actually put into a URL.
>
> So it isn't possible to arbitrarily insert the queryset as the
> argument to reverse, as you attempt here, because there is no way to
> insert that queryset into the URL in the redirect and extract it from
> there in the urlconf.
>
> Instead, you need to think about approaching this from a different
> angle. If you want to preserve a queryset across requests, you will
> need to save it somewhere - the session could be ideal for this.
> --
> DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: NoReverseMatch error when attempting to spawn an intermediate window from an admin action

2010-08-19 Thread Daniel Roseman
On Aug 19, 9:16 am, Guy  wrote:
> I am having trouble with learning to use httpresponseredirect and
> reverse.
> I am trying to generate an admin action on a selection of a list of
> items. The purpose is to generate an intermediate window that can be
> used to select a new
> status for all the objects,
>
> The admin action shows up in the pulldown menu on /admin/items/item.
> However, once clicked, I get the following error: NoReverseMatch at /
> admin/items/item/
>
> Any advice would be greatly appreciated, I have been pounding me head
> for a day or so on this.  I am certainly a novice, so this is likely
> to be a very newbie misunderstanding.
>
> Many thanks,
> Guy
>
> #myproject/app/admin.py
>
> class ItemAdmin(admin.ModelAdmin):
>
>     fieldsets = ( #... )
>
>     #set up management command
>     def change_status(self, request, queryset):
>         """call intermediary window to present admin with option to
> update
>         the status for a batch of items. Basically it seems
> inefficient to
>         make several 'admin actions' on the regular item list page,
> (one
>         for each status type). Seems more logical to select change
> status from
>         the admin action dropdown, and then have an intermediate
> window ask
>         what the status should be"""
>
>         return HttpResponseRedirect(reverse("change-item-status",
> kwargs = {'queryset': queryset, 'request': request,}))
>
>     change_status.short_description = "change status of items in
> batch"
>     actions = ['change_status']
>
> #myproject/urls.py
> from django.conf import settings
> from django.conf.urls.defaults import *
> from django.contrib import admin
>
> admin.autodiscover()
>
> urlpatterns = patterns('',
>     url(r'^admin/items/item/changestatus/$',
>         'myapp.items.admin_views.changeitemstatus', kwargs = {},
>         name="change-item-status")
>         )
>
> #myproject/app/admin_views.py
> def changeitemstatus(request,**kwargs):
>     """intermediary window to present admin with option to update the
> status
>     and apply any notes to a batch of items"""
>     template_name='admin/items/changeitemstatus.html'
>     context = RequestContext(request,
>                                 {'items': kwargs['queryset'],
>                                'choices': item.status_choices})
>
>     return render(template_name, context)

There seem to be a few confusions here. The arguments to a view are
those elements that are passed in the URL itself and extracted via the
urlconf regex. It is possible to insert extra arguments into the call
to the view by hard-coding them in the urlconf, as I think you are
trying to do with your `kwargs = {}`, but then there is no way of
specifying these dynamically - because the urlconf is matched against
the URL.

Next, what HttpResponseRedirect does - as the name implies - is send a
response to the browser, with an HTTP status code telling the browser
to request another URL, plus a Location header telling it what that
URL should be. So, again, any dynamic arguments you pass in (eg via
reverse) have to be things you can actually put into a URL.

So it isn't possible to arbitrarily insert the queryset as the
argument to reverse, as you attempt here, because there is no way to
insert that queryset into the URL in the redirect and extract it from
there in the urlconf.

Instead, you need to think about approaching this from a different
angle. If you want to preserve a queryset across requests, you will
need to save it somewhere - the session could be ideal for this.
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



NoReverseMatch error when attempting to spawn an intermediate window from an admin action

2010-08-19 Thread Guy
I am having trouble with learning to use httpresponseredirect and
reverse.
I am trying to generate an admin action on a selection of a list of
items. The purpose is to generate an intermediate window that can be
used to select a new
status for all the objects,

The admin action shows up in the pulldown menu on /admin/items/item.
However, once clicked, I get the following error: NoReverseMatch at /
admin/items/item/

Any advice would be greatly appreciated, I have been pounding me head
for a day or so on this.  I am certainly a novice, so this is likely
to be a very newbie misunderstanding.

Many thanks,
Guy

#myproject/app/admin.py

class ItemAdmin(admin.ModelAdmin):

fieldsets = ( #... )

#set up management command
def change_status(self, request, queryset):
"""call intermediary window to present admin with option to
update
the status for a batch of items. Basically it seems
inefficient to
make several 'admin actions' on the regular item list page,
(one
for each status type). Seems more logical to select change
status from
the admin action dropdown, and then have an intermediate
window ask
what the status should be"""

return HttpResponseRedirect(reverse("change-item-status",
kwargs = {'queryset': queryset, 'request': request,}))

change_status.short_description = "change status of items in
batch"
actions = ['change_status']

#myproject/urls.py
from django.conf import settings
from django.conf.urls.defaults import *
from django.contrib import admin

admin.autodiscover()

urlpatterns = patterns('',
url(r'^admin/items/item/changestatus/$',
'myapp.items.admin_views.changeitemstatus', kwargs = {},
name="change-item-status")
)


#myproject/app/admin_views.py
def changeitemstatus(request,**kwargs):
"""intermediary window to present admin with option to update the
status
and apply any notes to a batch of items"""
template_name='admin/items/changeitemstatus.html'
context = RequestContext(request,
{'items': kwargs['queryset'],
   'choices': item.status_choices})

return render(template_name, context)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Optional URL argument from model's get_absolute_url causing NoReverseMatch error

2009-10-09 Thread Javier Guerra

On Fri, Oct 9, 2009 at 9:38 AM, Aaron  wrote:
>
> On Oct 9, 11:22 am, Javier Guerra  wrote:
>> add a second line to your URL mappigs with the third argument:
>>
>> (r'^(?P[-\w]+)/(?P[-\w]+)/$', 'model_view'),
>> (r'^(?P[-\w]+)/(?P[-\w]+)/(?P[-\w]+)/$', 'model_view')
>
> That's the problem. 'c' is not supposed to be visible in the URL
> itself.  A person is only supposed to see /a/b/ when accessing the
> model's page.

so, you want to get a parameter from the URL, but not to be in the
URL?  i'd say get that 'c' parameter from somewhere else.

maybe something like this:

add the 3-params URL; but in the view validate 'c' and store it
somewhere else (probably in the session dict) then redirect to the
'user visible' 2-params URL.  the browser (w|sh)ouldn't record the
ephemeral 3-parms URL in the history.

-- 
Javier

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Optional URL argument from model's get_absolute_url causing NoReverseMatch error

2009-10-09 Thread Karen Tracey
On Fri, Oct 9, 2009 at 10:38 AM, Aaron  wrote:

>
> On Oct 9, 11:22 am, Javier Guerra  wrote:
> > add a second line to your URL mappigs with the third argument:
> >
> > (r'^(?P[-\w]+)/(?P[-\w]+)/$', 'model_view'),
> > (r'^(?P[-\w]+)/(?P[-\w]+)/(?P[-\w]+)/$', 'model_view')
>
> That's the problem. 'c' is not supposed to be visible in the URL
> itself.  A person is only supposed to see /a/b/ when accessing the
> model's page.
>
>
You seem to be asking for the impossible.  get_abolute_url returns a url
path.  If c is a bit of information that has to be returned by
get_absolute_url, then it has to go in the URL somewhere.  There's no place
else for it to be stashed away and remembered for later when you click on
the link generated from the return value of get_absolute_url.

Karen

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Optional URL argument from model's get_absolute_url causing NoReverseMatch error

2009-10-09 Thread Aaron

On Oct 9, 11:22 am, Javier Guerra  wrote:
> add a second line to your URL mappigs with the third argument:
>
> (r'^(?P[-\w]+)/(?P[-\w]+)/$', 'model_view'),
> (r'^(?P[-\w]+)/(?P[-\w]+)/(?P[-\w]+)/$', 'model_view')

That's the problem. 'c' is not supposed to be visible in the URL
itself.  A person is only supposed to see /a/b/ when accessing the
model's page.

The thing is that I'm actually using the same URL pattern for the
pages of two different models (not my decision, ugh!).  'c' is
actually storing the model type.  If 'c' is None, as when the URL is
being accessed directly, I'd determine the model type in the view
another way (I go through hoops, but it's possible).  However, if I
have a chance to use one of the model's get_absolue_url methods, I
want to specify the model's type in 'c' so that the view knows what
model it's working with at the start.  Except that Django doesn't like
my optional argument.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Optional URL argument from model's get_absolute_url causing NoReverseMatch error

2009-10-09 Thread Javier Guerra

On Fri, Oct 9, 2009 at 8:09 AM, Aaron  wrote:
> What is the proper way to introduce optional arguments here?

add a second line to your URL mappigs with the third argument:

(r'^(?P[-\w]+)/(?P[-\w]+)/$', 'model_view'),
(r'^(?P[-\w]+)/(?P[-\w]+)/(?P[-\w]+)/$', 'model_view')



-- 
Javier

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Optional URL argument from model's get_absolute_url causing NoReverseMatch error

2009-10-09 Thread Aaron

I want to have a model view with an optional argument that's specified
by the model's get_absolute_url. This argument is None if the model's
page is accessed by the user typing in the URL in his browser, while
the argument is set to some value if the model's page is accessed by
clicking on a link such as the "View on site" button in the admin
site.

This is what I came up with first:

The model:

class MyModel(models.Model):
...
@models.permalink
def get_absolute_url(self):
return ('mymodels.views.model_view', (),
  { 'a': self.some_field,
'b': self.another_field,
'c': something_else_again } )

The URLConf:

(r'^(?P[-\w]+)/(?P[-\w]+)/$', 'model_view')

The view:

def model_view(request, a, b, c = None):
if c:
# Do something
else:
# Do something else

Accessing the model's page by just typing in a URL works (where c is
None). However, accessing the model's page by, say, clicking "View on
site" in the admin (where c should be set to the model type's ID)
gives me this NoReverseMatch error:

NoReverseMatch at /admin/r///
Reverse for '' with arguments '()' and
keyword arguments '{'a': u'something', 'b': u'something-else', 'c':
'something-else-again'}' not found.
Exception location: C:\Python26\lib\site-packages\django\core
\urlresolvers.py in reverse, line 291

What is the proper way to introduce optional arguments here?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: NoReverseMatch error during Django 1.0 tutorial

2009-06-23 Thread Rafa Muñoz Cárdenas

return HttpResponseRedirect(reverse
('mysite.polls.vews.results', args=(p.id,)))

As you see, there is a mistake in "vews".
return HttpResponseRedirect(reverse
('mysite.polls.views.results', args=(p.id,)))

Now it should work :)

On 21 jun, 19:11, ebbnormal  wrote:
> Hello,
>
> I am still working on the Django 1.0 tutorial (http://
> docs.djangoproject.com/en/1.0/intro/tutorial04/) and
> got the following error after voting on my poll ( which simply makes a
> call to the Django reverse function which is supposed to give control
> to my results function in polls.views).
>
> The error is the following:
>
> NoReverseMatch at /polls/1/vote/
> Reverse for 'mysite.polls.vews.results' with arguments '(1,)' and
> keyword arguments '{}' not found.
>
> and my views.py is the following:
>
> from mysite.polls.models import  Choice, Poll
> from django.shortcuts import get_object_or_404, render_to_response
> from django.core.urlresolvers import reverse
> from django.http import HttpResponseRedirect
>
> # ...
>
> def vote(request, poll_id):
>     p = get_object_or_404(Poll, pk=poll_id)
>     try:
>         selected_choice = p.choice_set.get(pk=request.POST['choice'])
>     except (KeyError, Choice.DoesNotExist):
>         return render_to_response('detail.html', {
>             'poll': p,
>             'error_message': "You didnt select a choice.",
>         })
>
>     else:
>         selected_choice.votes += 1
>         selected_choice.save()
>         return HttpResponseRedirect(reverse
> ('mysite.polls.vews.results', args=(p.id,)))
>
> def results(request, poll_id):
>     p = get_object_or_404(Poll, pk=poll_id)
>     return render_to_response('results.html', {'poll': p})

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



NoReverseMatch error during Django 1.0 tutorial

2009-06-21 Thread ebbnormal

Hello,

I am still working on the Django 1.0 tutorial (http://
docs.djangoproject.com/en/1.0/intro/tutorial04/) and
got the following error after voting on my poll ( which simply makes a
call to the Django reverse function which is supposed to give control
to my results function in polls.views).

The error is the following:

NoReverseMatch at /polls/1/vote/
Reverse for 'mysite.polls.vews.results' with arguments '(1,)' and
keyword arguments '{}' not found.




and my views.py is the following:


from mysite.polls.models import  Choice, Poll
from django.shortcuts import get_object_or_404, render_to_response
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect

# ...


def vote(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
try:
selected_choice = p.choice_set.get(pk=request.POST['choice'])
except (KeyError, Choice.DoesNotExist):
return render_to_response('detail.html', {
'poll': p,
'error_message': "You didnt select a choice.",
})

else:
selected_choice.votes += 1
selected_choice.save()
return HttpResponseRedirect(reverse
('mysite.polls.vews.results', args=(p.id,)))

def results(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
return render_to_response('results.html', {'poll': p})


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: NoReverseMatch error

2007-10-15 Thread ashok.raavi



On Oct 15, 8:10 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2007-10-14 at 19:45 -0700, ashok.raavi wrote:
> > Any body got this NoReverseMatch problem fixed?. If so please point me
> > to that.
>
> Which problem would that be? You have provided no context at all for
> your question.
>
> We are helpful people, but not mind readers.

the patch link http://code.djangoproject.com/attachment/ticket/4409/4409.patch
is about that problem only

But i should have provided a clear context, which i am giving here

i am getting that NoReverseMatch  error when trying the "poll" example
application given in the django tutorial

http://www.djangoproject.com/documentation/tutorial04/

only after changing the code to use generic views as explained in the
tutorial.

i tried with the patch provided at 
http://code.djangoproject.com/attachment/ticket/4409/4409.patch
but still it's not working




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: NoReverseMatch error

2007-10-14 Thread Malcolm Tredinnick

On Sun, 2007-10-14 at 19:45 -0700, ashok.raavi wrote:
> Any body got this NoReverseMatch problem fixed?. If so please point me
> to that.

Which problem would that be? You have provided no context at all for
your question.

We are helpful people, but not mind readers.

Malcolm



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



NoReverseMatch error

2007-10-14 Thread ashok.raavi

Any body got this NoReverseMatch problem fixed?. If so please point me
to that.

The patch over here 
http://code.djangoproject.com/attachment/ticket/4409/4409.patch
is also not working for me .

I am using the latest trunk from django repository.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---