Re: while going through the django tutorial i commited a error and because of which i cannot execute the python manage.py runserver. The errors are attached below

2018-05-08 Thread Avitab Ayan Sarmah
Sure

On Tue 8 May, 2018, 12:08 AM Jani Tiainen,  wrote:

> Also next time please post exceptions as a text. Images are really hard to
> read specially on mobile device.
>
> ma 7. toukokuuta 2018 klo 20.34 Avitab Ayan Sarmah 
> kirjoitti:
>
>> i got the error thank you. It was a simple error i forgot to put "<"
>> before vote
>>
>> On Monday, May 7, 2018 at 10:55:51 PM UTC+5:30, Avitab Ayan Sarmah wrote:
>>>
>>> polls/urls.py:
>>>
>>> from django.urls import path
>>>
>>> from . import views
>>>
>>> app_name = 'polls'
>>> urlpatterns = [
>>> # ex: /polls/
>>> path('', views.index, name='index'),
>>> # ex: /polls/5/
>>> path('/', views.detail, name='detail'),
>>> #ex: /polls/5/results/
>>> path('/results/', views.results, name='results'),
>>> #ex: /polls/5/vote/
>>> path('int:question_id>/vote/', views.vote, name='vote'),
>>> ]
>>>
>>>
>>> On Monday, May 7, 2018 at 10:54:16 PM UTC+5:30, Dylan Reinhold wrote:

 Share your polls/url.py it's saying it cant find the url named "vote"
 in your polls.

 Dylan

 On Mon, May 7, 2018 at 10:14 AM, Avitab Ayan Sarmah >>> > wrote:

> Detail.html:
>
> {{ question.question_text }}
>
> {% if error_message %}{{ error_message }}{%
> endif %}
>
> 
> {% csrf_token %}
> {% for choice in question.choice_set.all %}
>    value="{{ choice.id }}" />
>   {{ choice.choice_text }}
> 
> {% endfor %}
> 
> 
>
> --
> 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/aab94309-a65f-49ec-bd4d-bb07bf5457a7%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/6176e606-7dbe-4a39-bd05-fc879482663c%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/bSlQt0K3Pe8/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/CAHn91oekr%3DRnKmb6ZCDpWgL5iBH5KpDmEFB4Jv%2BVVihEaRaJzg%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


M2M Magic Accessors without explicit ManyToMany Field

2018-05-08 Thread Clayton D
I posted a question on SO (https://stackoverflow.com/q/50222402/1978687), 
but it's been viewed very few times so I'm hoping this is the right place 
to get attention from those "in the know".  The complete question (and 
progress so far) is documented on SO so that's probably the best place to 
answer.

The essentials of the question are:

   - I need to create an M2M relationship between two models, but...
   - The models are from external libraries (trivially User and Car)
   - The models are non-abstract and multi-table inheritance would 
   introduce a ton of unnecessary overhead
   - Others will use my code like (if not literally as) a 3rd party library 
   so I want to provide all of the usual magic methods for usability -- e.g. 
   Cars.objects.filter(users=user) -- which doesn't happen if I create a 
   manual M2M (i.e. "through") table.
   
A commenter suggested using `add_to_class` on one of the 3rd party models.  
It passes trivial test cases, but has hair and some of the magic breaks 
because it's treated as a `through=` relationship even though it's a 
trivial M2M table.

I'm hoping someone who understands the ManyToMany implementation can tell 
me if I can hijack the `contribute...` methods (or something similar) to 
get this job done.

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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cc6f6c74-e5df-4fcf-b473-42f894fd3abb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


can you check what is wrong with def vote(request, question_id), i am not able to run server. The exceptions and my views.py code are wrriten below:

2018-05-08 Thread Avitab Ayan Sarmah
Views.py:

from django.shortcuts import get_object_or_404, render
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.views import generic

from . models import Choice, Question


class IndexView(generic.ListView):
template_name = 'polls/index.html'
context_object_name = 'latest_question_list'

def get_queryset(self):
"""Return the last five published questions."""
return Question.objects.order_by('-pub_date')[:5]


class DetailView(generic.DetailView):
model = Question
template_name = 'polls/detail.html'


class ResultsView(generic.DetailView):
model = Question
template_name = 'polls/results.html'


def vote(request, question_id):
... # Same as above, no changes needed.
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 form.
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 button.
return HttpResponseRedirect(reverse('polls:results', 
args=(question.id,)))



Exceptions:

Unhandled exception in thread started by .wrapper at 0x0261B72329D8>
Traceback (most recent call last):
  File "c:\python36\lib\site-packages\django\utils\autoreload.py", line 
225, in wrapper
fn(*args, **kwargs)
  File 
"c:\python36\lib\site-packages\django\core\management\commands\runserver.py", 
line 121, in inner_run
self.check(display_num_errors=True)
  File "c:\python36\lib\site-packages\django\core\management\base.py", line 
364, in check
include_deployment_checks=include_deployment_checks,
  File "c:\python36\lib\site-packages\django\core\management\base.py", line 
351, in _run_checks
return checks.run_checks(**kwargs)
  File "c:\python36\lib\site-packages\django\core\checks\registry.py", line 
73, in run_checks
new_errors = check(app_configs=app_configs)
  File "c:\python36\lib\site-packages\django\core\checks\urls.py", line 40, 
in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
  File "c:\python36\lib\site-packages\django\core\checks\urls.py", line 57, 
in _load_all_namespaces
url_patterns = getattr(resolver, 'url_patterns', [])
  File "c:\python36\lib\site-packages\django\utils\functional.py", line 36, 
in __get__
res = instance.__dict__[self.name] = self.func(instance)
  File "c:\python36\lib\site-packages\django\urls\resolvers.py", line 536, 
in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", 
self.urlconf_module)
  File "c:\python36\lib\site-packages\django\utils\functional.py", line 36, 
in __get__
res = instance.__dict__[self.name] = self.func(instance)
  File "c:\python36\lib\site-packages\django\urls\resolvers.py", line 529, 
in urlconf_module
return import_module(self.urlconf_name)
  File "c:\python36\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 978, in _gcd_import
  File "", line 961, in _find_and_load
  File "", line 950, in _find_and_load_unlocked
  File "", line 655, in _load_unlocked
  File "", line 678, in exec_module
  File "", line 205, in 
_call_with_frames_removed
  File "C:\Users\AVITABAYAN\mysite\mysite\urls.py", line 5, in 
path('', include('polls.urls')),
  File "c:\python36\lib\site-packages\django\urls\conf.py", line 34, in 
include
urlconf_module = import_module(urlconf_module)
  File "c:\python36\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 978, in _gcd_import
  File "", line 961, in _find_and_load
  File "", line 950, in _find_and_load_unlocked
  File "", line 655, in _load_unlocked
  File "", line 678, in exec_module
  File "", line 205, in 
_call_with_frames_removed
  File "C:\Users\AVITABAYAN\mysite\polls\urls.py", line 3, in 
from . import views
  File "C:\Users\AVITABAYAN\mysite\polls\views.py", line 31
try:
   ^
IndentationError: unindent does not match any outer indentation level

-- 
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/3d5c8e3c-b3c2-4624-9cd9-3a33de71dfff%40googlegroups.com.
For more options, visit https://groups.google.com/d/

RE: can you check what is wrong with def vote(request, question_id), i am not able to run server. The exceptions and my views.py code are wrriten below:

2018-05-08 Thread Matthew Pava
Hi Avitab,
The exception message tries to explain it to you.
“IndentationError: unindent does not match any outer indentation level”
Python expects perfect whitespace with your code, and you can’t mix spaces with 
tabs.
In your view function, you are indenting with 4 spaces most of the time, but 
your first line in the function is with a tab.
I recommend using an IDE such as PyCharm to help alleviate this issue so you 
don’t run into it again.



From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Avitab Ayan Sarmah
Sent: Tuesday, May 8, 2018 10:54 AM
To: Django users
Subject: can you check what is wrong with def vote(request, question_id), i am 
not able to run server. The exceptions and my views.py code are wrriten below:

Views.py:

from django.shortcuts import get_object_or_404, render
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.views import generic

from . models import Choice, Question


class IndexView(generic.ListView):
template_name = 'polls/index.html'
context_object_name = 'latest_question_list'

def get_queryset(self):
"""Return the last five published questions."""
return Question.objects.order_by('-pub_date')[:5]


class DetailView(generic.DetailView):
model = Question
template_name = 'polls/detail.html'


class ResultsView(generic.DetailView):
model = Question
template_name = 'polls/results.html'


def vote(request, question_id):
... # Same as above, no changes needed.
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 form.
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 button.
return HttpResponseRedirect(reverse('polls:results', 
args=(question.id,)))



Exceptions:

Unhandled exception in thread started by .wrapper at 0x0261B72329D8>
Traceback (most recent call last):
  File "c:\python36\lib\site-packages\django\utils\autoreload.py", line 225, in 
wrapper
fn(*args, **kwargs)
  File 
"c:\python36\lib\site-packages\django\core\management\commands\runserver.py", 
line 121, in inner_run
self.check(display_num_errors=True)
  File "c:\python36\lib\site-packages\django\core\management\base.py", line 
364, in check
include_deployment_checks=include_deployment_checks,
  File "c:\python36\lib\site-packages\django\core\management\base.py", line 
351, in _run_checks
return checks.run_checks(**kwargs)
  File "c:\python36\lib\site-packages\django\core\checks\registry.py", line 73, 
in run_checks
new_errors = check(app_configs=app_configs)
  File "c:\python36\lib\site-packages\django\core\checks\urls.py", line 40, in 
check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
  File "c:\python36\lib\site-packages\django\core\checks\urls.py", line 57, in 
_load_all_namespaces
url_patterns = getattr(resolver, 'url_patterns', [])
  File "c:\python36\lib\site-packages\django\utils\functional.py", line 36, in 
__get__
res = instance.__dict__[self.name] = self.func(instance)
  File "c:\python36\lib\site-packages\django\urls\resolvers.py", line 536, in 
url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "c:\python36\lib\site-packages\django\utils\functional.py", line 36, in 
__get__
res = instance.__dict__[self.name] = self.func(instance)
  File "c:\python36\lib\site-packages\django\urls\resolvers.py", line 529, in 
urlconf_module
return import_module(self.urlconf_name)
  File "c:\python36\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 978, in _gcd_import
  File "", line 961, in _find_and_load
  File "", line 950, in _find_and_load_unlocked
  File "", line 655, in _load_unlocked
  File "", line 678, in exec_module
  File "", line 205, in _call_with_frames_removed
  File "C:\Users\AVITABAYAN\mysite\mysite\urls.py", line 5, in 
path('', include('polls.urls')),
  File "c:\python36\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
  File "c:\python36\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 978, in _gcd_import
  File "", line 961, in _find_and_load
  File "", line 950, in _find_and_load_unlock

While going through Django tutorial i commited an error because of which i am not able to execute python manage.py runserver. The exceptions and codes are mentioned below: In exception it is mentioned

2018-05-08 Thread Avitab Ayan Sarmah
Exceptions:

PS C:\Users\AVITABAYAN\mysite> python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
May 08, 2018 - 22:00:28
Django version 2.0.1, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Internal Server Error: /
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 
158, in _get_response
response = self.process_exception_by_middleware(e, request)
  File "c:\python36\lib\site-packages\django\core\handlers\base.py", line 
156, in _get_response
response = response.render()
  File "c:\python36\lib\site-packages\django\template\response.py", line 
106, in render
self.content = self.rendered_content
  File "c:\python36\lib\site-packages\django\template\response.py", line 
83, in rendered_content
content = template.render(context, self._request)
  File "c:\python36\lib\site-packages\django\template\backends\django.py", 
line 61, in render
return self.template.render(context)
  File "c:\python36\lib\site-packages\django\template\base.py", line 175, 
in render
return self._render(context)
  File "c:\python36\lib\site-packages\django\template\base.py", line 167, 
in _render
return self.nodelist.render(context)
  File "c:\python36\lib\site-packages\django\template\base.py", line 943, 
in render
bit = node.render_annotated(context)
  File "c:\python36\lib\site-packages\django\template\base.py", line 910, 
in render_annotated
return self.render(context)
  File "c:\python36\lib\site-packages\django\template\defaulttags.py", line 
314, in render
return nodelist.render(context)
  File "c:\python36\lib\site-packages\django\template\base.py", line 943, 
in render
bit = node.render_annotated(context)
  File "c:\python36\lib\site-packages\django\template\base.py", line 910, 
in render_annotated
return self.render(context)
  File "c:\python36\lib\site-packages\django\template\defaulttags.py", line 
211, in render
nodelist.append(node.render_annotated(context))
  File "c:\python36\lib\site-packages\django\template\base.py", line 910, 
in render_annotated
return self.render(context)
  File "c:\python36\lib\site-packages\django\template\defaulttags.py", line 
447, in render
url = reverse(view_name, args=args, kwargs=kwargs, 
current_app=current_app)
  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 'detail' with arguments 
