Re: Automatic form submission and CSRF??

2010-09-26 Thread Joakim Hove
Thanks a lot - that did the trick!

Joakim

On Sep 27, 1:58 am, Russell Keith-Magee 
wrote:
> On Mon, Sep 27, 2010 at 12:18 AM, Joakim Hove  wrote:
> > Hello,
>
> > I have a simple form which has method POST. When I view the form in
> > the browser and fill it normally everything works fine. However; the
> > plan is to submit this form automagically from a client program - I
> > have currently tried with the Python script:
>
> > #!/usr/bin/python
> > import urllib
> > params = urllib.urlencode({"passwd": "Hemmelig",
> >                           "user_id" : 1000,
> >                           "subject" : "Tema",
> >                           "extra_addr" : "joakim-h...@gmail.com",
> >                           "date_list" : "10-10-2010",
> >                           "body" : "Lang melding"})
>
> > f = urllib.urlopen(form_url , params)
> > print f.read()
>
> > The server just returns error code 403: "No CSRF or session cookie";
> > how can I get around this? Do I have to create a csrfmiddlewaretoken
> > on the client (which will not even have Python installed)?
>
> If it's impractical or impossible to get access to the CSRF token by
> GET before POSTing, you can disable CSRF on that single view. See [1]
> for details.
>
> [1]http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#exceptions
>
> Yours,
> Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: sql query: how to

2010-09-26 Thread akaariai
The most efficient? Exactly that using raw SQL. I think something
along the following will also work:
Foo.objects.only('fieldname').value_list().distinct().order_by('fieldname').

 - Anssi

On Sep 27, 5:49 am, Bobby Roberts  wrote:
> what is the most efficient way to do the following sql command in
> django?
>
> select distinct fieldname from table order by fieldname

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Upload a File using the request.POST data

2010-09-26 Thread Danny Bos
There is no form, it's entirely Javascript.
Spoke to the creator of the script, who has popped up script examples
for PHP and ColdFusion he reckons:

"You basically have to put the whole post contents into a file."

Not altogether helpful, eh?

d


On Sep 27, 1:52 pm, Sam Lai  wrote:
> Have you got the right attribute in the form?
>
> Fromhttp://docs.djangoproject.com/en/dev/topics/http/file-uploads/
>
> "Note that request.FILES will only contain data if the request method
> was POST and the  that posted the request has the attribute
> enctype="multipart/form-data". Otherwise, request.FILES will be
> empty."
>
> On 27 September 2010 13:21, Danny Bos  wrote:
>
> > Can it even be done?
> > It seems pretty ordinary but everything I'm trying expects it to be a
> > request.FILE.
>
> > Frustrating stuff.
>
> > d
>
> > On Sep 27, 11:24 am, Danny Bos  wrote:
> >> Heya,
>
> >> I'm using the 'Valums File Uploader' which passes the file in the
> >> request.POST as you can see below. I'm wondering how to get that data
> >> into an actual file. Any ideas would be great as things like "for
> >> chunk in f.chunks()" only works on request.FILES which in this case is
> >> empty.
>
> >> Thanks,
> >> Hope all is well your side of the planet.
>
> >> Eg DATA:
>
> >> GET:,
> >> POST: >> \ufffd\x03\ufffd\x05\ufffd\ufffd\ufffdC\ufffdC\x1b\ufffd\ufffd\x0f/
> >> \x1eY:\ufffdZ\ufffd \ufffd8': [u''], u'5]]\x1f\u04ff\x7f\ufffd\ufffd
> >> \ufffd\x0f\x054\x15\u0622i\x1c\ufffd(\ufffdG\x01 \ufffd\x03u
> >> \x05\ufffdL]b*\x002\x18PW\x00\ufffd\ufffd%\ufffd\x02 \ufffd\x01u
> >> \x05\ufffdL]b*\x002\x18PW\x00\ufffd\ufffd%\ufffd\x02 \ufffd\x01u
> >> \x05\ufffdL]b*\x002\x18PW\x00\ufffd\ufffd%\ufffd\x02 \ufffd\x01u
> >> \x05\ufffdL]b*\x002\x18PW\x00\ufffd\ufffd%\ufffd\ufffd\ufffd\ufffd$X]]
> >> \u0775k\ufffd\ufffd\ufffd\ufffd\ufffd\ufffdt\ufffd_2\x13\ufffd\u01cf
> >> \x1fkkk\ufffd\ufffd\ufffdUe\ufffd\ufffd\ufffd\ufffdt2\u04ef\x1f?~|
> >> \ufffd\u0529\ufffd\ufffd$\ufffdx}\ufffd\ufffd*\ufffdNw9': [u''],
> >> u'\uff ... Etc ...
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://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-us...@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: Upload a File using the request.POST data

2010-09-26 Thread Sam Lai
Have you got the right attribute in the form?

>From http://docs.djangoproject.com/en/dev/topics/http/file-uploads/

"Note that request.FILES will only contain data if the request method
was POST and the  that posted the request has the attribute
enctype="multipart/form-data". Otherwise, request.FILES will be
empty."

On 27 September 2010 13:21, Danny Bos  wrote:
> Can it even be done?
> It seems pretty ordinary but everything I'm trying expects it to be a
> request.FILE.
>
> Frustrating stuff.
>
>
> d
>
> On Sep 27, 11:24 am, Danny Bos  wrote:
>> Heya,
>>
>> I'm using the 'Valums File Uploader' which passes the file in the
>> request.POST as you can see below. I'm wondering how to get that data
>> into an actual file. Any ideas would be great as things like "for
>> chunk in f.chunks()" only works on request.FILES which in this case is
>> empty.
>>
>> Thanks,
>> Hope all is well your side of the planet.
>>
>> Eg DATA:
>>
>> GET:,
>> POST:> \ufffd\x03\ufffd\x05\ufffd\ufffd\ufffdC\ufffdC\x1b\ufffd\ufffd\x0f/
>> \x1eY:\ufffdZ\ufffd \ufffd8': [u''], u'5]]\x1f\u04ff\x7f\ufffd\ufffd
>> \ufffd\x0f\x054\x15\u0622i\x1c\ufffd(\ufffdG\x01 \ufffd\x03u
>> \x05\ufffdL]b*\x002\x18PW\x00\ufffd\ufffd%\ufffd\x02 \ufffd\x01u
>> \x05\ufffdL]b*\x002\x18PW\x00\ufffd\ufffd%\ufffd\x02 \ufffd\x01u
>> \x05\ufffdL]b*\x002\x18PW\x00\ufffd\ufffd%\ufffd\x02 \ufffd\x01u
>> \x05\ufffdL]b*\x002\x18PW\x00\ufffd\ufffd%\ufffd\ufffd\ufffd\ufffd$X]]
>> \u0775k\ufffd\ufffd\ufffd\ufffd\ufffd\ufffdt\ufffd_2\x13\ufffd\u01cf
>> \x1fkkk\ufffd\ufffd\ufffdUe\ufffd\ufffd\ufffd\ufffdt2\u04ef\x1f?~|
>> \ufffd\u0529\ufffd\ufffd$\ufffdx}\ufffd\ufffd*\ufffdNw9': [u''],
>> u'\uff ... Etc ...
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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: Upload a File using the request.POST data

2010-09-26 Thread Danny Bos
Can it even be done?
It seems pretty ordinary but everything I'm trying expects it to be a
request.FILE.

Frustrating stuff.


d

On Sep 27, 11:24 am, Danny Bos  wrote:
> Heya,
>
> I'm using the 'Valums File Uploader' which passes the file in the
> request.POST as you can see below. I'm wondering how to get that data
> into an actual file. Any ideas would be great as things like "for
> chunk in f.chunks()" only works on request.FILES which in this case is
> empty.
>
> Thanks,
> Hope all is well your side of the planet.
>
> Eg DATA:
>
> GET:,
> POST: \ufffd\x03\ufffd\x05\ufffd\ufffd\ufffdC\ufffdC\x1b\ufffd\ufffd\x0f/
> \x1eY:\ufffdZ\ufffd \ufffd8': [u''], u'5]]\x1f\u04ff\x7f\ufffd\ufffd
> \ufffd\x0f\x054\x15\u0622i\x1c\ufffd(\ufffdG\x01 \ufffd\x03u
> \x05\ufffdL]b*\x002\x18PW\x00\ufffd\ufffd%\ufffd\x02 \ufffd\x01u
> \x05\ufffdL]b*\x002\x18PW\x00\ufffd\ufffd%\ufffd\x02 \ufffd\x01u
> \x05\ufffdL]b*\x002\x18PW\x00\ufffd\ufffd%\ufffd\x02 \ufffd\x01u
> \x05\ufffdL]b*\x002\x18PW\x00\ufffd\ufffd%\ufffd\ufffd\ufffd\ufffd$X]]
> \u0775k\ufffd\ufffd\ufffd\ufffd\ufffd\ufffdt\ufffd_2\x13\ufffd\u01cf
> \x1fkkk\ufffd\ufffd\ufffdUe\ufffd\ufffd\ufffd\ufffdt2\u04ef\x1f?~|
> \ufffd\u0529\ufffd\ufffd$\ufffdx}\ufffd\ufffd*\ufffdNw9': [u''],
> u'\uff ... Etc ...

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: In admin, is there a post-commit hook that is executed after all models and inlines are saved?

2010-09-26 Thread jonathan.morgan
Update:

Well, I cobbled together a few things to accomplish most of what I
needed to accomplish, and figured I'd write it down here so I can look
it up later and so others can learn from it (the doc on m2m_changed,
in particular, is not incomplete, but not detailed or particularly
precise, and I had trouble finding a good example).

The event to event_date relation was one-to-many, so there is a model
for event dates that contains the key to each date's related event.
For these, I overrode the save and delete methods for the event_dates
model so it notifies the related event when any related date is added,
changed, or deleted, after the actual save on insert, update, or
delete, so the related event (which is still present in the instance
even on delete, though the relation no longer exists in the database)
can invoke a method that accepts the date and checks if it potentially
needs to re-calculate its overall start and end dates from the
database based on where the date lies in relation to its current start
and end dates.  Part of the problem I was running into is that the
internal set of event_dates for an event were not getting updated as
updates from the admin screen were getting processed.  The database is
updated, though, and so the event can query the database for updated
dates and update its start and end date accurately even though its
internal Set representation of associated dates gets out of sync.

For the ManyToMany, I ended up being able to use the m2m_changed
signal combined with overriding the save and delete on the right-hand
side of the m2m relationship to let the event know that something had
changed, and so it should rebuild its cached list of series and
providers.  First, a few notes on what precisely the m2m_changed
signal passes:

- sender: Python new-class Type instance for the django-generated
"through" class that connects the two models (Event.presenters.through
and Event.series.through in this case).

- instance: an instance of the model that contains the ManyToManyField
relationship (Event, in this case).

- model: Python new-class Type instance for the class of the model
that is on the right side of the M2M relationship, joined by the
"through" class that is in the "sender" parameter (Series and
Presenter model classes in the two functions below).

- action - either "pre_add"/"post_add" or
"pre_clear"/"post_clear" ("pre_remove" and "post_remove" are never
sent by the admin, as far as I can tell, since it just clears all
relations each time a record is saved, then adds in relations again
that still are present - not perhaps how I would have done it, but
efficient).

Because of how django admin implements processing changes to m2m
relations (clear all, then re-add all that are present in form submit)
m2m_changed doesn't actually tell you how the relation changed (so no
signals for things getting removed, and no good signals on "add"
versus "still here"), so I had to just use these signals to let the
event know something had changed with a given set of relations, and
have it call a method to update itself from the database to figure out
what had changed and take the changes into account.  This worked, but
wasn't quite as targeted as it could be if admin actually passed
m2m_changed signals for removal, and didn't pass add signals for
relations that were unchanged.

