
from django.http import Http404
from django.shortcuts import render
from django.template import loader
from .models import Project


def index(request):
    '''
    Project listing
    '''

    projects = Project.objects.filter(status=Project.PUBLIC).order_by('-date')
    template = loader.get_template('projects/page-index.html')

    return HttpResponse(template.render({'projects': projects}))


def project(request, slug):
    '''
    Display project details
    '''

    try:
        project = Project.objects.get(slug=slug,status=Project.PUBLIC)
    except ObjectDoesNotExist:
        raise Http404('Project {} does not exist' % slug)

    template = loader.get_template('projects/page-project.html')

    return HttpResponse(template.render({'project': project}))



from django.http import Http404, HttpResponse
from django.shortcuts import render
from django.template import loader
from .models import Project


def index(request):
    '''
    Project listing
    '''

    projects = Project.objects.exclude(status=Project.HIDDEN).order_by('-date')
    template = loader.get_template('projects/page-index.html')

    return HttpResponse(template.render({'projects': projects}))


def project(request, slug):
    '''
    Display project details
    '''

    try:
        project = Project.objects.exclude(status=Project.HIDDEN).get(slug=slug)
    except ObjectDoesNotExist:
        raise Http404('Project {} does not exist' % slug)

    template = loader.get_template('projects/page-project.html')

    return HttpResponse(template.render({'project': project}))


Add missing include, and switch to exclude projects with HIDDEN status from public display
Add missing include, and switch to exclude projects with HIDDEN status from public display

  
- from django.http import Http404
+ from django.http import Http404, HttpResponse
  from django.shortcuts import render
  from django.template import loader
  from .models import Project
  
  
  def index(request):
      '''
      Project listing
      '''
  
-     projects = Project.objects.filter(status=Project.PUBLIC).order_by('-date')
+     projects = Project.objects.exclude(status=Project.HIDDEN).order_by('-date')
      template = loader.get_template('projects/page-index.html')
  
      return HttpResponse(template.render({'projects': projects}))
  
  
  def project(request, slug):
      '''
      Display project details
      '''
  
      try:
-         project = Project.objects.get(slug=slug,status=Project.PUBLIC)
+         project = Project.objects.exclude(status=Project.HIDDEN).get(slug=slug)
      except ObjectDoesNotExist:
          raise Http404('Project {} does not exist' % slug)
  
      template = loader.get_template('projects/page-project.html')
  
      return HttpResponse(template.render({'project': project}))
  
  
Add missing include, and switch to exclude projects with HIDDEN status from public display
## Code Before:

from django.http import Http404
from django.shortcuts import render
from django.template import loader
from .models import Project


def index(request):
    '''
    Project listing
    '''

    projects = Project.objects.filter(status=Project.PUBLIC).order_by('-date')
    template = loader.get_template('projects/page-index.html')

    return HttpResponse(template.render({'projects': projects}))


def project(request, slug):
    '''
    Display project details
    '''

    try:
        project = Project.objects.get(slug=slug,status=Project.PUBLIC)
    except ObjectDoesNotExist:
        raise Http404('Project {} does not exist' % slug)

    template = loader.get_template('projects/page-project.html')

    return HttpResponse(template.render({'project': project}))


## Instruction:
Add missing include, and switch to exclude projects with HIDDEN status from public display
## Code After:

from django.http import Http404, HttpResponse
from django.shortcuts import render
from django.template import loader
from .models import Project


def index(request):
    '''
    Project listing
    '''

    projects = Project.objects.exclude(status=Project.HIDDEN).order_by('-date')
    template = loader.get_template('projects/page-index.html')

    return HttpResponse(template.render({'projects': projects}))


def project(request, slug):
    '''
    Display project details
    '''

    try:
        project = Project.objects.exclude(status=Project.HIDDEN).get(slug=slug)
    except ObjectDoesNotExist:
        raise Http404('Project {} does not exist' % slug)

    template = loader.get_template('projects/page-project.html')

    return HttpResponse(template.render({'project': project}))

