How to use the Django-Scheduler package? - python

I am looking to use the Django-Scheduler package in my Django project but am finding it difficult to understand how to actually implement the calendar so that it can be seen on the actual website. My website is meant to be a timetable scheduling system where users can login and use and edit there own timetable/calendar. I have already implemented the login and registrastion using django registration redux. I have also already installed django-scheduler using pip and have edited my projects settings like so:
INSTALLED_APPS += ('schedule',)
add to
TEMPLATE_CONTEXT_PROCESSORS += (
"django.core.context_processors.request",
)
This is explained on the github page for django-scheduler. I have read through the documentation but am still not sure as to how to have a usable calendar on the page the user is sent to after logging in.
Could someone please explain to me as to how I can achieve this. What do I put in my projects url.py file for django-scheduler like eg the url for django-calendarium,
url(r'^calendar/', include('calendarium.urls')),
Do I have to create new templates etc.
Hope somebody can help ! Thanks

this will serve you
url(r'^calendar/', include('schedule.urls')),
if you still to know more about the url, views, models and config of schedule check https://github.com/llazzaro/django-scheduler/tree/develop/schedule and https://github.com/llazzaro/django-scheduler/tree/develop/schedule/urls.py for

Related

Integrate Piwik tracking code into Sphinx-generated docs hosted on readthedocs.io

While readthedocs.io offers the possibility to enable Google Analytics for a page by just adding the tracking ID within a project's settings, the same offer does not seem to exists for using Piwik.
I would like to use Piwik for a page that I generate for a Python project using Sphinx and that is hosted on readthedocs.io. I guess one way to enable it would be to add the Piwik tracking code to the page template as mentioned in https://github.com/rtfd/readthedocs.org/issues/199 however I'm not sure how to start with this.
Has someone been able to use Piwki in this configuration or an idea on how to achieve it? Thank you very much for your help!
Modify your theme's template, inserting your Piwik tracking code. My answer to a related question can point you in the right direction.

Templates on Django

I'm newbie on web dev and chose Django to start, in my application I need sign up and sign in freatures, searching i've found about django-registration:
Link to repo
The setting file and url are already configured, but I have to make the templates for login - I got some templates for test - but I have no idea where to put it, if I have to create a new app ("... startnewapp registration") or just create a directory for templates somewhere.
Can you help me?
you dont really need an external app for just a registration. it is simply one urlconf and one view.
but the most important thing for you now is to go through the tutorial, because tutorial tells you what to put where exactly.. and this cannot be explained here in 3 lines of text
Especially at the beginning it is very helpful to see an example where to put the things together. I developed a django-skeleton, which basically bootstraps a Django installation and boosts starting a new project. I also created views to use the builtin authentication module of Django for registration and to login: https://github.com/n2o/django-skeleton/
In this case I created a separate login app to modify the views and create my own templates.
This is not the easiest way to modify existing templates, but it fulfills all of my requirements.

Using custom forms in Django instead of modifying the source files

Let me preface this by saying I'm VERY new to Django and am also having a hard time with some of the documentation. I know that this question has surely been asked and answered a thousand times, but I can't seem to phrase my query properly.
I'm making a project that uses django-registration-redux, and I wanted to customize the template and the forms to accept additional user information. First, I noticed that my changes to the template files weren't having any effect , then I realized that it was using the template files from my Python install location instead of my actual project. I fixed this by setting the templates folder setting, but I also need to modify the registration-redux forms, and can't figure out how to override the default forms with local forms in my application.
You need not change the template settings for your existing project, but you have to make sure you have included 'registration' in the list of your INSTALLED_APPS. In the documentation its mentioned that
You can extend and customize the included templates as needed
Though its not very clear here, django registration redux is built on top of the in built django registration module. What you need to do is build your own custom registration form which is already explained in this answer.
In your case the template that you need to modify/extend is registration/registration_form.html.
Other useful resources that can help you:
http://www.tangowithdjango.com/book17/chapters/login_redux.html
https://www.youtube.com/watch?v=qkFWkOw-ByU

Add a debugging page to a Django project?

I'm supplying a Django project to a client, who has requested a 'debugging' page that will show useful information.
[UPDATE for clarity: We'd like this page so we can use it for debugging in future: the clients are not very technical and I won't have direct access to their servers. In the event of future issues, it would be very useful if I could check out this page without asking them to edit the Debug setting or do any other server-side fiddling.]
The project will be running in production, so I can't set DEBUG=True.
What I would like is a page similar to the Django debugging page but without any sensitive information in.
I guess I can simply write my own, but does anyone have any ideas? Anything standard in Django I could use?
Thanks!
Googling 'standard Django debugging page'
Isn't as effective as reading the Django source itself.
Look in base.py for code like this
from django.views import debug
That will provide you some hints as to how they do it.
Then you can look at django/views/debug.py for the "technical_404_response" view function. You can use this function in your code, also.
You can use Django Debug Toolbar and enable it only for choosen IPs

How to configure the webserver to server a particular page as the default page?

I am using Lighttpd and Django. I have configured my Lighttpd server to pass all the requests ending with ".psp" extension to Django.
My startup page is a page served through Django, which is accessed as "http://192.168.1.198/home.psp". I want to enable the user to browse this page without writing "home.psp" explicitly in the url i.e. using "http://192.168.1.198"
Is this possible?
Thanks for any help in advance.
I think you're confusing concepts here between the "old" method of having individual files represent web pages which themselves contain code that is passed off to an interpreter before being sent in a response to how django/frameworks work.
If you're familiar with apache, imagine django as in part taking on the role of mod_rewrite. Django, and other frameworks, have what's called a dispatcher, or routing, mechanism.
Basically, they subscribe to the MVC pattern that says you should separate out the model, controller and view (in django parlance, model, template and view).
Now what then happens is you have a file called urls.py in django, which contains a list of routes (urls) and names of methods (usually contained in views.py) which handle them. Here's an example:
urlpatterns = patterns('',
url(r'^dologin$', 'testapp.views.auth_login', name="auth-login-uri"),
url(r'^doopenidlogin$', 'testapp.views.auth_openid_login', name="auth-openid-login-uri"),
url(r'^dologout$', 'testapp.views.auth_logout', name="auth-logout-uri"),
url(r'^login$', 'testapp.views.loginform', name="login-form"),
url(r'^openidlogin$', 'testapp.views.openidloginform', name="openid-login-form"),
url(r'^$', 'testapp.views.index', name="index"),
)
Here testapp is a python package, views.py is a python file and index is a django view. The url is constructed from regex, so I can have whatever I want as the url, much how stackoverflow urls are formed.
So basically, you never need file extensions again. I'd strongly suggest getting a good book on django - there are a few around.
What you might be looking for is the index-file.names directive in Lighty's configuration file. Just add "home.psp" to the list in your configuration file, and Lighty will look for it when no filename is specified.
I solved the problem myself. Here is what I did:
I had to add a statement inside url.rewrite-once block of lighttpd's configuration file like:
url.rewrite-once = (
"^(/media.*)$" => "$1",
"^(/static.*)$" => "$1",
"^/favicon\.ico$" => "/media/favicon.ico",
"^(/)$" => "/my_project_dir/home.psp",
"^(/.*)$" => "/my_project_dir$1",
)
Apart from this, I added the following line in my urls.py:
(r'^$',my_index_view_name),
Hope this helps someone in the future. Thanks everybody for your replies above. Cheers!

Categories