Thank you james i found the error and now another error i found please help me on this.You will see this as another topic
On Friday, May 18, 2018 at 10:22:13 PM UTC+5:30, Avitab Ayan Sarmah wrote:
-- On Friday, May 18, 2018 at 10:22:13 PM UTC+5:30, Avitab Ayan Sarmah wrote:
Hi james,Please check my code clearly because i didn;t found any indentation error and everything is same
On Friday, May 18, 2018 at 10:09:35 PM UTC+5:30, James Farris wrote:The Indentation error is related to the spaces you have when you write your code.Based on looking at what you copy/pastedThe indentation of your def get_queryset is different from your other def's.Python is very picky of how much or how little you indent your code for good reason.Everything that is nested inside something else should be 4 spaces or a tab in. For example a def should be 4 spaces in from its class, a variable should be 4 spaces in from its def.IndentationError: unindent does not match any outer indentation levelOn Fri, May 18, 2018 at 9:08 AM Avitab Ayan Sarmah <avita...@gmail.com> wrote:While going through the django project i committed an error while executing "python manage.py runserver" inside my project directory.It is showing error is in line 24 of views.py.Please comment what exact the error is and how do i overcome this error.The exceptions and views.py is mentioned below:--Exceptions:PS C:\Users\AVITABAYAN\mysite> python manage.py runserverPerforming system checks...Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x0000017BA5FB29D8>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 "<frozen importlib._bootstrap>", line 978, in _gcd_importFile "<frozen importlib._bootstrap>", line 961, in _find_and_loadFile "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 655, in _load_unlockedFile "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removedFile "C:\Users\AVITABAYAN\mysite\mysite\urls.py", line 5, in <module> 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 "<frozen importlib._bootstrap>", line 978, in _gcd_importFile "<frozen importlib._bootstrap>", line 961, in _find_and_loadFile "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 655, in _load_unlockedFile "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removedFile "C:\Users\AVITABAYAN\mysite\polls\urls.py", line 3, in <module> from . import viewsFile "C:\Users\AVITABAYAN\mysite\polls\views.py", line 24 def get_queryset(self):^IndentationError: unindent does not match any outer indentation levelviews.py:from django.shortcuts import get_object_or_404, renderfrom django.http import HttpResponseRedirectfrom django.urls import reversefrom django.views import genericfrom django.utils import timezonefrom . models import Choice, Questionclass IndexView(generic.ListView):template_name = 'polls/index.html'context_object_name = 'latest_question_list'def get_queryset(self):"""Return the last five published questions(not including those settingsto bepublished in the future)."""return Question.objects.filter(pub_date__lte=timezone.now()). order_by('-pub_date')[:5] class DetailView(generic.DetailView): model = Questiontemplate_name = 'polls/detail.html'def get_queryset(self):"""Excludes any questions that aren't published yet."""return Question.objects.filter(pub_date__lte=timezone.now()) class ResultsView(generic.DetailView): model = Questiontemplate_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 +=1selected_choice.save()#...#...#...return HttpResponseRedirect(reverse('polls:results', args=(question.id,)))
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/37bf86bc- .9cc1-44b8-94e2-430a7daa557c% 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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c3fe5ecc-f1d2-462e-afd1-fc044801b5ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment