Re: submit parameters to py script

2012-07-07 Thread Babatunde Akinyanmi
Hi,
Just like Rohan said, why not do that in your view when processing your form?

Here's from the documentation:
https://docs.djangoproject.com/en/1.4/topics/forms/?from=olddocs



On 7/7/12, Smaran Harihar  wrote:
> Thanks for the reply Rohan. I am trying to create a Django App in which,
> user will be adding some info in the text box and on clicking submit, I
> wish to send the contents of the textbox to the py script. The output of
> the py script, I wish to display it in a table on my HTML template.
>
> I hope I was able to explain myself. Also where should I place my py sript,
> which will be triggered on submitting the data.
>
> Thanks,
> Smaran
>
> On Fri, Jul 6, 2012 at 6:14 PM, Rohan  wrote:
>
>>  For a cgi script or a wsgi script, all you need to do is add a script
>> alias in your apache conf (if you're using apache). The parameters should
>> be available as a a dictionary in both the cases (cgi.FieldStorage() and
>> envrion).
>>
>> Although it would help to know why you want to do this. If you already
>> have django up and running, you could just implement the functionality of
>> your script as a view function
>>
>>
>> On 7/6/2012 6:20 PM, Smaran Harihar wrote:
>>
>> Hey Djangoers,
>>
>>  I am trying to execute a python script on submit button on a html file.
>>
>>  So i have created a view which renders a html template file and on
>> 'submit', I wish to send few parameters to the py script.
>>
>>  I wanted to know,
>>
>>  1. where should I keep my py script?
>> 2. I have not modified my html into Django template, but what
>> modifications will it need if I want to send parameters to py script on
>> submit?
>>
>>  --
>> Thanks & Regards
>> Smaran Harihar
>>
>>  --
>> 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.
>>
>
>
>
> --
> Thanks & Regards
> Smaran Harihar
>
> --
> 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.
>
>

-- 
Sent from my mobile device

-- 
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 to use HTTPS with django

2012-07-07 Thread Melvyn Sopacua
On 7-7-2012 5:05, Timothy Makobu wrote:
> For secure logins, this helps
> https://docs.djangoproject.com/en/dev/topics/http/sessions/?from=olddocs/#session-cookie-secure
> 

No it doesn't. That is for secure /sessions/, which means that if you
use this during the login process then the session is created on the
HTTPS connection and only /valid/ on the HTTPS connection. In other
words, if you set this flag the scenario of having an unencrypted site
with an encrypted login procedure is impossible.

-- 
Melvyn Sopacua


-- 
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 to use HTTPS with django

2012-07-07 Thread Timothy Makobu
" I want to know how to use HTTPS to securely login ..." which satisfies
the first part of the question. This way it wont be possible to login
without HTTPS enabled for the project.

On Sat, Jul 7, 2012 at 11:22 AM, Melvyn Sopacua wrote:

> On 7-7-2012 5:05, Timothy Makobu wrote:
> > For secure logins, this helps
> >
> https://docs.djangoproject.com/en/dev/topics/http/sessions/?from=olddocs/#session-cookie-secure
> >
>
> No it doesn't. That is for secure /sessions/, which means that if you
> use this during the login process then the session is created on the
> HTTPS connection and only /valid/ on the HTTPS connection. In other
> words, if you set this flag the scenario of having an unencrypted site
> with an encrypted login procedure is impossible.
>
> --
> Melvyn Sopacua
>
>
> --
> 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: how to use HTTPS with django

2012-07-07 Thread Melvyn Sopacua
On 7-7-2012 10:27, Timothy Makobu wrote:
> " I want to know how to use HTTPS to securely login ..." which satisfies
> the first part of the question. This way it wont be possible to login
> without HTTPS enabled for the project.

What use is logging in if you're logged out the minute the connection
becomes unencrypted?

-- 
Melvyn Sopacua


-- 
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: submit parameters to py script

2012-07-07 Thread Melvyn Sopacua
On 7-7-2012 0:20, Smaran Harihar wrote:

> I am trying to execute a python script on submit button on a html file.
> 
> So i have created a view which renders a html template file and on
> 'submit', I wish to send few parameters to the py script.
> 
> I wanted to know,
> 
> 1. where should I keep my py script?

Anywhere you want. It's probably best you describe what your script
does. We don't really understand why you want to execute a script and
not just put that code in a view function.
Other than that, a python script you want to execute is no different
than a sh script or binary command, so you'll need to use python's
subprocess or os module functions, pass arguments in proper shell syntax
and read output.
-- 
Melvyn Sopacua


-- 
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 to use HTTPS with django

2012-07-07 Thread Timothy Makobu
I would think he would have areas that need to be logged in to all SSL. He
already has the cert for SSL logins, and its prudent these days to have
such apps all SSL, with tools making it straight forward to lift
unencrypted traffic off a network.

On Sat, Jul 7, 2012 at 11:28 AM, Melvyn Sopacua wrote:

> On 7-7-2012 10:27, Timothy Makobu wrote:
> > " I want to know how to use HTTPS to securely login ..." which satisfies
> > the first part of the question. This way it wont be possible to login
> > without HTTPS enabled for the project.
>
> What use is logging in if you're logged out the minute the connection
> becomes unencrypted?
>
> --
> Melvyn Sopacua
>
>
> --
> 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: submit parameters to py script

2012-07-07 Thread Smaran Harihar
Thanks for the reply Melvyn and Babatunde. So my script is, using the
parameters, to search in a database and then spitting out the output back
as CSV.
I wish to return the CSV and also display the output in the table on my
html template.
Ok, so adding it to view makes more sense, but how do i connect or execute
that view, on the click of the submit button??
On Jul 7, 2012 1:42 AM, "Melvyn Sopacua"  wrote:

> On 7-7-2012 0:20, Smaran Harihar wrote:
>
> > I am trying to execute a python script on submit button on a html file.
> >
> > So i have created a view which renders a html template file and on
> > 'submit', I wish to send few parameters to the py script.
> >
> > I wanted to know,
> >
> > 1. where should I keep my py script?
>
> Anywhere you want. It's probably best you describe what your script
> does. We don't really understand why you want to execute a script and
> not just put that code in a view function.
> Other than that, a python script you want to execute is no different
> than a sh script or binary command, so you'll need to use python's
> subprocess or os module functions, pass arguments in proper shell syntax
> and read output.
> --
> Melvyn Sopacua
>
>
> --
> 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: submit parameters to py script

2012-07-07 Thread Babatunde Akinyanmi
Errr, have you read this:
https://docs.djangoproject.com/en/1.4/howto/outputting-csv/

Your view can know if a form was submitted, submitted but with invalid
data and submitted with valid data. A view is just a python function
so if you have determined that the user submitted valid data, just go
ahead and extract the CSV to be output.
Perhaps you should go through the examples in the django forms
documentation again:
https://docs.djangoproject.com/en/1.4/topics/forms/?from=olddocs

However, I don't think its possible to send both an html page and a
CSV so I guess you'll have to choose one or send them one at a time
(html page then csv). I'm sure Mevlyn will know if its possible
though.

On 7/7/12, Smaran Harihar  wrote:
> Thanks for the reply Melvyn and Babatunde. So my script is, using the
> parameters, to search in a database and then spitting out the output back
> as CSV.
> I wish to return the CSV and also display the output in the table on my
> html template.
> Ok, so adding it to view makes more sense, but how do i connect or execute
> that view, on the click of the submit button??
> On Jul 7, 2012 1:42 AM, "Melvyn Sopacua"  wrote:
>
>> On 7-7-2012 0:20, Smaran Harihar wrote:
>>
>> > I am trying to execute a python script on submit button on a html file.
>> >
>> > So i have created a view which renders a html template file and on
>> > 'submit', I wish to send few parameters to the py script.
>> >
>> > I wanted to know,
>> >
>> > 1. where should I keep my py script?
>>
>> Anywhere you want. It's probably best you describe what your script
>> does. We don't really understand why you want to execute a script and
>> not just put that code in a view function.
>> Other than that, a python script you want to execute is no different
>> than a sh script or binary command, so you'll need to use python's
>> subprocess or os module functions, pass arguments in proper shell syntax
>> and read output.
>> --
>> Melvyn Sopacua
>>
>>
>> --
>> 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.
>
>

-- 
Sent from my mobile device

-- 
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: submit parameters to py script

2012-07-07 Thread Melvyn Sopacua
On 7-7-2012 11:44, Smaran Harihar wrote:
> Thanks for the reply Melvyn and Babatunde. So my script is, using the
> parameters, to search in a database and then spitting out the output back
> as CSV.

This only makes sense in the django world, if your script is accessing a
database that is not part of the application itself. For example an
accounting program in django that replaces a firms older software.
Access to previous years is then provided via a script that simply
provides CSV format so data can be entered into a spreadsheet program
and reports can be created. One would use this approach if converting
the old data to the new application consumes too many resources for the
few times the data will be used.

I can't think of many other cases where I would use this approach, so ...

> Ok, so adding it to view makes more sense, but how do i connect or execute
> that view, on the click of the submit button??

The key question is if you have models for the tables in this database?
If so your best option is to translate the parameters to django's
queryset syntax. If you don't understand what that means, you're
probably new to django and we'll try to be more verbose.

As a side note, especially when new to django but not unfamiliar with
webdevelopment/databases, you need to learn to let go of your SQL
knowledge and start thinking in models and querysets. Once you fully
understand how this works and what you can do with it, you can apply
your SQL knowledge to optimize what django's syncdb has created for you
or even start working the other way around using inspectdb.
-- 
Melvyn Sopacua


-- 
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: If using South, does it even matter what the underlying database is?

2012-07-07 Thread houmie

Oh one more thing:

I have created a new superuser for postgre called django_user

Now when I try to connect to it it says:

FATAL:  Peer authentication failed for user "django_user"

But the password is correct, I had no choice than change the settings 
in  /etc/postgresql/9.1/main/pg_hba.conf


from

# "local" is for Unix domain socket connections only
local   all all peer

to

# "local" is for Unix domain socket connections only
local   all all trust


Is this the normal approach?  Do I have to do the same thing on my 
production box?


Many Thanks,


--
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: If using South, does it even matter what the underlying database is?

2012-07-07 Thread kenneth gonsalves
On Sat, 2012-07-07 at 12:34 +0100, houmie wrote:
> # "local" is for Unix domain socket connections only
> local   all all peer
> 
> to
> 
> # "local" is for Unix domain socket connections only
> local   all all trust
> 
> 
> Is this the normal approach?  Do I have to do the same thing on my 
> production box? 

instead of 'trust' use password
-- 
regards
Kenneth Gonsalves

-- 
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: submit parameters to py script

2012-07-07 Thread Smaran Harihar
Once again thanks for the helpful guidance Melvyn and Babatunde.

Babatunde: I will go through the links you provided and come back with new
queries.

Melvyn : Ya, I am a newbie in Django but have Web Development exp. There is
one problem when I wish to create models and queryset for connecting to the
database and that is like this,

1. My settings.py points to Postgres database, which is my main database.
2. The data I wish to extract and display in CSV, is in another database
(mysql). What I have come to know after completing the basic tutorials of
Django is that we define the database in the settings.py and since I
already have the postgres defined, how can I also connect to this MySql
Database, using views/models? This is why I wanted to trigger an external
py script which will deal with this MySql database separately.

Is there a way to connect to multiple databases simultaneously? If so then
please let me know how?

Thanks,
Smaran

On Sat, Jul 7, 2012 at 4:01 AM, Melvyn Sopacua wrote:

> On 7-7-2012 11:44, Smaran Harihar wrote:
> > Thanks for the reply Melvyn and Babatunde. So my script is, using the
> > parameters, to search in a database and then spitting out the output back
> > as CSV.
>
> This only makes sense in the django world, if your script is accessing a
> database that is not part of the application itself. For example an
> accounting program in django that replaces a firms older software.
> Access to previous years is then provided via a script that simply
> provides CSV format so data can be entered into a spreadsheet program
> and reports can be created. One would use this approach if converting
> the old data to the new application consumes too many resources for the
> few times the data will be used.
>
> I can't think of many other cases where I would use this approach, so ...
>
> > Ok, so adding it to view makes more sense, but how do i connect or
> execute
> > that view, on the click of the submit button??
>
> The key question is if you have models for the tables in this database?
> If so your best option is to translate the parameters to django's
> queryset syntax. If you don't understand what that means, you're
> probably new to django and we'll try to be more verbose.
>
> As a side note, especially when new to django but not unfamiliar with
> webdevelopment/databases, you need to learn to let go of your SQL
> knowledge and start thinking in models and querysets. Once you fully
> understand how this works and what you can do with it, you can apply
> your SQL knowledge to optimize what django's syncdb has created for you
> or even start working the other way around using inspectdb.
> --
> Melvyn Sopacua
>
>
> --
> 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.
>
>


-- 
Thanks & Regards
Smaran Harihar

-- 
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: Model for ListView needed?

2012-07-07 Thread Smaran Harihar
Thanks for the reply Melvyn.

So by multiple model instances you mean the multiple records that poll app
has in it's database?

On Fri, Jul 6, 2012 at 3:22 AM, Melvyn Sopacua wrote:

> On 6-7-2012 0:35, Smaran Harihar wrote:
> > Thanks for the reply Luigi, but when should we use queryset and when
> should
> > we use model?
>
> A queryset returns a /list/ of model instances. Thus you should queryset
> when you want more then one instance of the model displayed.
>
> From the above you should also understand that the DetailView wants a
> model and "something from which it can identify a single instance" - the
> pk (primary key) in the example.
>
> --
> Melvyn Sopacua
>
>
> --
> 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.
>
>


-- 
Thanks & Regards
Smaran Harihar

-- 
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: migration via south for inheritance change -> please help

2012-07-07 Thread Daniel Walz
Thanks guys for this helpfull discussion

2012/7/5 Tomas Neme :
> [...] I assumed
> he maybe doesn't know about abstract models because he said he's just
> getting started programming (or at least on py/dj) and maybe he wasn't
> sure what behavior he needed, and what were his options.

...although I was aware of the concept of abstract classes and
abstract models, I just did not come up with the idea, that this could
solve my problem. As long as I work from my django-app this will be a
proper solution. And if somebody gets to work on the database
directly, well it's one join more, but doable.

> and from Tom's:
>
>> In the example, it is evident that the OP wants MTI, since he includes
>> the foreign key links in the class definition - there is no clearer
>> indicator than this!

I'm afraid you do me too much honor. During trying the concepts of
inheritance in django I just was never sure, what is done implicitely
and what I have to specify. So I just thought "it might help and won't
do any damage".
As a site note, i programm several years now c++ and having a degree
in CS, but I tend to solve these problems too much from the brain but
from practice. That's why I thought, the data *must* be in the super
class. Up to now I don't know if i will need the data to be in place,
but till then I will solve the problem with the abstract super class.

The big difference is, -as I see it- I will not get real polymorphism,
as the base class would need to do the join on all it's child classes.
Is that true?

I just got it, it's the same question you just answered:
> As I said before, the only thing this *really* depends on is in this
> question: do you need to be able to do something in the lines of:
> Fruit.objects.all()?

So this helps me to solve it, just differently than I thought.
(which actually would justify a title change ;-) )

Thanks again :-)
Best regards,
Daniel

-- 
Daniel Walz - mcj...@gmail.com
Bremen, Germany

-- 
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: submit parameters to py script

2012-07-07 Thread zae bee
I know that in django has database routes. May be, that cat you help? 
https://docs.djangoproject.com/en/dev/topics/db/multi-db/#using-routers 

суббота, 7 июля 2012 г., 2:20:59 UTC+4 пользователь Sam007 написал:
>
> Hey Djangoers,
>
> I am trying to execute a python script on submit button on a html file. 
>
> So i have created a view which renders a html template file and on 
> 'submit', I wish to send few parameters to the py script.
>
> I wanted to know,
>
> 1. where should I keep my py script?
> 2. I have not modified my html into Django template, but what 
> modifications will it need if I want to send parameters to py script on 
> submit?
>
> -- 
> Thanks & Regards
> Smaran Harihar
>
> 

-- 
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/-/T6scb-G0S0gJ.
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: migration via south for inheritance change -> please help

2012-07-07 Thread Tomas Neme
> The big difference is, -as I see it- I will not get real polymorphism,
> as the base class would need to do the join on all it's child classes.
> Is that true?

with abstract models you won't get polymorphism at all, in the
database level (this is, you WON'T be able to do Fruit.objects).
You'll mostly just be sharing structure and behavior, saving yourself
some repetition.

With multi table inheritane (MTI) you get three tables, one for Fruits
one for Oranges and one for Apples, Fruits have a row for every Orange
and every Apple, so you can do Fruit.objects.all(). Knowing whether
this is an orange or an apple is trickier, but not too much

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: submit parameters to py script

2012-07-07 Thread Daniel Walz
Hi Samir and Babatunde,


2012/7/7 Babatunde Akinyanmi :
> However, I don't think its possible to send both an html page and a
> CSV so I guess you'll have to choose one or send them one at a time
> (html page then csv). I'm sure Mevlyn will know if its possible
> though.
>

I think so too, one server request delivers one response.
But you can achieve this, if you place a link on top of the html view
of your page.
And if you are sure, *everybody* who accesses the page wants to
download the csv as well, you can put a redirect in the http-meta tags
to the csv view. You have probably seen this practice on pages like
"sourceforge" etc. : "If your download doesn't start automatically,
click this link..."

Hope that helps, best regards

Daniel

-- 
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: migration via south for inheritance change -> please help

2012-07-07 Thread Daniel Walz
Hi again,

2012/7/7 Tomas Neme :
>> The big difference is, -as I see it- I will not get real polymorphism,
>> as the base class would need to do the join on all it's child classes.
>> Is that true?
>
> with abstract models you won't get polymorphism at all, in the
> database level (this is, you WON'T be able to do Fruit.objects).
> You'll mostly just be sharing structure and behavior, saving yourself
> some repetition.
>
> With multi table inheritane (MTI) you get three tables, one for Fruits
> one for Oranges and one for Apples, Fruits have a row for every Orange
> and every Apple, so you can do Fruit.objects.all(). Knowing whether
> this is an orange or an apple is trickier, but not too much
>

...but using the django abstraction, what would happen, if I implement
this as MTI?
Say I implement the functions:
def Fruit.rott(): pass
def Apple.rott(): get_wrinkles()
def Orange.rott(): color=green

and I do
for fruit in Fruits.objects.all(): fruit.rott()

will anything happen at all? I know in C++ this would work... ;-)

on database-level I know how to do it, I just don't know if the django
abstraction handles this automalically.

Seems I have too little faith in the capabilities of python ;-)

Best regards

Daniel

-- 
Daniel Walz - mcj...@gmail.com
Bremen, Germany

-- 
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: migration via south for inheritance change -> please help

2012-07-07 Thread Tomas Neme
> and I do
> for fruit in Fruits.objects.all(): fruit.rott()
>
> will anything happen at all? I know in C++ this would work... ;-)
>
> on database-level I know how to do it, I just don't know if the django
> abstraction handles this automalically.

I.. don't know. I'd think yes, at least I wonder otherwise how does
the DB keep coherent if you do
BaseModel.objects.filter(foo=bar).delete(). "CASCADE" would deal with
it in PG, but mysql sometimes lacks that, and sqlite doesn't handle
foreign keys at all.

but you probably need to make some tests to make sure. It'd be quite
easy to do it from the shell

> Seems I have too little faith in the capabilities of python ;-)

Yah, and about that.. what you said WOULD work for any Objects of a
subclassed class in python, as it would in C. Actually, since you
don't declare types in python, you don't really know the class of your
parameters unless you ask, it is the concept of duck-typing that gets
used strongliest in python (you ask the parameter to respond to a
certain interface, you don't care what type it is).

The question is not whether python is able to know what the real class
of an object is, but rather whether django knows the real model of an
object it got from a supermodel's table.

my_fruit.apple returns the corresponding Apple instance, and
my_fruit.orange returns the corresponding Orange instance, but if you
call my_fruit.orange on an object that actually represents an Apple,
you'll get an Orange.DoesNotExist exception raised. But this behavior
is lazy (the Orange table doesn't get hit in the database until you do
.orange).

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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: help with rss feed ImproperlyConfigured

2012-07-07 Thread psychok7
anyone??

On Saturday, July 7, 2012 3:52:52 AM UTC+1, psychok7 wrote:
>
> hi, i am trying to implement the syndicate feed framework simple rss with 
> my program, but i get a ImproperlyConfigured at /latest/feed/
>
> Give your Debt class a get_absolute_url() method, or define an item_link() 
> method in your Feed class.
>
> I know i am supposed to create a get_absolute_url in my Debt model, but i 
> dont know how to do it (already seen tutorials but cant make it work)
>
> model: 
>
> class Debt (models.Model): 
>
>  user = models.ForeignKey(User) 
>
>  debt_name = models.TextField() 
>
>  creation_date = models.DateTimeField('date created') 
>
>  due_date = models.DateTimeField('due date') 
>
>  info = models.TextField() 
>
>  is_owing = models.BooleanField() 
>
>  is_payed = models.BooleanField()
>
>  def __unicode__(self):
> return self.debt_name
>
>
>

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



Problem with DetailView

2012-07-07 Thread Soviet
Now that I have basic understanding of models, I encountered even more 
confusing subjects - views and urls. Now, the class-generic views are quite 
easy to grasp at basic level, but I fail to understand what's wrong with 
this code:

urlpatterns = patterns('',
(r'^$', ListView.as_view(
model=Car,
context_object_name="cars_list",
template_name='data/cars_list.html',
)),
(r'^(?P\d+)/$', DetailView.as_view(
model=Car,
context_object_name="car_details",
template_name='data/car_details.html',
)),
)

The ListView is working fine, but when I try to get the details about 
single car, all I'm getting is error: "No car found matching the query". I 
tried adding 'queryset = Car.objects.all()' both in urls.py and in 
views.py, creating custom class, but the error persists.

-- 
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/-/fQZA1sl13VkJ.
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: Problem with DetailView

2012-07-07 Thread Smaran Harihar
If I am not wrong. The issue is with the List View not Detail View.

You need to provide, List View with query set. If you are providing model
parameter, you will also need to give it a primary key 'pk', like you did
for Detail View.

Hope that helps,
Smaran
On Jul 7, 2012 3:36 PM, "Soviet"  wrote:

> Now that I have basic understanding of models, I encountered even more
> confusing subjects - views and urls. Now, the class-generic views are quite
> easy to grasp at basic level, but I fail to understand what's wrong with
> this code:
>
> urlpatterns = patterns('',
> (r'^$', ListView.as_view(
> model=Car,
> context_object_name="cars_list",
> template_name='data/cars_list.html',
> )),
> (r'^(?P\d+)/$', DetailView.as_view(
> model=Car,
> context_object_name="car_details",
> template_name='data/car_details.html',
> )),
> )
>
> The ListView is working fine, but when I try to get the details about
> single car, all I'm getting is error: "No car found matching the query". I
> tried adding 'queryset = Car.objects.all()' both in urls.py and in
> views.py, creating custom class, but the error persists.
>
> --
> 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/-/fQZA1sl13VkJ.
> 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: Problem with DetailView

2012-07-07 Thread kooliah

On 07/07/2012 10:36 PM, Soviet wrote:
Now that I have basic understanding of models, I encountered even more 
confusing subjects - views and urls. Now, the class-generic views are 
quite easy to grasp at basic level, but I fail to understand what's 
wrong with this code:


urlpatterns = patterns('',
(r'^$', ListView.as_view(
model=Car,
context_object_name="cars_list",
template_name='data/cars_list.html',
)),
(r'^(?P\d+)/$', DetailView.as_view(
model=Car,
context_object_name="car_details",
template_name='data/car_details.html',
)),
)

The ListView is working fine, but when I try to get the details about 
single car, all I'm getting is error: "No car found matching the 
query". I tried adding 'queryset = Car.objects.all()' both in urls.py 
and in views.py, creating custom class, but the error persists.

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

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.
The parameters are from url and automatically passed to your view, i 
don't have to pass them explicitily, take a look on

https://docs.djangoproject.com/en/1.3//topics/http/urls/

--
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: Problem with DetailView

2012-07-07 Thread Soviet
But the ListView is working fine. And they don't use  in the 
documentation, just this, which I modified to fit my model:

urlpatterns = patterns('',
(r'^publishers/$', ListView.as_view(
model=Publisher,
)),
)

W dniu sobota, 7 lipca 2012 22:44:23 UTC+2 użytkownik Sam007 napisał:
>
> If I am not wrong. The issue is with the List View not Detail View.
>
> You need to provide, List View with query set. If you are providing model 
> parameter, you will also need to give it a primary key 'pk', like you did 
> for Detail View.
>
> Hope that helps,
> Smaran
> On Jul 7, 2012 3:36 PM, "Soviet"  wrote:
>
>> Now that I have basic understanding of models, I encountered even more 
>> confusing subjects - views and urls. Now, the class-generic views are quite 
>> easy to grasp at basic level, but I fail to understand what's wrong with 
>> this code:
>>
>> urlpatterns = patterns('',
>> (r'^$', ListView.as_view(
>> model=Car,
>> context_object_name="cars_list",
>> template_name='data/cars_list.html',
>> )),
>> (r'^(?P\d+)/$', DetailView.as_view(
>> model=Car,
>> context_object_name="car_details",
>> template_name='data/car_details.html',
>> )),
>> )
>>
>> The ListView is working fine, but when I try to get the details about 
>> single car, all I'm getting is error: "No car found matching the query". I 
>> tried adding 'queryset = Car.objects.all()' both in urls.py and in 
>> views.py, creating custom class, but the error persists.
>>
>> -- 
>> 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/-/fQZA1sl13VkJ.
>> 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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/2RYQ-kplLroJ.
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: Form wizard and dynamic fields

2012-07-07 Thread Leandro Alves
Does anyone have any advice please? :)

Thanks,

Leandro


On 7. juli 2012, at 02:33, Leandro Alves  wrote:

> Hello,
> 
> I'm starting to use Django now and I would need some orientations in order to 
> create a Form Wizard.
> 
> The idea is simple:
> 
> The first form will contain only one field to type the name of a directory.
> The content of the second form, will depend on the directory name that was 
> entered and the form fields will be a list of files that exist within that 
> directory in the form of checkbox.
> 
> I've been checking the documentation and I got the idea in how to build the 
> forms. What I'm not sure yet, it is in relation to these questions:
> 
>   1. I need to validate if the directory exists before you go to the next 
> step. Where would be the right place for this? It would be right to think 
> that I need to use "clean_ " method in a subclass form?
> 
>   2. Regarding the second form (step 2), which method and class I should 
> use in order to process the list of existing files in that directory? I 
> imagine it would be somewhere between the steps, but I'm not so sure how and 
> where...
> 
>   3. How could I set the fields in the second form dynamically based on 
> the existing files in that directory?
> 
> 
> Any tips and advice will be very welcome.
> 
> 
> Thanks in advance, 
> 
> Leandro
> 
> -- 
> 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/-/GxoUPiBgxmAJ.
> 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: Render time

2012-07-07 Thread Larry Martell
On Mon, Jun 25, 2012 at 9:04 PM, Andy McKay  wrote:
>> Now they want me to add to that how long
>> the browser takes to render the page after it gets the data.
>
> You can use the navigation timing API:
>
> https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html
>
> We use this in conjuction with graphite and django-statsd to produce
> graphs of hour long our sites takes to render.
>
> http://blog.mozilla.org/webdev/2012/01/06/timing-amo-user-experience/
>
> And some more links:
>
> https://github.com/andymckay/django-statsd
> http://django-statsd.readthedocs.org/en/latest/#front-end-timing-integration
> http://graphite.wikidot.com/

I have this working for our pages that execute all the javascript as
part of the page generation (i.e. all contained in or called from the
django template). But we have pages that have an onchange function
that gets triggered by something done in the template. In those the
loadEventEnd gets set before the onchange function runs. Any idea how
I can get the time the onchange function takes included in the
navigation timing?

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



[no subject]

2012-07-07 Thread Mario Gudelj
Hi djangoers,

I have signals issue I can not figure out. NAy help is greatly appreciated.

So, I have defined my own signal like this in my signals.py:

--- signals.py ---

from django.dispatch import Signal

# Sent when a payment is successfully processed.
payment_successful = Signal(providing_args=["business_id"])




I have a function that needs to send an email on successful payment inside
my listeners.py file:

 listeners.py 

@receiver(payment_successful)
def send_email_confirmation(sender, **kwargs):
#more stuff here
-


If I call send function from my payment model the receiver function is
never called.

 models.py --

#this is the line that gets called in models file. I have a print statement
in front of it and I know it gets called.
payment_successful.send(sender=self, business_id=self.id)

-


Also, I have this line before the above statement and I can see that no
receivers are registered inside the payment_successful signal object:

print "receivers: %s", payment_successful.receivers

However, if I open the shell and I pull in a payment and make the same call
to the send function like this:

payment_successful.send(sender=payment, business_id=13)

I get the the email sent and if I check payment_successful.receivers I can
see the receiver functions in there.

I have no idea why this is. If anyone can help I'll buy you a beer!

Thanks a million!

-m

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



Signal receivers not registered in the app. They work fine in shell

2012-07-07 Thread Mario Gudelj
Forgot to add subject. Sorry!

--

Hi djangoers,

I have signals issue I can not figure out. NAy help is greatly appreciated.

So, I have defined my own signal like this in my signals.py:

--- signals.py ---

from django.dispatch import Signal

# Sent when a payment is successfully processed.
payment_successful = Signal(providing_args=["business_id"])




I have a function that needs to send an email on successful payment inside
my listeners.py file:

 listeners.py 

@receiver(payment_successful)
def send_email_confirmation(sender, **kwargs):
#more stuff here
-


If I call send function from my payment model the receiver function is
never called.

 models.py --

#this is the line that gets called in models file. I have a print statement
in front of it and I know it gets called.
payment_successful.send(sender=self, business_id=self.id)

-


Also, I have this line before the above statement and I can see that no
receivers are registered inside the payment_successful signal object:

print "receivers: %s", payment_successful.receivers

However, if I open the shell and I pull in a payment and make the same call
to the send function like this:

payment_successful.send(sender=payment, business_id=13)

I get the the email sent and if I check payment_successful.receivers I can
see the receiver functions in there.

I have no idea why this is. If anyone can help I'll buy you a beer!

Thanks a million!

-m

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



database values in a select form.

2012-07-07 Thread Lee Hinde
I have a table, Choice, that is used to build common lists. For
instance, there might be a list "Employment_Status" with values
"Full-Time" and "Part-Time"

I want to use those values in various forms, so in the appropriate
models.py I have:

def _get_list_choices(list):
choices = Choice.on_site.filter(category =
list).values_list('choice', flat=True).order_by('sort_order')
return  tuple(choices)


and then I'd use it like this:

class PersonForm(ModelForm):
household = forms.CharField(
  widget=forms.HiddenInput())
employment_types = _get_list_choices('Employment_Status')
employment_status = ChoiceField(widget=forms.Select, choices =
zip(employment_types,employment_types))


What I'm noticing is that (in dev mode) the choice list for
'employment_status' doesn't update unless I trigger a change, either
to the forms.py or restart the dev server.

I'm wondering if there's a better place to handle this.

Thanks.

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



How to serve static files on heroku without any cloud storage like Amazon S3

2012-07-07 Thread surya
My project is on heroku and my website templates has some CSS, JS files. 
Totally 5 of them.

I don't want to get off with amazon s3 for the sake of those 5 files (very 
small ones). However, I even need to enter my credit -card, which I don't 
like :P

So, as far as I know, my only option is to configure and run those static 
file on heroku. Can anyone tell me how to do that??

I searched a lot but couldn't find any site which clearly explains it.

PS: I am using gunicorn on heroku (I know nothing about it, went through 
some sites to configue).
First I had to learn Apache Httpd.. an now gunicorn (I think it takes some 
time)

-- 
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/-/CKssXd9FL_QJ.
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 to serve static files on heroku without any cloud storage like Amazon S3

2012-07-07 Thread Rafael Durán Castañeda

El 08/07/12 06:08, surya escribió:
My project is on heroku and my website templates has some CSS, JS 
files. Totally 5 of them.


I don't want to get off with amazon s3 for the sake of those 5 files 
(very small ones). However, I even need to enter my credit -card, 
which I don't like :P


So, as far as I know, my only option is to configure and run those 
static file on heroku. Can anyone tell me how to do that??


I searched a lot but couldn't find any site which clearly explains it.

PS: I am using gunicorn on heroku (I know nothing about it, went 
through some sites to configue).
First I had to learn Apache Httpd.. an now gunicorn (I think it takes 
some time)

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

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.

Try http://matthewphiong.com/managing-django-static-files-on-heroku

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