Thanks to all in this community who helped me create this django app controlled art!

2013-10-30 Thread 7equivalents



It's just a raspberry Pi Logo but it is just the beginning. There is a user 
interface created with html, css, and javascript libraries. When a user 
changes colors or pushes a button, the interface sends an ajax request and 
Django processess it and updates a Mysql database. A python script checks 
for when the database has been updated and sends corresponding commands via 
usb to an Arduino which controls 96 RGB LED's.

Here is a link to the video...
http://ioiopi.com/raspberry-pi-logo-controlled-and-executed-by-pi-arduino-and-a-strip-of-96-rgb-leds/



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/63fbc7e2-97bc-4fa6-9c4e-99851b9f7159%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Need help figuring out why my { key:value } doesn't seem to be passed to my view by my javascript file.

2013-09-18 Thread 7equivalents
"So I think that the ajax() function is calling the URL 
"/pi/?pathID=somevalue," Is that different than how a key:value pair are 
normally sent? I don't know much about this.
This is the output from the development server...

"GET /pi/ HTTP/1.1" 200 2600

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Need help figuring out why my { key:value } doesn't seem to be passed to my view by my javascript file.

2013-09-17 Thread 7equivalents
I have a javascript file that successfully request a Django view. However 
it seems as if it is not passing the key:value pairs. I have created an if 
else statement that test for the key, and it never see's it. Not sure how 
to proceed. Here is my django View and Javascript click function, in the 
view the else statement always executes

def pi_page(request):
  
  if request.method == "GET":
get = request.GET.copy()
if get.has_key('pathID'):
path_ID = get['pathID']
path = Path.objects.get(pathID=1)
   #path.pathFill = '#fff'   
path.save()
variables = RequestContext(request, {'path': path})
return render_to_response('main_page.html', RequestContext(request))
else:
path = Path.objects.get(pathID=2)
path.pathFill = '#eee'   
path.save()
variables = RequestContext(request, {'path': path})
return render_to_response('main_page.html', RequestContext(request))


.click(function(){
var outputColor = document.getElementById("output");
var outputColorFill =  outputColor.value;
var pathID = paths[arr[this.id]].pathID;
var data = { pathID:pathID };
$.ajax({
url:"/pi/",
cache: "false",
data:data  
});

})



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Need Advise on the best way to track how much time a user is logged in.....

2013-08-22 Thread 7equivalents
My users will not be able to logout by closing a browser because they have 
no such interaction with the system. They will be passing an RFID tag over 
a reader to unlock the door and clock in and a python script will handle 
the loging in and out. So if I can get the logout to time stamp a database 
entry I'll be good.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Need Advise on the best way to track how much time a user is logged in.....

2013-08-22 Thread 7equivalents
 I notice the Django.contrib.Auth has a logout function, is there anyway to 
connect a timestamp to a model when the user uses the logout function? My 
users will be using the log out function. This is for a time clock I'm 
building using RFID tags.

>
> You cannot. The only thing you can do is to try and identify sessions. 
> A session starts when someone logs in, and stops when they stop using 
> the site. 
>
> Since a session only ends when someone stops using the site, the end 
> of a session cannot be recorded during a request, and therefore 
> session/usage analysis must be done outside of the request-response 
> life cycle. 
>
> IE, this needs to be a separate application that analyses the time and 
> user information that you log on each request. 
>
> Cheers 
>
> Tom 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Need Advise on the best way to track how much time a user is logged in.....

2013-08-22 Thread 7equivalents
I have created a model that gives me a time stamp  when a user logs in. I 
connected the 'user_logged_in signal' to a function:

def update_user_login(sender, user), **kwargs):
user.userlogin_set.create(timestamp=user.last_login)
user.save()

So this basically helps me track the login time, but how do I set the 
timestamp to the last_logout? There is no last_logout attribute like there 
is with last_login?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How do I create a script to fill in django admin login form and submit?

2013-08-21 Thread 7equivalents
Thank you so much! You really helped me. I went back and checked the source 
code sent to my browser and did indeed see, name = "this_is_the_login_form'.
I was using the "ID" rather than the "name". My weakness in html kicked me 
this time, thanks for lending a hand!






>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How do I create a script to fill in django admin login form and submit?

2013-08-21 Thread 7equivalents
Thankyou Wongo Bongo! Your solution was spot on correct. It came down to 
one line of code that I modified that was the problem.

login_data = {'username':'jim', 'password':'beam', 
'this_is_the_login_form':'1', 'csrfmiddlewaretoken':csrftoken}

You gave me the correct line, however the, 'this_is_the_login_form':'1' I 
thought you were giving me a generic form name to be replaced with my form 
name, however 'this_is_the_login_form' is the correct form name.

This is where my inexperince has shown through. How did you know that that 
was the name of the form? When I went to django.contrib.auth.forms, it 
seemed the form name was AuthenticationForm, and when I used view source in 
a browser it looked like the form was named login-form. How could one know 
the form was named 'this_is_the_login_form'?



On Monday, August 19, 2013 12:13:21 AM UTC-4, WongoBongo wrote:
>
> You were missing a key. The following works on my machine.
>
> K
>
> ---
>
>
> import requests
> login_url = "http://192.168.0.21/admin/login/";
>
>
> client = requests.session()
> client.get(login_url)
>
>
> csrftoken = client.cookies['csrftoken']
>
>
> login_data = {'username':'jim', 'password':'beam', 
> 'this_is_the_login_form':'1', 'csrfmiddlewaretoken':csrftoken}
>
>
> r = client.post(login_url, data=login_data)
>
>
> target_url = "http://192.168.0.21/admin/auth/user/";
> t = client.get(target_url)
>
>
> 'Select user to change' in t.text # True 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How do I create a script to fill in django admin login form and submit?

2013-08-21 Thread 7equivalents
Still trying to solve this. I cant seem to find anything by googling.

I did read this. 
https://docs.djangoproject.com/en/dev/topics/auth/default/#django.contrib.auth.login

However, when I'm doing this from the shell, I'm not sure what to use as 
request in the Login(request,user) function.

Also when I look at the contrib.auth forms. it appears the form is name 
AuthenticationForm. But when I open the actual admin login page with my 
browser and view source it appears to be called login-form.

I would thing trying to login as a user from the shell would be a common 
occurrence, but I cant figure out how.




-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How do I create a script to fill in django admin login form and submit?

2013-08-20 Thread 7equivalents
I feel as if I'm getting closer, yet haven't successfully  logged in yet. I 
have added in the missing key. I went to the django.contrib.auth.forms to 
find the name of the form that gets submitted in the login page. It seems 
to be called AuthenticationForm.

import requests
login_url = "http://192.168.0.21/admin/login/";


client = requests.session()
client.get(login_url)


csrftoken = client.cookies['csrftoken']


login_data = {'username':'jim', 'password':'beam', 
'AuthenticationForm':'1', 'csrfmiddlewaretoken':csrftoken}


r = client.post(login_url, data=login_data)


Basically after I do this from the python shell, I use another machine to 
log into the admin page and look at user logins, and the user is not logged 
in. Not sure how to proceed.


On Monday, August 19, 2013 12:13:21 AM UTC-4, WongoBongo wrote:
>
> You were missing a key. The following works on my machine.
>
> K
>
> ---
>
>
> import requests
> login_url = "http://192.168.0.21/admin/login/";
>
>
> client = requests.session()
> client.get(login_url)
>
>
> csrftoken = client.cookies['csrftoken']
>
>
> login_data = {'username':'jim', 'password':'beam', 
> 'this_is_the_login_form':'1', 'csrfmiddlewaretoken':csrftoken}
>
>
> r = client.post(login_url, data=login_data)
>
>
> target_url = "http://192.168.0.21/admin/auth/user/";
> t = client.get(target_url)
>
>
> 'Select user to change' in t.text # True 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How do I create a script to fill in django admin login form and submit?

