Question

I'm doing a website for my school in Django. The blog part is almost ready, but on every page I want to have a sidebar with planned changes in the timetable (i.e. when a teacher is ill and classes will have lessons with another teachers in another classrooms). What would be the best way to implement that? I've heard about templatetags, RequestContext and other things like that. That is my first Django project and I'm learning new things every day.

Now I have one app in the project which is called blog (it's models are: Posts, Categories and Pages; Page is like a flatpage but it is assigned to a category by a ForeignKey). In project's urls.py every request (beside /admin) is forwarded to blog.urls where the further actions are taken (choosing the appropriate view class). Views are written using generic views and class inheritance. There are: PostListView, PostView, PageView. The PageListView is unneeded because user is able to choose Page from the main navbar.

The 'changes sidebar' should allow the user to choose a date and reload itself without reloading the whole page.

I would be really grateful if someone could help me with an idea on implementing it. If you have any questions - ask.

Was it helpful?

Solution

The 'changes sidebar' should allow the user to choose a date and reload itself without reloading the whole page.

Ok, so you need AJAX for this part. For more complex projects you can use django-rest-framework or tastypie but for this I reccomend to do an AJAX function that gets a date as parameter and return a rendered template. See this thread and this one too

To include the sidebar, I'll just create a separate template for it and include {% include 'changes_sidebar.html' %} you also need to include the javascript to do the ajax requests.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top