unchecked checkboxes not accessed through request.POST['check_name']

2008-11-16 Thread limas

hello all
I am doing a project in Django.
I want to create a list by clicking upon a link, it will open up a new
window using javascript window.open() method.
I have two tables for list.
class Saved_list(models.Model):
description=models.CharField(max_length=100)
number_entries=models.IntegerField()
date_created=models.DateTimeField(auto_now_add=True)
date_modified=models.DateTimeField(auto_now=True)

class Saved_list_entry(models.Model):
saved_list=models.ForeignKey(Saved_list)
date_created=models.DateTimeField(auto_now_add=True)

Onload all entries in the Saved_list is listed with description and
number entries with a check box in front of it.
I want to create new Saved_list. I have done it with a a link.
When any one of the Checkbox is checked I want to increment the
number_entries field and insert a new row in Saved_list_entry.

my view is :
def add_to_list(request):
saved_list=Saved_list.objects.all()
lists=saved_list.values()
if request.method=='POST':
name=''
for lst in lists:
if request.POST[lst['description']]=='On':
name=lst['description']
break
if name!='':
try:
slist1=Saved_list.objects.get
(description=name)
except KeyError:
pass
slist_entry=Saved_list_entry
(saved_list_id=slist1.id)
slist1.number_entries=slist1.number_entries+1;
slist1.save()
else:
slist=Saved_list(description=request.POST
['listname'],number_entries=0)
slist.save()
else:
pass
return render_to_response('candidates/add_to_list.html',
{'list':lists})


and my template is:

{% for l in list %}

{{ l.description }} ({{ l.number_entries }})
{% endfor %}

Save




But i can't retrieve the unchecked checkboxes
please help me..
thanks in advance
Lima
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: avoid cascade delete

2008-11-16 Thread David Zhou

On Mon, Nov 17, 2008 at 2:34 AM, David Zhou <[EMAIL PROTECTED]> wrote:
> On Mon, Nov 17, 2008 at 2:21 AM, Merrick <[EMAIL PROTECTED]> wrote:
>>
>> How do I avoid the default behavior that does a cascade delete. Of
>> course I could use the cursor but would am hoping there is some option
>> I don't know of for delete().
>
> Try using clear() prior to deleting:
>
> http://docs.djangoproject.com/en/dev/topics/db/queries/#following-relationships-backward

Another way is to consider using a many to many there, rather than a
one to many.

-- 
---
David Zhou
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: avoid cascade delete

2008-11-16 Thread David Zhou

On Mon, Nov 17, 2008 at 2:21 AM, Merrick <[EMAIL PROTECTED]> wrote:
>
> I have two models, links and groups. A Link has an optional foreign
> key Group.
>
> When I delete a Group, Django by default deletes all Links that
> referenced the Group that is being deleted.
>
> How do I avoid the default behavior that does a cascade delete. Of
> course I could use the cursor but would am hoping there is some option
> I don't know of for delete().

Try using clear() prior to deleting:

http://docs.djangoproject.com/en/dev/topics/db/queries/#following-relationships-backward

-- 
---
David Zhou
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



avoid cascade delete

2008-11-16 Thread Merrick

I have two models, links and groups. A Link has an optional foreign
key Group.

When I delete a Group, Django by default deletes all Links that
referenced the Group that is being deleted.

How do I avoid the default behavior that does a cascade delete. Of
course I could use the cursor but would am hoping there is some option
I don't know of for delete().
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: In forms, how add dynamic initial values out of reach for clients?

2008-11-16 Thread David Zhou

On Mon, Nov 17, 2008 at 1:24 AM, dexter <[EMAIL PROTECTED]> wrote:
>
> I want logged in users to be able to add comments but only want some
> of the formfields displayed. Fields 'user', 'date' and 'discussion'
> should be out of reach for my sitevisitors/clients.
> ...
> How should i solve this? I've tried numerous ways but none of them
> really worked.

http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a-subset-of-fields-on-the-form

---
David Zhou
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



In forms, how add dynamic initial values out of reach for clients?

2008-11-16 Thread dexter

I want logged in users to be able to add comments but only want some
of the formfields displayed. Fields 'user', 'date' and 'discussion'
should be out of reach for my sitevisitors/clients.

#models.py:
class Comment(models.Model):
user = models.ForeignKey(User)
date = models.DateTimeField(default=datetime.now())
text = models.TextField()
discussion = models.ForeignKey(Discussion)

How should i solve this? I've tried numerous ways but none of them
really worked.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: cascading drop down lists

2008-11-16 Thread David Zhou

On Sun, Nov 16, 2008 at 10:56 PM, adelevie <[EMAIL PROTECTED]> wrote:

> I want to use a series of drop down lists to define this criteria. For
> example, I want to first have to select the year. Then I hit submit
> and the form is processed on the same page. Then the next drop down
> list will become populated with a list of seasons associated with that
> year. Submit. Then the next drop down list will become populated with
> departments associated with that season and year. Submit. The next
> list is filled with courses associated with with that year, season,
> and department. I hope this gives you the right idea.
> Do I have to create a form model to do this?
> Is there any other way to retrieve POST data?

Look into form wizards and the process_step() method:

http://docs.djangoproject.com/en/dev/ref/contrib/formtools/form-wizard/#django.contrib.formtools.wizard.FormWizard.process_step

-- 
---
David Zhou
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Best way for making a "Poll"?

2008-11-16 Thread David Zhou

On Sun, Nov 16, 2008 at 11:20 PM, killsto <[EMAIL PROTECTED]> wrote:

> How can I get choices, a CharField I guess, to show up as radio select
> widgets in a form?

You can manually retrieve form fields and display them however you want:

http://docs.djangoproject.com/en/dev/topics/forms/#customizing-the-form-template

-- 
---
David Zhou
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multithreaded Dev Server

2008-11-16 Thread [EMAIL PROTECTED]

Having two instances of the dev server running does seem like another
easy way to do it, as it won't require installing anymore software.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django monitoring page

2008-11-16 Thread Harish

thank you very much

On Nov 14, 7:10 pm, Doug Van Horn <[EMAIL PROTECTED]> wrote:
> Is the username/password prompt fromDjangoor Apache Auth?
>
> If it'sDjango, change the view to accept username/password params on
> the query string (removing decorators and/or changing middleware to
> allow access to that url).  
> e.g.,http://example.com/some/url/?username=foo=bar
>
> If it's Apache Auth, use a URL like this: http://username:[EMAIL 
> PROTECTED]/some/url/
>
> Hope that gets you moving in the right direction...
>
> doug.
>
> On Nov 14, 6:44 am, Harish <[EMAIL PROTECTED]> wrote:
>
> > hi.. friends,
>
> > I have onedjangosite which is running on the internet...
>
> > Now the web service provider needs to monitor thedjangosite and the
> > database.
>
> > Now they told me to create a webpage which goes throughdjangoand
> > fetch some data and
> > print in the webpage
>
> > the problem i am facing is, every time I run the url, i need to give
> > the user and password...
>
> > The monitoring is done by software  which is located in the
> > webserver...
>
> > any help from the group
>
> > regards
> > Harish Bhat 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Best way for making a "Poll"?

2008-11-16 Thread killsto

First of all, I know the tutorial supplies somewhat of a poll, and
I've been through it.

What I want to do is make an app that has one poll (or question) of
the day that someone can edit from the admin interface. Each question
has 4 choices. Also, there will not be user registration, just a field
to input your name. I also want to use ModelForm.

Now, should I have each question have a ManyToMany with choices, or
each choice have a ForeignKey with a question? Initially I thought a
ManyToMany would be good since its widget is multiple choice field in
ModelForm. But, it also showed up as a multiple choice (with no
choices yet!) in the admin interface.

So I decided to go with the way the tutorial had it setup, but I got
some error about a missing column when I tried to save a choice. (I'm
using sqlite3 and the SVN version) It also did that when I tried to
have it stacked inline with question. I tried flushing, resyncing the
db, and using django-evolution (after it didn't work). So I'm deciding
to start all over.

How can I get choices, a CharField I guess, to show up as radio select
widgets in a form?
Also, at the bottom of the page I want to show each (in standard text)
Question of the day and its choices. I'm assuming that's just simply
reading CharFields and displaying them?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: djangobook ch3, can't see the view current_datetime

2008-11-16 Thread Adam Yee

You were right, Django didn't see any URLs in the URLconf file because
I wasn't using the right one.  I had another site also called
'testproject' in a different directory (deleted now).  So I was using
views.py and settings.py in the /web/django directory, but the urls.py
from a totally different one.  It was subtle, and I'm glad I caught it
sooner than later.  All is working fine now with this urls.py when
accessing http://localhost:8080/testproject/time

from django.conf.urls.defaults import *
from testproject.views import current_datetime

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
(r'^time/$', current_datetime),
# Example:
# (r'^testproject/', include('testproject.foo.urls')),

# Uncomment the admin/doc line below and add
'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
# (r'^admin/(.*)', admin.site.root),
)

Thanks again.

On Nov 16, 6:31 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2008-11-16 at 17:41 -0800, Adam Yee wrote:
>
> [...]
>
> Good debugging info snipped.
>
> > When enteringhttp://localhost:8080/testproject/timeI'm reading this
> > in the Apache error log:
>
> > [Sun Nov 16 17:27:37 2008] [info] mod_wsgi (pid=1768): Create
> > interpreter 'ADAMYEE.gateway.2wire.net:8080|/testproject'.
> > [Sun Nov 16 17:27:37 2008] [info] [client 127.0.0.1] mod_wsgi
> > (pid=1768, process='', application='ADAMYEE.gateway.2wire.net:8080|/
> > testproject'): Loading WSGI script 'C:/web/django/apache/django.wsgi'.
>
> >http://localhost:8080/testproject/timejust brings up 'It worked!'
>
> So the good news is that this means Django is handling the request and
> not exploding, since "it worked" is produced by Django. Which means your
> webserver configuration is correct (or at least very close to correct).
> You're not seeing an error saying something like "Apache doesn't know
> anything about Django".
>
> > Notice how it shows the process as just /testproject and not /
> > testproject/time.
>
> That's correct. The web server hands everything off to what you've
> called "testproject" and Django handles the rest of the stuff.
>
> What's interesting here is that it doesn't redirect to testproject/time/
> (with a trailing slash). Which means Django thinks your URL Conf file is
> empty. Did you just change it and save it without telling Apache to
> reload/restart, so it hasn't picked up the changes, perhaps?
>
> I can't immediately see anything wrong with the setup information you've
> posted, so it's something subtle (or I'm going blind in my old age,
> which is also a candidate).
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



cascading drop down lists

2008-11-16 Thread adelevie