2013-08-18 Thread 7equivalents
Ok, I've gotten further. I have confirmed the problem was related to the 
csrf token. This is my new code:


client = requests.session()
# Retrieve the CSRF token first
client.get(URL)  # sets the cookie
csrftoken = client.cookies['csrftoken']

login_data = dict(Username='jim', Password='beam, csrfmiddlewaretoken=csrftoken)
r = client.post(URL, data=login_data)

Now, I get a 200 for the status code, but it still doesn't actually 
login..

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How do I create a script to fill in django admin login form and submit?

2013-08-18 Thread 7equivalents
Ok, I've gotten further. I have confirmed the problem was related to the 
csrf token. This is my new code:


client = requests.session()
# Retrieve the CSRF token first
client.get(URL)  # sets the cookie
csrftoken = client.cookies['csrftoken']

login_data = dict(Username='jim', Password='beam, csrfmiddlewaretoken=csrftoken)
r = client.post(URL, data=login_data)

Now, I get a 200 for the status code, but it still doesn't actually 
login..



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How do I create a script to fill in django admin login form and submit?

2013-08-18 Thread 7equivalents
Well this is where I'm at. I have used the requests package  to try and 
request the Django Admin login page and submit the username and password. 
However, when I do this I get a 403 error. I have tried to turn off the 
dependency for csrf tokens in the login view by using the csrf_exempt,but 
this gave me a 500 error. So I need to break this down to learn whats going 
on. So here is the code I'm typing into the python prompt:

import rquests

url = "http://192.168.0.21/admin/login/";
payload = {'Username':'jimmy', 'Password':'Beam'}
r = requests.post(url, payload)


I get a 403.

My questions are:
(1) Is the the code above the correct way to fill in and submit the django user 
login form?
(2) What should I do next to troubleshoot the problem?


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


How do I create a script to fill in django admin login form and submit?

2013-08-13 Thread 7equivalents
Here is what I'm doing. I have written a script the runs and monitors a 
serial connection for incoming data. The data comes from an RFID tag 
reader. I have that working. What I'd like to do is use this rfid tag 
number to fill in the password feild and  submit the django Admin login form. 
I'm still a novice and Any advise is appreciated... Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Need explanation of the flow of info between my javascript, my View, and my template, trying to diagnose my current roadblock.

2013-04-30 Thread 7equivalents
"Redirect" Is that what you kids are calling it nowdays.. Thanks, that was 
the terminology I was lacking. That works I'm learning html, 
javascript, and Django all together on the fly so I'm not well versed in 
basics. Thankyou for your help! It helped clear up the puzzle a bit.


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Need explanation of the flow of info between my javascript, my View, and my template, trying to diagnose my current roadblock.

2013-04-30 Thread 7equivalents
Hey guys, I need a little help. Here is what I'm trying to do.
I would like to have a html button execute a javascript on click, and the 
javascript should send an GET reguest to the server which should execute 
the View for the page requested. For some reason I can't get it to work...

here is what I've done
(1) I have a working View that executes successfully when the main page is 
requested.
(2) The View loads the template that has the html button and javascript.
(3) I have confirmed the when the button is clicked the javascript executes.

However the page doesn't change to the new page requested, and I get a 404 
error however, the page is there and I link to it from other places in 
the code.

Maybe I misunderstand something in the way the request and load and ajax 
stuff works, I'm still a novice.

Here is my code...

 html & javascript 

 
$(function (){
  $("#blog1").click(function (){
var id =  $( "#blog1" ).val();
var data = { id:id };
$("#blog1").prop('value', 'works');
$.get({ 
  url:"/control/"
});
  });
  return false;
});

//

/// View 
/
def control_page(request):

  sliderB = Slider.objects.get(sliderID=1)
  sliderR = Slider.objects.get(sliderID=2)
  sliderG = Slider.objects.get(sliderID=3)
  sliderP = Slider.objects.get(sliderID=4)
  preprogram1 = Preprogram.objects.get(preprogramID=1)
  preprogram2 = Preprogram.objects.get(preprogramID=2)
  preprogram3 = Preprogram.objects.get(preprogramID=3)
  pin1 = Pin.objects.get(pinID=1)
  variables = RequestContext(request, {'pin1': pin1, 'preprogram1': 
preprogram1, 'preprogram2': preprogram2, 'preprogram3': preprogram3, 
'sliderB':sliderB, 'sliderR':sliderR, 'sliderG':sliderG, 'sliderP':sliderP})
  return render_to_response('control_page.html', variables) 
/

/// urls 
///
urlpatterns = patterns('',
  (r'^$', main_page),
  (r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': 
settings.MEDIA_ROOT}),
  (r'^login/$', 'django.contrib.auth.views.login'),
  (r'^logout/$', logout_page),
  (r'^user/(\w+)/$', user_page),
  (r'^control/$', control_page),
  (r'^gpio_control/$', gpio_control_page),
  (r'^slider/$', slider_page),
  (r'^read_more/$', read_more_page),
  (r'^admin/', include(admin.site.urls)),

)///

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




question on howt to run phpadmin on my Django web app server.

2013-04-03 Thread 7equivalents
Hello, I'm just looking for a point in the right direction. I have a 
raspberry pi running an apache server that is serving a Django web app. If 
I want to also use myphpadmin, would it be some thing I configured Apache 
to help happen, or Django, I'm thinking apache, but I want to be sure.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How can my JQuery Sliderbar pass a value to the Veiw and cause the View to execute?

2013-03-13 Thread 7equivalents
[Solved]

Thanks for the help,  it helped me solve the problem and is much 
appreciated.

I still have a few hiccups, like for some reason I had to change 
type:"POST" to type:"GET" for it to workand it doesn't always 
work(really bad with IE, better with Firefox).
But I still need to study it and poke at it, and start new threads for 
those problems.

This one is SOLVED! Thanks!


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How can my JQuery Sliderbar pass a value to the Veiw and cause the View to execute?

2013-03-08 Thread 7equivalents
Ok, thanks Shawn, still having a bit of  a snag. I have read the JQuery doc 
on $.ajax, but still don't have a complete grasp... So here is my next 
question,

I added this to my sliderbar script:

var args = { type:"POST", url:"/slider/" }
$.ajax(args);

Would those two lines of code cause my slider_page View to execute 
(assuming of coarse the url is correct)?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




How can my JQuery Sliderbar pass a value to the Veiw and cause the View to execute?

2013-03-07 Thread 7equivalents
I am trying to create my first Django AJAX App. I have a template that 
creates a JQuery slider bar. I also have a datamodel which has a 
sliderbarValue entry and a View that writes to it.
 I need to know how to make the Javascript call the View and pass it the 
slider bar value. Here is the template and javascript I have...
 
 {% block external %}
  
{% endblock %}
  
{% block content %} 
  
  
Intensity:

   
  
  
  
  $(function (){
$( "#slider_1" ).slider({
  range: "min",
  value: {{ slider1.sliderValue }},
  min: 0,
  max: 100,
  slide: function( event, ui ) {
$( "#power" ).val(ui.value );
  }
});
$( "#power" ).val($( "#slider_1" ).slider( "value" ) );
return false;
  });
  
{% endblock %}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to pass a value from a Django View to a JQuery Slider bar.

2013-03-07 Thread 7equivalents

>
> Thankyou Daniel, That's my name too I appreciate that, it clears 
> things up and now I understand why the tinkering I did worked!
>
 
Thankyou  Tom, Gabriel, and everyone for the help...
 
Please follow my next post where I seek help one more time(Need slider to 
write to database), after that I'm going to tear my code down and build it 
back up, and examine so many details that have been lost on me. Django + 
Raspberry Pi + Microcontrolers = cool stuff! 
 
Thanks again!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to pass a value from a Django View to a JQuery Slider bar.

2013-03-06 Thread 7equivalents
Now that I have that part working, I would like to make since of what was 
going on and why it didn't work in the first place. I have a question...

Let's say
(1) a page is requested, and the View renders_to_response  a template
(2) this template uses a {% include 'second_template.html' %}

Does the second_templates View get executed or does the Html just get added?


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to pass a value from a Django View to a JQuery Slider bar.

2013-03-06 Thread 7equivalents
 Hey, Thanks alot I tried to do that before and it didn't work(the 
slider bar disappeared) and on your suggestion tried again, still didn't 
work, however since you suggested it, I knew it had to be the right track, 
so I got rid of the variable in the Javascript and the slider bar came 
back, so from there I played with the the variables in the Views and got it 
to work.

