Jul-03-2020, 04:36 AM
OK I got it to where it's spitting out the information from GitHub Markdown and showing it to me.
Now I'm onto the next step which is the search engine. I'm not sure where I would type my if statements. Do I do this in the view? Or in the manage.py? I'm a little confused as how to go about it can someone try to get me started?
here's what I have :
view.py:
Now I'm onto the next step which is the search engine. I'm not sure where I would type my if statements. Do I do this in the view? Or in the manage.py? I'm a little confused as how to go about it can someone try to get me started?
here's what I have :
view.py:
from django.shortcuts import render from . import util def index(request): return render(request, "encyclopedia/index.html", { "entries": util.list_entries() }) def wiki(request, title): return render(request, "encyclopedia/wiki.html", { "entries": util.get_entry(title) }) def search(request, search): return render(request, "encyclopedia/index.html", { "entries": util.get_entry(search) })urls.py:
from django.urls import path from . import views urlpatterns = [ path("", views.index, name="index"), path("wiki/<str:title>", views.wiki, name="wiki"), ]
#!/usr/bin/env python """Django's command-line utility for administrative tasks.""" import os import sys def main(): os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'wiki.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: raise ImportError( "Couldn't import Django. Are you sure it's installed and " "available on your PYTHONPATH environment variable? Did you " "forget to activate a virtual environment?" ) from exc execute_from_command_line(sys.argv) if __name__ == '__main__': main()Thanks!