I also limited the event listeners to only the "through" senders I
cared about (see code sample below for accessing a "through" class -
import the class that contains the ManyToManyField, then reference
"class_name"."m2m_field_name".through).  Here is the code I ended up
with for registering the signals (in my models.py file, so the Event
class is already there, doesn't need to be imported, and including the
debug and logging code I used to figure much of this out):

# imports for handling signals that ManyToMany relations have changed.
from django.db.models.signals import m2m_changed
from django.dispatch import receiver

@receiver( m2m_changed, sender = Event.series.through )
def process_event_series_updates( sender, **kwargs_IN ):

# declare variables
instance_IN = None #-- kwargs_IN[ "instance" ]
action_IN = '' #-- kwargs_IN[ "action" ] - from
http://docs.djangoproject.com/en/dev/ref/signals/, will be either
"pre_add", "post_add", "pre_remove", "post_remove", "pre_clear", or
"post_clear"
reverse_IN = '' #-- kwargs_IN[ "reverse" ]
model_IN = None #-- kwargs_IN[ "model" ]
pk_set_IN = None #-- kwargs_IN[ "pk_set" ]
using_IN = None #-- kwargs_IN[ "using" ]
instance_IN = None #-- kwargs_IN[ instance ]

# just try reading the arguments, outputting a log message.
instance_IN = kwargs_IN[ "instance" ]
action_IN = kwargs_IN[ "action" ]
reverse_IN = kwargs_IN[ "reverse" ]
model_IN = kwargs_IN[ "model" ]
pk_set_IN = kwargs_IN[ "pk_set" ]
using_IN = kwargs_IN[ "using" ]

#logging.debug( "In process_event_series_updates(): We have a
signal. sender = " + str( sender ) 

sql query: how to

2010-09-26 Thread Bobby Roberts
what is the most efficient way to do the following sql command in
django?


select distinct fieldname from table order by fieldname

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Upload a File using the request.POST data

2010-09-26 Thread Danny Bos
Heya,

I'm using the 'Valums File Uploader' which passes the file in the
request.POST as you can see below. I'm wondering how to get that data
into an actual file. Any ideas would be great as things like "for
chunk in f.chunks()" only works on request.FILES which in this case is
empty.

Thanks,
Hope all is well your side of the planet.

Eg DATA:

GET:,
POST:http://groups.google.com/group/django-users?hl=en.



Need access to http basic authentication from request object inside view

2010-09-26 Thread mortenlp

Dear reader

I have been fighting this really simple problem for 12 straight hours
now.
I just really can't seem to gain access to the simple http
authorization string from my view-functions.

e.g: "Basic bWF4bTpwYXNzd29yZA=="

Here is my simple test function inside my views.py:

def authenticate(request):
if 'HTTP_AUTHORIZATION' in request.META:
return HttpResponse(request.META['HTTP_AUTHORIZATION'])
elif 'AUTHORIZATION' in request.META:
return HttpResponse(request.META['AUTHORIZATION'])
elif 'REMOTE_USER' in request.META:
return HttpResponse(request.META['REMOTE_USER'])
else:
return HttpResponse(request) #Output is appended below

All of these keys do not exist... and the complete request object does
not contain the string either.

Many experience this problem using apache+mod_wsgi because
"WSGIPassAuthorization on" has to be set.
However i am experiencing the problem both with the built-in-django-
deleopment-server and apache+mod_wsgi+"WSGIPassAuthorization on".

Client: Safari and CocoaRestClient - so i know the authentication get
sent

I would greatly appreciate any help in making an simple django example
app, that prints out the basic_http_auth_string.

Best wished
Morten Pedersen




The full request object print out like so:
,
POST:,
COOKIES:{'sessionid': '26efb99003df54f49b468faac87cf523'},
META:{'CONTENT_TYPE': 'text/plain',
 'DOCUMENT_ROOT': '/var/www',
 'GATEWAY_INTERFACE': 'CGI/1.1',
 'HTTP_ACCEPT': '*/*',
 'HTTP_ACCEPT_ENCODING': 'gzip, deflate',
 'HTTP_ACCEPT_LANGUAGE': 'en-us',
 'HTTP_CONNECTION': 'keep-alive',
 'HTTP_COOKIE': 'sessionid=26efb99003df54f49b468faac87cf523',
 'HTTP_HOST': '172.16.116.130',
 'HTTP_USER_AGENT': 'CocoaRestClient/1 CFNetwork/454.9.8 Darwin/10.4.0
(i386) (MacBookPro5%2C5)',
 'PATH_INFO': u'/auth/authenticate/',
 'PATH_TRANSLATED': '/usr/local/rhk/var/rhkest/apache/django.wsgi/auth/
authenticate/',
 'QUERY_STRING': '',
 'REMOTE_ADDR': '172.16.116.1',
 'REMOTE_PORT': '55399',
 'REQUEST_METHOD': 'GET',
 'REQUEST_URI': '/auth/authenticate/',
 'SCRIPT_FILENAME': '/usr/local/rhk/var/rhkest/apache/django.wsgi',
 'SCRIPT_NAME': u'',
 'SERVER_ADDR': '172.16.116.130',
 'SERVER_ADMIN': '(REMOVED)',
 'SERVER_NAME': '172.16.116.130',
 'SERVER_PORT': '80',
 'SERVER_PROTOCOL': 'HTTP/1.1',
 'SERVER_SIGNATURE': 'Apache/2.2.16 (Debian) Server at
172.16.116.130 Port 80\n',
 'SERVER_SOFTWARE': 'Apache/2.2.16 (Debian)',
 'mod_wsgi.application_group': '(REMOVED)|',
 'mod_wsgi.callable_object': 'application',
 'mod_wsgi.handler_script': '',
 'mod_wsgi.input_chunked': '0',
 'mod_wsgi.listener_host': '',
 'mod_wsgi.listener_port': '80',
 'mod_wsgi.process_group': '(REMOVED)',
 'mod_wsgi.request_handler': 'wsgi-script',
 'mod_wsgi.script_reloading': '1',
 'mod_wsgi.version': (3, 3),
 'wsgi.errors': ,
 'wsgi.file_wrapper': ,
 'wsgi.input': ,
 'wsgi.multiprocess': True,
 'wsgi.multithread': False,
 'wsgi.run_once': False,
 'wsgi.url_scheme': 'http',
 'wsgi.version': (1, 1)}>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Automatic form submission and CSRF??