'(1,)' not found. 1 pattern(s) tried: ['\\
  {% for question in latest_question_list %}
  {{
question.question_text }}
  {% endfor %}
  
{% else %}
  No polls are available.
{% endif %}


-- 
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/1681bb6e-226e-4792-ab5c-1cadcf836eff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: While going through Django tutorial i commited an error because of which i am not able to execute python manage.py runserver. The exceptions and codes are mentioned below: In exception it is menti

2018-05-08 Thread Julio Biason
Your problem is your urls.py:

django.urls.exceptions.NoReverseMatch: Reverse for 'detail' with arguments
'(1,)' not found. 1 pattern(s) tried: ['\\
wrote:

> Exceptions:
>
> PS C:\Users\AVITABAYAN\mysite> python manage.py runserver
> Performing system checks...
>
> System check identified no issues (0 silenced).
> May 08, 2018 - 22:00:28
> Django version 2.0.1, using settings 'mysite.settings'
> Starting development server at http://127.0.0.1:8000/
> Quit the server with CTRL-BREAK.
> Internal Server Error: /
> 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
> 158, in _get_response
> response = self.process_exception_by_middleware(e, request)
>   File "c:\python36\lib\site-packages\django\core\handlers\base.py", line
> 156, in _get_response
> response = response.render()
>   File "c:\python36\lib\site-packages\django\template\response.py", line
> 106, in render
> self.content = self.rendered_content
>   File "c:\python36\lib\site-packages\django\template\response.py", line
> 83, in rendered_content
> content = template.render(context, self._request)
>   File "c:\python36\lib\site-packages\django\template\backends\django.py",
> line 61, in render
> return self.template.render(context)
>   File "c:\python36\lib\site-packages\django\template\base.py", line 175,
> in render
> return self._render(context)
>   File "c:\python36\lib\site-packages\django\template\base.py", line 167,
> in _render
> return self.nodelist.render(context)
>   File "c:\python36\lib\site-packages\django\template\base.py", line 943,
> in render
> bit = node.render_annotated(context)
>   File "c:\python36\lib\site-packages\django\template\base.py", line 910,
> in render_annotated
> return self.render(context)
>   File "c:\python36\lib\site-packages\django\template\defaulttags.py",
> line 314, in render
> return nodelist.render(context)
>   File "c:\python36\lib\site-packages\django\template\base.py", line 943,
> in render
> bit = node.render_annotated(context)
>   File "c:\python36\lib\site-packages\django\template\base.py", line 910,
> in render_annotated
> return self.render(context)
>   File "c:\python36\lib\site-packages\django\template\defaulttags.py",
> line 211, in render
> nodelist.append(node.render_annotated(context))
>   File "c:\python36\lib\site-packages\django\template\base.py", line 910,
> in render_annotated
> return self.render(context)
>   File "c:\python36\lib\site-packages\django\template\defaulttags.py",
> line 447, in render
> url = reverse(view_name, args=args, kwargs=kwargs,
> current_app=current_app)
>   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 'detail' with
> arguments '(1,)' not found. 1 pattern(s) tried: ['\\ [08/May/2018 22:00:42] "GET / HTTP/1.1" 500 134672
>
> views.py:
>
> from django.shortcuts import get_object_or_404, render
> from django.http import HttpResponseRedirect
> from django.urls import reverse
> from django.views import generic
>
> from . models import Choice, Question
>
>
> class IndexView(generic.ListView):
> template_name = 'polls/index.html'
> context_object_name = 'latest_question_list'
>
> def get_queryset(self):
> """Return the last five published questions."""
> return Question.objects.order_by('-pub_date')[:5]
>
>
> class DetailView(generic.DetailView):
> model = Question
> template_name = 'polls/detail.html'
>
>
> class ResultsView(generic.DetailView):
> model = Question
> template_name = 'polls/results.html'
>
>
> 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 form.
> return render(request, 'polls/detail.html', {
> 'question': question,
> 'error_message': "you didn't select a choice.",
> })
> else:
> selected_choice.votes +=1
> selected_choice.save()
> #...
> #...
> #...
> return HttpResponseRedirect(reverse('polls:results', args=(question.id,)))
>
> index.html:
>
> {% if latest_question_list %}
>   
>   {% for question in latest_question_list %}
>   {{
> question.question_text }}
>   {% endfor %}
>   
> {% else %}
>   No polls are available.
> {% endif %}
>
>
> --
> 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 

Re: While going through Django tutorial i commited an error because of which i am not able to execute python manage.py runserver. The exceptions and codes are mentioned below: In exception it is menti

2018-05-08 Thread Avitab Ayan Sarmah
Wait I am sharing my URLs.py

On Tue 8 May, 2018, 10:09 PM Julio Biason,  wrote:

> Your problem is your urls.py:
>
> django.urls.exceptions.NoReverseMatch: Reverse for 'detail' with arguments
> '(1,)' not found. 1 pattern(s) tried: ['\\
> You are looking for a URL named "details" which accepts 1 number and
> Django does not know it.
>
> On Tue, May 8, 2018 at 1:34 PM, Avitab Ayan Sarmah 
> wrote:
>
>> Exceptions:
>>
>> PS C:\Users\AVITABAYAN\mysite> python manage.py runserver
>> Performing system checks...
>>
>> System check identified no issues (0 silenced).
>> May 08, 2018 - 22:00:28
>> Django version 2.0.1, using settings 'mysite.settings'
>> Starting development server at http://127.0.0.1:8000/
>> Quit the server with CTRL-BREAK.
>> Internal Server Error: /
>> 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
>> 158, in _get_response
>> response = self.process_exception_by_middleware(e, request)
>>   File "c:\python36\lib\site-packages\django\core\handlers\base.py", line
>> 156, in _get_response
>> response = response.render()
>>   File "c:\python36\lib\site-packages\django\template\response.py", line
>> 106, in render
>> self.content = self.rendered_content
>>   File "c:\python36\lib\site-packages\django\template\response.py", line
>> 83, in rendered_content
>> content = template.render(context, self._request)
>>   File
>> "c:\python36\lib\site-packages\django\template\backends\django.py", line
>> 61, in render
>> return self.template.render(context)
>>   File "c:\python36\lib\site-packages\django\template\base.py", line 175,
>> in render
>> return self._render(context)
>>   File "c:\python36\lib\site-packages\django\template\base.py", line 167,
>> in _render
>> return self.nodelist.render(context)
>>   File "c:\python36\lib\site-packages\django\template\base.py", line 943,
>> in render
>> bit = node.render_annotated(context)
>>   File "c:\python36\lib\site-packages\django\template\base.py", line 910,
>> in render_annotated
>> return self.render(context)
>>   File "c:\python36\lib\site-packages\django\template\defaulttags.py",
>> line 314, in render
>> return nodelist.render(context)
>>   File "c:\python36\lib\site-packages\django\template\base.py", line 943,
>> in render
>> bit = node.render_annotated(context)
>>   File "c:\python36\lib\site-packages\django\template\base.py", line 910,
>> in render_annotated
>> return self.render(context)
>>   File "c:\python36\lib\site-packages\django\template\defaulttags.py",
>> line 211, in render
>> nodelist.append(node.render_annotated(context))
>>   File "c:\python36\lib\site-packages\django\template\base.py", line 910,
>> in render_annotated
>> return self.render(context)
>>   File "c:\python36\lib\site-packages\django\template\defaulttags.py",
>> line 447, in render
>> url = reverse(view_name, args=args, kwargs=kwargs,
>> current_app=current_app)
>>   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 'detail' with
>> arguments '(1,)' not found. 1 pattern(s) tried: ['\\> [08/May/2018 22:00:42] "GET / HTTP/1.1" 500 134672
>>
>> views.py:
>>
>> from django.shortcuts import get_object_or_404, render
>> from django.http import HttpResponseRedirect
>> from django.urls import reverse
>> from django.views import generic
>>
>> from . models import Choice, Question
>>
>>
>> class IndexView(generic.ListView):
>> template_name = 'polls/index.html'
>> context_object_name = 'latest_question_list'
>>
>> def get_queryset(self):
>> """Return the last five published questions."""
>> return Question.objects.order_by('-pub_date')[:5]
>>
>>
>> class DetailView(generic.DetailView):
>> model = Question
>> template_name = 'polls/detail.html'
>>
>>
>> class ResultsView(generic.DetailView):
>> model = Question
>> template_name = 'polls/results.html'
>>
>>
>> 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 form.
>> return render(request, 'polls/detail.html', {
>> 'question': question,
>> 'error_message': "you didn't select a choice.",
>> })
>> else:
>> selected_choice.votes +=1
>> selected_choice.save()
>> #...
>> #...
>> #...
>> return HttpResponseRedirect(reverse('polls:results', args=(question.id
>> ,)))
>>
>> index.html:
>>
>> {% if latest_question_list %}
>>   
>>   {% for question in latest_question_list %}
>>   {{
>>

Re: While going through Django tutorial i commited an error because of which i am not able to execute python manage.py runserver. The exceptions and codes are mentioned below: In exception it is menti

2018-05-08 Thread Avitab Ayan Sarmah
polls/urls.py:

from django.urls import path

from . import views

app_name = 'polls'
urlpatterns = [
# ex: /polls/
path('', views.IndexView.as_view(), name='index'),
path('/results/', views.ResultsView.as_view(), name='results'),
path('/vote/', views.vote, name='vote'),
]


On Tuesday, May 8, 2018 at 10:09:44 PM UTC+5:30, Julio Biason wrote:
>
> Your problem is your urls.py:
>
> django.urls.exceptions.NoReverseMatch: Reverse for 'detail' with arguments 
> '(1,)' not found. 1 pattern(s) tried: ['\\
> You are looking for a URL named "details" which accepts 1 number and 
> Django does not know it.
>
> On Tue, May 8, 2018 at 1:34 PM, Avitab Ayan Sarmah  > wrote:
>
>> Exceptions:
>>
>> PS C:\Users\AVITABAYAN\mysite> python manage.py runserver
>> Performing system checks...
>>
>> System check identified no issues (0 silenced).
>> May 08, 2018 - 22:00:28
>> Django version 2.0.1, using settings 'mysite.settings'
>> Starting development server at http://127.0.0.1:8000/
>> Quit the server with CTRL-BREAK.
>> Internal Server Error: /
>> 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 
>> 158, in _get_response
>> response = self.process_exception_by_middleware(e, request)
>>   File "c:\python36\lib\site-packages\django\core\handlers\base.py", line 
>> 156, in _get_response
>> response = response.render()
>>   File "c:\python36\lib\site-packages\django\template\response.py", line 
>> 106, in render
>> self.content = self.rendered_content
>>   File "c:\python36\lib\site-packages\django\template\response.py", line 
>> 83, in rendered_content
>> content = template.render(context, self._request)
>>   File 
>> "c:\python36\lib\site-packages\django\template\backends\django.py", line 
>> 61, in render
>> return self.template.render(context)
>>   File "c:\python36\lib\site-packages\django\template\base.py", line 175, 
>> in render
>> return self._render(context)
>>   File "c:\python36\lib\site-packages\django\template\base.py", line 167, 
>> in _render
>> return self.nodelist.render(context)
>>   File "c:\python36\lib\site-packages\django\template\base.py", line 943, 
>> in render
>> bit = node.render_annotated(context)
>>   File "c:\python36\lib\site-packages\django\template\base.py", line 910, 
>> in render_annotated
>> return self.render(context)
>>   File "c:\python36\lib\site-packages\django\template\defaulttags.py", 
>> line 314, in render
>> return nodelist.render(context)
>>   File "c:\python36\lib\site-packages\django\template\base.py", line 943, 
>> in render
>> bit = node.render_annotated(context)
>>   File "c:\python36\lib\site-packages\django\template\base.py", line 910, 
>> in render_annotated
>> return self.render(context)
>>   File "c:\python36\lib\site-packages\django\template\defaulttags.py", 
>> line 211, in render
>> nodelist.append(node.render_annotated(context))
>>   File "c:\python36\lib\site-packages\django\template\base.py", line 910, 
>> in render_annotated
>> return self.render(context)
>>   File "c:\python36\lib\site-packages\django\template\defaulttags.py", 
>> line 447, in render
>> url = reverse(view_name, args=args, kwargs=kwargs, 
>> current_app=current_app)
>>   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 'detail' with 
>> arguments '(1,)' not found. 1 pattern(s) tried: ['\\> [08/May/2018 22:00:42] "GET / HTTP/1.1" 500 134672
>>
>> views.py:
>>
>> from django.shortcuts import get_object_or_404, render
>> from django.http import HttpResponseRedirect
>> from django.urls import reverse
>> from django.views import generic
>>
>> from . models import Choice, Question
>>
>>
>> class IndexView(generic.ListView):
>> template_name = 'polls/index.html'
>> context_object_name = 'latest_question_list'
>>
>> def get_queryset(self):
>> """Return the last five published questions."""
>> return Question.objects.order_by('-pub_date')[:5]
>>
>>
>> class DetailView(generic.DetailView):
>> model = Question
>> template_name = 'polls/detail.html'
>>
>>
>> class ResultsView(generic.DetailView):
>> model = Question
>> template_name = 'polls/results.html'
>>
>>
>> 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 form.
>> return render(request, 'polls/detail.html', {
>> 'question': question,
>> 'error_message': "you didn't select a choice.",
>> })
>> 

Re: While going through Django tutorial i commited an error because of which i am not able to execute python manage.py runserver. The exceptions and codes are mentioned below: In exception it is menti

2018-05-08 Thread C. Kirby
You are missing a closing '>' in your detail url

On Tuesday, May 8, 2018 at 12:42:20 PM UTC-4, Avitab Ayan Sarmah wrote:
>
> polls/urls.py:
>
> from django.urls import path
>
> from . import views
>
> app_name = 'polls'
> urlpatterns = [
> # ex: /polls/
> path('', views.IndexView.as_view(), name='index'),
> path(' path('/results/', views.ResultsView.as_view(), name='results'),
> path('/vote/', views.vote, name='vote'),
> ]
>
>
> On Tuesday, May 8, 2018 at 10:09:44 PM UTC+5:30, Julio Biason wrote:
>>
>> Your problem is your urls.py:
>>
>> django.urls.exceptions.NoReverseMatch: Reverse for 'detail' with 
>> arguments '(1,)' not found. 1 pattern(s) tried: ['\\>
>> You are looking for a URL named "details" which accepts 1 number and 
>> Django does not know it.
>>
>> On Tue, May 8, 2018 at 1:34 PM, Avitab Ayan Sarmah  
>> wrote:
>>
>>> Exceptions:
>>>
>>> PS C:\Users\AVITABAYAN\mysite> python manage.py runserver
>>> Performing system checks...
>>>
>>> System check identified no issues (0 silenced).
>>> May 08, 2018 - 22:00:28
>>> Django version 2.0.1, using settings 'mysite.settings'
>>> Starting development server at http://127.0.0.1:8000/
>>> Quit the server with CTRL-BREAK.
>>> Internal Server Error: /
>>> 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 158, in _get_response
>>> response = self.process_exception_by_middleware(e, request)
>>>   File "c:\python36\lib\site-packages\django\core\handlers\base.py", 
>>> line 156, in _get_response
>>> response = response.render()
>>>   File "c:\python36\lib\site-packages\django\template\response.py", line 
>>> 106, in render
>>> self.content = self.rendered_content
>>>   File "c:\python36\lib\site-packages\django\template\response.py", line 
>>> 83, in rendered_content
>>> content = template.render(context, self._request)
>>>   File 
>>> "c:\python36\lib\site-packages\django\template\backends\django.py", line 
>>> 61, in render
>>> return self.template.render(context)
>>>   File "c:\python36\lib\site-packages\django\template\base.py", line 
>>> 175, in render
>>> return self._render(context)
>>>   File "c:\python36\lib\site-packages\django\template\base.py", line 
>>> 167, in _render
>>> return self.nodelist.render(context)
>>>   File "c:\python36\lib\site-packages\django\template\base.py", line 
>>> 943, in render
>>> bit = node.render_annotated(context)
>>>   File "c:\python36\lib\site-packages\django\template\base.py", line 
>>> 910, in render_annotated
>>> return self.render(context)
>>>   File "c:\python36\lib\site-packages\django\template\defaulttags.py", 
>>> line 314, in render
>>> return nodelist.render(context)
>>>   File "c:\python36\lib\site-packages\django\template\base.py", line 
>>> 943, in render
>>> bit = node.render_annotated(context)
>>>   File "c:\python36\lib\site-packages\django\template\base.py", line 
>>> 910, in render_annotated
>>> return self.render(context)
>>>   File "c:\python36\lib\site-packages\django\template\defaulttags.py", 
>>> line 211, in render
>>> nodelist.append(node.render_annotated(context))
>>>   File "c:\python36\lib\site-packages\django\template\base.py", line 
>>> 910, in render_annotated
>>> return self.render(context)
>>>   File "c:\python36\lib\site-packages\django\template\defaulttags.py", 
>>> line 447, in render
>>> url = reverse(view_name, args=args, kwargs=kwargs, 
>>> current_app=current_app)
>>>   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 'detail' with 
>>> arguments '(1,)' not found. 1 pattern(s) tried: ['\\>> [08/May/2018 22:00:42] "GET / HTTP/1.1" 500 134672
>>>
>>> views.py:
>>>
>>> from django.shortcuts import get_object_or_404, render
>>> from django.http import HttpResponseRedirect
>>> from django.urls import reverse
>>> from django.views import generic
>>>
>>> from . models import Choice, Question
>>>
>>>
>>> class IndexView(generic.ListView):
>>> template_name = 'polls/index.html'
>>> context_object_name = 'latest_question_list'
>>>
>>> def get_queryset(self):
>>> """Return the last five published questions."""
>>> return Question.objects.order_by('-pub_date')[:5]
>>>
>>>
>>> class DetailView(generic.DetailView):
>>> model = Question
>>> template_name = 'polls/detail.html'
>>>
>>>
>>> class ResultsView(generic.DetailView):
>>> model = Question
>>> template_name = 'polls/results.html'
>>>
>>>
>>> def vote(request, question_id):
>>> question = get_object_or_404(Question, pk=question_id)
>>> try:
>>> sele

Re: While going through Django tutorial i commited an error because of which i am not able to execute python manage.py runserver. The exceptions and codes are mentioned below: In exception it is menti

2018-05-08 Thread Avitab Ayan Sarmah
Please mention where exactly I missed >


On Tue 8 May, 2018, 10:19 PM C. Kirby,  wrote:

> You are missing a closing '>' in your detail url
>
> On Tuesday, May 8, 2018 at 12:42:20 PM UTC-4, Avitab Ayan Sarmah wrote:
>>
>> polls/urls.py:
>>
>> from django.urls import path
>>
>> from . import views
>>
>> app_name = 'polls'
>> urlpatterns = [
>> # ex: /polls/
>> path('', views.IndexView.as_view(), name='index'),
>> path('> path('/results/', views.ResultsView.as_view(), name='results'),
>> path('/vote/', views.vote, name='vote'),
>> ]
>>
>>
>> On Tuesday, May 8, 2018 at 10:09:44 PM UTC+5:30, Julio Biason wrote:
>>>
>>> Your problem is your urls.py:
>>>
>>> django.urls.exceptions.NoReverseMatch: Reverse for 'detail' with
>>> arguments '(1,)' not found. 1 pattern(s) tried: ['\\>>
>>> You are looking for a URL named "details" which accepts 1 number and
>>> Django does not know it.
>>>
>>> On Tue, May 8, 2018 at 1:34 PM, Avitab Ayan Sarmah 
>>> wrote:
>>>
 Exceptions:

 PS C:\Users\AVITABAYAN\mysite> python manage.py runserver
 Performing system checks...

 System check identified no issues (0 silenced).
 May 08, 2018 - 22:00:28
 Django version 2.0.1, using settings 'mysite.settings'
 Starting development server at http://127.0.0.1:8000/
 Quit the server with CTRL-BREAK.
 Internal Server Error: /
 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 158, in _get_response
 response = self.process_exception_by_middleware(e, request)
   File "c:\python36\lib\site-packages\django\core\handlers\base.py",
 line 156, in _get_response
 response = response.render()
   File "c:\python36\lib\site-packages\django\template\response.py",
 line 106, in render
 self.content = self.rendered_content
   File "c:\python36\lib\site-packages\django\template\response.py",
 line 83, in rendered_content
 content = template.render(context, self._request)
   File
 "c:\python36\lib\site-packages\django\template\backends\django.py", line
 61, in render
 return self.template.render(context)
   File "c:\python36\lib\site-packages\django\template\base.py", line
 175, in render
 return self._render(context)
   File "c:\python36\lib\site-packages\django\template\base.py", line
 167, in _render
 return self.nodelist.render(context)
   File "c:\python36\lib\site-packages\django\template\base.py", line
 943, in render
 bit = node.render_annotated(context)
   File "c:\python36\lib\site-packages\django\template\base.py", line
 910, in render_annotated
 return self.render(context)
   File "c:\python36\lib\site-packages\django\template\defaulttags.py",
 line 314, in render
 return nodelist.render(context)
   File "c:\python36\lib\site-packages\django\template\base.py", line
 943, in render
 bit = node.render_annotated(context)
   File "c:\python36\lib\site-packages\django\template\base.py", line
 910, in render_annotated
 return self.render(context)
   File "c:\python36\lib\site-packages\django\template\defaulttags.py",
 line 211, in render
 nodelist.append(node.render_annotated(context))
   File "c:\python36\lib\site-packages\django\template\base.py", line
 910, in render_annotated
 return self.render(context)
   File "c:\python36\lib\site-packages\django\template\defaulttags.py",
 line 447, in render
 url = reverse(view_name, args=args, kwargs=kwargs,
 current_app=current_app)
   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 'detail' with
 arguments '(1,)' not found. 1 pattern(s) tried: ['\\>>> [08/May/2018 22:00:42] "GET / HTTP/1.1" 500 134672

 views.py:

 from django.shortcuts import get_object_or_404, render
 from django.http import HttpResponseRedirect
 from django.urls import reverse
 from django.views import generic

 from . models import Choice, Question


 class IndexView(generic.ListView):
 template_name = 'polls/index.html'
 context_object_name = 'latest_question_list'

 def get_queryset(self):
 """Return the last five published questions."""
 return Question.objects.order_by('-pub_date')[:5]


 class DetailView(generic.DetailView):
 model = Question
 template_name = 'polls/detail.html'


 class ResultsView(gener

Re: While going through Django tutorial i commited an error because of which i am not able to execute python manage.py runserver. The exceptions and codes are mentioned below: In exception it is menti

2018-05-08 Thread Avitab Ayan Sarmah
please mention where exactly i am missing >?

On Tuesday, May 8, 2018 at 10:18:43 PM UTC+5:30, C. Kirby wrote:
>
> You are missing a closing '>' in your detail url
>
> On Tuesday, May 8, 2018 at 12:42:20 PM UTC-4, Avitab Ayan Sarmah wrote:
>>
>> polls/urls.py:
>>
>> from django.urls import path
>>
>> from . import views
>>
>> app_name = 'polls'
>> urlpatterns = [
>> # ex: /polls/
>> path('', views.IndexView.as_view(), name='index'),
>> path('> path('/results/', views.ResultsView.as_view(), name='results'),
>> path('/vote/', views.vote, name='vote'),
>> ]
>>
>>
>> On Tuesday, May 8, 2018 at 10:09:44 PM UTC+5:30, Julio Biason wrote:
>>>
>>> Your problem is your urls.py:
>>>
>>> django.urls.exceptions.NoReverseMatch: Reverse for 'detail' with 
>>> arguments '(1,)' not found. 1 pattern(s) tried: ['\\>>
>>> You are looking for a URL named "details" which accepts 1 number and 
>>> Django does not know it.
>>>
>>> On Tue, May 8, 2018 at 1:34 PM, Avitab Ayan Sarmah  
>>> wrote:
>>>
 Exceptions:

 PS C:\Users\AVITABAYAN\mysite> python manage.py runserver
 Performing system checks...

 System check identified no issues (0 silenced).
 May 08, 2018 - 22:00:28
 Django version 2.0.1, using settings 'mysite.settings'
 Starting development server at http://127.0.0.1:8000/
 Quit the server with CTRL-BREAK.
 Internal Server Error: /
 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 158, in _get_response
 response = self.process_exception_by_middleware(e, request)
   File "c:\python36\lib\site-packages\django\core\handlers\base.py", 
 line 156, in _get_response
 response = response.render()
   File "c:\python36\lib\site-packages\django\template\response.py", 
 line 106, in render
 self.content = self.rendered_content
   File "c:\python36\lib\site-packages\django\template\response.py", 
 line 83, in rendered_content
 content = template.render(context, self._request)
   File 
 "c:\python36\lib\site-packages\django\template\backends\django.py", line 
 61, in render
 return self.template.render(context)
   File "c:\python36\lib\site-packages\django\template\base.py", line 
 175, in render
 return self._render(context)
   File "c:\python36\lib\site-packages\django\template\base.py", line 
 167, in _render
 return self.nodelist.render(context)
   File "c:\python36\lib\site-packages\django\template\base.py", line 
 943, in render
 bit = node.render_annotated(context)
   File "c:\python36\lib\site-packages\django\template\base.py", line 
 910, in render_annotated
 return self.render(context)
   File "c:\python36\lib\site-packages\django\template\defaulttags.py", 
 line 314, in render
 return nodelist.render(context)
   File "c:\python36\lib\site-packages\django\template\base.py", line 
 943, in render
 bit = node.render_annotated(context)
   File "c:\python36\lib\site-packages\django\template\base.py", line 
 910, in render_annotated
 return self.render(context)
   File "c:\python36\lib\site-packages\django\template\defaulttags.py", 
 line 211, in render
 nodelist.append(node.render_annotated(context))
   File "c:\python36\lib\site-packages\django\template\base.py", line 
 910, in render_annotated
 return self.render(context)
   File "c:\python36\lib\site-packages\django\template\defaulttags.py", 
 line 447, in render
 url = reverse(view_name, args=args, kwargs=kwargs, 
 current_app=current_app)
   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 'detail' with 
 arguments '(1,)' not found. 1 pattern(s) tried: ['\\>>> [08/May/2018 22:00:42] "GET / HTTP/1.1" 500 134672

 views.py:

 from django.shortcuts import get_object_or_404, render
 from django.http import HttpResponseRedirect
 from django.urls import reverse
 from django.views import generic

 from . models import Choice, Question


 class IndexView(generic.ListView):
 template_name = 'polls/index.html'
 context_object_name = 'latest_question_list'

 def get_queryset(self):
 """Return the last five published questions."""
 return Question.objects.order_by('-pub_date')[:5]


 class DetailView(generic.DetailView):
 model = Question
 template_name = 'po

Re: While going through Django tutorial i commited an error because of which i am not able to execute python manage.py runserver. The exceptions and codes are mentioned below: In exception it is menti

2018-05-08 Thread C. Kirby
Seriously?

path('/', views.DetailView.as_view(), name='detail'),

You have posted several time in the last two days and every issue you have 
had has been a typo. People on this board are happy to help with django 
issues, but you should be really using an IDE that will catch at least some 
of these typos. PyCharm is a good one

On Tuesday, May 8, 2018 at 12:52:15 PM UTC-4, Avitab Ayan Sarmah wrote:
>
> Please mention where exactly I missed >
>
>
> On Tue 8 May, 2018, 10:19 PM C. Kirby, > 
> wrote:
>
>> You are missing a closing '>' in your detail url
>>
>> On Tuesday, May 8, 2018 at 12:42:20 PM UTC-4, Avitab Ayan Sarmah wrote:
>>>
>>> polls/urls.py:
>>>
>>> from django.urls import path
>>>
>>> from . import views
>>>
>>> app_name = 'polls'
>>> urlpatterns = [
>>> # ex: /polls/
>>> path('', views.IndexView.as_view(), name='index'),
>>> path('>> path('/results/', views.ResultsView.as_view(), name='results'),
>>> path('/vote/', views.vote, name='vote'),
>>> ]
>>>
>>>
>>> On Tuesday, May 8, 2018 at 10:09:44 PM UTC+5:30, Julio Biason wrote:

 Your problem is your urls.py:

 django.urls.exceptions.NoReverseMatch: Reverse for 'detail' with 
 arguments '(1,)' not found. 1 pattern(s) tried: ['\\>>>
 You are looking for a URL named "details" which accepts 1 number and 
 Django does not know it.

 On Tue, May 8, 2018 at 1:34 PM, Avitab Ayan Sarmah  
 wrote:

> Exceptions:
>
> PS C:\Users\AVITABAYAN\mysite> python manage.py runserver
> Performing system checks...
>
> System check identified no issues (0 silenced).
> May 08, 2018 - 22:00:28
> Django version 2.0.1, using settings 'mysite.settings'
> Starting development server at http://127.0.0.1:8000/
> Quit the server with CTRL-BREAK.
> Internal Server Error: /
> 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 158, in _get_response
> response = self.process_exception_by_middleware(e, request)
>   File "c:\python36\lib\site-packages\django\core\handlers\base.py", 
> line 156, in _get_response
> response = response.render()
>   File "c:\python36\lib\site-packages\django\template\response.py", 
> line 106, in render
> self.content = self.rendered_content
>   File "c:\python36\lib\site-packages\django\template\response.py", 
> line 83, in rendered_content
> content = template.render(context, self._request)
>   File 
> "c:\python36\lib\site-packages\django\template\backends\django.py", line 
> 61, in render
> return self.template.render(context)
>   File "c:\python36\lib\site-packages\django\template\base.py", line 
> 175, in render
> return self._render(context)
>   File "c:\python36\lib\site-packages\django\template\base.py", line 
> 167, in _render
> return self.nodelist.render(context)
>   File "c:\python36\lib\site-packages\django\template\base.py", line 
> 943, in render
> bit = node.render_annotated(context)
>   File "c:\python36\lib\site-packages\django\template\base.py", line 
> 910, in render_annotated
> return self.render(context)
>   File "c:\python36\lib\site-packages\django\template\defaulttags.py", 
> line 314, in render
> return nodelist.render(context)
>   File "c:\python36\lib\site-packages\django\template\base.py", line 
> 943, in render
> bit = node.render_annotated(context)
>   File "c:\python36\lib\site-packages\django\template\base.py", line 
> 910, in render_annotated
> return self.render(context)
>   File "c:\python36\lib\site-packages\django\template\defaulttags.py", 
> line 211, in render
> nodelist.append(node.render_annotated(context))
>   File "c:\python36\lib\site-packages\django\template\base.py", line 
> 910, in render_annotated
> return self.render(context)
>   File "c:\python36\lib\site-packages\django\template\defaulttags.py", 
> line 447, in render
> url = reverse(view_name, args=args, kwargs=kwargs, 
> current_app=current_app)
>   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 'detail' with 
> arguments '(1,)' not found. 1 pattern(s) tried: ['\\ [08/May/2018 22:00:42] "GET / HTTP/1.1" 500 134672
>
> views.py:
>
> from django.shortcuts import get_object_or_404, render
> from django.http import HttpResponseRedirec

Re: While going through Django tutorial i commited an error because of which i am not able to execute python manage.py runserver. The exceptions and codes are mentioned below: In exception it is menti

2018-05-08 Thread Avitab Ayan Sarmah
Thank you Kirby I found the error and now my code is running fine. Thanks
again

On Tue 8 May, 2018, 10:26 PM C. Kirby,  wrote:

> Seriously?
>
> path(' Should be
> path('/', views.DetailView.as_view(), name='detail'),
>
> You have posted several time in the last two days and every issue you have
> had has been a typo. People on this board are happy to help with django
> issues, but you should be really using an IDE that will catch at least some
> of these typos. PyCharm is a good one
>
> On Tuesday, May 8, 2018 at 12:52:15 PM UTC-4, Avitab Ayan Sarmah wrote:
>>
>> Please mention where exactly I missed >
>>
>>
>> On Tue 8 May, 2018, 10:19 PM C. Kirby,  wrote:
>>
>>> You are missing a closing '>' in your detail url
>>>
>>> On Tuesday, May 8, 2018 at 12:42:20 PM UTC-4, Avitab Ayan Sarmah wrote:

 polls/urls.py:

 from django.urls import path

 from . import views

 app_name = 'polls'
 urlpatterns = [
 # ex: /polls/
 path('', views.IndexView.as_view(), name='index'),
 path('>>> path('/results/', views.ResultsView.as_view(), name='results'),
 path('/vote/', views.vote, name='vote'),
 ]


 On Tuesday, May 8, 2018 at 10:09:44 PM UTC+5:30, Julio Biason wrote:
>
> Your problem is your urls.py:
>
> django.urls.exceptions.NoReverseMatch: Reverse for 'detail' with
> arguments '(1,)' not found. 1 pattern(s) tried: ['\\
> You are looking for a URL named "details" which accepts 1 number and
> Django does not know it.
>
> On Tue, May 8, 2018 at 1:34 PM, Avitab Ayan Sarmah  > wrote:
>
>> Exceptions:
>>
>> PS C:\Users\AVITABAYAN\mysite> python manage.py runserver
>> Performing system checks...
>>
>> System check identified no issues (0 silenced).
>> May 08, 2018 - 22:00:28
>> Django version 2.0.1, using settings 'mysite.settings'
>> Starting development server at http://127.0.0.1:8000/
>> Quit the server with CTRL-BREAK.
>> Internal Server Error: /
>> 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 158, in _get_response
>> response = self.process_exception_by_middleware(e, request)
>>   File "c:\python36\lib\site-packages\django\core\handlers\base.py",
>> line 156, in _get_response
>> response = response.render()
>>   File "c:\python36\lib\site-packages\django\template\response.py",
>> line 106, in render
>> self.content = self.rendered_content
>>   File "c:\python36\lib\site-packages\django\template\response.py",
>> line 83, in rendered_content
>> content = template.render(context, self._request)
>>   File
>> "c:\python36\lib\site-packages\django\template\backends\django.py", line
>> 61, in render
>> return self.template.render(context)
>>   File "c:\python36\lib\site-packages\django\template\base.py", line
>> 175, in render
>> return self._render(context)
>>   File "c:\python36\lib\site-packages\django\template\base.py", line
>> 167, in _render
>> return self.nodelist.render(context)
>>   File "c:\python36\lib\site-packages\django\template\base.py", line
>> 943, in render
>> bit = node.render_annotated(context)
>>   File "c:\python36\lib\site-packages\django\template\base.py", line
>> 910, in render_annotated
>> return self.render(context)
>>   File
>> "c:\python36\lib\site-packages\django\template\defaulttags.py", line 314,
>> in render
>> return nodelist.render(context)
>>   File "c:\python36\lib\site-packages\django\template\base.py", line
>> 943, in render
>> bit = node.render_annotated(context)
>>   File "c:\python36\lib\site-packages\django\template\base.py", line
>> 910, in render_annotated
>> return self.render(context)
>>   File
>> "c:\python36\lib\site-packages\django\template\defaulttags.py", line 211,
>> in render
>> nodelist.append(node.render_annotated(context))
>>   File "c:\python36\lib\site-packages\django\template\base.py", line
>> 910, in render_annotated
>> return self.render(context)
>>   File
>> "c:\python36\lib\site-packages\django\template\defaulttags.py", line 447,
>> in render
>> url = reverse(view_name, args=args, kwargs=kwargs,
>> current_app=current_app)
>>   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 'd

Re: M2M Magic Accessors without explicit ManyToMany Field

2018-05-08 Thread Vijay Khemlani
Why would it be a muti table inheritance?

I would just inherit Car (class MyCar) and add the m2m field there, seems
way more explicit and easy to understand too.

On Tue, May 8, 2018 at 12:18 PM Clayton D  wrote:

> I posted a question on SO (https://stackoverflow.com/q/50222402/1978687),
> but it's been viewed very few times so I'm hoping this is the right place
> to get attention from those "in the know".  The complete question (and
> progress so far) is documented on SO so that's probably the best place to
> answer.
>
> The essentials of the question are:
>
>- I need to create an M2M relationship between two models, but...
>- The models are from external libraries (trivially User and Car)
>- The models are non-abstract and multi-table inheritance would
>introduce a ton of unnecessary overhead
>- Others will use my code like (if not literally as) a 3rd party
>library so I want to provide all of the usual magic methods for usability
>-- e.g. Cars.objects.filter(users=user) -- which doesn't happen if I create
>a manual M2M (i.e. "through") table.
>
> A commenter suggested using `add_to_class` on one of the 3rd party
> models.  It passes trivial test cases, but has hair and some of the magic
> breaks because it's treated as a `through=` relationship even though it's a
> trivial M2M table.
>
> I'm hoping someone who understands the ManyToMany implementation can tell
> me if I can hijack the `contribute...` methods (or something similar) to
> get this job done.
>
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/cc6f6c74-e5df-4fcf-b473-42f894fd3abb%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/CALn3ei1SzY12rvv%2BQsL9NP9yc_z%2BET6ZZD%2BssgmALHA43xtY%2BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Upgrading from 1.11 to 2.0: "sqlite3.OperationalError: no such table"

2018-05-08 Thread Informatico Neurodesarrollo

Check 1.11 to 2.0 upgrade.
You already checked the project configuration and make migrations ?, it 
could be changed with the upgrade!!!

I will hope help you.

PD I'm a beginner in Django.

El 06/05/18 a las 23:38, Michael Gauland escribió:
Just in case anyone else runs into this, I fixed it by specifying 
db_contraint=False for foreign keys which cross databases.

--
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/aaca2372-f0f3-4e60-98cc-b7f906867606%40googlegroups.com 
.

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


--

Jesús Reyes Piedra
Admin Red Neurodesarrollo,Cárdenas
La caja decía:"Requiere windows 95 o superior"...
Entonces instalé LINUX.



--
Este mensaje le ha llegado mediante el servicio de correo electronico que 
ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema 
Nacional de Salud. La persona que envia este correo asume el compromiso de usar 
el servicio a tales fines y cumplir con las regulaciones establecidas

Infomed: http://www.sld.cu/

--
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/5AF1F35F.8060903%40infomed.sld.cu.
For more options, visit https://groups.google.com/d/optout.


@mark_safe decorator and filters & tags

2018-05-08 Thread Torsten Bronger
Hallöchen!

Up to Django 1.11, I had the following pattern frequently in my
code:

@register.filter
@mark_safe
def myfilter(value):
...

Smilarly for tags.  This has worked for years, however, with Django
2.0, this leads to the TemplateError saying that "myfilter requires
0 arguments, 1 provided".  For tags, it results in an IndexError
because the "params" list when processing the tag is empty.

If I make @mark_safe the outmost (i.e. first) decorator, no
exception occurs – but the output is escaped HTML instead of
passed-through HTML.

The safe and obvious workaround is to use mark_safe() as a function
instead of @mark_safe.  Would be a pity, though.

Is this a bug or am I doing something wrong?

Tschö,
Torsten.

-- 
Torsten Bronger

-- 
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/87vabxj2s4.fsf%40wilson.bronger.org.
For more options, visit https://groups.google.com/d/optout.


Re: sphinx is showing the django base views instead of my own views.py

2018-05-08 Thread Anthony Petrillo
Solved.

Thank you again Tony for pointing me in the right direction.

Jens Hedegaard Nielsen gave the answer (indirectly) 
at https://github.com/sphinx-doc/sphinx/issues/4182. There he pointed to 

autodoc_mock_imports = ["django"] 

in the Sphinx 
documentation 
http://www.sphinx-doc.org/en/stable/ext/autodoc.html#confval-autodoc_mock_imports

Anthony

On Friday, May 4, 2018 at 11:25:20 AM UTC-4, Anthony Petrillo wrote:
>
> The view being shown when using Sphinx on a Django site is: 
>
>
> 
>
>
> The beginning of my views.py is:
>
>
> import os
>
> from django.shortcuts import render, redirect 
>
> from django.urls import reverse 
>
> from django.http import HttpResponse, HttpResponseRedirect 
>
> from django.utils import timezone
>
> from . forms import PlayForm, RollForm, checkBoard, BossForm
>
> from random import randint 
>
> from . templatetags.playExtras import translateDice 
>
> from .models import Board, Winner, Boss
>
>
> def getFirstFolder(req):
>
> """ return the string between first two / - this is a hack, find out 
> how to do it with the object """
>
> r = req.split("'")
>
> loc = r[1].find('/',1)
>
> x = r[1][1:loc]
>
> return(x)
>
>
> def loadBoard(request,context,location=''):
>
> ''' Load the board from the database into context. Add a hyperlink for 
> available squares.
>
>
> :param context: context for template
>
> :type context: dictionary
>
>
> :param location: Comma seperated string of available locations or 
> empty string so no links included.
>
> :type location: str
>
>
> :return: 'not on the board' or 'all taken' or comma seperated string 
> of location options such as 'A0,B0'
>
> :rtype: str
>
> '''
>
> req = request.__str__()
>
> I was getting errors if I didn't show Sphinx where the Python was located. 
> The path additions I made in the Sphinx's conf.py are:
>
> ourPaths = [
> '/game/',
> '/game/game',
> '/game/play',
> '/game/play/templatetags'
> ]
> for p in ourPaths:
> abspath = os.path.abspath('.')  + p
> print('path..',abspath)
> sys.path.insert(0, abspath)
> # Need to point to where the Django is on this system. FIND OUT HOW TO 
> MAKE THIS RELATIVE
> sys.path.insert(0,'/home/ajp/Downloads/env/lib/python3.5/site-packages')
>
> sys.path.insert(0,'/home/ajp/Downloads/env/lib/python3.5/site-packages/django')
>
>
> The views.rst file I'm using: 
>
> views module
> ==
>
> .. automodule:: views
> :members:
> :undoc-members:
> :show-inheritance:
>
> I searched for days but I'm afraid I do not know the right terms search 
> for to find the answer. I posted on stackoverflow for a couple weeks and no 
> responses at all. 
>
> I'm okay with the other code showing up, but I'd need to see my code in 
> the manual as well.
>
> Thank you for any help you can give. 
>

-- 
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/ebe15a98-9139-4eba-bd4d-f86e015477bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.