Hi. I am creating a separate admin page than the built in one. This
new admin site is meant to scrape data from my university's course
catalog based on a given set of criteria.
I want to use a series of drop down lists to define this criteria. For
example, I want to first have to select the year. Then I hit submit
and the form is processed on the same page. Then the next drop down
list will become populated with a list of seasons associated with that
year. Submit. Then the next drop down list will become populated with
departments associated with that season and year. Submit. The next
list is filled with courses associated with with that year, season,
and department. I hope this gives you the right idea.
Do I have to create a form model to do this?
Is there any other way to retrieve POST data?

If I must make a model, what are your suggestions for the best way to
go about this?

Thank you very much and any help would be greatly appreciated.

-Alan

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django - Python 3

2008-11-16 Thread Malcolm Tredinnick


On Sun, 2008-11-16 at 19:10 -0700, Leonel Nunez wrote:
> Hello:
> 
> As we know python 3 is comming in December:
> 
> http://www.python.org/download/releases/3.0/
> 
> Will there be many changes  for django with  python 3

Well, Django doesn't run out of the box on the Python 3 alphas, nor does
2to3.py convert it over cleanly to run on Python 3, so the answer is
"yes".

Since Django supports everything from Python 2.3 to 2.6, plus Jython,
PyPy and IronPython (in theory), we've got a few hairy corners. There's
been a few threads on django-developers about a patch that could make
Django run through 2to3.py more or less, as of a few months back. We'll
probably do something about that once Python 3 is released, but I wager
(not too much, though) it's unlikely that on day 1 of Python 3.0 being
released Django will work straight out of subversion. It's going to be a
miniscule portion of the total userbase, after all.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: djangobook ch3, can't see the view current_datetime

2008-11-16 Thread Malcolm Tredinnick


On Sun, 2008-11-16 at 17:41 -0800, Adam Yee wrote:
[...]

Good debugging info snipped.

> When entering http://localhost:8080/testproject/time I'm reading this
> in the Apache error log:
> 
> [Sun Nov 16 17:27:37 2008] [info] mod_wsgi (pid=1768): Create
> interpreter 'ADAMYEE.gateway.2wire.net:8080|/testproject'.
> [Sun Nov 16 17:27:37 2008] [info] [client 127.0.0.1] mod_wsgi
> (pid=1768, process='', application='ADAMYEE.gateway.2wire.net:8080|/
> testproject'): Loading WSGI script 'C:/web/django/apache/django.wsgi'.
> 
> http://localhost:8080/testproject/time just brings up 'It worked!'

So the good news is that this means Django is handling the request and
not exploding, since "it worked" is produced by Django. Which means your
webserver configuration is correct (or at least very close to correct).
You're not seeing an error saying something like "Apache doesn't know
anything about Django".

> Notice how it shows the process as just /testproject and not /
> testproject/time.

That's correct. The web server hands everything off to what you've
called "testproject" and Django handles the rest of the stuff.

What's interesting here is that it doesn't redirect to testproject/time/
(with a trailing slash). Which means Django thinks your URL Conf file is
empty. Did you just change it and save it without telling Apache to
reload/restart, so it hasn't picked up the changes, perhaps?

I can't immediately see anything wrong with the setup information you've
posted, so it's something subtle (or I'm going blind in my old age,
which is also a candidate).

Regards,
Malcolm



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django - Python 3

2008-11-16 Thread James Bennett

On Sun, Nov 16, 2008 at 8:10 PM, Leonel Nunez <[EMAIL PROTECTED]> wrote:
> Will there be many changes  for django with  python 3

As this is a fairly common question, *please* consider searching the
list archives for information.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django - Python 3

2008-11-16 Thread Leonel Nunez

Hello:

As we know python 3 is comming in December:

http://www.python.org/download/releases/3.0/

Will there be many changes  for django with  python 3

Thank You

Leonel



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Query spanning two foreign keys

2008-11-16 Thread Will McCutchen

On Nov 15, 7:55 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> This should do the job:
>
>         User.objects.filter(posts__parent__pk=1).distinct()

That does the trick.  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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



djangobook ch3, can't see the view current_datetime

2008-11-16 Thread Adam Yee

I'm a new user to Django, hi everyone.

My system:
Windows XP
Python 2.5
Apache 2.2
>>configured for mod_wsgi
MySQL, MySQLdb   #Irrelevant at this point

My issue:
Having trouble getting the through the first example.  Basically, when
directing the browser to '.../time/' I'm still at the 'It worked!'
beginning page.  I haven't been able to bring up the view with
current_datetime.

Some things you might ask to know:
- For Apache:

WSGIScriptAlias /testproject "C:/web/django/apache/django.wsgi"

Order allow,deny
Allow from all


- For my app:
## django.wsgi
import os, sys
sys.path.append('C:/web/django')
os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

## views.py
from django.http import HttpResponse
import datetime

def current_datetime(request):
now = datetime.datetime.now()
html = "It is now %s." % now
return HttpResponse(html)

## urls.py
from django.conf.urls.defaults import *
from testproject.views import current_datetime

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
(r'^testproject/time/$', current_datetime),
# Example:
# (r'^testproject/', include('testproject.foo.urls')),

# Uncomment the admin/doc line below and add
'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
# (r'^admin/(.*)', admin.site.root),
)

When entering http://localhost:8080/testproject/time I'm reading this
in the Apache error log:

[Sun Nov 16 17:27:37 2008] [info] mod_wsgi (pid=1768): Create
interpreter 'ADAMYEE.gateway.2wire.net:8080|/testproject'.
[Sun Nov 16 17:27:37 2008] [info] [client 127.0.0.1] mod_wsgi
(pid=1768, process='', application='ADAMYEE.gateway.2wire.net:8080|/
testproject'): Loading WSGI script 'C:/web/django/apache/django.wsgi'.

http://localhost:8080/testproject/time just brings up 'It worked!'

Notice how it shows the process as just /testproject and not /
testproject/time.  Is this supposed to be that way?  Is there
something I'm missing in the 'testproject.settings.py' that is
preventing me from seeing the /time URL?  I think everything is setup
correctly.  I've spent a little time looking for an issue related to
this, but couldn't find a post.  Does anybody have any suggestions?
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to deal with NTLM authentication

2008-11-16 Thread Lee Connell
Thomas,

Thanks for reply, I will check it out, doesn't seem there is any
documentation at least on the website, maybe there is some in the source.
Is it possible to just add the appropriate headers to a response object? I
would be interested in this working for basic authentication as well, that
seems to be easier.

thanks!

On Sun, Nov 16, 2008 at 7:11 PM, Thomas Kerpe
<[EMAIL PROTECTED]>wrote:

>
> Am 16.11.2008 21:51 Uhr, Lee Connell schrieb:
> > ... What I want to do is allow the user of my django app to login just
> > once, then if the user wishes to access the "embeded site" and
> > recieves the WWW-Authentication : NTLM response, I can just pass the
> > user and pass so the user is allowed access transparently.  How do I
> > go about doing this?  I haven't been able to find anything definitive
> > online, help would be greatly
> Have you looked at:
> http://ntlmaps.sourceforge.net/
>
> HTH,
> Thomas
>
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Caching and I18n

2008-11-16 Thread [EMAIL PROTECTED]

Hello Ramiro,

thanks for your reply. According to the docs, the Locale and Session
middlewares should set the Vary-On headers accordingly, and indeed
they are:

Date: Sun, 16 Nov 2008 23:49:29 GMT
Server: WSGIServer/0.1 Python/2.5.2
Vary: Accept-Language, Cookie
Content-Type: text/html; charset=utf-8
Content-Language: de

200 OK

I'm lost. Maybe Beegee from the other thread found a solution in the
meantime.

On Nov 16, 10:33 pm, "Ramiro Morales" <[EMAIL PROTECTED]> wrote:
> On Sun, Nov 16, 2008 at 10:51 AM, [EMAIL PROTECTED]
>
>
>
>
>
> <[EMAIL PROTECTED]> wrote:
>
> > Hello everyone,
>
> > I'm trying to implement caching for my bilingual site. The problem is
> > that once I enable caching and I change the language (via the example
> > code 
> > inhttp://docs.djangoproject.com/en/dev/topics/i18n/?from=olddocs#the-se...
> > ), the page does not change. The Content-Language header that the
> > browser receives is indeed changed accordingly, but apparently the
> > caching system is not aware of the change.
> > I've set up my middleware as follows:
>
> > MIDDLEWARE_CLASSES = (
> >    'django.middleware.cache.UpdateCacheMiddleware',
> >    'django.contrib.sessions.middleware.SessionMiddleware', # muss vor
> > auth
> >    'django.contrib.auth.middleware.AuthenticationMiddleware',
> >    'django.middleware.locale.LocaleMiddleware',
> >    'django.middleware.common.CommonMiddleware',
> >    'django.middleware.cache.FetchFromCacheMiddleware',
> > )
>
> > I also tried per-site caching (disabling caching in the middleware),
> > but did get the same results, even when I specified vary_on_headers
> > ('Content-Language','Accept-Language').
>
> > I have found a snippet (http://www.djangosnippets.org/snippets/443/)
> > that might work, but I'm reluctant to use this hack and also rely on
> > the deprecated CacheMiddleware.
>
> > Any help and hints are appreciated!
>
> > Thanks,
> > Maik
>
> > PS. relevant settings.py excerpt:
> > CACHE_BACKEND = 'locmem:///'
> > CACHE_MIDDLEWARE_SECONDS = 300
> > CACHE_MIDDLEWARE_KEY_PREFIX = ''
> > CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True
>
> The user's language preference might end being stored (and sent back) in
> the django language preferences cookie or the session-related cookie.
> So, to cover all the possible channels that preference could come in,
> you will also need to indicate 'cookie', in the Vary header:
>
> @vary_on_headers(''Accept-Language', 'Cookie')
>
> See the following posts for related discussions:
>
> http://groups.google.com/group/django-developers/browse_thread/thread...http://groups.google.com/group/django-users/browse_thread/thread/256f...
>
> Regards,
>
> --
>  Ramiro Morales
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to deal with NTLM authentication

2008-11-16 Thread Thomas Kerpe

Am 16.11.2008 21:51 Uhr, Lee Connell schrieb:
> ... What I want to do is allow the user of my django app to login just 
> once, then if the user wishes to access the "embeded site" and 
> recieves the WWW-Authentication : NTLM response, I can just pass the 
> user and pass so the user is allowed access transparently.  How do I 
> go about doing this?  I haven't been able to find anything definitive 
> online, help would be greatly
Have you looked at:
http://ntlmaps.sourceforge.net/

HTH,
Thomas

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: populating database model with form model

2008-11-16 Thread jtobe

yes, i wanted all the new features and enhancements from 1.0 over
0.96, so i package my own django 1.0 version in the project.

i have tried to use google's djangoforms as well as django.form and
using either one, i get the same errors.

i do appreciate all you trying to help me with this. i just wish i
knew enough to figure it out without bothering you guys.



On Nov 16, 5:47 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> Beware, though, of assuming exact parallels. The django on GAE is a)
> somewhat out of date, and b) modified to adapt it to the Google App
> Engine hosting environment.
>
> Good luck with your project.
>
> regards
>  Steve
>
>
>
> jtobe wrote:
> > thanks for trying to help.
>
> > app engine models use .put() instead of .save() and according to
> > guido, there is very little difference between the two.
>
> > I have pasted models.py and search.py so you can see the two. maybe
> > that will help.
>
> > paste url:http://dpaste.com/91258/
>
> > the django app i'm bulding here is suppose to be an "orbitz
> > equivalent" for my software engineering class. we chose to use django
> > and app engine for the free hosting and a chance to use something we
> > had only read about (django).
>
> [...]
> --
> Steve Holden        +1 571 484 6266   +1 800 494 3119
> Holden Web LLC              http://www.holdenweb.com/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: populating database model with form model

2008-11-16 Thread Steve Holden

Beware, though, of assuming exact parallels. The django on GAE is a)
somewhat out of date, and b) modified to adapt it to the Google App
Engine hosting environment.