So thank you so much for the help 

I am trying to implement control of GPIO pins and UART modules on a 
Raspberry Pi via a web interface.

Here's a short youtube video of my App and hardware, Thanks again!

http://www.youtube.com/watch?v=ebkxEL30bno

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to pass a value from a Django View to a JQuery Slider bar.

2013-03-05 Thread 7equivalents
Alright guys, thanks for the input, I need something a bit more specific to 
my case due to my ignorance on the subject at hand, so I am posting the 
code for my View, Template, and JQuery.  So, basically I want to take the 
slider1 object value in the View, and place it in the Javascript where 
value = 37 has been coded. 

// Here is my view 
//
def slider_page(request):
  
  slider1 = Slider.objects.get(sliderID=1)
  variables = RequestContext(request, {'slider1': slider1})
  return render_to_response('slider_page.html', variables)
  
/ Here is my Template 
// 
 
{% block external %}
  
{% endblock %}
  
{% block content %} 
  
  
Intensity:

   
  
  
{% endblock %}

// Here is my JQuery 
//

  $(function (){
$( "#slider_1" ).slider({
  range: "min",
  value: 37,
  min: 0,
  max: 100,
  slide: function( event, ui ) {
$( "#power" ).val(ui.value );
  }
});
$( "#power" ).val($( "#slider_1" ).slider( "value" ) );
return false;
  });

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to pass a value from a Django View to a JQuery Slider bar.

2013-03-05 Thread 7equivalents
Well, I definitly can't just throw a variable into the Javascript using the 
{{ }} tags. I tried it and it didn't work. I'm sure Shawn Milochik is 
correct about consuming the view with AJAX, however that is going to take 
sometime to learn and explore, as I am novice at this. It seems there 
should be an easy way for something so simple, I can pass a variable from a 
view to a template, but not from a view to a javascript file.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to pass a value from a Django View to a JQuery Slider bar.

2013-03-04 Thread 7equivalents
Yes, Thankyou for helping me clean up my line of questioning, That is 
exactly what I want to know, can I use the {{ }} tags to do this, and can 
they be placed in a seperate .js file.

On Monday, March 4, 2013 1:50:39 PM UTC-5, Gabriel wrote:
>
> If I understood it right, I think it would be enough to serve the 
> javascript with the initialization
> value hardcoded in it, right? Like using {{ }} tags.
> Is there a way to do this if there's a separate .js file?
>
> - Gabriel
>
> On Mon, Mar 4, 2013 at 1:41 PM, Shawn Milochik 
> 
> > wrote:
>
>> Probably consume the view with AJAX, doing a POST on the change event
>> of the slider.
>>
>> http://api.jquery.com/category/ajax/
>>
>> Put your result in a dictionary within your view and return it as JSON:
>>
>> return HttpResponse(json.dumps(result), mimetype="application/json")
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




How to pass a value from a Django View to a JQuery Slider bar.

2013-03-04 Thread 7equivalents
Hello, my goal is to use a Django powered website to control the brightness 
of a light. I am using a JQuery slider bar as a dimmer switch. When the 
JQuery slider bar loads, I need it to iniciate to a value I have in my 
database.

I already have my View, Model, and Template setup, and can pass variables 
from the View to the HTML part of the template. My Question is, How do I 
pass the variable from the View to the JQuery slider bar?

