Did anyone installed RPi and use it in the django Python framework? I've tried to wire up a motion sensor with the django but I'm stuck while trying to use RPi.GPIO inside django view and I get:

Django - Module (RPi.GPIO) not imported correctly

1 Answer 1


to install django you may try:

sudo apt-get install python-django

or even better, you may try a better/smaller jinja instead:

sudo apt-get install python-jinja2 (or 3, if you like)

jinja is very much like django, but very lightweight and has more features.

  • Thanks for your answer but I'm not sure how can use that...
    – el.severo
    Commented Jun 9, 2013 at 12:47
  • could you please revise your question in the form, "i've tried this and this and i'm stuck at [something]?", otherwise it's quite difficult to understand what exactly you need help with.
    – lenik
    Commented Jun 9, 2013 at 16:30
  • Thanks for your comments! I'm aware that a better elaboration of this problem could be done. Do you have any background with RaspberryPi, Django and RPi.GPIO ?
    – el.severo
    Commented Jun 9, 2013 at 17:30
  • 1
    i have experience with all of them, but not at the same time =) regarding the django and GPIO -- the main problem is you have to run GPIO software as root, and running django as root is generally not recommended. if i were you, i'd make a small separate modules, that have setUID bit set and access GPIO pins, printing some results to the stdout. then you may call them from your django scripts and parse the results. anyway, it's much easies to debug GPIO as a separate small modules, and only when these work you may think about interfacing them to django.
    – lenik
    Commented Jun 10, 2013 at 9:53
  • Thanks for sharing the tip! Can you help me out with a code sample? That would help me a lot!. I've tried almost everything that I could imagine, and in the final stage decided to use Flask but if that's not so hard as you say maybe its not to late to get the old option back ;)
    – el.severo
    Commented Jun 11, 2013 at 21:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.