Good luck with your project.

regards
 Steve

jtobe wrote:
> thanks for trying to help.
> 
> app engine models use .put() instead of .save() and according to
> guido, there is very little difference between the two.
> 
> I have pasted models.py and search.py so you can see the two. maybe
> that will help.
> 
> paste url: http://dpaste.com/91258/
> 
> the django app i'm bulding here is suppose to be an "orbitz
> equivalent" for my software engineering class. we chose to use django
> and app engine for the free hosting and a chance to use something we
> had only read about (django).
> 
[...]
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: general problems with installing downloaded django apps

2008-11-16 Thread Steve Holden

webcomm wrote:
[yet again at the top of the message, so I have yet again moved the
response down to where it reads logically ...]
> On Nov 16, 2:35 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
>> webcomm wrote:
>>
>> [Please don't top-post ... I've moved your answer down]
>>
>>> On Nov 16, 1:01 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
 webcomm wrote:
> Maybe I'm starting to get the idea... can apps be installed anywhere,
> as long as they are on the python path?  Are there any restrictions at
> all with respect to where apps are installed?
 You've got it. There are no restriction (by Django) on where apps are
 installed, as long as their base directories end up on sys.path[].
 Some apps have their own templates with them (typically extending some
 notional basic template called "base.html", some apps expect you to
 provide templates.
 In the former case you can pick them up by having
 'django.template.loaders.app_directories.load_template_source'
 in your settings.TEMPLATE_LOADERS, in the latter case you can put the
 templates pretty much wherever you want.
>>> Hmm.  I've created several apps using the startapp command, but I
>>> don't see any references to those apps when I print sys.path.
>>> Does something happen behind the scenes when I use the startapp
>>> command that isn't visible when I print sys.path?  If so, why not run
>>> the startapp command for all apps?  For example, to install the
>>> tagging app, I could create an app called "tagging" with startapp.
>>> Then I could replace the contents of that directory with the tagging
>>> app I download from code.google.com.  Would that work?
>> Well, startapp just creates a directory suitable for use a local app.
>>
>> You are running manage.py to start the test server. Python by default
>> puts the directory containing the program you run at the start of
>> sys.path. You will notice that all the apps you installed contain an
>> __init__.py file, which means they are packages. and can be imported
>> from the directory containing them (which is also the directory
>> containing manage.py). So the mere act of running manage.py ensures that
>> all your app packages can be loaded.
>>
>> But they can also be loaded from any other directory on sys.path ...

> Thanks Steve.  That moves me forward.  I'll read about module packages
> in my python book.  I think what I'm discovering is that I've gotten
> somewhat deep into Django without really understanding some of the
> underlying python concepts.
>
> What is the point of setup.py files, if they are not really necessary
> for installing apps?  I see that the tagging app gives me the option
> to install using setup.py, but it's not required.
>
setup.py is just a standard way of taking advantage of Python's
"distutils" distribution utilities package. A lot of times a "pure
Python" module or package can be simply installed just by dropping it
into a directory that's already on the installer's Python path, but if
you have requirements for data files to land in a particular spot or of
C code needs to be compiled to provide an extension module then setup.py
can be invaluable.

Most Django apps aren't that complicated. setup.py will traditionally
put the packages it installs in /Lib/site-packages
under Windows, or /usr/lib/pythonx.y/site-packages under Linux/UNIX.

If you need help with Python the comp.lang.python newsgroup (also
available as [EMAIL PROTECTED]) is a friendly place, but this list
can also help out with the odd Python-related question.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: populating database model with form model

2008-11-16 Thread jtobe

thanks for trying to help.

app engine models use .put() instead of .save() and according to
guido, there is very little difference between the two.

I have pasted models.py and search.py so you can see the two. maybe
that will help.

paste url: http://dpaste.com/91258/

the django app i'm bulding here is suppose to be an "orbitz
equivalent" for my software engineering class. we chose to use django
and app engine for the free hosting and a chance to use something we
had only read about (django).

On Nov 16, 3:18 pm, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Nov 16, 6:43 pm, jtobe <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi, i wasn't sure whether i should ask this here or on the google app
> > engine list.
>
> > I really have two problems. The first is, if i have a form that i
> > populate choices in a choicefield using entries in the database, it
> > only updates once. Every time after the first time it just uses the
> > same vales it found before, even if i go add more items to the
> > dateabase. I have tried deleting all browser cache.
>
> > I have a datastore model (reason for being unsure) that i am trying to
> > load with information submitted through a django model form. For a
> > long time, when i would submit the form i would get an error
> > initialize the datastore model using named arguments in the
> > constructor. it would say:
> > 'unicode' object has no attribute 'is_saved'
>
> > I would send these values using:
> > form = SearchForm(request.POST)
> > MyModel(
> >     field_name = form.cleaned_data.get('field_name', 'default'),
> >     bool_field_name = form.cleaned_data.get('bool_field_name', False)
> > )
>
> > I would get this error even if i tried to pass values directly, like:
> > MyModel(field_name="value", bool_field_name=True)
>
> > Lately, though, the page has just been always failing when checking
> > is_valid() on the form. (always returns False)
>
> > I am a fairly novice django user, and a fairly novice app engine user.
> > I have read the djangobook many times, and i have googled this problem
> > to death. If anyone has any suggestions or advice or anything that
> > might help me, please reply. I would greatly appreciate it.
>
> I don't know anything about Google App Engine, except that it manages
> models differently from normal Django. All I can say is that in
> standard Django, your two MyModel calls above do exactly the same
> thing: create a new model instance with the values you pass, then
> immediately throw it away. It won't be saved to the database, because
> you're not telling it to be.
>
> You would need to do something like:
> new_obj = MyModel(field_name='value')
> new_obj.save()
>
> For your other problems, you'll need to give more details. Preferably,
> post your code on dpaste.com and post a link here.
> --
> 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: general problems with installing downloaded django apps

2008-11-16 Thread webcomm

Thanks Steve.  That moves me forward.  I'll read about module packages
in my python book.  I think what I'm discovering is that I've gotten
somewhat deep into Django without really understanding some of the
underlying python concepts.

What is the point of setup.py files, if they are not really necessary
for installing apps?  I see that the tagging app gives me the option
to install using setup.py, but it's not required.

-Ryan


On Nov 16, 2:35 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> webcomm wrote:
>
> [Please don't top-post ... I've moved your answer down]
>
> > On Nov 16, 1:01 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> >> webcomm wrote:
> >>> Maybe I'm starting to get the idea... can apps be installed anywhere,
> >>> as long as they are on the python path?  Are there any restrictions at
> >>> all with respect to where apps are installed?
> >> You've got it. There are no restriction (by Django) on where apps are
> >> installed, as long as their base directories end up on sys.path[].
>
> >> Some apps have their own templates with them (typically extending some
> >> notional basic template called "base.html", some apps expect you to
> >> provide templates.
>
> >> In the former case you can pick them up by having
>
> >> 'django.template.loaders.app_directories.load_template_source'
>
> >> in your settings.TEMPLATE_LOADERS, in the latter case you can put the
> >> templates pretty much wherever you want.
>
> > Hmm.  I've created several apps using the startapp command, but I
> > don't see any references to those apps when I print sys.path.
>
> > Does something happen behind the scenes when I use the startapp
> > command that isn't visible when I print sys.path?  If so, why not run
> > the startapp command for all apps?  For example, to install the
> > tagging app, I could create an app called "tagging" with startapp.
> > Then I could replace the contents of that directory with the tagging
> > app I download from code.google.com.  Would that work?
>
> Well, startapp just creates a directory suitable for use a local app.
>
> You are running manage.py to start the test server. Python by default
> puts the directory containing the program you run at the start of
> sys.path. You will notice that all the apps you installed contain an
> __init__.py file, which means they are packages. and can be imported
> from the directory containing them (which is also the directory
> containing manage.py). So the mere act of running manage.py ensures that
> all your app packages can be loaded.
>
> But they can also be loaded from any other directory on sys.path ...
>
> regards
>  Steve
> --
> Steve Holden        +1 571 484 6266   +1 800 494 3119
> Holden Web LLC              http://www.holdenweb.com/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Saving associated data with multiple formset_factory

2008-11-16 Thread Tane Piper

Hey there,

The last Django application I worked on was in 0.96 and I'm trying to
get used to the new stuff in there.

I've been following the docs here: 
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#id2
trying to use the formset_factory on some forms.

I have a Contact model, and associated through a FK it has several
ContactNumber and ContactEmail instances.  I've used ModelForm to
create the forms and it works successfully if I just have one instance
of the number and email, but when I try to create a formset for it, I
get this problem:

'ContactNumberFormFormSet' object has no attribute 'save'

But as far as I can see, I've followed the docs correctly??

I've pasted the code for my model, form and view below:

Contact,ContactNumber,ContactEmail models: http://paste.ifies.org/158
Forms: http://paste.ifies.org/161
View: http://paste.ifies.org/160

Any help on this would be appreciated

Tane
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Caching and I18n

2008-11-16 Thread Ramiro Morales

On Sun, Nov 16, 2008 at 10:51 AM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> Hello everyone,
>
> I'm trying to implement caching for my bilingual site. The problem is
> that once I enable caching and I change the language (via the example
> code in 
> http://docs.djangoproject.com/en/dev/topics/i18n/?from=olddocs#the-set-language-redirect-view
> ), the page does not change. The Content-Language header that the
> browser receives is indeed changed accordingly, but apparently the
> caching system is not aware of the change.
> I've set up my middleware as follows:
>
> MIDDLEWARE_CLASSES = (
>'django.middleware.cache.UpdateCacheMiddleware',
>'django.contrib.sessions.middleware.SessionMiddleware', # muss vor
> auth
>'django.contrib.auth.middleware.AuthenticationMiddleware',
>'django.middleware.locale.LocaleMiddleware',
>'django.middleware.common.CommonMiddleware',
>'django.middleware.cache.FetchFromCacheMiddleware',
> )
>
> I also tried per-site caching (disabling caching in the middleware),
> but did get the same results, even when I specified vary_on_headers
> ('Content-Language','Accept-Language').
>
> I have found a snippet (http://www.djangosnippets.org/snippets/443/)
> that might work, but I'm reluctant to use this hack and also rely on
> the deprecated CacheMiddleware.
>
> Any help and hints are appreciated!
>
> Thanks,
> Maik
>
> PS. relevant settings.py excerpt:
> CACHE_BACKEND = 'locmem:///'
> CACHE_MIDDLEWARE_SECONDS = 300
> CACHE_MIDDLEWARE_KEY_PREFIX = ''
> CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True
>

The user's language preference might end being stored (and sent back) in
the django language preferences cookie or the session-related cookie.
So, to cover all the possible channels that preference could come in,
you will also need to indicate 'cookie', in the Vary header:

@vary_on_headers(''Accept-Language', 'Cookie')

See the following posts for related discussions:

http://groups.google.com/group/django-developers/browse_thread/thread/740f8d434e0660ff/5033945a4cdde102?hl=en=gst
http://groups.google.com/group/django-users/browse_thread/thread/256faa01c62b4f27/f4a382c540f47b5b?hl=en=gst

Regards,

--
 Ramiro Morales

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: populating database model with form model

2008-11-16 Thread Daniel Roseman

On Nov 16, 6:43 pm, jtobe <[EMAIL PROTECTED]> wrote:
> Hi, i wasn't sure whether i should ask this here or on the google app
> engine list.
>
> I really have two problems. The first is, if i have a form that i
> populate choices in a choicefield using entries in the database, it
> only updates once. Every time after the first time it just uses the
> same vales it found before, even if i go add more items to the
> dateabase. I have tried deleting all browser cache.
>
> I have a datastore model (reason for being unsure) that i am trying to
> load with information submitted through a django model form. For a
> long time, when i would submit the form i would get an error
> initialize the datastore model using named arguments in the
> constructor. it would say:
> 'unicode' object has no attribute 'is_saved'
>
> I would send these values using:
> form = SearchForm(request.POST)
> MyModel(
>     field_name = form.cleaned_data.get('field_name', 'default'),
>     bool_field_name = form.cleaned_data.get('bool_field_name', False)
> )
>
> I would get this error even if i tried to pass values directly, like:
> MyModel(field_name="value", bool_field_name=True)
>
> Lately, though, the page has just been always failing when checking
> is_valid() on the form. (always returns False)
>
> I am a fairly novice django user, and a fairly novice app engine user.
> I have read the djangobook many times, and i have googled this problem
> to death. If anyone has any suggestions or advice or anything that
> might help me, please reply. I would greatly appreciate it.

I don't know anything about Google App Engine, except that it manages
models differently from normal Django. All I can say is that in
standard Django, your two MyModel calls above do exactly the same
thing: create a new model instance with the values you pass, then
immediately throw it away. It won't be saved to the database, because
you're not telling it to be.

You would need to do something like:
new_obj = MyModel(field_name='value')
new_obj.save()

For your other problems, you'll need to give more details. Preferably,
post your code on dpaste.com and post a link here.
--
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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to deal with NTLM authentication

2008-11-16 Thread Lee Connell
I have a website outside of django that uses NTLM authentication, requires
username and pass to be entered before access to the site is allowed.  I
want to embed this site in a particular section within my django app which
is not a problem.  What I want to do is allow the user of my django app to
login just once, then if the user wishes to access the "embeded site" and
recieves the WWW-Authentication : NTLM response, I can just pass the user
and pass so the user is allowed access transparently.  How do I go about
doing this?  I haven't been able to find anything definitive online, help
would be greatly appreciated!

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Date Field question -

2008-11-16 Thread Lars Stavholm

Mahesh Vaidya wrote:
> Hi,
> I am going to used "DateField" in my model. Which format does date
> field user is it DD/MM/ (European) or MM/DD/ (American) style
> ?  and is it customizable ?

Have a look at...
http://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#date-format

But beware, there seems to be an open ticket suggesting that you need...

USE_I18N = False

...in your settings.py in order for the DATE_FORMAT to work as expected.

/L


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: general problems with installing downloaded django apps

2008-11-16 Thread Steve Holden

webcomm wrote:
[Please don't top-post ... I've moved your answer down]
> On Nov 16, 1:01 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
>> webcomm wrote:
>>> Maybe I'm starting to get the idea... can apps be installed anywhere,
>>> as long as they are on the python path?  Are there any restrictions at
>>> all with respect to where apps are installed?
>> You've got it. There are no restriction (by Django) on where apps are
>> installed, as long as their base directories end up on sys.path[].
>>
>> Some apps have their own templates with them (typically extending some
>> notional basic template called "base.html", some apps expect you to
>> provide templates.
>>
>> In the former case you can pick them up by having
>>
>> 'django.template.loaders.app_directories.load_template_source'
>>
>> in your settings.TEMPLATE_LOADERS, in the latter case you can put the
>> templates pretty much wherever you want.
>>
> Hmm.  I've created several apps using the startapp command, but I
> don't see any references to those apps when I print sys.path.
>
> Does something happen behind the scenes when I use the startapp
> command that isn't visible when I print sys.path?  If so, why not run
> the startapp command for all apps?  For example, to install the
> tagging app, I could create an app called "tagging" with startapp.
> Then I could replace the contents of that directory with the tagging
> app I download from code.google.com.  Would that work?
>
Well, startapp just creates a directory suitable for use a local app.

You are running manage.py to start the test server. Python by default
puts the directory containing the program you run at the start of
sys.path. You will notice that all the apps you installed contain an
__init__.py file, which means they are packages. and can be imported
from the directory containing them (which is also the directory
containing manage.py). So the mere act of running manage.py ensures that
all your app packages can be loaded.

But they can also be loaded from any other directory on sys.path ...

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: general problems with installing downloaded django apps

2008-11-16 Thread webcomm

Hmm.  I've created several apps using the startapp command, but I
don't see any references to those apps when I print sys.path.

Does something happen behind the scenes when I use the startapp
command that isn't visible when I print sys.path?  If so, why not run
the startapp command for all apps?  For example, to install the
tagging app, I could create an app called "tagging" with startapp.
Then I could replace the contents of that directory with the tagging
app I download from code.google.com.  Would that work?

-Ryan


On Nov 16, 1:01 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> webcomm wrote:
> > Maybe I'm starting to get the idea... can apps be installed anywhere,
> > as long as they are on the python path?  Are there any restrictions at
> > all with respect to where apps are installed?
>
> You've got it. There are no restriction (by Django) on where apps are
> installed, as long as their base directories end up on sys.path[].
>
> Some apps have their own templates with them (typically extending some
> notional basic template called "base.html", some apps expect you to
> provide templates.
>
> In the former case you can pick them up by having
>
> 'django.template.loaders.app_directories.load_template_source'
>
> in your settings.TEMPLATE_LOADERS, in the latter case you can put the
> templates pretty much wherever you want.
>
> regards
>  Steve
> --
> Steve Holden        +1 571 484 6266   +1 800 494 3119
> Holden Web LLC              http://www.holdenweb.com/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Beginner desperately seeking Django experts.

2008-11-16 Thread bruno desthuilliers



On 15 nov, 07:54, Innergy <[EMAIL PROTECTED]> wrote:
> Thanks for reading my question.  I may not be asking all the right
> questions.
>
> I am looking for a fast way to build a ecommerce site with many of the
> qualities of threadless.com.  I was told Django is an excellent
> language

Django is not a language, it's a framework. The language is named
Python. (NB : just like Rails is a framework built on the Ruby
language).

> and allows for rapid fast implementation.
>
> My back ground is not in development. So I am agnostic. I am currently
> leaning towards Ruby for my project.  How does Django compare to
> Ruby?  Is Django faster to develop in? Is it as stable as Ruby?

I assume you mean Rails. But anyway : wrt/ frameworks (Rails vs
Django), both are of equal quality and stability - even if  Django has
IMHO a big plus : the automatic (yet fully customizable) admin
interface. wrt/ languages (Ruby vs Python), both are pretty good
languages, but Python has a somewhat better implementation, and a way
bigger community (mostly because it's older FWIW).




--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



populating database model with form model

2008-11-16 Thread jtobe

Hi, i wasn't sure whether i should ask this here or on the google app
engine list.

I really have two problems. The first is, if i have a form that i
populate choices in a choicefield using entries in the database, it
only updates once. Every time after the first time it just uses the
same vales it found before, even if i go add more items to the
dateabase. I have tried deleting all browser cache.

I have a datastore model (reason for being unsure) that i am trying to
load with information submitted through a django model form. For a
long time, when i would submit the form i would get an error
initialize the datastore model using named arguments in the
constructor. it would say:
'unicode' object has no attribute 'is_saved'

I would send these values using:
form = SearchForm(request.POST)
MyModel(
field_name = form.cleaned_data.get('field_name', 'default'),
bool_field_name = form.cleaned_data.get('bool_field_name', False)
)

I would get this error even if i tried to pass values directly, like:
MyModel(field_name="value", bool_field_name=True)

Lately, though, the page has just been always failing when checking
is_valid() on the form. (always returns False)

I am a fairly novice django user, and a fairly novice app engine user.
I have read the djangobook many times, and i have googled this problem
to death. If anyone has any suggestions or advice or anything that
might help me, please reply. I would greatly appreciate it.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: general problems with installing downloaded django apps

2008-11-16 Thread Steve Holden

webcomm wrote:
> Maybe I'm starting to get the idea... can apps be installed anywhere,
> as long as they are on the python path?  Are there any restrictions at
> all with respect to where apps are installed?

You've got it. There are no restriction (by Django) on where apps are
installed, as long as their base directories end up on sys.path[].

Some apps have their own templates with them (typically extending some
notional basic template called "base.html", some apps expect you to
provide templates.

In the former case you can pick them up by having

'django.template.loaders.app_directories.load_template_source'

in your settings.TEMPLATE_LOADERS, in the latter case you can put the
templates pretty much wherever you want.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using Admin From a Sub-Directory

2008-11-16 Thread Chris Spencer

Ah, thanks. Yeah, I included my baseurl in the admin prefix, and added
/myapp/media/admin to my modwsgi config and now admin looks perfect.

On Sun, Nov 16, 2008 at 12:18 PM, Jeff FW <[EMAIL PROTECTED]> wrote:
>
> You need a trailing slash after /myapp/media/admin.  The final URL
> will then come out to:
> http://localhost/media/admin/css/dashboard.css
>
> -Jeff
>
> On Nov 16, 11:37 am, Chris <[EMAIL PROTECTED]> wrote:
>> I'm trying to setup my app so it's accessible from a /myapp sub-
>> directory. I defined BASEURL = '/myapp' in settings.py, and created a
>> context preprocessor so this variable is available to all templates. I
>> then insert this variable at the beginning of all paths for js/css
>> includes, links, etc.
>>
>> Everything seems to work fine, except for admin, which has broken css
>> links. Admin's css links are using /media/admincss 
>> (e.g.http://localhost/media/admincss/dashboard.css). Is this dervived from
>> ADMIN_MEDIA_PREFIX? I've tried changing this to /myapp/media/admin,
>> but it has no effect, and I just get 404 errors.
>>
>> How do I get admin fully working from a application-wide sub directory?
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: object_create generic view, how to deal with hidden field in my model?

2008-11-16 Thread Eric Veiras Galisson

On Sun, Nov 16, 2008 at 5:30 PM, Eric Veiras Galisson
<[EMAIL PROTECTED]> wrote:
> blablablabla

I'm continuing tests to use obect_create generic view, and changed the
way I call it, using a form class instead of a model class.
So I have created a form which inherits from ModelForm and it works
well (if i exclude fields, they are excluded).

But I have created a save() method for my form class, like I have
allready did in other apps, but this save() method seems to never be
used.
Is it normal? Is object_create supposed to only look at the form
definition and not form custom methods like clean() or save()?
If is this the case, how I can deal with my original problem (fill in
creation_author field)? Do i have to abandon generic views for this
purpose?



-- 
Eric Veiras Galisson
http://www.veiras.info

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ManyToManyField with multiple model options

2008-11-16 Thread Eric Veiras Galisson

Hi,

On Sun, Nov 16, 2008 at 4:13 AM, Malcolm Tredinnick
<[EMAIL PROTECTED]> wrote:

>
> You can't do what you're trying to do in that fashion (using
> ManyToManyField to an abstract base class). Many-to-many and foreign-key
> relations are relations between one table to another table, not to many
> other tables. They model the database's idea of relations. That's why
> they aren't allowed to be declared for abstract models (which aren't
> really models at all).
>
> You could, however, model this using an intermediate table with generic
> relations, which allows links to multiple types of remote models through
> a content-type field. You won't be able to use anything like "through",
> but that's really just a kind of syntactic sugar anyway. You can write
> the same sorts of queries referring to the intermediate model
> explicitly.

As I'm concerned by the same problem (refering by a ForeignKey to an
abstract class) and don't want to make my abstract class concrete, I'm
interested in the solution you talk about.
Can you explain me more what do you think about, I don't really
understand how I can do that?

Thanks in advance.

-- 
Eric Veiras Galisson
http://www.veiras.info

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: general problems with installing downloaded django apps

2008-11-16 Thread webcomm

Maybe I'm starting to get the idea... can apps be installed anywhere,
as long as they are on the python path?  Are there any restrictions at
all with respect to where apps are installed?
-Ryan
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using Admin From a Sub-Directory

2008-11-16 Thread Jeff FW

You need a trailing slash after /myapp/media/admin.  The final URL
will then come out to:
http://localhost/media/admin/css/dashboard.css

-Jeff

On Nov 16, 11:37 am, Chris <[EMAIL PROTECTED]> wrote:
> I'm trying to setup my app so it's accessible from a /myapp sub-
> directory. I defined BASEURL = '/myapp' in settings.py, and created a
> context preprocessor so this variable is available to all templates. I
> then insert this variable at the beginning of all paths for js/css
> includes, links, etc.
>
> Everything seems to work fine, except for admin, which has broken css
> links. Admin's css links are using /media/admincss 
> (e.g.http://localhost/media/admincss/dashboard.css). Is this dervived from
> ADMIN_MEDIA_PREFIX? I've tried changing this to /myapp/media/admin,
> but it has no effect, and I just get 404 errors.
>
> How do I get admin fully working from a application-wide sub directory?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Intercepting return from new ForeignKey popups? (RelatedObjectLookups.js)

2008-11-16 Thread Ben Gerdemann

I've been experimenting with an autocomplete widget for ForeignKey
model fields following the very useful advice from Jannis here:
http://jannisleidel.com/2008/11/autocomplete-form-widget-foreignkey-model-fields/
The basic idea is to create a widget with a hidden text field that
contains the ForeignKey ID that is updated by the results of the
autocomplete field.

I've got everything working correctly except for one problem. When
adding a new foreign key by clicking on the "+" the hidden field is
correctly updated with the primary key of the new object, but the
autocomplete field still shows the previous text which is confusing to
the user. The insertion still works correctly of course as it's the
hidden field that is actually used. Any ideas on how to correct this?
It seems the JavaScript code RelatedObjectLookups.js controls this
behavior, but I can't quite get my head around what to do. I need
someway to intercept the return from the Popup to update fields on my
form.

Cheers,
Ben
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



object_create generic view, how to deal with hidden field in my model?

2008-11-16 Thread Eric Veiras Galisson

Hi django users,

Currently writing an application in Django, I'm trying to use most of
the super-powered tools that Django provide.
One of them is generic views.

Use of object_list and object_detail works well, even with more
complex queries which I implement using a 'wrapper' view.

But now I'm blocked with object_create generic view, and can't find a
way to solve it.

My model is composed of several fields, some of them (creation_author
and creation_datetime) are not showed on the creation form because
they are not supposed to be editable by the application user.
It looks like this (simplified)

class Model(models.Model):
name = models.CharField(max_length=100)
description = models.TextField()
creation_author = models.ForeignKey(User,
related_name='%(class)s_creation_author')
creation_datetime = models.DateTimeField(editable=False)


To fill the creation_datetime field, I have created a save() method
directly in my models.py field and I think it should works.

My problem is with the creation_author field. How can i fill it using
the generic view? Because in my model save() method I have no
conscience of the user logged in, so I can't fill this field there.

ps : I'm not really sure my problem is there, but I think so...

-- 
Eric Veiras Galisson
http://www.veiras.info

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Model Formset Factory

2008-11-16 Thread Stu


When using a modelform on its own, I see that overriding __init__()
enables the customization of generated forms.

Is it possible to customize each of the modelforms (say changing the
widgets on some of the form fields, adding/removing a field, etc.) in
a modelformset when using modelformset_factory?  The same
customization may be applied to all forms in the formset (based on
requesting user perhaps), or to only some of the forms (based on the
initial modelform data or related data). If so, how would you go about
doing 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Using Admin From a Sub-Directory

2008-11-16 Thread Chris

I'm trying to setup my app so it's accessible from a /myapp sub-
directory. I defined BASEURL = '/myapp' in settings.py, and created a
context preprocessor so this variable is available to all templates. I
then insert this variable at the beginning of all paths for js/css
includes, links, etc.

Everything seems to work fine, except for admin, which has broken css
links. Admin's css links are using /media/admincss (e.g.
http://localhost/media/admincss/dashboard.css). Is this dervived from
ADMIN_MEDIA_PREFIX? I've tried changing this to /myapp/media/admin,
but it has no effect, and I just get 404 errors.

How do I get admin fully working from a application-wide sub directory?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how can i get the object comments are attached to after post?

2008-11-16 Thread popufig

Thank you very much, Dave :)

On 11月16日, 下午11时22分, DavidA <[EMAIL PROTECTED]> wrote:
> From a quick scan of the source code, I don't think the object is
> passed into the template, but you can get the related content object
> directly from the comment (which is passed into the template). Just
> use the content_object field of the comment like this:
>
> {{ comment.content_object.slug }}  (or whatever property in the
> related object you want to access)
>
> content_object is a foreign key to the original object so in my case
> it's a blog Post object which has a slug field.
>
> -Dave
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



general problems with installing downloaded django apps

2008-11-16 Thread webcomm

I am fairly new to python and Django.  I have no problem setting up my
own apps by following the tutorial.  However, I *always* have problems
setting up someone else's apps.  I think I've tried installing 5 apps
that I've downloaded from code.google.com and elsewhere, and have been
unsuccessful every time.

I think my problems in some cases have to do with not understanding
how paths work in Django.  The directory structure seems to be pretty
loose.  There don't seem to be conventions about where to put things,
at least none that are spelled out... unless there's some
documentation I'm missing (quite possible!).

I feel like I need some general primer on where to upload things.  For
example, I've been putting my own apps in a directory called
myproject.  I understand that I can call that directory whatever I
want as long as I referenced it the right way in the py files.  But I
would think that I would also put other downloaded apps in that same
directory... but I'm finding (I think) that when I install someone
else's app, it needs to go alongside that directory and not inside
that directory.

I'm hoping that someone reading this will be able to see what the gap
is in my knowledge... what is the concept I'm not understanding here?

Thanks,
Ryan
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django unicode error

2008-11-16 Thread Karen Tracey
On Sun, Nov 16, 2008 at 10:18 AM, jamesM
<[EMAIL PROTECTED]>wrote:

>
> there is a value 'Qué Onda Guero' in a mysql database. When i SELECT
> this row from mysql, it's displayed correctly. When i connect to mysql
> DB through python 2.6 shell using mySQLObject and assign the value to
> a list, the >>list_name[0]  gives 'Qu\xc3\xa9 Onda Guero', and
> >>variable =list_name[0] , >>print variable gives 'Qué Onda Guero' as
> expected. Problems start when i try to access the same data from
> django. Admin web interface represents the data as 'QuÃ(c) Onda Guero'
> and django shell on the attempt to represent this object as a string
> raises http://dpaste.com/hold/91142/ error. Any ideas how to make
> unicode characters to appear correctly in django ecosystem? Model has
> def __unicode__(self): function set, which works great except when
> encounters non-ascii character. According to docs, __unicode__(self),
> with help from above, should help avoiding such errors. In my case, i
> guess, the help from above is not influential enough :( Thanks in
> advance for any ideas or guidance.
>
>
Please tell us:

1 - What is the output from 'show create table' in a mysql command prompt
for the table containing this data.
2 - Exactly what does your model's __unicode__ method look like?
3 - When you say "When i SELECT this row from mysql, it's displayed
correctly" what do you mean exactly?  If you mean when you SELECT in a mysql
shell, what OS is the shell running on?

Karen

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how can i get the object comments are attached to after post?

2008-11-16 Thread DavidA

>From a quick scan of the source code, I don't think the object is
passed into the template, but you can get the related content object
directly from the comment (which is passed into the template). Just
use the content_object field of the comment like this:

{{ comment.content_object.slug }}  (or whatever property in the
related object you want to access)

content_object is a foreign key to the original object so in my case
it's a blog Post object which has a slug field.

-Dave

On Nov 16, 8:00 am, popufig <[EMAIL PROTECTED]> wrote:
> Hi everyone,
>
>     i am now using Django’s comments framework,  accoring to the book
> , after end user post the
> comment, we can create our own template comments/posted.html, and this
> template has a variable called object that refers to the object that
> received the comment. But i cannot get this object in the template, i
> am not sure it's old version feature or not.
>
> Any help and hints are appreciated!
>
> Thanks,
> Sky
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



django unicode error

2008-11-16 Thread jamesM

there is a value 'Qué Onda Guero' in a mysql database. When i SELECT
this row from mysql, it's displayed correctly. When i connect to mysql
DB through python 2.6 shell using mySQLObject and assign the value to
a list, the >>list_name[0]  gives 'Qu\xc3\xa9 Onda Guero', and
>>variable =list_name[0] , >>print variable gives 'Qué Onda Guero' as
expected. Problems start when i try to access the same data from
django. Admin web interface represents the data as 'Qué Onda Guero'
and django shell on the attempt to represent this object as a string
raises http://dpaste.com/hold/91142/ error. Any ideas how to make
unicode characters to appear correctly in django ecosystem? Model has
def __unicode__(self): function set, which works great except when
encounters non-ascii character. According to docs, __unicode__(self),
with help from above, should help avoiding such errors. In my case, i
guess, the help from above is not influential enough :( Thanks in
advance for any ideas or guidance.

Best,
J

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Date Field question -

2008-11-16 Thread Mahesh Vaidya

Hi,
I am going to used "DateField" in my model. Which format does date
field user is it DD/MM/ (European) or MM/DD/ (American) style
?  and is it customizable ?

Thank You in advance
-Mahesh

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: POP before SMTP authentication in Django while avoiding that the server mail goes to users' spam folder

2008-11-16 Thread Srdjan Popovic

Thanks for your reply. I have just tried to send one message through
Python script and the other from Outlook to my GMX account and here
are the headers:

FROM PYTHON (CONSIDERED SPAM):

Return-Path: <[EMAIL PROTECTED]>
X-Flags: 
Delivered-To: GMX delivery to [EMAIL PROTECTED]
Received: (qmail invoked by alias); 16 Nov 2008 13:29:24 -
Received: from new.bortolete-popovic.com (EHLO new.bortolete-
popovic.com) [69.89.12.241]
  by mx0.gmx.net (mx096) with SMTP; 16 Nov 2008 14:29:24 +0100
Received-SPF: pass (new.bortolete-popovic.com: domain of
[EMAIL PROTECTED] designates 69.89.12.241 as permitted sender)
receiver=new.bortolete-popovic.com; client-ip=69.89.12.241;
helo=new.bortolete-popovic.com; envelope-
[EMAIL PROTECTED]; x-software=spfmilter 0.97
http://www.acme.com/software/spfmilter/ with libspf2-1.0.0;
Received: from new.bortolete-popovic.com (new.bortolete-popovic.com
[69.89.12.241])
by new.bortolete-popovic.com (8.14.2/8.13.8) with ESMTP id
mAGDEcxK028170
for <[EMAIL PROTECTED]>; Sun, 16 Nov 2008 08:14:38 -0500
Date: Sun, 16 Nov 2008 08:14:38 -0500
Message-Id: <[EMAIL PROTECTED]>
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Your Registration at Darela.com

FROM OUTLOOK (NOT CONSIDERED AS SPAM - WORKS FINE):

Return-Path: <[EMAIL PROTECTED]>
X-Flags: 
Delivered-To: GMX delivery to [EMAIL PROTECTED]
Received: (qmail invoked by alias); 16 Nov 2008 13:32:31 -
Received: from new.bortolete-popovic.com (EHLO new.bortolete-
popovic.com) [69.89.12.241]
  by mx0.gmx.net (mx072) with SMTP; 16 Nov 2008 14:32:31 +0100
Received-SPF: softfail (new.bortolete-popovic.com: domain of
transitioning [EMAIL PROTECTED] does not designate
201.88.34.171 as permitted sender) receiver=new.bortolete-popovic.com;
client-ip=201.88.34.171; helo=p380; envelope-
[EMAIL PROTECTED]; x-software=spfmilter 0.97
http://www.acme.com/software/spfmilter/ with libspf2-1.0.0;
Received: from p380 (201-88-34-171.bsace702.dsl.brasiltelecom.net.br
[201.88.34.171])
by new.bortolete-popovic.com (8.14.2/8.13.8) with ESMTP id
mAGDHhqs003643
for <[EMAIL PROTECTED]>; Sun, 16 Nov 2008 08:17:44 -0500
From: "Darela Site Administration" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Subject: Your Registration at Darela.com
Date: Sun, 16 Nov 2008 11:31:50 -0200
Message-ID: <[EMAIL PROTECTED]>
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="=_NextPart_000_0004_01C947DE.ECF4D570"
X-Mailer: Microsoft Office Outlook 12.0
Thread-Index: AclH765BeRGdnjCoQiK+0dJCnOfEOw==
Content-Language: en-us

The have the same date/timestamps.

It is weird to see that the one that arrived had Received-SPF:
softfail, while the one blocked had Received-SPF: pass. My VPS on
CentOS is new.bortolete-popovic.com and I have several domains sharing
the same IP (69.89.12.241) but that should not be the problem as it is
the same in both cases.

So I am still confused...

Regards, Srdjan


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: POP before SMTP authentication in Django while avoiding that the server mail goes to users' spam folder

2008-11-16 Thread Kenneth Gonsalves

On Sunday 16 November 2008 06:26:18 pm Srdjan Popovic wrote:
> def send_mail(subject='', text='', sender='', to=''):
>     M = poplib.POP3(settings.EMAIL_HOST)
>     M.user(settings.EMAIL_HOST_USER)
>     M.pass_(settings.EMAIL_HOST_PASSWORD)
>     headers = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (sender,
> to, subject)
>     message = headers + text
>     mailServer = smtplib.SMTP(settings.EMAIL_HOST)
>     mailServer.sendmail(sender, to, message)
>     mailServer.quit()

i was using something similar in a python (not django) programme, and found on 
reception that the date of post section was missing - kmail has a field 
called 'Order of arrival' and this was not there in the mails. Could be that 
you have to put some date/timestamp?

-- 
regards
KG
http://lawgon.livejournal.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



POP before SMTP authentication in Django while avoiding that the server mail goes to users' spam folder

2008-11-16 Thread Srdjan Popovic

I have recently started a new Django website, www.darela.com, and I
have some problems with sending automatic mails.

This is a community website, where consultants, contractors and other
specialists can present themselves, publish their profiles and
describe their skills and experience, publish technical articles,
discuss news, participate in discussion boards etc.

During registration, users recieve token-based email confirmation and
are asked to verify their accounts. There is also an internal
messaging systems (between users) where messages are forwarded to
users email address, and several other cases where email are sent
automatically by the server.

Registration confirmation mails, for example, are sent from
[EMAIL PROTECTED], however, they almost invariably go directly
to user's spam folder. I know that there are many reasons why a
legitimate message can be considered spam, including the content,
discrepancy with reverse DNS, blacklists etc... However, if I
configure Outlook to use this address ([EMAIL PROTECTED]) and
send an identical message to the same user, it will go through to
user's mailbox and will not get to spam folder - even when users have
Yahoo or Hotmail account.

I am sending these messages using smtplib. I am not using Django's
send_mail because my mail server requires POP before SMTP
authentication - and I am not aware of how to have this in Django - so
I am using a modified version:

def send_mail(subject='', text='', sender='', to=''):
M = poplib.POP3(settings.EMAIL_HOST)
M.user(settings.EMAIL_HOST_USER)
M.pass_(settings.EMAIL_HOST_PASSWORD)
headers = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (sender,
to, subject)
message = headers + text
mailServer = smtplib.SMTP(settings.EMAIL_HOST)
mailServer.sendmail(sender, to, message)
mailServer.quit()

Before I start trying to insert the same headers as in Outlook, I was
wondering if someone had a similar problem before? Does anyone know
another way to achieve pop-before-smtp with Django? Or what else can I
do to avoid these messages ending up in spam folders? Any ideas?

Many thanks for your help.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Post/redirect/get pattern for file upload with confirmation

2008-11-16 Thread [EMAIL PROTECTED]

Accidentally posted the first reply and you already beat me to my
actual reply, wow. The "not feeling right" part meant to imply that
the disadvantages I could see for both made me wonder if there wasn't
another (and better) option available, but based on your answer it
seems that won't happen anytime soon.


On Nov 16, 1:51 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi Malcolm,
> thanks for the fast reply.
>
> What is the downside of sticking this kind of information into a
> session, just that the session backend needs to carry this amount of
> information around and cookies have to be enabled for it to work? I
> otherwise would prefer it over (2) just for the cleaner URL.
>
> Thanks
> Stefan
>
> On Nov 16, 1:16 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
> wrote:
>
> > On Sun, 2008-11-16 at 12:58 +0100, Stefan Wallner wrote:
>
> > p,,,[
>
> > > My basic idea would be to use the same URL and view/template for  
> > > getting the directory listing and posting a file for uploading to it.  
> > > If a file is uploaded successfully the renamed file name and the users  
> > > that received the email should be listed in a notification part of the  
> > > template (i.e. ...) which confirms to the user  
> > > that everything is ok.
>
> > > Now I am stuck on how to best do this. POST/REDIRECT/GET does not seem  
> > > to fit here, since HttpResponseRedirect cannot pass any parameters to  
> > > a template and redirecting to the same URL does not make sense anyway.  
> > > What other pattern could/should I use?
>
> > I suspect you're actually asking the wrong question. The question isn't
> > "where should I redirect to?", but rather "how can I tell when loading
> > the file listing page, after a GET request, that some extra information
> > about the renamed file and notified people should be displayed?". It
> > doesn't matter what URL you actually retrieve after the file is
> > uploaded, that question still remains -- how to tell that you need to
> > display that information.
>
> > Once you've solved that problem, redirecting the the normal file listing
> > page is quite a natural place to go, since it shows the file listing
> > (plus this extra information sometimes), but that's really a side-issue.
>
> > You have at least a couple of choices:
>
> > (1) Use sessions and store the fact that a file was just uploaded (and
> > renamed) and the list of people notified in a key in the session. When
> > the user accesses the directory listing page using GET and if they have
> > that session key, display the extra information and then remove it from
> > the session (so it's displayed only once). Or possibly you want to keep
> > it in the session for a period of time or something. In any case, you
> > can use the session.
>
> > (2) The more HTTP/REST-like approach is to come up with a unique
> > identifier for the page that displays the newly uploaded information.
> > This identifier tells you (the webserver side of the code) that you need
> > to display the new filename and list of notified people. One way to do
> > this is to add a parameter to the GET request that is, say, the primary
> > key (or some other token) of the newly uploaded file. Then, when you are
> > processing that page, if the querystring contains that parameter, you
> > retrieve the new filename and the list of people who would have been
> > notified from the database.
>
> > The second way uses the fact that you can attach a querystring to a URL
> > and that's quite valid for an HTTP redirect. It's also probably not that
> > hard to implement, providing you can easily determine from the id of the
> > file who the recipients were. The slight drawback is that anybody who
> > knows that URL can view the same information. Maybe that's not a
> > problem. If it is, you can use access checking (e.g. the special display
> > information is only presented if the currently logged in user is the
> > person who uploaded the file with that id).
>
> > Thus the 'normal' view is, say, /foo/file_listing/ and the target after
> > an upload is, say, /foo/file_listing/?upload=123.
>
> > The first of these two choices is pretty fast to implement, but puts
> > information in the session, which you may or may not like doing. The
> > second is more "natural" in a way, but you have to do some work to
> > process the incoming optional querystring. It's still not particularly
> > hard, though.
>
> > Regards,
> > Malcolm
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



[django1.0+comment framewok ]how can i get the object comments are attached to after post?

2008-11-16 Thread popufig

Hi everyone,

i am now using Django’s comments framework,  accoring to the book
, after end user post the
comment, we can create our own template comments/posted.html, and this
template has a variable called object that refers to the object that
received the comment. But i cannot get this object in the template, i
am not sure it's old version feature or not.

Any help and hints are appreciated!

Thanks,
Sky

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Caching and I18n

2008-11-16 Thread [EMAIL PROTECTED]

Hello everyone,

I'm trying to implement caching for my bilingual site. The problem is
that once I enable caching and I change the language (via the example
code in 
http://docs.djangoproject.com/en/dev/topics/i18n/?from=olddocs#the-set-language-redirect-view
), the page does not change. The Content-Language header that the
browser receives is indeed changed accordingly, but apparently the
caching system is not aware of the change.
I've set up my middleware as follows:

MIDDLEWARE_CLASSES = (
'django.middleware.cache.UpdateCacheMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', # muss vor
auth
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
)

I also tried per-site caching (disabling caching in the middleware),
but did get the same results, even when I specified vary_on_headers
('Content-Language','Accept-Language').

I have found a snippet (http://www.djangosnippets.org/snippets/443/)
that might work, but I'm reluctant to use this hack and also rely on
the deprecated CacheMiddleware.

Any help and hints are appreciated!

Thanks,
Maik

PS. relevant settings.py excerpt:
CACHE_BACKEND = 'locmem:///'
CACHE_MIDDLEWARE_SECONDS = 300
CACHE_MIDDLEWARE_KEY_PREFIX = ''
CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Post/redirect/get pattern for file upload with confirmation

2008-11-16 Thread [EMAIL PROTECTED]

Hi Malcolm,
thanks for the fast reply.

What is the downside of sticking this kind of information into a
session, just that the session backend needs to carry this amount of
information around and cookies have to be enabled for it to work? I
otherwise would prefer it over (2) just for the cleaner URL.

Thanks
Stefan




On Nov 16, 1:16 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2008-11-16 at 12:58 +0100, Stefan Wallner wrote:
>
> p,,,[
>
> > My basic idea would be to use the same URL and view/template for  
> > getting the directory listing and posting a file for uploading to it.  
> > If a file is uploaded successfully the renamed file name and the users  
> > that received the email should be listed in a notification part of the  
> > template (i.e. ...) which confirms to the user  
> > that everything is ok.
>
> > Now I am stuck on how to best do this. POST/REDIRECT/GET does not seem  
> > to fit here, since HttpResponseRedirect cannot pass any parameters to  
> > a template and redirecting to the same URL does not make sense anyway.  
> > What other pattern could/should I use?
>
> I suspect you're actually asking the wrong question. The question isn't
> "where should I redirect to?", but rather "how can I tell when loading
> the file listing page, after a GET request, that some extra information
> about the renamed file and notified people should be displayed?". It
> doesn't matter what URL you actually retrieve after the file is
> uploaded, that question still remains -- how to tell that you need to
> display that information.
>
> Once you've solved that problem, redirecting the the normal file listing
> page is quite a natural place to go, since it shows the file listing
> (plus this extra information sometimes), but that's really a side-issue.
>
> You have at least a couple of choices:
>
> (1) Use sessions and store the fact that a file was just uploaded (and
> renamed) and the list of people notified in a key in the session. When
> the user accesses the directory listing page using GET and if they have
> that session key, display the extra information and then remove it from
> the session (so it's displayed only once). Or possibly you want to keep
> it in the session for a period of time or something. In any case, you
> can use the session.
>
> (2) The more HTTP/REST-like approach is to come up with a unique
> identifier for the page that displays the newly uploaded information.
> This identifier tells you (the webserver side of the code) that you need
> to display the new filename and list of notified people. One way to do
> this is to add a parameter to the GET request that is, say, the primary
> key (or some other token) of the newly uploaded file. Then, when you are
> processing that page, if the querystring contains that parameter, you
> retrieve the new filename and the list of people who would have been
> notified from the database.
>
> The second way uses the fact that you can attach a querystring to a URL
> and that's quite valid for an HTTP redirect. It's also probably not that
> hard to implement, providing you can easily determine from the id of the
> file who the recipients were. The slight drawback is that anybody who
> knows that URL can view the same information. Maybe that's not a
> problem. If it is, you can use access checking (e.g. the special display
> information is only presented if the currently logged in user is the
> person who uploaded the file with that id).
>
> Thus the 'normal' view is, say, /foo/file_listing/ and the target after
> an upload is, say, /foo/file_listing/?upload=123.
>
> The first of these two choices is pretty fast to implement, but puts
> information in the session, which you may or may not like doing. The
> second is more "natural" in a way, but you have to do some work to
> process the incoming optional querystring. It's still not particularly
> hard, though.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Post/redirect/get pattern for file upload with confirmation

2008-11-16 Thread Malcolm Tredinnick


On Sun, 2008-11-16 at 04:39 -0800, [EMAIL PROTECTED] wrote:
> Hi Malcolm,
> thanks for the fast response. I had thought about both approaches, but
> both didn't feel 100% right (more a gut feeling than anything).

Then you're going to have provide more information about what would
"feel right", since both those approaches are technically valid and
common to boot. The second one is basically the canonical way to do it
for the REST style of architecture. The exact form of the URL is a
design issue -- it doesn't have to use a querystring, after all -- but
the naming of a resource to do conditional data display is standard.

Since you've nixed the two standard ways to do this, aren't you rapidly
running out of choices? You don't want to store the information in the
session (which is the only really transient way to move data between
requests that doesn't go via the URL) and you don't want to create a new
identifiable URL for the new resource. It seems like we're reduced to
using The Force to convey the information at that point. That's not
supported in Python yet.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Post/redirect/get pattern for file upload with confirmation

2008-11-16 Thread [EMAIL PROTECTED]

Hi Malcolm,
thanks for the fast response. I had thought about both approaches, but
both didn't feel 100% right (more a gut feeling than anything).



On Nov 16, 1:16 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2008-11-16 at 12:58 +0100, Stefan Wallner wrote:
>
> p,,,[
>
> > My basic idea would be to use the same URL and view/template for  
> > getting the directory listing and posting a file for uploading to it.  
> > If a file is uploaded successfully the renamed file name and the users  
> > that received the email should be listed in a notification part of the  
> > template (i.e. ...) which confirms to the user  
> > that everything is ok.
>
> > Now I am stuck on how to best do this. POST/REDIRECT/GET does not seem  
> > to fit here, since HttpResponseRedirect cannot pass any parameters to  
> > a template and redirecting to the same URL does not make sense anyway.  
> > What other pattern could/should I use?
>
> I suspect you're actually asking the wrong question. The question isn't
> "where should I redirect to?", but rather "how can I tell when loading
> the file listing page, after a GET request, that some extra information
> about the renamed file and notified people should be displayed?". It
> doesn't matter what URL you actually retrieve after the file is
> uploaded, that question still remains -- how to tell that you need to
> display that information.
>
> Once you've solved that problem, redirecting the the normal file listing
> page is quite a natural place to go, since it shows the file listing
> (plus this extra information sometimes), but that's really a side-issue.
>
> You have at least a couple of choices:
>
> (1) Use sessions and store the fact that a file was just uploaded (and
> renamed) and the list of people notified in a key in the session. When
> the user accesses the directory listing page using GET and if they have
> that session key, display the extra information and then remove it from
> the session (so it's displayed only once). Or possibly you want to keep
> it in the session for a period of time or something. In any case, you
> can use the session.
>
> (2) The more HTTP/REST-like approach is to come up with a unique
> identifier for the page that displays the newly uploaded information.
> This identifier tells you (the webserver side of the code) that you need
> to display the new filename and list of notified people. One way to do
> this is to add a parameter to the GET request that is, say, the primary
> key (or some other token) of the newly uploaded file. Then, when you are
> processing that page, if the querystring contains that parameter, you
> retrieve the new filename and the list of people who would have been
> notified from the database.
>
> The second way uses the fact that you can attach a querystring to a URL
> and that's quite valid for an HTTP redirect. It's also probably not that
> hard to implement, providing you can easily determine from the id of the
> file who the recipients were. The slight drawback is that anybody who
> knows that URL can view the same information. Maybe that's not a
> problem. If it is, you can use access checking (e.g. the special display
> information is only presented if the currently logged in user is the
> person who uploaded the file with that id).
>
> Thus the 'normal' view is, say, /foo/file_listing/ and the target after
> an upload is, say, /foo/file_listing/?upload=123.
>
> The first of these two choices is pretty fast to implement, but puts
> information in the session, which you may or may not like doing. The
> second is more "natural" in a way, but you have to do some work to
> process the incoming optional querystring. It's still not particularly
> hard, though.
>
> Regards,
> Malcolm

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Post/redirect/get pattern for file upload with confirmation

2008-11-16 Thread Malcolm Tredinnick


On Sun, 2008-11-16 at 12:58 +0100, Stefan Wallner wrote:
p,,,[
> My basic idea would be to use the same URL and view/template for  
> getting the directory listing and posting a file for uploading to it.  
> If a file is uploaded successfully the renamed file name and the users  
> that received the email should be listed in a notification part of the  
> template (i.e. ...) which confirms to the user  
> that everything is ok.
> 
> Now I am stuck on how to best do this. POST/REDIRECT/GET does not seem  
> to fit here, since HttpResponseRedirect cannot pass any parameters to  
> a template and redirecting to the same URL does not make sense anyway.  
> What other pattern could/should I use?

I suspect you're actually asking the wrong question. The question isn't
"where should I redirect to?", but rather "how can I tell when loading
the file listing page, after a GET request, that some extra information
about the renamed file and notified people should be displayed?". It
doesn't matter what URL you actually retrieve after the file is
uploaded, that question still remains -- how to tell that you need to
display that information.

Once you've solved that problem, redirecting the the normal file listing
page is quite a natural place to go, since it shows the file listing
(plus this extra information sometimes), but that's really a side-issue.

You have at least a couple of choices:

(1) Use sessions and store the fact that a file was just uploaded (and
renamed) and the list of people notified in a key in the session. When
the user accesses the directory listing page using GET and if they have
that session key, display the extra information and then remove it from
the session (so it's displayed only once). Or possibly you want to keep
it in the session for a period of time or something. In any case, you
can use the session.

(2) The more HTTP/REST-like approach is to come up with a unique
identifier for the page that displays the newly uploaded information.
This identifier tells you (the webserver side of the code) that you need
to display the new filename and list of notified people. One way to do
this is to add a parameter to the GET request that is, say, the primary
key (or some other token) of the newly uploaded file. Then, when you are
processing that page, if the querystring contains that parameter, you
retrieve the new filename and the list of people who would have been
notified from the database.

The second way uses the fact that you can attach a querystring to a URL
and that's quite valid for an HTTP redirect. It's also probably not that
hard to implement, providing you can easily determine from the id of the
file who the recipients were. The slight drawback is that anybody who
knows that URL can view the same information. Maybe that's not a
problem. If it is, you can use access checking (e.g. the special display
information is only presented if the currently logged in user is the
person who uploaded the file with that id).

Thus the 'normal' view is, say, /foo/file_listing/ and the target after
an upload is, say, /foo/file_listing/?upload=123.

The first of these two choices is pretty fast to implement, but puts
information in the session, which you may or may not like doing. The
second is more "natural" in a way, but you have to do some work to
process the incoming optional querystring. It's still not particularly
hard, though.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Post/redirect/get pattern for file upload with confirmation

2008-11-16 Thread Stefan Wallner

Hi,
I am confused on how to best use the post/redirect/get pattern for the  
following problem:

Part of the application I am writing is a basic file manager, i.e. it  
lists directory contents to users and lets users download files or  
upload a file to the directory. Upon upload the file is renamed (to  
include date and user) and then saved to disk, users that need to be  
informed receive an email that a new file was uploaded.

My basic idea would be to use the same URL and view/template for  
getting the directory listing and posting a file for uploading to it.  
If a file is uploaded successfully the renamed file name and the users  
that received the email should be listed in a notification part of the  
template (i.e. ...) which confirms to the user  
that everything is ok.

Now I am stuck on how to best do this. POST/REDIRECT/GET does not seem  
to fit here, since HttpResponseRedirect cannot pass any parameters to  
a template and redirecting to the same URL does not make sense anyway.  
What other pattern could/should I use?

Right now I am just doing a render_to_response with the same template,  
regardless of whether it is a first GET of the page or the POST for  
the file upload. Of course this means once a file was uploaded and the  
notification is displayed any refresh of the will give you a browser  
warning about resending data which I would like to avoid.

Any suggestions?


Thanks
Stefan



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to create a form with dynamic number of fields?

2008-11-16 Thread Low Kian Seong

Thanks Ryan for the reply. Another idea that came to me is  can we
make an input like a list?
as in  wrote:
>
> I've recently had a situation where I needed to create dynamic forms
> and corresponding code to handle them.
>
> One thing that you should know about python is that there's nothing
> special about classes, you can take a collection of attributes and
> methods and use them to create a new class on-the-fly using python's
> type() function. You can use this to dynamically build a form class
> with a new field.
>
> My roommate wrote a great blog post on how to do build classes
> dynamically (http://askawizard.blogspot.com/2008/09/metaclasses-python-
> saga-part-4_30.html), which you should read before attempting this.
>
> Once you understand what that is talking about (or not), you end up
> writing some code like this:
>
> If you want this form to be dynamic:
>
> class MyDynamicForm(Form):
>foo = CharField(max_len = 100)
>bar = IntegerField()
>def clean_foo(self):
>value = self.cleaned_data['foo']
>if value != 'foo':
>raise ValidationError('foo is not foo!')
>def clean_bar(self):
>value = self.cleaned_data['bar']
>if value != 42:
>raise ValidationError('wrong answer')
>
> You could build it programatically with:
>
> # Our base classes (which you could build programatically if you
> wanted)
> bases  = (Form,)
>
> # Our class attributes
> attys  = {
>'foo' : CharField(max_len = 100),
>'bar' : IntegerField(),
> }
>
> # This returns a clean method built from some parameters
> def general_clean(name, correct_value, error_text):
>def inner(self):
>value = self.cleaned_data[name]
>if value != correct_value:
>raise ValidationError(error_text)
>return inner
>
> # Now add the clean methods. You could just define methods and assign,
> but this illustrates generating them programatically.
> for name, correct_value, error_text in (
>('foo', 'foo', 'foo is not foo!'),
>('bar', 42, 'wrong answer'),
> ):
>attys['clean_' + name] = general_clean(name, correct_value,
> error_text)
>
> # Now, to create the dynamic class, you need the following
> incantation:
> DynamicForm = getattr(Form, '__metaclass__', type)('DynamicForm',
> bases, attys)
>
> # That only creates the *class*, we still have to create an instance
> form = DynamicForm({'foo': 'foo', 'bar': 42})
>
> Does this help? It would let you dynamically add elements and handlers
> to the form that django is aware of, thus you get all the benefits of
> using the form framework. Let me know if this is a bit thick and I'll
> be happy to explain it and perhaps blog a more coherent example.
>
> --Ryan
>
>
>
> >
>



-- 
Low Kian Seong
blog: http://lowkster.blogspot.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to create a form with dynamic number of fields?

2008-11-16 Thread Ryan Witt

I've recently had a situation where I needed to create dynamic forms
and corresponding code to handle them.

One thing that you should know about python is that there's nothing
special about classes, you can take a collection of attributes and
methods and use them to create a new class on-the-fly using python's
type() function. You can use this to dynamically build a form class
with a new field.

My roommate wrote a great blog post on how to do build classes
dynamically (http://askawizard.blogspot.com/2008/09/metaclasses-python-
saga-part-4_30.html), which you should read before attempting this.

Once you understand what that is talking about (or not), you end up
writing some code like this:

If you want this form to be dynamic:

class MyDynamicForm(Form):
foo = CharField(max_len = 100)
bar = IntegerField()
def clean_foo(self):
value = self.cleaned_data['foo']
if value != 'foo':
raise ValidationError('foo is not foo!')
def clean_bar(self):
value = self.cleaned_data['bar']
if value != 42:
raise ValidationError('wrong answer')

You could build it programatically with:

# Our base classes (which you could build programatically if you
wanted)
bases  = (Form,)

# Our class attributes
attys  = {
'foo' : CharField(max_len = 100),
'bar' : IntegerField(),
}

# This returns a clean method built from some parameters
def general_clean(name, correct_value, error_text):
def inner(self):
value = self.cleaned_data[name]
if value != correct_value:
raise ValidationError(error_text)
return inner

# Now add the clean methods. You could just define methods and assign,
but this illustrates generating them programatically.
for name, correct_value, error_text in (
('foo', 'foo', 'foo is not foo!'),
('bar', 42, 'wrong answer'),
):
attys['clean_' + name] = general_clean(name, correct_value,
error_text)

# Now, to create the dynamic class, you need the following
incantation:
DynamicForm = getattr(Form, '__metaclass__', type)('DynamicForm',
bases, attys)

# That only creates the *class*, we still have to create an instance
form = DynamicForm({'foo': 'foo', 'bar': 42})

Does this help? It would let you dynamically add elements and handlers
to the form that django is aware of, thus you get all the benefits of
using the form framework. Let me know if this is a bit thick and I'll
be happy to explain it and perhaps blog a more coherent example.

--Ryan




--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to create a form with dynamic number of fields?

2008-11-16 Thread Ryan Witt

I've recently had a situation where I needed to create dynamic forms
and corresponding code to handle them.

One thing that you should know about python is that there's nothing
special about classes, you can take a collection of attributes and
methods and use them to create a new class on-the-fly using python's
type() function. You can use this to dynamically build a form class
with a new field.

My roommate wrote a great blog post on how to do build classes
dynamically (http://askawizard.blogspot.com/2008/09/metaclasses-python-
saga-part-4_30.html), which you should read before attempting this.

Once you understand what that is talking about (or not), you end up
writing some code like this:

If you want this form to be dynamic:

class MyDynamicForm(Form):
foo = CharField(max_len = 100)
bar = IntegerField()
def clean_foo(self):
value = self.cleaned_data['foo']
if value != 'foo':
raise ValidationError('foo is not foo!')
def clean_bar(self):
value = self.cleaned_data['bar']
if value != 42:
raise ValidationError('wrong answer')

You could build it programatically with:

# Our base classes (which you could build programatically if you
wanted)
bases  = (Form,)

# Our class attributes
attys  = {
'foo' : CharField(max_len = 100),
'bar' : IntegerField(),
}

# This returns a clean method built from some parameters
def general_clean(name, correct_value, error_text):
def inner(self):
value = self.cleaned_data[name]
if value != correct_value:
raise ValidationError(error_text)
return inner

# Now add the clean methods. You could just define methods and assign,
but this illustrates generating them programatically.
for name, correct_value, error_text in (
('foo', 'foo', 'foo is not foo!'),
('bar', 42, 'wrong answer'),
):
attys['clean_' + name] = general_clean(name, correct_value,
error_text)

# Now, to create the dynamic class, you need the following
incantation:
DynamicForm = getattr(Form, '__metaclass__', type)('DynamicForm',
bases, attys)

# That only creates the *class*, we still have to create an instance
form = DynamicForm({'foo': 'foo', 'bar': 42})

Does this help? It would let you dynamically add elements and handlers
to the form that django is aware of, thus you get all the benefits of
using the form framework. Let me know if this is a bit thick and I'll
be happy to explain it and perhaps blog a more coherent example.

--Ryan



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---