Thankyou for any help. I am new to Django, JQuery and pretty much all Web 
programming, my main experince is working with microcontollers and low 
level language between chips.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Controlling GPIO on rasPi, need help with Refreshing switch status without reloading page via jquery

2013-02-04 Thread 7equivalents
I also have a javascript file, but I'm not quite sure what to out in 
it..

  function gpio_submit(){
$("#gpio_results").load("/control_page");
return false;
  }
  
$(document).ready(function () {
$("#gpio_form").submit(gpio_submit);
});

On Monday, February 4, 2013 11:12:27 PM UTC-5, 7equiv...@gmail.com wrote:
>
> I'm controlling the GPIO pins on a raspberryPi that is running a Django 
> web app. I have a form with only one button that is "On" or "off", it 
> writes this to a database. The Button's value has to display the current 
> status "On" or"off".
> So I need to be able to update the value of the button in the form, 
> without reloading the entire page.
>
> I have jquery, so I'm trying to figure out how to use it in conjunction 
> with the Django View to get this done. Here is my View.py and 
> control_page.html
>
> I am a novice in Programming so don't be afraid to dumb it down
>
> @login_required
> def control_page(request):
>   if request.method == 'POST':   
> pin1 = Pin.objects.get(pinID=1)
> 
> if 'pin1Status' in request.POST:
>   if pin1.pinStatus == 'hi':
> pin1.pinStatus = 'low'
>   else:
> pin1.pinStatus = 'hi'
>   pin1.save()
>   
> variables = RequestContext(request, {'pin1': pin1})  
> return render_to_response('control_page.html', variables)
>   else:
> pin1 = Pin.objects.get(pinID=1)
> variables = RequestContext(request, {'pin1': pin1})
> return render_to_response('control_page.html', variables) 
> 
> 
> 
> 
> {% extends "base.html" %}
> {% block external %}
>   
>
>   
> {% endblock %}
> {% block title %}Control Panel{% endblock %}
> {% block head %}
>
> {% endblock %}
> {% block content %}
>
>   
>   
> {% csrf_token %}
> {{ pin1.pinDescription}} {{ pin1.pinDirection}}  
> 
>   
>   
>   
>   http://192.168.137.96:8081"; scrolling="no" width="275" 
> height="220" frameboarder="0">
> iframes are not supported by your browser.
>   
>   
> {% endblock %}
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Controlling GPIO on rasPi, need help with Refreshing switch status without reloading page via jquery

2013-02-04 Thread 7equivalents
I'm controlling the GPIO pins on a raspberryPi that is running a Django web 
app. I have a form with only one button that is "On" or "off", it writes 
this to a database. The Button's value has to display the current status 
"On" or"off".
So I need to be able to update the value of the button in the form, without 
reloading the entire page.

I have jquery, so I'm trying to figure out how to use it in conjunction 
with the Django View to get this done. Here is my View.py and 
control_page.html

I am a novice in Programming so don't be afraid to dumb it down

@login_required
def control_page(request):
  if request.method == 'POST':   
pin1 = Pin.objects.get(pinID=1)

if 'pin1Status' in request.POST:
  if pin1.pinStatus == 'hi':
pin1.pinStatus = 'low'
  else:
pin1.pinStatus = 'hi'
  pin1.save()
  
variables = RequestContext(request, {'pin1': pin1})  
return render_to_response('control_page.html', variables)
  else:
pin1 = Pin.objects.get(pinID=1)
variables = RequestContext(request, {'pin1': pin1})
return render_to_response('control_page.html', variables) 




{% extends "base.html" %}
{% block external %}
  
   
  
{% endblock %}
{% block title %}Control Panel{% endblock %}
{% block head %}

{% endblock %}
{% block content %}

  
  
{% csrf_token %}
{{ pin1.pinDescription}} {{ pin1.pinDirection}}  

  
  
  
  http://192.168.137.96:8081"; scrolling="no" width="275" 
