How can I integrate simple Custom login page in Django.......?

2012-10-15 Thread Pervez Mulla
Hi,

I have login.html , login,js ang login.pl.

I want to integrate basic login page in Django with perl back-end from 
where Am reading my DB.
I was trying to integrate it from last day but come out with empty .There 
might be some settings in setting.py.
Below is my code

--
login.html
--
http://www.w3.org/1999/xhtml";>
  




  #loginContent { width: 350px; margin: 100px auto; }
  button[type] { margin: 0.5em 0; }
label {font-weight:bold;}
fieldset {padding:0 1.4em 1.4em 1.4em;margin:0 0 1.5em 0;border:1px solid 
#ccc;}
legend 
{font-weight:bold;font-size:1.2em;margin-top:-0.2em;margin-bottom:1em;}
fieldset, #IE8#HACK {padding-top:1.4em;}
legend, #IE8#HACK {margin-top:0;margin-bottom:0;}
input[type=text], input[type=password], input.text, input.title, textarea 
{background-color:#fff;border:1px solid #bbb;}
input[type=text]:focus, input[type=password]:focus, input.text:focus, 
input.title:focus, textarea:focus {border-color:#666;}
select {background-color:#fff;border-width:1px;border-style:solid;}
input[type=text], input[type=password], input.text, input.title, textarea, 
select {margin:0.5em 0;}
input.text, input.title {width:300px;padding:5px;}
input.title {font-size:1.5em;}
textarea {width:390px;height:250px;padding:5px;}
form.inline {line-height:3;}
form.inline p {margin-bottom:0;}
.error, .alert, .notice, .success, .info 
{padding:0.8em;margin-bottom:1em;border:2px solid #ddd;}
.error, .alert {background:#fbe3e4;color:#8a1f11;border-color:#fbc2c4;}
.notice {background:#fff6bf;color:#514721;border-color:#ffd324;}
.success {background:#e6efc2;color:#264409;border-color:#c6d880;}
.info {background:#d5edf8;color:#205791;border-color:#92cae4;}
.error a, .alert a {color:#8a1f11;}
.notice a {color:#514721;}
.success a {color:#264409;}
.info a {color:#205791;}

  
  

  
  
  

  Enter information
  
Username
  
  
Password
  
  
Login
  

  

  


-
login.js
-
$(document).ready(function(){
  $("form#loginForm").submit(function() { // loginForm is submitted
var username = $('#username').attr('value'); // get username
var password = $('#password').attr('value'); // get password

if (username && password) { // values are not empty
  $.ajax({
type: "GET",
url: "http://localhost:8080/cgi-bin/login.pl";, // URL of the Perl 
script
contentType: "application/json; charset=utf-8",
dataType: "json",
data: "username=" + username + "&password=" + password,
error: function(XMLHttpRequest, textStatus, errorThrown) { 
  $('div#loginResult').text("responseText: " + 
XMLHttpRequest.responseText 
+ ", textStatus: " + textStatus 
+ ", errorThrown: " + errorThrown);
  $('div#loginResult').addClass("error");
}, // error 
success: function(data){
  if (data.error) { // script returned error
$('div#loginResult').text("data.error: " + data.error);
$('div#loginResult').addClass("error");
  } // if
  else { // login was successful
$('form#loginForm').hide();
$('div#loginResult').text("data.success: " + data.success 
  + ", data.userid: " + data.userid);
$('div#loginResult').addClass("success");
  } //else
} // success
  }); // ajax
} // if
else {
  $('div#loginResult').text("enter username and password");
  $('div#loginResult').addClass("error");
} // else
$('div#loginResult').fadeIn();
return false;
  });
});

--
login.pl
--
#!/usr/bin/perl -T

use CGI;
use DBI;
use strict;
use warnings;
use netsharkusr;

my $cgi = CGI->new;
my $username = $cgi->param("username");
my $password = $cgi->param("password");
 my $tempuser = new netsharkusr();
 if($tempuser->readbyusername($username) eq 1) {
if($tempuser->{username} eq $username)
{
print "success \n";
#exit;
}
 }

#$password = "123go";
my $userid;
my $tempuser2 = new netsharkusr();
if($tempuser2->readbypassword($password)) {
if($tempuser2->{password} eq $password)
{
print "sccess \n";
$userid = $tempuser2->{userID};
}
}

# check the username and password in the database

# create a JSON string according to the database result
my $json = ($userid) ? 
  qq{{"success" : "login is successful", "userid" : $userid}} : 
  qq{{"error" : "username or password is wrong"}};

# return JSON string
print $cgi->header(-type => "application/json", -charset => "utf-8");
print $json;

 How can I do this ..? Please Help  


Thank You
Pervez

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.

Re: How can I integrate simple Custom login page in Django.......?

2012-10-15 Thread Sergiy Khohlov
https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-LOGIN_URL

 set this one in setting.py

2012/10/15 Pervez Mulla :
> Hi,
>
> I have login.html , login,js ang login.pl.
>
> I want to integrate basic login page in Django with perl back-end from where
> Am reading my DB.
> I was trying to integrate it from last day but come out with empty .There
> might be some settings in setting.py.
> Below is my code
>
> --
> login.html
> --
> http://www.w3.org/1999/xhtml";>
>   
> 
> 
> 
> 
>   #loginContent { width: 350px; margin: 100px auto; }
>   button[type] { margin: 0.5em 0; }
> label {font-weight:bold;}
> fieldset {padding:0 1.4em 1.4em 1.4em;margin:0 0 1.5em 0;border:1px solid
> #ccc;}
> legend
> {font-weight:bold;font-size:1.2em;margin-top:-0.2em;margin-bottom:1em;}
> fieldset, #IE8#HACK {padding-top:1.4em;}
> legend, #IE8#HACK {margin-top:0;margin-bottom:0;}
> input[type=text], input[type=password], input.text, input.title, textarea
> {background-color:#fff;border:1px solid #bbb;}
> input[type=text]:focus, input[type=password]:focus, input.text:focus,
> input.title:focus, textarea:focus {border-color:#666;}
> select {background-color:#fff;border-width:1px;border-style:solid;}
> input[type=text], input[type=password], input.text, input.title, textarea,
> select {margin:0.5em 0;}
> input.text, input.title {width:300px;padding:5px;}
> input.title {font-size:1.5em;}
> textarea {width:390px;height:250px;padding:5px;}
> form.inline {line-height:3;}
> form.inline p {margin-bottom:0;}
> .error, .alert, .notice, .success, .info
> {padding:0.8em;margin-bottom:1em;border:2px solid #ddd;}
> .error, .alert {background:#fbe3e4;color:#8a1f11;border-color:#fbc2c4;}
> .notice {background:#fff6bf;color:#514721;border-color:#ffd324;}
> .success {background:#e6efc2;color:#264409;border-color:#c6d880;}
> .info {background:#d5edf8;color:#205791;border-color:#92cae4;}
> .error a, .alert a {color:#8a1f11;}
> .notice a {color:#514721;}
> .success a {color:#264409;}
> .info a {color:#205791;}
> 
>   
>   
> 
>   
>   
>   
> 
>   Enter information
>   
> Username id="username" name="username" class="text" size="20" />
>   
>   
> Password id="password" name="password" class="text" size="20" />
>   
>   
>  />Login
>   
> 
>   
> 
>   
> 
>
> -
> login.js
> -
> $(document).ready(function(){
>   $("form#loginForm").submit(function() { // loginForm is submitted
> var username = $('#username').attr('value'); // get username
> var password = $('#password').attr('value'); // get password
>
> if (username && password) { // values are not empty
>   $.ajax({
> type: "GET",
> url: "http://localhost:8080/cgi-bin/login.pl";, // URL of the Perl
> script
> contentType: "application/json; charset=utf-8",
> dataType: "json",
> data: "username=" + username + "&password=" + password,
> error: function(XMLHttpRequest, textStatus, errorThrown) {
>   $('div#loginResult').text("responseText: " +
> XMLHttpRequest.responseText
> + ", textStatus: " + textStatus
> + ", errorThrown: " + errorThrown);
>   $('div#loginResult').addClass("error");
> }, // error
> success: function(data){
>   if (data.error) { // script returned error
> $('div#loginResult').text("data.error: " + data.error);
> $('div#loginResult').addClass("error");
>   } // if
>   else { // login was successful
> $('form#loginForm').hide();
> $('div#loginResult').text("data.success: " + data.success
>   + ", data.userid: " + data.userid);
> $('div#loginResult').addClass("success");
>   } //else
> } // success
>   }); // ajax
> } // if
> else {
>   $('div#loginResult').text("enter username and password");
>   $('div#loginResult').addClass("error");
> } // else
> $('div#loginResult').fadeIn();
> return false;
>   });
> });
>
> --
> login.pl
> --
> #!/usr/bin/perl -T
>
> use CGI;
> use DBI;
> use strict;
> use warnings;
> use netsharkusr;
>
> my $cgi = CGI->new;
> my $username = $cgi->param("username");
> my $password = $cgi->param("password");
>  my $tempuser = new netsharkusr();
>  if($tempuser->readbyusername($username) eq 1) {
> if($tempuser->{username} eq $username)
> {
> print "success \n";
> #exit;
> }
>  }
>
> #$password = "123go";
> my $userid;
> my $tempuser2 = new netsharkusr();
> if($tempuser2->readbypassword($password)) {
> if($tempuser2->{password} eq $password)
> {
> print "sccess \n";
> $userid = $tempuser2->{userID};
>   

Re: How can I integrate simple Custom login page in Django.......?

2012-10-15 Thread Pervez Mulla
Thank You for your response Sergiy ,

I already try'd to run this script as shown in Django DOC as u given .but
still it didnt work:(

Thank You
Pervez

On Mon, Oct 15, 2012 at 1:28 PM, Sergiy Khohlov  wrote:

> https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-LOGIN_URL
>
>  set this one in setting.py
>
> 2012/10/15 Pervez Mulla :
> > Hi,
> >
> > I have login.html , login,js ang login.pl.
> >
> > I want to integrate basic login page in Django with perl back-end from
> where
> > Am reading my DB.
> > I was trying to integrate it from last day but come out with empty .There
> > might be some settings in setting.py.
> > Below is my code
> >
> > --
> > login.html
> > --
> > http://www.w3.org/1999/xhtml";>
> >   
> > 
> > 
> > 
> > 
> >   #loginContent { width: 350px; margin: 100px auto; }
> >   button[type] { margin: 0.5em 0; }
> > label {font-weight:bold;}
> > fieldset {padding:0 1.4em 1.4em 1.4em;margin:0 0 1.5em 0;border:1px solid
> > #ccc;}
> > legend
> > {font-weight:bold;font-size:1.2em;margin-top:-0.2em;margin-bottom:1em;}
> > fieldset, #IE8#HACK {padding-top:1.4em;}
> > legend, #IE8#HACK {margin-top:0;margin-bottom:0;}
> > input[type=text], input[type=password], input.text, input.title, textarea
> > {background-color:#fff;border:1px solid #bbb;}
> > input[type=text]:focus, input[type=password]:focus, input.text:focus,
> > input.title:focus, textarea:focus {border-color:#666;}
> > select {background-color:#fff;border-width:1px;border-style:solid;}
> > input[type=text], input[type=password], input.text, input.title,
> textarea,
> > select {margin:0.5em 0;}
> > input.text, input.title {width:300px;padding:5px;}
> > input.title {font-size:1.5em;}
> > textarea {width:390px;height:250px;padding:5px;}
> > form.inline {line-height:3;}
> > form.inline p {margin-bottom:0;}
> > .error, .alert, .notice, .success, .info
> > {padding:0.8em;margin-bottom:1em;border:2px solid #ddd;}
> > .error, .alert {background:#fbe3e4;color:#8a1f11;border-color:#fbc2c4;}
> > .notice {background:#fff6bf;color:#514721;border-color:#ffd324;}
> > .success {background:#e6efc2;color:#264409;border-color:#c6d880;}
> > .info {background:#d5edf8;color:#205791;border-color:#92cae4;}
> > .error a, .alert a {color:#8a1f11;}
> > .notice a {color:#514721;}
> > .success a {color:#264409;}
> > .info a {color:#205791;}
> > 
> >   
> >   
> > 
> >   
> >   
> >   
> > 
> >   Enter information
> >   
> > Username > id="username" name="username" class="text" size="20" />
> >   
> >   
> > Password > id="password" name="password" class="text" size="20" />
> >   
> >   
> >  > />Login
> >   
> > 
> >   
> > 
> >   
> > 
> >
> > -
> > login.js
> > -
> > $(document).ready(function(){
> >   $("form#loginForm").submit(function() { // loginForm is submitted
> > var username = $('#username').attr('value'); // get username
> > var password = $('#password').attr('value'); // get password
> >
> > if (username && password) { // values are not empty
> >   $.ajax({
> > type: "GET",
> > url: "http://localhost:8080/cgi-bin/login.pl";, // URL of the
> Perl
> > script
> > contentType: "application/json; charset=utf-8",
> > dataType: "json",
> > data: "username=" + username + "&password=" + password,
> > error: function(XMLHttpRequest, textStatus, errorThrown) {
> >   $('div#loginResult').text("responseText: " +
> > XMLHttpRequest.responseText
> > + ", textStatus: " + textStatus
> > + ", errorThrown: " + errorThrown);
> >   $('div#loginResult').addClass("error");
> > }, // error
> > success: function(data){
> >   if (data.error) { // script returned error
> > $('div#loginResult').text("data.error: " + data.error);
> > $('div#loginResult').addClass("error");
> >   } // if
> >   else { // login was successful
> > $('form#loginForm').hide();
> > $('div#loginResult').text("data.success: " + data.success
> >   + ", data.userid: " + data.userid);
> > $('div#loginResult').addClass("success");
> >   } //else
> > } // success
> >   }); // ajax
> > } // if
> > else {
> >   $('div#loginResult').text("enter username and password");
> >   $('div#loginResult').addClass("error");
> > } // else
> > $('div#loginResult').fadeIn();
> > return false;
> >   });
> > });
> >
> > --
> > login.pl
> > --
> > #!/usr/bin/perl -T
> >
> > use CGI;
> > use DBI;
> > use strict;
> > use warnings;
> > use netsharkusr;
> >
> > my $cgi = CGI->new;
> > my $username = $cgi->param("username");
> > my $password = $cgi->param("password");
> >  my $tempuser = new netsharkusr();
> > 

Re: How can I integrate simple Custom login page in Django.......?

2012-10-15 Thread Sergiy Khohlov
please provide error message

2012/10/15 Pervez Mulla :
> Thank You for your response Sergiy ,
>
> I already try'd to run this script as shown in Django DOC as u given .but
> still it didnt work:(
>
> Thank You
> Pervez
>
> On Mon, Oct 15, 2012 at 1:28 PM, Sergiy Khohlov  wrote:
>>
>> https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-LOGIN_URL
>>
>>  set this one in setting.py
>>
>> 2012/10/15 Pervez Mulla :
>> > Hi,
>> >
>> > I have login.html , login,js ang login.pl.
>> >
>> > I want to integrate basic login page in Django with perl back-end from
>> > where
>> > Am reading my DB.
>> > I was trying to integrate it from last day but come out with empty
>> > .There
>> > might be some settings in setting.py.
>> > Below is my code
>> >
>> > --
>> > login.html
>> > --
>> > http://www.w3.org/1999/xhtml";>
>> >   
>> > > > />
>> > 
>> > 
>> > 
>> >   #loginContent { width: 350px; margin: 100px auto; }
>> >   button[type] { margin: 0.5em 0; }
>> > label {font-weight:bold;}
>> > fieldset {padding:0 1.4em 1.4em 1.4em;margin:0 0 1.5em 0;border:1px
>> > solid
>> > #ccc;}
>> > legend
>> > {font-weight:bold;font-size:1.2em;margin-top:-0.2em;margin-bottom:1em;}
>> > fieldset, #IE8#HACK {padding-top:1.4em;}
>> > legend, #IE8#HACK {margin-top:0;margin-bottom:0;}
>> > input[type=text], input[type=password], input.text, input.title,
>> > textarea
>> > {background-color:#fff;border:1px solid #bbb;}
>> > input[type=text]:focus, input[type=password]:focus, input.text:focus,
>> > input.title:focus, textarea:focus {border-color:#666;}
>> > select {background-color:#fff;border-width:1px;border-style:solid;}
>> > input[type=text], input[type=password], input.text, input.title,
>> > textarea,
>> > select {margin:0.5em 0;}
>> > input.text, input.title {width:300px;padding:5px;}
>> > input.title {font-size:1.5em;}
>> > textarea {width:390px;height:250px;padding:5px;}
>> > form.inline {line-height:3;}
>> > form.inline p {margin-bottom:0;}
>> > .error, .alert, .notice, .success, .info
>> > {padding:0.8em;margin-bottom:1em;border:2px solid #ddd;}
>> > .error, .alert {background:#fbe3e4;color:#8a1f11;border-color:#fbc2c4;}
>> > .notice {background:#fff6bf;color:#514721;border-color:#ffd324;}
>> > .success {background:#e6efc2;color:#264409;border-color:#c6d880;}
>> > .info {background:#d5edf8;color:#205791;border-color:#92cae4;}
>> > .error a, .alert a {color:#8a1f11;}
>> > .notice a {color:#514721;}
>> > .success a {color:#264409;}
>> > .info a {color:#205791;}
>> > 
>> >   
>> >   
>> > 
>> >   
>> >   
>> >   
>> > 
>> >   Enter information
>> >   
>> > Username> > id="username" name="username" class="text" size="20" />
>> >   
>> >   
>> > Password> > id="password" name="password" class="text" size="20" />
>> >   
>> >   
>> > > > />Login
>> >   
>> > 
>> >   
>> > 
>> >   
>> > 
>> >
>> > -
>> > login.js
>> > -
>> > $(document).ready(function(){
>> >   $("form#loginForm").submit(function() { // loginForm is submitted
>> > var username = $('#username').attr('value'); // get username
>> > var password = $('#password').attr('value'); // get password
>> >
>> > if (username && password) { // values are not empty
>> >   $.ajax({
>> > type: "GET",
>> > url: "http://localhost:8080/cgi-bin/login.pl";, // URL of the
>> > Perl
>> > script
>> > contentType: "application/json; charset=utf-8",
>> > dataType: "json",
>> > data: "username=" + username + "&password=" + password,
>> > error: function(XMLHttpRequest, textStatus, errorThrown) {
>> >   $('div#loginResult').text("responseText: " +
>> > XMLHttpRequest.responseText
>> > + ", textStatus: " + textStatus
>> > + ", errorThrown: " + errorThrown);
>> >   $('div#loginResult').addClass("error");
>> > }, // error
>> > success: function(data){
>> >   if (data.error) { // script returned error
>> > $('div#loginResult').text("data.error: " + data.error);
>> > $('div#loginResult').addClass("error");
>> >   } // if
>> >   else { // login was successful
>> > $('form#loginForm').hide();
>> > $('div#loginResult').text("data.success: " + data.success
>> >   + ", data.userid: " + data.userid);
>> > $('div#loginResult').addClass("success");
>> >   } //else
>> > } // success
>> >   }); // ajax
>> > } // if
>> > else {
>> >   $('div#loginResult').text("enter username and password");
>> >   $('div#loginResult').addClass("error");
>> > } // else
>> > $('div#loginResult').fadeIn();
>> > return false;
>> >   });
>> > });
>> >
>> > --
>> > login.pl
>> > --
>> > #!/usr/bin/perl -T
>> >
>> >

Re: How can I integrate simple Custom login page in Django.......?

2012-10-15 Thread Pervez Mulla
On error note its printing all pelr script itself.


On Mon, Oct 15, 2012 at 3:31 PM, Sergiy Khohlov  wrote:

> please provide error message
>
> 2012/10/15 Pervez Mulla :
> > Thank You for your response Sergiy ,
> >
> > I already try'd to run this script as shown in Django DOC as u given .but
> > still it didnt work:(
> >
> > Thank You
> > Pervez
> >
> > On Mon, Oct 15, 2012 at 1:28 PM, Sergiy Khohlov 
> wrote:
> >>
> >>
> https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-LOGIN_URL
> >>
> >>  set this one in setting.py
> >>
> >> 2012/10/15 Pervez Mulla :
> >> > Hi,
> >> >
> >> > I have login.html , login,js ang login.pl.
> >> >
> >> > I want to integrate basic login page in Django with perl back-end from
> >> > where
> >> > Am reading my DB.
> >> > I was trying to integrate it from last day but come out with empty
> >> > .There
> >> > might be some settings in setting.py.
> >> > Below is my code
> >> >
> >> > --
> >> > login.html
> >> > --
> >> > http://www.w3.org/1999/xhtml";>
> >> >   
> >> >  >> > />
> >> > 
> >> > 
> >> > 
> >> >   #loginContent { width: 350px; margin: 100px auto; }
> >> >   button[type] { margin: 0.5em 0; }
> >> > label {font-weight:bold;}
> >> > fieldset {padding:0 1.4em 1.4em 1.4em;margin:0 0 1.5em 0;border:1px
> >> > solid
> >> > #ccc;}
> >> > legend
> >> >
> {font-weight:bold;font-size:1.2em;margin-top:-0.2em;margin-bottom:1em;}
> >> > fieldset, #IE8#HACK {padding-top:1.4em;}
> >> > legend, #IE8#HACK {margin-top:0;margin-bottom:0;}
> >> > input[type=text], input[type=password], input.text, input.title,
> >> > textarea
> >> > {background-color:#fff;border:1px solid #bbb;}
> >> > input[type=text]:focus, input[type=password]:focus, input.text:focus,
> >> > input.title:focus, textarea:focus {border-color:#666;}
> >> > select {background-color:#fff;border-width:1px;border-style:solid;}
> >> > input[type=text], input[type=password], input.text, input.title,
> >> > textarea,
> >> > select {margin:0.5em 0;}
> >> > input.text, input.title {width:300px;padding:5px;}
> >> > input.title {font-size:1.5em;}
> >> > textarea {width:390px;height:250px;padding:5px;}
> >> > form.inline {line-height:3;}
> >> > form.inline p {margin-bottom:0;}
> >> > .error, .alert, .notice, .success, .info
> >> > {padding:0.8em;margin-bottom:1em;border:2px solid #ddd;}
> >> > .error, .alert
> {background:#fbe3e4;color:#8a1f11;border-color:#fbc2c4;}
> >> > .notice {background:#fff6bf;color:#514721;border-color:#ffd324;}
> >> > .success {background:#e6efc2;color:#264409;border-color:#c6d880;}
> >> > .info {background:#d5edf8;color:#205791;border-color:#92cae4;}
> >> > .error a, .alert a {color:#8a1f11;}
> >> > .notice a {color:#514721;}
> >> > .success a {color:#264409;}
> >> > .info a {color:#205791;}
> >> > 
> >> >   
> >> >   
> >> > 
> >> >   
> >> >   
> >> >   
> >> > 
> >> >   Enter information
> >> >   
> >> > Username >> > id="username" name="username" class="text" size="20" />
> >> >   
> >> >   
> >> > Password type="password"
> >> > id="password" name="password" class="text" size="20" />
> >> >   
> >> >   
> >> >  alt="ok"
> >> > />Login
> >> >   
> >> > 
> >> >   
> >> > 
> >> >   
> >> > 
> >> >
> >> > -
> >> > login.js
> >> > -
> >> > $(document).ready(function(){
> >> >   $("form#loginForm").submit(function() { // loginForm is submitted
> >> > var username = $('#username').attr('value'); // get username
> >> > var password = $('#password').attr('value'); // get password
> >> >
> >> > if (username && password) { // values are not empty
> >> >   $.ajax({
> >> > type: "GET",
> >> > url: "http://localhost:8080/cgi-bin/login.pl";, // URL of the
> >> > Perl
> >> > script
> >> > contentType: "application/json; charset=utf-8",
> >> > dataType: "json",
> >> > data: "username=" + username + "&password=" + password,
> >> > error: function(XMLHttpRequest, textStatus, errorThrown) {
> >> >   $('div#loginResult').text("responseText: " +
> >> > XMLHttpRequest.responseText
> >> > + ", textStatus: " + textStatus
> >> > + ", errorThrown: " + errorThrown);
> >> >   $('div#loginResult').addClass("error");
> >> > }, // error
> >> > success: function(data){
> >> >   if (data.error) { // script returned error
> >> > $('div#loginResult').text("data.error: " + data.error);
> >> > $('div#loginResult').addClass("error");
> >> >   } // if
> >> >   else { // login was successful
> >> > $('form#loginForm').hide();
> >> > $('div#loginResult').text("data.success: " + data.success
> >> >   + ", data.userid: " + data.userid);
> >> > $('div#loginResult').addClass("success");
> >> >  

Re: How can I integrate simple Custom login page in Django.......?

2012-10-15 Thread Sergiy Khohlov
please provide error

2012/10/15 Pervez Mulla :
> On error note its printing all pelr script itself.
>
>
> On Mon, Oct 15, 2012 at 3:31 PM, Sergiy Khohlov  wrote:
>>
>> please provide error message
>>
>> 2012/10/15 Pervez Mulla :
>> > Thank You for your response Sergiy ,
>> >
>> > I already try'd to run this script as shown in Django DOC as u given
>> > .but
>> > still it didnt work:(
>> >
>> > Thank You
>> > Pervez
>> >
>> > On Mon, Oct 15, 2012 at 1:28 PM, Sergiy Khohlov 
>> > wrote:
>> >>
>> >>
>> >> https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-LOGIN_URL
>> >>
>> >>  set this one in setting.py
>> >>
>> >> 2012/10/15 Pervez Mulla :
>> >> > Hi,
>> >> >
>> >> > I have login.html , login,js ang login.pl.
>> >> >
>> >> > I want to integrate basic login page in Django with perl back-end
>> >> > from
>> >> > where
>> >> > Am reading my DB.
>> >> > I was trying to integrate it from last day but come out with empty
>> >> > .There
>> >> > might be some settings in setting.py.
>> >> > Below is my code
>> >> >
>> >> > --
>> >> > login.html
>> >> > --
>> >> > http://www.w3.org/1999/xhtml";>
>> >> >   
>> >> > > >> > />
>> >> > > >> > src="jquery-1.7.2.min.js">
>> >> > 
>> >> > 
>> >> >   #loginContent { width: 350px; margin: 100px auto; }
>> >> >   button[type] { margin: 0.5em 0; }
>> >> > label {font-weight:bold;}
>> >> > fieldset {padding:0 1.4em 1.4em 1.4em;margin:0 0 1.5em 0;border:1px
>> >> > solid
>> >> > #ccc;}
>> >> > legend
>> >> >
>> >> > {font-weight:bold;font-size:1.2em;margin-top:-0.2em;margin-bottom:1em;}
>> >> > fieldset, #IE8#HACK {padding-top:1.4em;}
>> >> > legend, #IE8#HACK {margin-top:0;margin-bottom:0;}
>> >> > input[type=text], input[type=password], input.text, input.title,
>> >> > textarea
>> >> > {background-color:#fff;border:1px solid #bbb;}
>> >> > input[type=text]:focus, input[type=password]:focus, input.text:focus,
>> >> > input.title:focus, textarea:focus {border-color:#666;}
>> >> > select {background-color:#fff;border-width:1px;border-style:solid;}
>> >> > input[type=text], input[type=password], input.text, input.title,
>> >> > textarea,
>> >> > select {margin:0.5em 0;}
>> >> > input.text, input.title {width:300px;padding:5px;}
>> >> > input.title {font-size:1.5em;}
>> >> > textarea {width:390px;height:250px;padding:5px;}
>> >> > form.inline {line-height:3;}
>> >> > form.inline p {margin-bottom:0;}
>> >> > .error, .alert, .notice, .success, .info
>> >> > {padding:0.8em;margin-bottom:1em;border:2px solid #ddd;}
>> >> > .error, .alert
>> >> > {background:#fbe3e4;color:#8a1f11;border-color:#fbc2c4;}
>> >> > .notice {background:#fff6bf;color:#514721;border-color:#ffd324;}
>> >> > .success {background:#e6efc2;color:#264409;border-color:#c6d880;}
>> >> > .info {background:#d5edf8;color:#205791;border-color:#92cae4;}
>> >> > .error a, .alert a {color:#8a1f11;}
>> >> > .notice a {color:#514721;}
>> >> > .success a {color:#264409;}
>> >> > .info a {color:#205791;}
>> >> > 
>> >> >   
>> >> >   
>> >> > 
>> >> >   
>> >> >   
>> >> >   
>> >> > 
>> >> >   Enter information
>> >> >   
>> >> > Username> >> > id="username" name="username" class="text" size="20" />
>> >> >   
>> >> >   
>> >> > Password> >> > type="password"
>> >> > id="password" name="password" class="text" size="20" />
>> >> >   
>> >> >   
>> >> > > >> > alt="ok"
>> >> > />Login
>> >> >   
>> >> > 
>> >> >   
>> >> > 
>> >> >   
>> >> > 
>> >> >
>> >> > -
>> >> > login.js
>> >> > -
>> >> > $(document).ready(function(){
>> >> >   $("form#loginForm").submit(function() { // loginForm is submitted
>> >> > var username = $('#username').attr('value'); // get username
>> >> > var password = $('#password').attr('value'); // get password
>> >> >
>> >> > if (username && password) { // values are not empty
>> >> >   $.ajax({
>> >> > type: "GET",
>> >> > url: "http://localhost:8080/cgi-bin/login.pl";, // URL of the
>> >> > Perl
>> >> > script
>> >> > contentType: "application/json; charset=utf-8",
>> >> > dataType: "json",
>> >> > data: "username=" + username + "&password=" + password,
>> >> > error: function(XMLHttpRequest, textStatus, errorThrown) {
>> >> >   $('div#loginResult').text("responseText: " +
>> >> > XMLHttpRequest.responseText
>> >> > + ", textStatus: " + textStatus
>> >> > + ", errorThrown: " + errorThrown);
>> >> >   $('div#loginResult').addClass("error");
>> >> > }, // error
>> >> > success: function(data){
>> >> >   if (data.error) { // script returned error
>> >> > $('div#loginResult').text("data.error: " + data.error);
>> >> > $('div#loginResult').addClass("error");
>> >> >   } // if
>> >> >   else { // login was s

Re: How can I integrate simple Custom login page in Django.......?

2012-10-15 Thread Pervez Mulla
responseText: #!/usr/bin/perl -T use CGI; use DBI; use strict; use
warnings; use netsharkusr; my $cgi = CGI->new; my $username =
$cgi->param("username"); my $password = $cgi->param("password"); my
$tempuser = new netsharkusr(); if($tempuser->readbyusername($username) eq
1) { if($tempuser->{username} eq $username) { print "success \n"; #exit; }
} #$password = "123go"; my $userid; my $tempuser2 = new netsharkusr();
if($tempuser2->readbypassword($password)) { if($tempuser2->{password} eq
$password) { print "sccess \n"; $userid = $tempuser2->{userID}; } } # check
the username and password in the database # create a JSON string according
to the database result my $json = ($userid) ? qq{{"success" : "login is
successful", "userid" : $userid}} : qq{{"error" : "username or password is
wrong"}}; # return JSON string print $cgi->header(-type =>
"application/json", -charset => "utf-8"); print $json;, textStatus:
parsererror, errorThrown: undefined

On Mon, Oct 15, 2012 at 4:07 PM, Sergiy Khohlov  wrote:

> please provide error
>
> 2012/10/15 Pervez Mulla :
> > On error note its printing all pelr script itself.
> >
> >
> > On Mon, Oct 15, 2012 at 3:31 PM, Sergiy Khohlov 
> wrote:
> >>
> >> please provide error message
> >>
> >> 2012/10/15 Pervez Mulla :
> >> > Thank You for your response Sergiy ,
> >> >
> >> > I already try'd to run this script as shown in Django DOC as u given
> >> > .but
> >> > still it didnt work:(
> >> >
> >> > Thank You
> >> > Pervez
> >> >
> >> > On Mon, Oct 15, 2012 at 1:28 PM, Sergiy Khohlov 
> >> > wrote:
> >> >>
> >> >>
> >> >>
> https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-LOGIN_URL
> >> >>
> >> >>  set this one in setting.py
> >> >>
> >> >> 2012/10/15 Pervez Mulla :
> >> >> > Hi,
> >> >> >
> >> >> > I have login.html , login,js ang login.pl.
> >> >> >
> >> >> > I want to integrate basic login page in Django with perl back-end
> >> >> > from
> >> >> > where
> >> >> > Am reading my DB.
> >> >> > I was trying to integrate it from last day but come out with empty
> >> >> > .There
> >> >> > might be some settings in setting.py.
> >> >> > Below is my code
> >> >> >
> >> >> > --
> >> >> > login.html
> >> >> > --
> >> >> > http://www.w3.org/1999/xhtml";>
> >> >> >   
> >> >> >  >> >> > />
> >> >> >  >> >> > src="jquery-1.7.2.min.js">
> >> >> > 
> >> >> > 
> >> >> >   #loginContent { width: 350px; margin: 100px auto; }
> >> >> >   button[type] { margin: 0.5em 0; }
> >> >> > label {font-weight:bold;}
> >> >> > fieldset {padding:0 1.4em 1.4em 1.4em;margin:0 0 1.5em 0;border:1px
> >> >> > solid
> >> >> > #ccc;}
> >> >> > legend
> >> >> >
> >> >> >
> {font-weight:bold;font-size:1.2em;margin-top:-0.2em;margin-bottom:1em;}
> >> >> > fieldset, #IE8#HACK {padding-top:1.4em;}
> >> >> > legend, #IE8#HACK {margin-top:0;margin-bottom:0;}
> >> >> > input[type=text], input[type=password], input.text, input.title,
> >> >> > textarea
> >> >> > {background-color:#fff;border:1px solid #bbb;}
> >> >> > input[type=text]:focus, input[type=password]:focus,
> input.text:focus,
> >> >> > input.title:focus, textarea:focus {border-color:#666;}
> >> >> > select {background-color:#fff;border-width:1px;border-style:solid;}
> >> >> > input[type=text], input[type=password], input.text, input.title,
> >> >> > textarea,
> >> >> > select {margin:0.5em 0;}
> >> >> > input.text, input.title {width:300px;padding:5px;}
> >> >> > input.title {font-size:1.5em;}
> >> >> > textarea {width:390px;height:250px;padding:5px;}
> >> >> > form.inline {line-height:3;}
> >> >> > form.inline p {margin-bottom:0;}
> >> >> > .error, .alert, .notice, .success, .info
> >> >> > {padding:0.8em;margin-bottom:1em;border:2px solid #ddd;}
> >> >> > .error, .alert
> >> >> > {background:#fbe3e4;color:#8a1f11;border-color:#fbc2c4;}
> >> >> > .notice {background:#fff6bf;color:#514721;border-color:#ffd324;}
> >> >> > .success {background:#e6efc2;color:#264409;border-color:#c6d880;}
> >> >> > .info {background:#d5edf8;color:#205791;border-color:#92cae4;}
> >> >> > .error a, .alert a {color:#8a1f11;}
> >> >> > .notice a {color:#514721;}
> >> >> > .success a {color:#264409;}
> >> >> > .info a {color:#205791;}
> >> >> > 
> >> >> >   
> >> >> >   
> >> >> > 
> >> >> >   
> >> >> >   
> >> >> >action="">
> >> >> > 
> >> >> >   Enter information
> >> >> >   
> >> >> > Username type="text"
> >> >> > id="username" name="username" class="text" size="20" />
> >> >> >   
> >> >> >   
> >> >> > Password >> >> > type="password"
> >> >> > id="password" name="password" class="text" size="20" />
> >> >> >   
> >> >> >   
> >> >> >  >> >> > alt="ok"
> >> >> > />Login
> >> >> >   
> >> >> > 
> >> >> >   
> >> >> > 
> >> >> >   
> >> >> > 
> >> >> >
> >> >> > -
> >> >> > login.js
> >> >> > -
> >> >> > $(document).ready(function(){
> >> >> 

Re: How can I integrate simple Custom login page in Django.......?

2012-10-15 Thread Pervez Mulla
Instead of CGI server path , I places perl script in static folder and
given path for that .

On Mon, Oct 15, 2012 at 4:09 PM, Pervez Mulla  wrote:

> responseText: #!/usr/bin/perl -T use CGI; use DBI; use strict; use
> warnings; use netsharkusr; my $cgi = CGI->new; my $username =
> $cgi->param("username"); my $password = $cgi->param("password"); my
> $tempuser = new netsharkusr(); if($tempuser->readbyusername($username) eq
> 1) { if($tempuser->{username} eq $username) { print "success \n"; #exit; }
> } #$password = "123go"; my $userid; my $tempuser2 = new netsharkusr();
> if($tempuser2->readbypassword($password)) { if($tempuser2->{password} eq
> $password) { print "sccess \n"; $userid = $tempuser2->{userID}; } } # check
> the username and password in the database # create a JSON string according
> to the database result my $json = ($userid) ? qq{{"success" : "login is
> successful", "userid" : $userid}} : qq{{"error" : "username or password is
> wrong"}}; # return JSON string print $cgi->header(-type =>
> "application/json", -charset => "utf-8"); print $json;, textStatus:
> parsererror, errorThrown: undefined
>
>
> On Mon, Oct 15, 2012 at 4:07 PM, Sergiy Khohlov wrote:
>
>> please provide error
>>
>> 2012/10/15 Pervez Mulla :
>> > On error note its printing all pelr script itself.
>> >
>> >
>> > On Mon, Oct 15, 2012 at 3:31 PM, Sergiy Khohlov 
>> wrote:
>> >>
>> >> please provide error message
>> >>
>> >> 2012/10/15 Pervez Mulla :
>> >> > Thank You for your response Sergiy ,
>> >> >
>> >> > I already try'd to run this script as shown in Django DOC as u given
>> >> > .but
>> >> > still it didnt work:(
>> >> >
>> >> > Thank You
>> >> > Pervez
>> >> >
>> >> > On Mon, Oct 15, 2012 at 1:28 PM, Sergiy Khohlov 
>> >> > wrote:
>> >> >>
>> >> >>
>> >> >>
>> https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-LOGIN_URL
>> >> >>
>> >> >>  set this one in setting.py
>> >> >>
>> >> >> 2012/10/15 Pervez Mulla :
>> >> >> > Hi,
>> >> >> >
>> >> >> > I have login.html , login,js ang login.pl.
>> >> >> >
>> >> >> > I want to integrate basic login page in Django with perl back-end
>> >> >> > from
>> >> >> > where
>> >> >> > Am reading my DB.
>> >> >> > I was trying to integrate it from last day but come out with empty
>> >> >> > .There
>> >> >> > might be some settings in setting.py.
>> >> >> > Below is my code
>> >> >> >
>> >> >> > --
>> >> >> > login.html
>> >> >> > --
>> >> >> > http://www.w3.org/1999/xhtml";>
>> >> >> >   
>> >> >> > > >> >> > />
>> >> >> > > >> >> > src="jquery-1.7.2.min.js">
>> >> >> > 
>> >> >> > 
>> >> >> >   #loginContent { width: 350px; margin: 100px auto; }
>> >> >> >   button[type] { margin: 0.5em 0; }
>> >> >> > label {font-weight:bold;}
>> >> >> > fieldset {padding:0 1.4em 1.4em 1.4em;margin:0 0 1.5em
>> 0;border:1px
>> >> >> > solid
>> >> >> > #ccc;}
>> >> >> > legend
>> >> >> >
>> >> >> >
>> {font-weight:bold;font-size:1.2em;margin-top:-0.2em;margin-bottom:1em;}
>> >> >> > fieldset, #IE8#HACK {padding-top:1.4em;}
>> >> >> > legend, #IE8#HACK {margin-top:0;margin-bottom:0;}
>> >> >> > input[type=text], input[type=password], input.text, input.title,
>> >> >> > textarea
>> >> >> > {background-color:#fff;border:1px solid #bbb;}
>> >> >> > input[type=text]:focus, input[type=password]:focus,
>> input.text:focus,
>> >> >> > input.title:focus, textarea:focus {border-color:#666;}
>> >> >> > select
>> {background-color:#fff;border-width:1px;border-style:solid;}
>> >> >> > input[type=text], input[type=password], input.text, input.title,
>> >> >> > textarea,
>> >> >> > select {margin:0.5em 0;}
>> >> >> > input.text, input.title {width:300px;padding:5px;}
>> >> >> > input.title {font-size:1.5em;}
>> >> >> > textarea {width:390px;height:250px;padding:5px;}
>> >> >> > form.inline {line-height:3;}
>> >> >> > form.inline p {margin-bottom:0;}
>> >> >> > .error, .alert, .notice, .success, .info
>> >> >> > {padding:0.8em;margin-bottom:1em;border:2px solid #ddd;}
>> >> >> > .error, .alert
>> >> >> > {background:#fbe3e4;color:#8a1f11;border-color:#fbc2c4;}
>> >> >> > .notice {background:#fff6bf;color:#514721;border-color:#ffd324;}
>> >> >> > .success {background:#e6efc2;color:#264409;border-color:#c6d880;}
>> >> >> > .info {background:#d5edf8;color:#205791;border-color:#92cae4;}
>> >> >> > .error a, .alert a {color:#8a1f11;}
>> >> >> > .notice a {color:#514721;}
>> >> >> > .success a {color:#264409;}
>> >> >> > .info a {color:#205791;}
>> >> >> > 
>> >> >> >   
>> >> >> >   
>> >> >> > 
>> >> >> >   
>> >> >> >   
>> >> >> >   > action="">
>> >> >> > 
>> >> >> >   Enter information
>> >> >> >   
>> >> >> > Username> type="text"
>> >> >> > id="username" name="username" class="text" size="20" />
>> >> >> >   
>> >> >> >   
>> >> >> > Password> >> >> > type="password"
>> >> >> > id="password" name="password" class="text" size="20" />
>> >> >> >   
>> >> >> > 

Re: Trouble with VirtualEnv on Windows

2012-10-15 Thread Joshua Russo
Sweet! Thank you!

On Monday, October 15, 2012 12:56:37 AM UTC-4, Jani Tiainen wrote:
>
> Because the setup procedure used there is faulty. 
>
> This is what happens: 
>
> When installing Python install package will bind .PY(C) file execution 
> to use _always_ main installation. It won't follow any path settings 
> which virtualenv relies on. 
>
> I'm not sure can you even overcome that restriction easily on cmd. I 
> know that powershell can do it (don't know how though) or personally I 
> use TCC/LE. 
>
> Also psycopg2 is installed on main installation and virtualenv created 
> with --no-site-packages should disable it from virtualenv. 
>
> This is the battle tested procedure how I do set up my environment: 
>
> http://djangonautlostinspace.wordpress.com/2012/04/16/django-and-windows/ 
>
>
> 15.10.2012 5:45, Joshua Russo kirjoitti: 
> > I suppose I was a little light on the details of how I setup the 
> > environment. I don't often setup a new environment from scratch so I 
> > used this post as the basis: 
> > 
> http://slacy.com/blog/2011/06/django-postgresql-virtualenv-development-setup-for-windows-7/
>  
> > 
> > 
> > The versions of each program I used / ended up with were: 
> > Python 2.7.3 (32 bit) 
> > Postgres 9.2 (32 bit) 
> > Setuptools 0.6c11 for Python 2.7 
> > Psycopg2 2.4.5 for Python 2.7 (32 bit) 
> > VirtualEnv 1.8.2 
> > Django 1.4.1 
> > 
> > 
> > 
> > On Sunday, October 14, 2012 6:25:41 PM UTC-4, Joshua Russo wrote: 
> > 
> > This is probably a VirturalEnv problem as opposed to a Django 
> > problem but I was wondering if someone here could point me in the 
> > right direction. 
> > 
> > I'm trying to setup clean environment for a demonstration of Django 
> > on Tuesday but I get the following when I try to setup the project 
> > within the virtual environment. You can see that if I just run 
> > python from within the virtual environment I do have access to the 
> > libraries, but if I try to use the django-admin.py script, the 
> > libraries aren't found. Any thoughts? 
> > 
> > (django-tutorial) 
> > C:\dev\venv\django-tutorial>Scripts\django-admin.py startproject 
> > testsite 
> > Traceback (most recent call last): 
> >File "C:\dev\venv\django-tutorial\Scripts\django-admin.py", line 
> > 2, in  
> >  from django.core import management 
> > ImportError: No module named django.core 
> > 
> > (django-tutorial) 
> > C:\dev\venv\django-tutorial>C:\dev\venv\django-tutorial\Script 
> > s\python.exe 
> > Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit 
> > (Intel)] on win 
> > 32 
> > Type "help", "copyright", "credits" or "license" for more 
> information. 
> >  >>> from django.core import management 
> >  >>> management 
> >  > 'C:\dev\venv\django-tutorial\lib\site-pack 
> > ages\django\core\management\__init__.pyc'> 
> >  >>> 
> > 
> > -- 
> > 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/-/YuSLHUyt6xIJ. 
> > 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. 
>
>
> -- 
> Jani Tiainen 
>
> - Well planned is half done and a half done has been sufficient before... 
>

-- 
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/-/ahUGFdt6pEgJ.
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.



Re: Trouble with VirtualEnv on Windows

2012-10-15 Thread Frank Bieniek

Hi,

do a "pip freeze" after you have activated your environment,
this way you see the packages that are visible to the python interpreter 
inside your virtual env.


Possible Problem
You have installed all packaged before you created the virtual env.
-> virtual env shows no components.
pip install componentname should solve the problem.

or:
Windows reads the registry for some packages (mainly none native 
packages) and

inside the virutual env this does not work.
Try to recreate the virtualenv with --system-site-packages option set.

another solution - use vagrant: - google for djangocon 2012 vagrant

Thanks
Frank







Am 15.10.2012 04:45, schrieb Joshua Russo:
I suppose I was a little light on the details of how I setup the 
environment. I don't often setup a new environment from scratch so I 
used this post as the basis: 
http://slacy.com/blog/2011/06/django-postgresql-virtualenv-development-setup-for-windows-7/ 



The versions of each program I used / ended up with were:
   Python 2.7.3 (32 bit)
   Postgres 9.2 (32 bit)
   Setuptools 0.6c11 for Python 2.7
   Psycopg2 2.4.5 for Python 2.7 (32 bit)
   VirtualEnv 1.8.2
   Django 1.4.1



On Sunday, October 14, 2012 6:25:41 PM UTC-4, Joshua Russo wrote:

This is probably a VirturalEnv problem as opposed to a Django
problem but I was wondering if someone here could point me in the
right direction.

I'm trying to setup clean environment for a demonstration of
Django on Tuesday but I get the following when I try to setup the
project within the virtual environment. You can see that if I just
run python from within the virtual environment I do have access to
the libraries, but if I try to use the django-admin.py script, the
libraries aren't found. Any thoughts?

(django-tutorial)
C:\dev\venv\django-tutorial>Scripts\django-admin.py startproject
testsite
Traceback (most recent call last):
  File "C:\dev\venv\django-tutorial\Scripts\django-admin.py", line
2, in 
from django.core import management
ImportError: No module named django.core

(django-tutorial)
C:\dev\venv\django-tutorial>C:\dev\venv\django-tutorial\Script
s\python.exe
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit
(Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> from django.core import management
>>> management

>>>

--
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/-/YuSLHUyt6xIJ.

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.


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
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.



Re: How can I integrate simple Custom login page in Django.......?

2012-10-15 Thread Jason Sibre
Hi,
Just a hunch, but it kinda smells like your web server isn't executing the CGI 
script.  I'd suggest checking into what is necessary to get your server to 
execute CGI, vs serving it up as text.


On Oct 15, 2012, at 5:40 AM, Pervez Mulla wrote:

> Instead of CGI server path , I places perl script in static folder and given 
> path for that . 
> 
> On Mon, Oct 15, 2012 at 4:09 PM, Pervez Mulla  wrote:
> responseText: #!/usr/bin/perl -T use CGI; use DBI; use strict; use warnings; 
> use netsharkusr; my $cgi = CGI->new; my $username = $cgi->param("username"); 
> my $password = $cgi->param("password"); my $tempuser = new netsharkusr(); 
> if($tempuser->readbyusername($username) eq 1) { if($tempuser->{username} eq 
> $username) { print "success \n"; #exit; } } #$password = "123go"; my $userid; 
> my $tempuser2 = new netsharkusr(); if($tempuser2->readbypassword($password)) 
> { if($tempuser2->{password} eq $password) { print "sccess \n"; $userid = 
> $tempuser2->{userID}; } } # check the username and password in the database # 
> create a JSON string according to the database result my $json = ($userid) ? 
> qq{{"success" : "login is successful", "userid" : $userid}} : qq{{"error" : 
> "username or password is wrong"}}; # return JSON string print 
> $cgi->header(-type => "application/json", -charset => "utf-8"); print $json;, 
> textStatus: parsererror, errorThrown: undefined
> 
> 
> On Mon, Oct 15, 2012 at 4:07 PM, Sergiy Khohlov  wrote:
> please provide error
> 
> 2012/10/15 Pervez Mulla :
> > On error note its printing all pelr script itself.
> >
> >
> > On Mon, Oct 15, 2012 at 3:31 PM, Sergiy Khohlov  wrote:
> >>
> >> please provide error message
> >>
> >> 2012/10/15 Pervez Mulla :
> >> > Thank You for your response Sergiy ,
> >> >
> >> > I already try'd to run this script as shown in Django DOC as u given
> >> > .but
> >> > still it didnt work:(
> >> >
> >> > Thank You
> >> > Pervez
> >> >
> >> > On Mon, Oct 15, 2012 at 1:28 PM, Sergiy Khohlov 
> >> > wrote:
> >> >>
> >> >>
> >> >> https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-LOGIN_URL
> >> >>
> >> >>  set this one in setting.py
> >> >>
> >> >> 2012/10/15 Pervez Mulla :
> >> >> > Hi,
> >> >> >
> >> >> > I have login.html , login,js ang login.pl.
> >> >> >
> >> >> > I want to integrate basic login page in Django with perl back-end
> >> >> > from
> >> >> > where
> >> >> > Am reading my DB.
> >> >> > I was trying to integrate it from last day but come out with empty
> >> >> > .There
> >> >> > might be some settings in setting.py.
> >> >> > Below is my code
> >> >> >
> >> >> > --
> >> >> > login.html
> >> >> > --
> >> >> > http://www.w3.org/1999/xhtml";>
> >> >> >   
> >> >> >  >> >> > />
> >> >> >  >> >> > src="jquery-1.7.2.min.js">
> >> >> > 
> >> >> > 
> >> >> >   #loginContent { width: 350px; margin: 100px auto; }
> >> >> >   button[type] { margin: 0.5em 0; }
> >> >> > label {font-weight:bold;}
> >> >> > fieldset {padding:0 1.4em 1.4em 1.4em;margin:0 0 1.5em 0;border:1px
> >> >> > solid
> >> >> > #ccc;}
> >> >> > legend
> >> >> >
> >> >> > {font-weight:bold;font-size:1.2em;margin-top:-0.2em;margin-bottom:1em;}
> >> >> > fieldset, #IE8#HACK {padding-top:1.4em;}
> >> >> > legend, #IE8#HACK {margin-top:0;margin-bottom:0;}
> >> >> > input[type=text], input[type=password], input.text, input.title,
> >> >> > textarea
> >> >> > {background-color:#fff;border:1px solid #bbb;}
> >> >> > input[type=text]:focus, input[type=password]:focus, input.text:focus,
> >> >> > input.title:focus, textarea:focus {border-color:#666;}
> >> >> > select {background-color:#fff;border-width:1px;border-style:solid;}
> >> >> > input[type=text], input[type=password], input.text, input.title,
> >> >> > textarea,
> >> >> > select {margin:0.5em 0;}
> >> >> > input.text, input.title {width:300px;padding:5px;}
> >> >> > input.title {font-size:1.5em;}
> >> >> > textarea {width:390px;height:250px;padding:5px;}
> >> >> > form.inline {line-height:3;}
> >> >> > form.inline p {margin-bottom:0;}
> >> >> > .error, .alert, .notice, .success, .info
> >> >> > {padding:0.8em;margin-bottom:1em;border:2px solid #ddd;}
> >> >> > .error, .alert
> >> >> > {background:#fbe3e4;color:#8a1f11;border-color:#fbc2c4;}
> >> >> > .notice {background:#fff6bf;color:#514721;border-color:#ffd324;}
> >> >> > .success {background:#e6efc2;color:#264409;border-color:#c6d880;}
> >> >> > .info {background:#d5edf8;color:#205791;border-color:#92cae4;}
> >> >> > .error a, .alert a {color:#8a1f11;}
> >> >> > .notice a {color:#514721;}
> >> >> > .success a {color:#264409;}
> >> >> > .info a {color:#205791;}
> >> >> > 
> >> >> >   
> >> >> >   
> >> >> > 
> >> >> >   
> >> >> >   
> >> >> >   
> >> >> > 
> >> >> >   Enter information
> >> >> >   
> >> >> > Username >> >> > id="username" name="username" class="text" size="20" />
> >> >> >   
> >> >> >   
> >> >> > Password >> >> 

Re: Adding a new row to the database in user form

2012-10-15 Thread Nicolas Emiliani
On Mon, Oct 15, 2012 at 3:16 AM, Satinderpal Singh <
satinder.goray...@gmail.com> wrote:

> Hello,
> I want to add a new row in the existing database table by using add
> button in the html form from the user as user can create as much rows
> in the table as he needed, how will i add this?
> Thanks, in advance.
>
>
Hi, correct me if I'm wrong but, it seems that you are talking about
formsets. Check this out :

https://docs.djangoproject.com/en/dev/topics/forms/formsets/


> --
> Satinderpal Singh
> http://satindergoraya.blogspot.in/
> http://satindergoraya91.blogspot.in/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> 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.
>
>


-- 
Nicolas Emiliani

Lo unico instantaneo en la vida es el cafe, y es bien feo.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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.



Re: get_or_create gave IntegrityError: (1062, "Duplicate entry) error sometimes

2012-10-15 Thread Zheng Li
get_or_create shouldn't give duplicate entry error
anyone help.

On 2012/10/13, at 11:06, Wei Wei wrote:

> I am new to Django. But does the error message literally mean you have 
> duplicated records against your unique_together constriction?
> 
> On Sat, Oct 13, 2012 at 9:47 AM, Zheng Li  wrote:
> class AB(models.Model):
> a = models.ForeignKey(A)
> b = models.ForeignKey(B)
> c = models.IntegerField(default=0)
> d = models.FloatField(default=0)
> e = models.IntegerField(default=0)
> f = models.FloatField(default=0)
> class Meta:
> unique_together = (('a', 'b'),)
> 
> I have a class like above.
> when I call get_or_create, sometimes IntegrityError: (1062, "Duplicate entry) 
> error happens.
> a, _ = AB.objects.get_or_create(a=a, b=b)
> 
> I really have googled and worked on it for a while, but still nothing.
> anyone can help?
> Thanks in advance.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> 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.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> 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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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.



Re: get_or_create gave IntegrityError: (1062, "Duplicate entry) error sometimes

2012-10-15 Thread Reinout van Rees

On 15-10-12 14:50, Zheng Li wrote:

get_or_create shouldn't give duplicate entry error


Perhaps you have existing data that violates your unique-together 
constraint? Data that existed before that constraint was in place?


Check it directly in your database by searching for that a=a, b=b entry.


Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
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.



Re: get_or_create gave IntegrityError: (1062, "Duplicate entry) error sometimes

2012-10-15 Thread Tom Evans
On Mon, Oct 15, 2012 at 1:50 PM, Zheng Li  wrote:
> get_or_create shouldn't give duplicate entry error
> anyone help.
>

This is incorrect, and a common misconception: get_or_create() is not
atomic. If this happens, you will get duplicate key errors:

Thread A calls get_or_create(a='a', b='b')
Thread B calls get_or_create(a='a', b='b')
Thread A get_or_create looks for entry in DB, not found
Thread B get_or_create looks for entry in DB, not found
Thread B creates entry in DB
Thread A get_or_create tries to create entry in DB

Where I say 'thread', you could also read 'process'. If you are
capable of serving multiple requests simultaneously, this can happen,
even if you aren't using threads.

If this is a problem for you, use a transaction aware DB instead of
MySQL. It won't solve the issue, but at least you will be able to
unroll the transaction.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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.



Re: get_or_create gave IntegrityError: (1062, "Duplicate entry) error sometimes

2012-10-15 Thread Karen Tracey
On Mon, Oct 15, 2012 at 9:43 AM, Tom Evans  wrote:

> On Mon, Oct 15, 2012 at 1:50 PM, Zheng Li  wrote:
> > get_or_create shouldn't give duplicate entry error
> > anyone help.
> >
>
> This is incorrect, and a common misconception: get_or_create() is not
> atomic. If this happens, you will get duplicate key errors:
>

No, get_or_create IS intended to be atomic.


>
> Thread A calls get_or_create(a='a', b='b')
> Thread B calls get_or_create(a='a', b='b')
> Thread A get_or_create looks for entry in DB, not found
> Thread B get_or_create looks for entry in DB, not found
> Thread B creates entry in DB
> Thread A get_or_create tries to create entry in DB
>

Internally, get_or_create code in thread A will now attempt to GET the
object created by thread B. It will not automatically reflect the error to
the caller. See:

https://github.com/django/django/blob/stable/1.4.x/django/db/models/query.py#L430


>
> Where I say 'thread', you could also read 'process'. If you are
> capable of serving multiple requests simultaneously, this can happen,
> even if you aren't using threads.
>
> If this is a problem for you, use a transaction aware DB instead of
> MySQL. It won't solve the issue, but at least you will be able to
> unroll the transaction.
>

The issue with MySQL here is when you ARE using its transactional DB
engine, InnoDB, AND using its (default) "repeatable read" transaction
isolation level. In that case, the DB will refuse to return the object
created by thread B to thread A if thread A has already "read" the
non-existence of such a row. See:

https://code.djangoproject.com/ticket/13906

This particular issue can be fixed by changing the transaction isolation
level to "read committed". Although I have heard various people say this
can cause "other problems" with MySQL apps, I've never seen a concrete
example of one, so switching to "read committed" would be my preferred way
to use get_or_created if I had to use MySQL/InnoDB.

Karen
-- 
http://tracey.org/kmt/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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.



Re: get_or_create gave IntegrityError: (1062, "Duplicate entry) error sometimes

2012-10-15 Thread Tom Evans
On Mon, Oct 15, 2012 at 3:28 PM, Karen Tracey  wrote:
> On Mon, Oct 15, 2012 at 9:43 AM, Tom Evans  wrote:
>>
>> On Mon, Oct 15, 2012 at 1:50 PM, Zheng Li  wrote:
>> > get_or_create shouldn't give duplicate entry error
>> > anyone help.
>> >
>>
>> This is incorrect, and a common misconception: get_or_create() is not
>> atomic. If this happens, you will get duplicate key errors:
>
>
> No, get_or_create IS intended to be atomic.
>

I can be intended to be whatever it wants, but since there is no
atomic database operation to get or create a tuple, there is no
guarantee of atomicity.

>>
>>
>> Thread A calls get_or_create(a='a', b='b')
>> Thread B calls get_or_create(a='a', b='b')
>> Thread A get_or_create looks for entry in DB, not found
>> Thread B get_or_create looks for entry in DB, not found
>> Thread B creates entry in DB
>> Thread A get_or_create tries to create entry in DB
>
>
> Internally, get_or_create code in thread A will now attempt to GET the
> object created by thread B. It will not automatically reflect the error to
> the caller. See:
>
> https://github.com/django/django/blob/stable/1.4.x/django/db/models/query.py#L430

I regularly - once every few months - see get_or_create raise
IntegrityError due to duplicate key on MySQL 5.0/MyISAM/Django 1.3. So
whilst that is the intention of the code, it isn't what happens. I'm
happy to blame MySQL.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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.



Re: User can't edit model even after permissions are issued

2012-10-15 Thread Shawn H
Yes.  I can connect as the super user and edit, add and delete.

On Sunday, October 14, 2012 9:48:32 AM UTC-5, Karen Tracey wrote:
>
> On Fri, Oct 12, 2012 at 4:52 PM, Shawn H 
> > wrote:
>
>> I'm new to Django, and I'm using the admin site to manage my users.  I 
>> have one app installed, and it has one model.  I created a new user, issued 
>> that user add, change, and delete privileges (as app | model | privilege), 
>> but when I log on as that user, I get the "you don't have permission to 
>> edit anything" error.  The user is active and is staff, but no joy.  What 
>> might I be missing? 
>
>
> Are the app's models registered in admin? 
>
> -- 
> http://tracey.org/kmt/
>
>

-- 
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/-/jcW8IAVIMiQJ.
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.



bug in use of mark_safe and i18n _ ?

2012-10-15 Thread Federico Marani
Hi,

I am using a form which defines this field:

terms = forms.BooleanField(
error_messages={'required': _('You must accept the terms and 
conditions')},
label="",
help_text=_(mark_safe("I understand and accept the terms of use and privacy policy of this site."))
)

unfortunately running "./manage.py makemessages --all" does not seem to 
pickup the help_text named argument.

---

If i change this to:

terms = forms.BooleanField(
error_messages={'required': _('You must accept the terms and 
conditions')},
label="",
help_text=mark_safe(_("I understand and accept the terms of use and privacy policy of this site."))
)

the message in the html is left untranslated.

---

any advice?

-- 
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/-/W5p21l-sTb0J.
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.



Re: User can't edit anything

2012-10-15 Thread Nikolas Stevenson-Molnar
Being 'staff' only means that the user can access the admin area, not
that they can do anything there. Double check that they have permissions
(or are a member of a group which has permissions) to edit each content
type you want them to be able to edit.

_Nik

On 10/12/2012 2:02 PM, Shawn H wrote:
> I'm new to django, and using the admin site for user management.  I've
> created a new user, issued app | model | permission of add, change,
> and delete to this user for the app I've built, but when I logon as
> that user, I get the "you don't have permission to edit anything".
>  The user is active (obviously as I can logon as that user) and is
> staff, but the permissions don't seem to be working.  What might I be
> missing?  Thanks. --
> 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/-/5zMO9ZPGel4J.
> 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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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.



django-pci-auth

2012-10-15 Thread Alex Clark

Hello Djangonauts!

I'm about to develop a Django app for PCI auth compliance for a client. 
It's open source under the same BSD license that Django users. I'm 
interested in any and all feedback as I develop this application over 
the course of the next two months.


You can track the project and report issues here:


- https://github.com/aclark4life/django-pci-auth


I look forward to your comments,


Alex



--
Alex Clark · https://www.gittip.com/aclark4life/


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
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.



csrf cookie and varnish

2012-10-15 Thread Àlex Pérez
Today I had a problem with CSRF protection of Djando and varnish, the
varnish basically detects that a cookie (the CSRF) and does not perform its
task (cache requests).

The solutions found on google have not convinced me. And I tried an idea,
delete all cookies when I'm not on a website that requires cookies and
delete on the rest.

Someone may find any inconvenient to this solution?

I do not need user authentication ...

thanks
-- 
Alex Perez
alex.pe...@bebabum.com

 *bebabum* be successful

c/ Còrsega 301-303, Àtic 2
08008 Barcelona
http://www.bebabum.com
http://www.facebook.com/bebabum
http://twitter.com/bebabum

This message is intended exclusively for its addressee and may contain
information that is confidential and protected by professional privilege.
If you are not the intended recipient you are hereby notified that any
dissemination, copy or disclosure of this communication is strictly
prohibited by law.

Este mensaje se dirige exclusivamente a su destinatario y puede contener
información privilegiada o confidencial. Si no es vd. el destinatario
indicado,
queda notificado que la utilización, divulgación y/o copia sin autorización
está prohibida en virtud de la legislación vigente.

Le informamos que los datos personales que facilite/ha facilitado pasarán a
formar parte de un fichero responsabilidad de bebabum, S.L. y que tiene
por finalidad gestionar las relaciones con usted.
Tiene derecho al acceso, rectificación cancelación y oposición en nuestra
oficina ubicada en c/ Còrsega 301-303, Àtic 2 de Barcelona o a la dirección
de e-mail l...@bebabum.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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.



Craziest conferenece idea ever - announcing next DjangoCon EU

2012-10-15 Thread Ola Sitarska
Hi guys!


Just wanted to let you know that we launched DjangoCon Europe 2013 website. 
This time we've decided to put some more magic and came up with this crazy 
idea of throwing a fun Django conference in a real CIRCUS tent, so make 
sure to check it out: http://2013.djangocon.eu/

We're gonna start Call for papers really soon, so signup for newsletter to 
follow updates :) 

Cheers,
Ola

-- 
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/-/OZQSwDoz0ZUJ.
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.



Craziest conference idea ever - announcing next DjangoCon Europe

2012-10-15 Thread Ola Sitarska
Hi guys & girls!

Just wanted to let you know that we launched DjangoCon Europe 2013 website. 
This time we've decided to put some more magic and came up with this crazy 
idea of throwing a fun Django conference in a real CIRCUS tent, so make 
sure to check it out: http://2013.djangocon.eu/

We're gonna start Call for papers really soon, so signup for newsletter to 
follow updates :) 

Cheers,
Ola

-- 
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/-/IPk-RA-QSasJ.
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.



Overriding admin save event

2012-10-15 Thread Lachlan Musicman
Hola,

I wanted to override the save event in the admin so that users were
redirected to a different page.

I found this page describing how to do it:
http://www.ibm.com/developerworks/opensource/library/os-django-admin/index.html#listing10

It recommends two methods and describes one:

"There are two ways to change the behavior of the Save button: You can
override admin.ModelAdmin.response_add, which is responsible for the
actual redirection after a save, or you can override
admin.ModelAdmin.change_view. The latter is somewhat simple"

This post is from 2009. Are these two methods still the best way to go
about this, and rather than which is simple, which is considered "more
django/more pythonic/more canonical"?

cheers
L.

-- 
...we look at the present day through a rear-view mirror. This is
something Marshall McLuhan said back in the Sixties, when the world
was in the grip of authentic-seeming future narratives. He said, “We
look at the present through a rear-view mirror. We march backwards
into the future.”

http://www.warrenellis.com/?p=14314

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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.



Re: Overriding admin save event

2012-10-15 Thread Lachlan Musicman
On Tue, Oct 16, 2012 at 12:52 PM, Lachlan Musicman  wrote:
> Hola,
>
> I wanted to override the save event in the admin so that users were
> redirected to a different page.

Of course, further reading has turned up signals. Is this the current
recommended method?

eg:

from django.db.models.signals import pre_save
from django.dispatch import receiver
from myapp.models import MyModel

@receiver(post_save)
def redirect(sender, **kwargs):
HttpResponseRedirect('/my/prefered/url/')

?

Cheers
L.

-- 
...we look at the present day through a rear-view mirror. This is
something Marshall McLuhan said back in the Sixties, when the world
was in the grip of authentic-seeming future narratives. He said, “We
look at the present through a rear-view mirror. We march backwards
into the future.”

http://www.warrenellis.com/?p=14314

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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.



Re: Overriding admin save event

2012-10-15 Thread Lachlan Musicman
On Tue, Oct 16, 2012 at 1:44 PM, Lachlan Musicman  wrote:
>> Hola,
>>
>> I wanted to override the save event in the admin so that users were
>> redirected to a different page.
>
> Of course, further reading has turned up signals. Is this the current
> recommended method?
>
> eg:
>
> from django.db.models.signals import pre_save
> from django.dispatch import receiver
> from myapp.models import MyModel
>
> @receiver(post_save)
> def redirect(sender, **kwargs):
> HttpResponseRedirect('/my/prefered/url/')


For reference, the above doesn't work

I'll try the IBM example

Cheers
L.


>
> ?
>
> Cheers
> L.
>
> --
> ...we look at the present day through a rear-view mirror. This is
> something Marshall McLuhan said back in the Sixties, when the world
> was in the grip of authentic-seeming future narratives. He said, “We
> look at the present through a rear-view mirror. We march backwards
> into the future.”
>
> http://www.warrenellis.com/?p=14314



-- 
...we look at the present day through a rear-view mirror. This is
something Marshall McLuhan said back in the Sixties, when the world
was in the grip of authentic-seeming future narratives. He said, “We
look at the present through a rear-view mirror. We march backwards
into the future.”

http://www.warrenellis.com/?p=14314

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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.



Re: Overriding admin save event

2012-10-15 Thread Lachlan Musicman
On Tuesday, October 16, 2012, Lachlan Musicman wrote:

> Hola,
>
> I wanted to override the save event in the admin so that users were
> redirected to a different page.
>
> I found this page describing how to do it:
>
> http://www.ibm.com/developerworks/opensource/library/os-django-admin/index.html#listing10
>
> It recommends two methods and describes one:
>
> "There are two ways to change the behavior of the Save button: You can
> override admin.ModelAdmin.response_add, which is responsible for the
> actual redirection after a save, or you can override
> admin.ModelAdmin.change_view. The latter is somewhat simple"
>

This method throws error:

You called this URL via POST, but the URL doesn't end in a slash and you
have APPEND_SLASH set. Django can't redirect to the slash URL while
maintaining POST data. Change your form to point to
127.0.0.1:8000/admin/tafe/applicant/4/None/ (note the trailing slash), or
set APPEND_SLASH=False in your Django settings.

Gah. Do I bother trying to work out why it's redirecting to
127.0.0.1:8000/admin/tafe/applicant/4/None/ instead of where I want it to
or rethink completely?

cheers
L.


-- 
...we look at the present day through a rear-view mirror. This is something
Marshall McLuhan said back in the Sixties, when the world was in the grip
of authentic-seeming future narratives. He said, “We look at the present
through a rear-view mirror. We march backwards into the future.”

http://www.warrenellis.com/?p=14314

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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.



Help getting my GeoDjango setup.

2012-10-15 Thread JJ Zolper
Hello everyone,

So I've installed GDAL, PostGIS, PROJ.4, and GEOS. I have Postgres set up 
too.

What I need help on is the logistics of getting the GeoDjango portion of my 
website up and running. I already have my website code I'm just trying to 
add in GeoDjango so I can handle geographic operations on the website.

So I've been reading here:

https://docs.djangoproject.com/en/1.4/ref/contrib/gis/tutorial/#introduction

I see:
Create GeoDjango 
Project

Use the django-admin.py script like normal to create a geodjango project:

$ django-admin.py startproject geodjango

With the project initialized, now create a world Django application within 
the geodjango project:

$ cd geodjango$ python manage.py startapp world

Configure 
settings.py

The geodjango project settings are stored in the geodjango/settings.py file. 
Edit the database connection settings appropriately:

DATABASES = {
'default': {
 'ENGINE': 'django.contrib.gis.db.backends.postgis',
 'NAME': 'geodjango',
 'USER': 'geo',
 }}

In addition, modify the 
INSTALLED_APPS
 setting 
to include 
django.contrib.admin
, 
django.contrib.gis,
 
and world (our newly created application):

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.gis',
'world')



My question is do I need to start a new project if I already have one 
project already? I already have my project "madtrak" which is the project 
that contains my entire website. Do I need a separate project just for 
GeoDjango? I thought that the start project command was only done once and 
for the website. Or do I need to run "django-admin.py startproject 
geodjango" ?

If I find that I don't need to start a new project that would help a lot 
because then I would already have a settings.py file with my installed apps 
and an app that will have a model that connects up to the Geodjango 
database.

One more thing on this topic I see:

 'ENGINE': 'django.contrib.gis.db.backends.postgis',


Even if I don't need an entire separate project do I need to add this 
backend to my current django project? That way I can handle all the 
Geodjango necessities? 

Because currently I have:

'ENGINE': 'django.db.backends.postgresql_psycopg2',

and I would guess that is not sufficient. Any advice on handling my current 
settings file and interfacing that with the GeoDjango database would be 
great!



Okay secondly I see this:
Create a Spatial 
Database

Note

MySQL and Oracle users can skip this section because spatial types are 
already built into the database.

First, a spatial database needs to be created for our project. If using 
PostgreSQL and PostGIS, then the following commands will create the 
database from a spatial database 
template
:

$ createdb -T template_postgis geodjango


So it seems to me I need a new database because it will be a spatial 
database for GeoDjango? I would think my current database would not be 
sufficient because there is nothing special about it to hold the geometric 
data I will need to process with GeoDjango. So do I need to run this 
command and set up a new database and remove my old one? If I do this is 
the idea that I have those extra features that I need in my spatial 
database for GeoDjango and I then have the option on when to use that 
functionality within each django app I build?


Any advice regarding the integration of GeoDjango into a current django 
project environment would be really useful!

Thanks so much for your time.

JJ Zolper

-- 
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/-/RP4zIl1e4XoJ.
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.



Re: get_or_create gave IntegrityError: (1062, "Duplicate entry) error sometimes

2012-10-15 Thread Zheng Li
Isn't it because MyISAM does not support transaction?

BTW
I am using django 1.3.1, mysql 5.5, innodb
mysql> SELECT @@GLOBAL.tx_isolation, @@tx_isolation;
+---+-+
| @@GLOBAL.tx_isolation | @@tx_isolation  |
+---+-+
| REPEATABLE-READ   | REPEATABLE-READ |
+---+-+

another question,
does "read committed" affects performance?

On 2012/10/16, at 0:35, Tom Evans wrote:

> On Mon, Oct 15, 2012 at 3:28 PM, Karen Tracey  wrote:
>> On Mon, Oct 15, 2012 at 9:43 AM, Tom Evans  wrote:
>>> 
>>> On Mon, Oct 15, 2012 at 1:50 PM, Zheng Li  wrote:
 get_or_create shouldn't give duplicate entry error
 anyone help.
 
>>> 
>>> This is incorrect, and a common misconception: get_or_create() is not
>>> atomic. If this happens, you will get duplicate key errors:
>> 
>> 
>> No, get_or_create IS intended to be atomic.
>> 
> 
> I can be intended to be whatever it wants, but since there is no
> atomic database operation to get or create a tuple, there is no
> guarantee of atomicity.
> 
>>> 
>>> 
>>> Thread A calls get_or_create(a='a', b='b')
>>> Thread B calls get_or_create(a='a', b='b')
>>> Thread A get_or_create looks for entry in DB, not found
>>> Thread B get_or_create looks for entry in DB, not found
>>> Thread B creates entry in DB
>>> Thread A get_or_create tries to create entry in DB
>> 
>> 
>> Internally, get_or_create code in thread A will now attempt to GET the
>> object created by thread B. It will not automatically reflect the error to
>> the caller. See:
>> 
>> https://github.com/django/django/blob/stable/1.4.x/django/db/models/query.py#L430
> 
> I regularly - once every few months - see get_or_create raise
> IntegrityError due to duplicate key on MySQL 5.0/MyISAM/Django 1.3. So
> whilst that is the intention of the code, it isn't what happens. I'm
> happy to blame MySQL.
> 
> Cheers
> 
> Tom
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> 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.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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.



Re: Trouble with VirtualEnv on Windows

2012-10-15 Thread Jani Tiainen

Hi,

Don't forget "yolk". Very powerful tool to display virtualenv contents 
in readable format. You can install it with pip install yolk.


15.10.2012 9:00, Frank Bieniek kirjoitti:

Hi,

do a "pip freeze" after you have activated your environment,
this way you see the packages that are visible to the python interpreter
inside your virtual env.

Possible Problem
You have installed all packaged before you created the virtual env.
-> virtual env shows no components.
pip install componentname should solve the problem.

or:
Windows reads the registry for some packages (mainly none native
packages) and
inside the virutual env this does not work.
Try to recreate the virtualenv with --system-site-packages option set.

another solution - use vagrant: - google for djangocon 2012 vagrant

Thanks
Frank







Am 15.10.2012 04:45, schrieb Joshua Russo:

I suppose I was a little light on the details of how I setup the
environment. I don't often setup a new environment from scratch so I
used this post as the basis:
http://slacy.com/blog/2011/06/django-postgresql-virtualenv-development-setup-for-windows-7/


The versions of each program I used / ended up with were:
   Python 2.7.3 (32 bit)
   Postgres 9.2 (32 bit)
   Setuptools 0.6c11 for Python 2.7
   Psycopg2 2.4.5 for Python 2.7 (32 bit)
   VirtualEnv 1.8.2
   Django 1.4.1



On Sunday, October 14, 2012 6:25:41 PM UTC-4, Joshua Russo wrote:

This is probably a VirturalEnv problem as opposed to a Django
problem but I was wondering if someone here could point me in the
right direction.

I'm trying to setup clean environment for a demonstration of
Django on Tuesday but I get the following when I try to setup the
project within the virtual environment. You can see that if I just
run python from within the virtual environment I do have access to
the libraries, but if I try to use the django-admin.py script, the
libraries aren't found. Any thoughts?

(django-tutorial)
C:\dev\venv\django-tutorial>Scripts\django-admin.py startproject
testsite
Traceback (most recent call last):
  File "C:\dev\venv\django-tutorial\Scripts\django-admin.py", line
2, in 
from django.core import management
ImportError: No module named django.core

(django-tutorial)
C:\dev\venv\django-tutorial>C:\dev\venv\django-tutorial\Script
s\python.exe
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit
(Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> from django.core import management
>>> management

>>>

--
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/-/YuSLHUyt6xIJ.
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.


--
You received this message because you are subscribed to the Google
Groups "Django users" group.
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.



--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
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.