2010-09-26 Thread Amao Zhao
Hi, I think you should add the 'django.middleware.csrf.CsrfResponseMiddleware'
into your MIDDLEWARE_CLASSES in the settings model.

Yours,
BR

On Mon, Sep 27, 2010 at 7:58 AM, Russell Keith-Magee <
russ...@keith-magee.com> wrote:

> On Mon, Sep 27, 2010 at 12:18 AM, Joakim Hove 
> wrote:
> > Hello,
> >
> > I have a simple form which has method POST. When I view the form in
> > the browser and fill it normally everything works fine. However; the
> > plan is to submit this form automagically from a client program - I
> > have currently tried with the Python script:
> >
> > #!/usr/bin/python
> > import urllib
> > params = urllib.urlencode({"passwd": "Hemmelig",
> >   "user_id" : 1000,
> >   "subject" : "Tema",
> >   "extra_addr" : "joakim-h...@gmail.com",
> >   "date_list" : "10-10-2010",
> >   "body" : "Lang melding"})
> >
> > f = urllib.urlopen(form_url , params)
> > print f.read()
> >
> > The server just returns error code 403: "No CSRF or session cookie";
> > how can I get around this? Do I have to create a csrfmiddlewaretoken
> > on the client (which will not even have Python installed)?
>
> If it's impractical or impossible to get access to the CSRF token by
> GET before POSTing, you can disable CSRF on that single view. See [1]
> for details.
>
> [1] http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#exceptions
>
> Yours,
> Russ Magee %-)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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: JavaScript with Dango

2010-09-26 Thread Axel Bock
I gotta say this is the kind of answer which usually upsets me for obvious
reasons, although I gotta admit the question surely is not very well
phrased, too :)

But well. I just discovered dajaxproject.com from another thread - maybe you
could start from there. It seems to be a framework which coupoles Django
with some Ajax libs to some extend, if that's what you want. I only had a
short look and filed it for later.

http://www.dajaxproject.com/


HTH,
Axel.



2010/9/26 CrabbyPete 

> Yes.
>
> On Sep 26, 7:48 am, aug dawg  wrote:
> > Does Django work with JavaScript? If so, how can I use JavaScript in my
> > Django projects?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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: Automatic form submission and CSRF??

2010-09-26 Thread Russell Keith-Magee
On Mon, Sep 27, 2010 at 12:18 AM, Joakim Hove  wrote:
> Hello,
>
> I have a simple form which has method POST. When I view the form in
> the browser and fill it normally everything works fine. However; the
> plan is to submit this form automagically from a client program - I
> have currently tried with the Python script:
>
> #!/usr/bin/python
> import urllib
> params = urllib.urlencode({"passwd": "Hemmelig",
>                           "user_id" : 1000,
>                           "subject" : "Tema",
>                           "extra_addr" : "joakim-h...@gmail.com",
>                           "date_list" : "10-10-2010",
>                           "body" : "Lang melding"})
>
> f = urllib.urlopen(form_url , params)
> print f.read()
>
> The server just returns error code 403: "No CSRF or session cookie";
> how can I get around this? Do I have to create a csrfmiddlewaretoken
> on the client (which will not even have Python installed)?

If it's impractical or impossible to get access to the CSRF token by
GET before POSTing, you can disable CSRF on that single view. See [1]
for details.

[1] http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#exceptions

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Vim for Python and Django

2010-09-26 Thread Tran Cao Thai
@flebber: try this http://tortoisehg.bitbucket.org/

On Mon, Sep 27, 2010 at 9:28 AM, Mathieu Leduc-Hamel  wrote:
> Anybody know of there's the same kind of resources for emacs ?
>
> On Sun, Sep 26, 2010 at 7:22 PM, flebber  wrote:
>> Do the instructions here http://code.google.com/p/trespams-vim/wiki/readme
>> only work on linux ? I tried to follow it on Windows as i wanted to
>> download and try your version but received this error.
>>
>> C:\>hg clone https://trespams-vim.googlecode.com/hg/ trespams-vim
>> 'hg' is not recognized as an internal or external command,
>> operable program or batch file.
>>
>> C:\>
>>
>>
>> On Sep 27, 2:55 am, ionut cristian cucu  wrote:
>>> Very helpful, thanks alot!
>>>
>>> 2010/9/26 Piotr Zalewa :
>>>
>>> >  Hi Antoni,
>>>
>>> > Thanks for that!
>>>
>>> > zalun
>>>
>>> > On 09/26/10 10:36, Antoni Aloy wrote:
>>> >> Hello all!
>>>
>>> >> In this list we have a recurrent thread: "What'ts the best IDE for
>>> >> Django and Python development?" trespams-vim is my try to answer this
>>> >> question for people who likes to have a very powerful editor and needs
>>> >> to have an editor which is able to run in the desktop as well as in a
>>> >> remote session. I have updated the previous version with delimMate and
>>> >> easytags, so actually you'll find:
>>>
>>> >> * Syntax highlight
>>> >> * Python autocompletion
>>> >> * Smart tabbing
>>> >> * Templates for Python, Django, js, html, ... (just try to edit a
>>> >> python file and press sbu + tab as an example)
>>> >> * Add/remove comments on multiple lines
>>> >> * Tabs
>>> >> * Surround
>>> >> * marks
>>>
>>> >> etc. etc. :
>>>
>>> >> This is a list of my favorite shortcuts
>>>
>>> >>http://code.google.com/p/trespams-vim/wiki/readme
>>>
>>> >> So, you'll find a collection of plugins and .vimrc settings that I
>>> >> have found very useful in my day-by-day work in Python and Django.
>>>
>>> >>http://code.google.com/p/trespams-vim/
>>>
>>> >> Happy coding!
>>>
>>> > --
>>> > blog  http://piotr.zalewa.info
>>> > jobs  http://webdev.zalewa.info
>>> > twit  http://twitter.com/zalun
>>> > face  http://facebook.com/zaloon
>>>
>>> > --
>>> > You received this message because you are subscribed to the Google Groups 
>>> > "Django users" group.
>>> > To post to this group, send email to django-us...@googlegroups.com.
>>> > To unsubscribe from this group, send email to 
>>> > django-users+unsubscr...@googlegroups.com.
>>> > For more options, visit this group 
>>> > athttp://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-us...@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.
>>
>>
>
>
>
> --
> Mathieu Leduc-Hamel
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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: JavaScript with Dango