height="220" frameboarder="0">
iframes are not supported by your browser.
  
  
{% endblock %}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Need help configuring Apache production server on Raspberry PI to work with Django.

2013-01-11 Thread 7equivalents
Hey guys, thanks for the help. 
(1 )I have confirmed mod-wsgi has been compiled against the correct version 
of python.
(2) I have also confirmed mod-wsgi is in the list of loaded modules.

My next question is what file do I place the WSGIScript directive in? I 
can't seem to find which file it goes in



On Thursday, January 10, 2013 3:54:12 PM UTC-5, ke1g wrote:
>
> The apache configuration files must have, at a minimum, a WSGIScriptAlias 
> directive.
>
> There is also a list of the apache modules which get loaded, and mod_wsgi 
> must be included.
>
> mod_wsgi must be linked against the particular apache, but the 
> distribution, if you're using the OS's package manager, should have made 
> sure of that.
>
> As previously mentioned by another, mod_wsgi is linked against a 
> particular python interpreter.  Again, hopefully the OS package manager 
> pulls in stuff built to work together, but this does mean that you can't, 
> say, use python2.7 if the distribution's python is a 2.6.
>
> It is much to be preferred, though not absolutely required, that the 
> python in question was build after passing "--enable-shared" to the 
> configure script.  Unless you build everything yourself (which I usually 
> do, but not yet on Raspberry PI), you have no control of this.
>
> That WSGIScriptAlias directive should probably specify a python-path 
> argument specifying the directory with manage.py in it, though I've seen it 
> work with the adding of this path deferred to the wsgi script  python 
> module.
>
> You can use a virtualenv, but it must have been made with the python 
> interpreter against which mod_wsgi is linked (not the same file, but 
> ve/bin/python is generally a copy, and this works well enough), but you 
> will either need to use the WSGIPythonHome directive, or, if your mod_wsgi 
> is new enough, the python-home argument of the WSGIScriptAlias directive.  
> (The advantage of the latter is the ability to use separate virtualenvs in 
> separate VirtualHosts, whereas WSGIPytonHome is global across all mod_wsgi 
> daemon processes under a single apache..)
>
> You will want to configure Alias directives to allow serving your STATIC 
> and MEDIA files at the expected URLs.
>
> You will need a number of Directory directives (though fewer than some 
> people think).
>
> The mod_wsgi documentation is excellent.  If you think otherwise it is 
> because you don't yet appreciate the complexity of the issues.
>
> Bill
>
> On Thu, Jan 10, 2013 at 3:27 PM, <7equiv...@gmail.com >wrote:
>
>> When you say "From there it should just be configuration." Do you mean 
>> either (1) Configuring mod-wsgi to work with apache, or (2) Configuring 
>> mod_wsgi to work with Django. 
>>
>> The errors where involved with my first attempt at installing mod-wsgi 
>> according to the Django instructions, However now I'm using *sudo 
>> apt-get install libapache2-mod-wsgi *which is not mentioned in the 
>> Django docs. And step (3) seems to do whatever it does just fine with no 
>> errors.
>>
>> I'm not sure if I should be focusing on configuring mod-wsgi to work with 
>> apach or configuring mod-wsgi to work with Django. I'm sure there are steps 
>> for both that need to be taken
>>
>>
>> On Thursday, January 10, 2013 2:53:35 PM UTC-5, Nikolas Stevenson-Molnar 
>> wrote:
>>
>>> From there, it should just be configuration. What errors are you seeing? 
>>>
>>> _Nik 
>>>
>>> On 1/10/2013 10:59 AM, 7equiv...@gmail.com wrote: 
>>> > Hello, I need help configuring the Apache production server to work 
>>> > with Django on a Rapberry pi. I am still new to Linux. Here is what 
>>> > I've done so far. 
>>> > 
>>> > (1) I have successfully installed Apache on my Raspberry pi. I have 
>>> > used it to serve up php webpages. 
>>> > (2) I have successfully installed Django on the RaspPi and created a 
>>> > project that works with the Django development server. 
>>> > (3) I have run the command ~$ sudo apt-get install libapache2-mod-wsgi 
>>> > 
>>> > I am unsure where to proceed after step 3. Did step 3 install and 
>>> > configure mod-wsgi to work with Apache, or do I still have some 
>>> > initialization steps? Or, does the next step involve Django. I have 
>>> > read and followed the steps from the Django website, but they produced 
>>> > errors and where confusing to me. 
>>> > 
>>> > Any help would be greatly appreciated! 
>>> > -- 
>>> > You received this message because you are subscribed to the Google 
>>> > Groups "Django users" group. 
>>> > To view this discussion on the web visit 
>>> > https://groups.google.com/d/**msg/django-users/-/**6SE8SJkDxf0J.
>>> >  
>>>
>>> > To post to this group, send email to django...@googlegroups.com. 
>>> > To unsubscribe from this group, send email to 
>>> > django-users...@**googlegroups.com. 
>>> > For more options, visit this group at 
>>> > http://groups.google.com/**group/django-users?hl=en

