Answer the question
In order to leave comments, you need to log in
What can be used as help for a project in Django?
Good afternoon!
There is a task: take the directory structure:
directory/
./name.txt
./content.html
./subdirectory/
./subdirectory/name.txt
./subdirectory/content.html On the
left, display the names for each directory in the form of a tree, and on the right - content in content.html when clicked.
Before implementing help for the application in this form, I would like to ask: are there ready-made solutions that can be used and easily transferred from one server to another? (and what are the problems with help-s that store everything in relational databases?)
Thank you!
Answer the question
In order to leave comments, you need to log in
I’ll bring my bike)
First, the structure can be simplified and universalized at the same time:
docs/
./intro1.md
./intro2.md
./chapter1/
./chapter1/part1.md
./chapter1/part2.md
urlpatterns = patterns(
'',
url(r'^wiki/(.*)$', 'wiki.views.wiki', name='wiki'),
)
def wiki(request, page=None):
if not page:
page = 'main'
file_name = os.path.join('.', 'wiki', page)
file_name = ''.join((file_name, '.md'))
input_file = codecs.open(file_name, mode="r", encoding="utf-8")
text = input_file.read()
input_file.close()
content = markdown.markdown(text)
context = {
"wiki_content": content,
"wiki_title": page
}
return render_to_response(
'wiki.html',
dirs=get_dirs(),
dictionary=context,
context_instance=RequestContext(request)
)
<!DOCTYPE html>
<html>
<head>
<title>{{ wiki_title }} - Wiki</title>
</head>
<body>
<h1>{{ wiki_title }}</h1>
<hr>
<div class="content">
{{ wiki_content|safe }}
</div>
</body>
</html>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question