2010-09-26 Thread CrabbyPete
Yes.

On Sep 26, 7:48 am, aug dawg  wrote:
> Does Django work with JavaScript? If so, how can I use JavaScript in my
> Django projects?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Vim for Python and Django

2010-09-26 Thread Mathieu Leduc-Hamel
Anybody know of there's the same kind of resources for emacs ?

On Sun, Sep 26, 2010 at 7:22 PM, flebber  wrote:
> Do the instructions here http://code.google.com/p/trespams-vim/wiki/readme
> only work on linux ? I tried to follow it on Windows as i wanted to
> download and try your version but received this error.
>
> C:\>hg clone https://trespams-vim.googlecode.com/hg/ trespams-vim
> 'hg' is not recognized as an internal or external command,
> operable program or batch file.
>
> C:\>
>
>
> On Sep 27, 2:55 am, ionut cristian cucu  wrote:
>> Very helpful, thanks alot!
>>
>> 2010/9/26 Piotr Zalewa :
>>
>> >  Hi Antoni,
>>
>> > Thanks for that!
>>
>> > zalun
>>
>> > On 09/26/10 10:36, Antoni Aloy wrote:
>> >> Hello all!
>>
>> >> In this list we have a recurrent thread: "What'ts the best IDE for
>> >> Django and Python development?" trespams-vim is my try to answer this
>> >> question for people who likes to have a very powerful editor and needs
>> >> to have an editor which is able to run in the desktop as well as in a
>> >> remote session. I have updated the previous version with delimMate and
>> >> easytags, so actually you'll find:
>>
>> >> * Syntax highlight
>> >> * Python autocompletion
>> >> * Smart tabbing
>> >> * Templates for Python, Django, js, html, ... (just try to edit a
>> >> python file and press sbu + tab as an example)
>> >> * Add/remove comments on multiple lines
>> >> * Tabs
>> >> * Surround
>> >> * marks
>>
>> >> etc. etc. :
>>
>> >> This is a list of my favorite shortcuts
>>
>> >>http://code.google.com/p/trespams-vim/wiki/readme
>>
>> >> So, you'll find a collection of plugins and .vimrc settings that I
>> >> have found very useful in my day-by-day work in Python and Django.
>>
>> >>http://code.google.com/p/trespams-vim/
>>
>> >> Happy coding!
>>
>> > --
>> > blog  http://piotr.zalewa.info
>> > jobs  http://webdev.zalewa.info
>> > twit  http://twitter.com/zalun
>> > face  http://facebook.com/zaloon
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "Django users" group.
>> > To post to this group, send email to django-us...@googlegroups.com.
>> > To unsubscribe from this group, send email to 
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group 
>> > athttp://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-us...@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.
>
>



-- 
Mathieu Leduc-Hamel

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Vim for Python and Django

2010-09-26 Thread flebber
Do the instructions here http://code.google.com/p/trespams-vim/wiki/readme
only work on linux ? I tried to follow it on Windows as i wanted to
download and try your version but received this error.

C:\>hg clone https://trespams-vim.googlecode.com/hg/ trespams-vim
'hg' is not recognized as an internal or external command,
operable program or batch file.

C:\>


On Sep 27, 2:55 am, ionut cristian cucu  wrote:
> Very helpful, thanks alot!
>
> 2010/9/26 Piotr Zalewa :
>
> >  Hi Antoni,
>
> > Thanks for that!
>
> > zalun
>
> > On 09/26/10 10:36, Antoni Aloy wrote:
> >> Hello all!
>
> >> In this list we have a recurrent thread: "What'ts the best IDE for
> >> Django and Python development?" trespams-vim is my try to answer this
> >> question for people who likes to have a very powerful editor and needs
> >> to have an editor which is able to run in the desktop as well as in a
> >> remote session. I have updated the previous version with delimMate and
> >> easytags, so actually you'll find:
>
> >> * Syntax highlight
> >> * Python autocompletion
> >> * Smart tabbing
> >> * Templates for Python, Django, js, html, ... (just try to edit a
> >> python file and press sbu + tab as an example)
> >> * Add/remove comments on multiple lines
> >> * Tabs
> >> * Surround
> >> * marks
>
> >> etc. etc. :
>
> >> This is a list of my favorite shortcuts
>
> >>http://code.google.com/p/trespams-vim/wiki/readme
>
> >> So, you'll find a collection of plugins and .vimrc settings that I
> >> have found very useful in my day-by-day work in Python and Django.
>
> >>http://code.google.com/p/trespams-vim/
>
> >> Happy coding!
>
> > --
> > blog  http://piotr.zalewa.info
> > jobs  http://webdev.zalewa.info
> > twit  http://twitter.com/zalun
> > face  http://facebook.com/zaloon
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://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-us...@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 saving a form

2010-09-26 Thread Marc Aymerich
On Sun, Sep 26, 2010 at 10:15 PM, Marc Aymerich  wrote:

>
>
> On Sun, Sep 26, 2010 at 8:51 PM, Marc Aymerich wrote:
>
>> I'm trying to make a ModelForm in order to edit an existing object of the
>> class 'member'. So I followed this documentation:
>>
>>
>> http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method
>>
>>
>> # Create a form to edit an existing Article.
>> >>> a = Article.objects.get(pk=1)
>> >>> f = ArticleForm(instance=a)
>> >>> f.save()
>>
>>
>> The form is displayed correctly, however it doesn't work properly, as it
>> does not save the data neither validate the fields (for instance it does not
>> check the e-mail is an e-mail). It doesn't report any error though, so im
>> not sure what could have gone wrong.
>> Can anyone enlighten me?
>>
>> This is my view:
>>
>> @login_required()
>> def edit_member(request):
>> """ edit member information """
>>
>> Member=member.objects.get(id=request.user.id)
>> title = "Edit member " + Member.name
>>
>> if request.method == 'POST':
>> form = MemberForm(request.POST, instance=Member)
>> if form.is_valid():
>> form.save()
>> return HttpResponseRedirect(reverse('list_member'))
>> else:
>> form = MemberForm(instance=Member)
>>
>> if request.user.is_authenticated():
>> return render_to_response('generic_form.html', locals(),
>> context_instance=RequestContext(request))
>> return render_to_response('list_member.html', locals())
>>
>
>
> It seems that the condition request.method == 'POST' is never true :(
> whyy??
>
>
>
I tried with a generic view, but it does not save the object nor validates
the form :( just redirect to post_save_redirect.

return update_object(request,
form_class=MemberForm,
object_id=request.user.member.id,
template_name='generic_form.html',
post_save_redirect=reverse('list_member'),
extra_context=dict(title="Edit Memmber " ),
login_required=True,)
-- 
Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 saving a form

2010-09-26 Thread Marc Aymerich
On Sun, Sep 26, 2010 at 10:34 PM, Karen Tracey  wrote:

> On Sun, Sep 26, 2010 at 4:15 PM, Marc Aymerich wrote:
>
>> It seems that the condition request.method == 'POST' is never true :(
>> whyy??
>
>
> What does the template that contains the form look like?
>
>
Hi Karen, Here the template:

{% extends "base.html" %}

{% block title %}Domain Section{% endblock %}

{% block content %}
{{ title }}

 {% csrf_token %}

 {{ form.as_table }}


 

{% endblock %}


I use it succesfully with others forms.


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



-- 
Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 saving a form

2010-09-26 Thread Karen Tracey
On Sun, Sep 26, 2010 at 4:15 PM, Marc Aymerich  wrote:

> It seems that the condition request.method == 'POST' is never true :(
> whyy??


What does the template that contains the form look like?

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-us...@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 saving a form

2010-09-26 Thread Marc Aymerich
On Sun, Sep 26, 2010 at 8:51 PM, Marc Aymerich  wrote:

> I'm trying to make a ModelForm in order to edit an existing object of the
> class 'member'. So I followed this documentation:
>
>
> http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method
>
>
> # Create a form to edit an existing Article.
> >>> a = Article.objects.get(pk=1)
> >>> f = ArticleForm(instance=a)
> >>> f.save()
>
>
> The form is displayed correctly, however it doesn't work properly, as it
> does not save the data neither validate the fields (for instance it does not
> check the e-mail is an e-mail). It doesn't report any error though, so im
> not sure what could have gone wrong.
> Can anyone enlighten me?
>
> This is my view:
>
> @login_required()
> def edit_member(request):
> """ edit member information """
>
> Member=member.objects.get(id=request.user.id)
> title = "Edit member " + Member.name
>
> if request.method == 'POST':
> form = MemberForm(request.POST, instance=Member)
> if form.is_valid():
> form.save()
> return HttpResponseRedirect(reverse('list_member'))
> else:
> form = MemberForm(instance=Member)
>
> if request.user.is_authenticated():
> return render_to_response('generic_form.html', locals(),
> context_instance=RequestContext(request))
> return render_to_response('list_member.html', locals())
>


It seems that the condition request.method == 'POST' is never true :(
whyy??


-- 
Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: reverse ForeignKey

2010-09-26 Thread ionut cristian cucu
2010/9/25 Daniel Roseman :
>
>
> On Sep 25, 9:51 am, ionut cristian cucu  wrote:
>> I've tried to do something like that:
>> class Pacienti_manager(models.Manager):
>>   def get_visible(self):
>>     return(super(Pacienti_manager,
>> self).get_query_set().filter(pacient_id__exact=pacient_id)
>> but still no go, I tried
>> def queryset(self, request):
>>   qs= super(Pacient, self).queryset(request)
>>   return qs.filter(exit_pacient_id=pacient_id)
>> in Pacient class, but again all objects in Pacient who have an Exit do
>> show up in the view.
>> Any ideas what I'm doing wrong?
>
>
> That method needs to go in your ModelAdmin class,  not your model.
> --
> DR.
I tried that also, but I noticed I can't write the right part of the
expresion, I get global name pacien_id not defined. How do I write
that?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 testing a view decorated with @login_required

2010-09-26 Thread Brandon Taylor
Sorry, the second test is the one that fails.

On Sep 26, 2:01 pm, Brandon Taylor  wrote:
> Hi Everyone,
>
> I'm having an issue testing a page protected with @login_required. I'm
> loading a user via a fixture. I can call
> self.client.login(**credentials) successfully and get True back. I can
> retrieve a User object using the _auth_user_id key held in session
> from the call to self.client.login. However, my "dashboard" view keeps
> returning a 302.
>
> I'm using the built-in AuthenticationForm, and not sure what could be
> wrong at this point. I would really appreciate someone taking a look
> at this code...
>
> #views.py
> @login_required
> def dashboard(request):
>     return render_to_response('accounts/dashboard.html', {},
>         context_instance=RequestContext(request))
>
> #tests.py
> import httplib
>
> from django.contrib.auth.models import User
> from django.contrib.auth import SESSION_KEY
> from django.core.urlresolvers import reverse
> from django.test import TestCase
>
> class AccountsTestCase(TestCase):
>     def setUp(self):
>         self.dashboard_url = reverse('account_dashboard')
>
>     def tearDown(self):
>         self.client.logout()
>
>     def test_dashboard_redirects_unauthenticated_user(self):
>         dashboard_url = self.dashboard_url
>         #test that we can't get to the account dashboard if not logged
> in
>         login_url = '%s?next=%s' % (reverse('login'), dashboard_url)
>         response = self.client.get(dashboard_url)
>         self.assertRedirects(response, login_url,
> status_code=httplib.FOUND, target_status_code=httplib.OK)
>
>     def test_dashboard_allows_authenticated_user(self):
>         #test that we can login and then view the dashboard
>         logged_in = self.client.login(username='my_username',
> password='my_password')
>         self.failUnless(logged_in, 'User could not be authenticated')
>         user =
> User.objects.get(pk=self.client.session.get('_auth_user_id'))
>         response = self.client.get(self.dashboard_url)
>         self.assertEqual(response.status_code, httplib.OK)
>
> TIA,
> Brandon

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 testing a view decorated with @login_required

2010-09-26 Thread Brandon Taylor
Hi Everyone,

I'm having an issue testing a page protected with @login_required. I'm
loading a user via a fixture. I can call
self.client.login(**credentials) successfully and get True back. I can
retrieve a User object using the _auth_user_id key held in session
from the call to self.client.login. However, my "dashboard" view keeps
returning a 302.

I'm using the built-in AuthenticationForm, and not sure what could be
wrong at this point. I would really appreciate someone taking a look
at this code...

#views.py
@login_required
def dashboard(request):
return render_to_response('accounts/dashboard.html', {},
context_instance=RequestContext(request))


#tests.py
import httplib

from django.contrib.auth.models import User
from django.contrib.auth import SESSION_KEY
from django.core.urlresolvers import reverse
from django.test import TestCase


class AccountsTestCase(TestCase):
def setUp(self):
self.dashboard_url = reverse('account_dashboard')

def tearDown(self):
self.client.logout()

def test_dashboard_redirects_unauthenticated_user(self):
dashboard_url = self.dashboard_url
#test that we can't get to the account dashboard if not logged
in
login_url = '%s?next=%s' % (reverse('login'), dashboard_url)
response = self.client.get(dashboard_url)
self.assertRedirects(response, login_url,
status_code=httplib.FOUND, target_status_code=httplib.OK)

def test_dashboard_allows_authenticated_user(self):
#test that we can login and then view the dashboard
logged_in = self.client.login(username='my_username',
password='my_password')
self.failUnless(logged_in, 'User could not be authenticated')
user =
User.objects.get(pk=self.client.session.get('_auth_user_id'))
response = self.client.get(self.dashboard_url)
self.assertEqual(response.status_code, httplib.OK)

TIA,
Brandon

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 saving a form

2010-09-26 Thread Marc Aymerich
I'm trying to make a ModelForm in order to edit an existing object of the
class 'member'. So I followed this documentation:

http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method


# Create a form to edit an existing Article.
>>> a = Article.objects.get(pk=1)
>>> f = ArticleForm(instance=a)
>>> f.save()


The form is displayed correctly, however it doesn't work properly, as it
does not save the data neither validate the fields (for instance it does not
check the e-mail is an e-mail). It doesn't report any error though, so im
not sure what could have gone wrong.
Can anyone enlighten me?

This is my view:

@login_required()
def edit_member(request):
""" edit member information """

Member=member.objects.get(id=request.user.id)
title = "Edit member " + Member.name

if request.method == 'POST':
form = MemberForm(request.POST, instance=Member)
if form.is_valid():
form.save()
return HttpResponseRedirect(reverse('list_member'))
else:
form = MemberForm(instance=Member)

if request.user.is_authenticated():
return render_to_response('generic_form.html', locals(),
context_instance=RequestContext(request))
return render_to_response('list_member.html', locals())


and this is the form definition:

from django.contrib.localflavor.es.forms import *
from django.contrib.localflavor.es.es_provinces import PROVINCE_CHOICES

class MemberForm(ModelForm):
cifnif = ESIdentityCardNumberField()
phone = ESPhoneNumberField()
phone2 = ESPhoneNumberField()
fax = ESPhoneNumberField()
province = forms.ChoiceField(choices=PROVINCE_CHOICES)
zipcode = ESPostalCodeField()

class Meta:
model = member

-- 
Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Patterns / Best practice for automated data refreshes

2010-09-26 Thread ALJ
Hi Shawn,

Thanks for that. I'll have a look at using models then.

Cheers

ALJ

On Sep 26, 7:32 pm, Shawn Milochik  wrote:
> If you're updating a database created by Django, I recommend that your import 
> script import your Django models and update them with the data. Otherwise you 
> run the risk of running SQL that breaks your Django app (or worse, causes it 
> to run with corrupted data and no errors).
>
> I'd do something with cron (or Celery), use the XLRD module to read the Excel 
> into Python data structures (dictionaries and lists), then use that data to 
> update the models.
>
> Shawn

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Patterns / Best practice for automated data refreshes

2010-09-26 Thread Shawn Milochik
If you're updating a database created by Django, I recommend that your import 
script import your Django models and update them with the data. Otherwise you 
run the risk of running SQL that breaks your Django app (or worse, causes it to 
run with corrupted data and no errors).

I'd do something with cron (or Celery), use the XLRD module to read the Excel 
into Python data structures (dictionaries and lists), then use that data to 
update the models.

Shawn

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: [Announcement] Vim for Python and Django

2010-09-26 Thread ionut cristian cucu
Very helpful, thanks alot!

2010/9/26 Piotr Zalewa :
>  Hi Antoni,
>
> Thanks for that!
>
> zalun
>
> On 09/26/10 10:36, Antoni Aloy wrote:
>> Hello all!
>>
>> In this list we have a recurrent thread: "What'ts the best IDE for
>> Django and Python development?" trespams-vim is my try to answer this
>> question for people who likes to have a very powerful editor and needs
>> to have an editor which is able to run in the desktop as well as in a
>> remote session. I have updated the previous version with delimMate and
>> easytags, so actually you'll find:
>>
>> * Syntax highlight
>> * Python autocompletion
>> * Smart tabbing
>> * Templates for Python, Django, js, html, ... (just try to edit a
>> python file and press sbu + tab as an example)
>> * Add/remove comments on multiple lines
>> * Tabs
>> * Surround
>> * marks
>>
>> etc. etc. :
>>
>> This is a list of my favorite shortcuts
>>
>> http://code.google.com/p/trespams-vim/wiki/readme
>>
>> So, you'll find a collection of plugins and .vimrc settings that I
>> have found very useful in my day-by-day work in Python and Django.
>>
>> http://code.google.com/p/trespams-vim/
>>
>> Happy coding!
>>
>
>
> --
> blog  http://piotr.zalewa.info
> jobs  http://webdev.zalewa.info
> twit  http://twitter.com/zalun
> face  http://facebook.com/zaloon
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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.



Automatic form submission and CSRF??

2010-09-26 Thread Joakim Hove
Hello,

I have a simple form which has method POST. When I view the form in
the browser and fill it normally everything works fine. However; the
plan is to submit this form automagically from a client program - I
have currently tried with the Python script:

#!/usr/bin/python
import urllib
params = urllib.urlencode({"passwd": "Hemmelig",
   "user_id" : 1000,
   "subject" : "Tema",
   "extra_addr" : "joakim-h...@gmail.com",
   "date_list" : "10-10-2010",
   "body" : "Lang melding"})

f = urllib.urlopen(form_url , params)
print f.read()

The server just returns error code 403: "No CSRF or session cookie";
how can I get around this? Do I have to create a csrfmiddlewaretoken
on the client (which will not even have Python installed)?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Patterns / Best practice for automated data refreshes

2010-09-26 Thread ALJ
We have an extranet web application (using sqlite) that is hosted
outside our network. One of the tables it uses is an excel report from
our main accounting system that contains a list of our customers. To
begin with this was imported manually but now I want to set up an
automated monthly refresh of the data.

Is there a best way to do this?

I was going to set up a python script run via a cron on the internal
servers to connect to the external ftp site and dump the file there,
and then have another cron on the external site to run through the
spreadsheet updating the sqlite database using standard sql calls.

I also suppose I could convert the spreadsheet to json, and have the
databases restart and automatically import the fixture ... although
this seems more complicated and probably prone to problems than the
above suggestion.

ALJ

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: JavaScript with Dango

2010-09-26 Thread Felix Dreissig
Yep, sure you can use AJAX/Javascript in Django projects.

http://www.b-list.org/weblog/2006/jul/02/django-and-ajax/ might be a
good read.

Regards,
Felix


On 26.09.2010 13:48, aug dawg wrote:
> Does Django work with JavaScript? If so, how can I use JavaScript in my
> Django projects?
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-us...@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-us...@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: JavaScript with Dango

2010-09-26 Thread Daniel Roseman


On Sep 26, 12:48 pm, aug dawg  wrote:
> Does Django work with JavaScript? If so, how can I use JavaScript in my
> Django projects?

What a strange question.  Django creates web pages,  and you can use
JavaScript in the pages it produces just as you would with any other
website pages.
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



JavaScript with Dango

2010-09-26 Thread aug dawg
Does Django work with JavaScript? If so, how can I use JavaScript in my
Django projects?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: [Announcement] Vim for Python and Django

2010-09-26 Thread Piotr Zalewa
 Hi Antoni,

Thanks for that!

zalun

On 09/26/10 10:36, Antoni Aloy wrote:
> Hello all!
>
> In this list we have a recurrent thread: "What'ts the best IDE for
> Django and Python development?" trespams-vim is my try to answer this
> question for people who likes to have a very powerful editor and needs
> to have an editor which is able to run in the desktop as well as in a
> remote session. I have updated the previous version with delimMate and
> easytags, so actually you'll find:
>
> * Syntax highlight
> * Python autocompletion
> * Smart tabbing
> * Templates for Python, Django, js, html, ... (just try to edit a
> python file and press sbu + tab as an example)
> * Add/remove comments on multiple lines
> * Tabs
> * Surround
> * marks
>
> etc. etc. :
>
> This is a list of my favorite shortcuts
>
> http://code.google.com/p/trespams-vim/wiki/readme
>
> So, you'll find a collection of plugins and .vimrc settings that I
> have found very useful in my day-by-day work in Python and Django.
>
> http://code.google.com/p/trespams-vim/
>
> Happy coding!
>


-- 
blog  http://piotr.zalewa.info
jobs  http://webdev.zalewa.info
twit  http://twitter.com/zalun
face  http://facebook.com/zaloon

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



[Announcement] Vim for Python and Django

2010-09-26 Thread Antoni Aloy
Hello all!

In this list we have a recurrent thread: "What'ts the best IDE for
Django and Python development?" trespams-vim is my try to answer this
question for people who likes to have a very powerful editor and needs
to have an editor which is able to run in the desktop as well as in a
remote session. I have updated the previous version with delimMate and
easytags, so actually you'll find:

* Syntax highlight
* Python autocompletion
* Smart tabbing
* Templates for Python, Django, js, html, ... (just try to edit a
python file and press sbu + tab as an example)
* Add/remove comments on multiple lines
* Tabs
* Surround
* marks

etc. etc. :

This is a list of my favorite shortcuts

http://code.google.com/p/trespams-vim/wiki/readme

So, you'll find a collection of plugins and .vimrc settings that I
have found very useful in my day-by-day work in Python and Django.

http://code.google.com/p/trespams-vim/

Happy coding!

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Django on Apache

2010-09-26 Thread Vincent den Boer
On Saturday 25 of September 2010 20:36:52 Derek wrote:
> Can someone briefly explain the difference between PHP apps -- which
> run your code "as is" without need for refreshing the server -- and
> Django?

The difference is that Django starts once, loads all modules it needs and then 
starts handling requests with the code it has in memory, PHP on the other hand, 
each time it handles a request loads each script and then throws away the 
loaded 
script after it has run (altough it can cache scripts somewhere I believe).

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.