Re: Need help configuring Apache production server on Raspberry PI to work with Django.

2013-01-10 Thread 7equivalents
When you say "From there it should just be configuration." Do you mean 
either (1) Configuring mod-wsgi to work with apache, or (2) Configuring 
mod_wsgi to work with Django. 

The errors where involved with my first attempt at installing mod-wsgi 
according to the Django instructions, However now I'm using *sudo apt-get 
install libapache2-mod-wsgi *which is not mentioned in the Django docs. And 
step (3) seems to do whatever it does just fine with no errors.

I'm not sure if I should be focusing on configuring mod-wsgi to work with 
apach or configuring mod-wsgi to work with Django. I'm sure there are steps 
for both that need to be taken

On Thursday, January 10, 2013 2:53:35 PM UTC-5, Nikolas Stevenson-Molnar 
wrote:
>
> From there, it should just be configuration. What errors are you seeing? 
>
> _Nik 
>
> On 1/10/2013 10:59 AM, 7equiv...@gmail.com  wrote: 
> > Hello, I need help configuring the Apache production server to work 
> > with Django on a Rapberry pi. I am still new to Linux. Here is what 
> > I've done so far. 
> > 
> > (1) I have successfully installed Apache on my Raspberry pi. I have 
> > used it to serve up php webpages. 
> > (2) I have successfully installed Django on the RaspPi and created a 
> > project that works with the Django development server. 
> > (3) I have run the command ~$ sudo apt-get install libapache2-mod-wsgi 
> > 
> > I am unsure where to proceed after step 3. Did step 3 install and 
> > configure mod-wsgi to work with Apache, or do I still have some 
> > initialization steps? Or, does the next step involve Django. I have 
> > read and followed the steps from the Django website, but they produced 
> > errors and where confusing to me. 
> > 
> > Any help would be greatly appreciated! 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Django users" group. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msg/django-users/-/6SE8SJkDxf0J. 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > To unsubscribe from this group, send email to 
> > django-users...@googlegroups.com . 
> > For more options, visit this group at 
> > http://groups.google.com/group/django-users?hl=en. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/F8Bo4d3IP5oJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Need help configuring Apache production server on Raspberry PI to work with Django.

2013-01-10 Thread 7equivalents
Hello, I need help configuring the Apache production server to work with 
Django on a Rapberry pi. I am still new to Linux. Here is what I've done so 
far.

(1) I have successfully installed Apache on my Raspberry pi. I have used it 
to serve up php webpages.
(2) I have successfully installed Django on the RaspPi and created a 
project that works with the Django development server.
(3) I have run the command ~$ sudo apt-get install libapache2-mod-wsgi

I am unsure where to proceed after step 3. Did step 3 install and configure 
mod-wsgi to work with Apache, or do I still have some initialization steps? 
Or, does the next step involve Django. I have read and followed the steps 
from the Django website, but they produced errors and where confusing to me.

Any help would be greatly appreciated!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/6SE8SJkDxf0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.