Re: webfaction django installation

2008-11-01 Thread Benn

This article really helped. For all those django and webfaction
newbies out there: this article is a must read. Worked perfect!

Ben

On Sep 21, 1:26 am, tupixo <[EMAIL PROTECTED]> wrote:
> > I had also similar problems, because instead of documentation they have a
> > screencast(?!) and the forum.
>
> Did you at least spend 30 seconds looking for docs before writing
> that?
> They have a Django category in their knowledge base with quite a few
> articles:https://help.webfaction.com/index.php?_m=knowledgebase&_a=view...
> (btw, that link is included in their welcome e-mail).
>
> The "Getting started with Django at WebFaction" article should solve
> Bobby's 
> problem:https://help.webfaction.com/index.php?_m=knowledgebase&_a=viewarticle...
>
> Kevin.

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



sharing a module level variable

2008-11-01 Thread belred

i have an wget event in a cron job.  the view does some processing
which involves calling external websites and databases (takes about 25
seconds) and updates some module level dictionary lookup variables
(about 7 MB of data) which the rest of the program reads.  but
unfortunately, only the one apache child process seems to be updated,
not all the others.  how can i share this module level variable across
processes?  this lookup happens multiple times per  request.  but the
internal data gets updated nightly.

thanks,

bryan
--~--~-~--~~~---~--~~
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 signals

2008-11-01 Thread belred

i'm having touble finding documention about django signals that
explain how they behave under apache child processes. if i have a
signal go off and have a listener for that signal. will only the
listener in same child process receive it or will that same listener
in all apache child processes receive it?

what is the best way to signal all of your apache child process for
you project?

thanks,

bryan
--~--~-~--~~~---~--~~
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: Dojango question

2008-11-01 Thread Rob Goedman

Wolfram,

You bet I've read your blogs! Wouldn't have gotten where I got to  
without them!

Clearly I had missed the to_dojo_data(), that's exactly what I was  
looking for.

This works super.

Thanks a lot,
Rob

On Nov 1, 2008, at 4:45 PM, Wolfram Kriesing wrote:

>
> Hi Rob,
>
> aehm, maybe what you were looking for was this:
>
> @json_response
> def send_toxids_list(request):
>ret = Toxid.objects.all()
>return to_dojo_data(ret, identifier='docno')
>
> the json_response decorator takes care of extrcting only the
> fields form the model, you dont have to do this
> by hand. And the to_dojo_data() function converts the
> data into a dojo.data store compatible format.
>
> See also this blog post about more info
> about the json_response decorator/function
> and insight details.
> http://wolfram.kriesing.de/blog/index.php/2007/json-serialization-for-django
>
>
> -- 
> cu
>
> Wolfram
>
> http://uxebu.com - the AJAX experts
> You need AJAX, RIA, JavaScript and all this modern stuff? We got it!


> On Nov 1, 2008, at 4:34 PM, Wolfram Kriesing wrote:
>>
>> Hi Rob,
>>
>> did you see the blog article
>> http://blog.uxebu.com/2008/07/26/ajax-with-dojango/
>> and the examples in
>> http://code.google.com/p/dojango/source/browse/trunk/dojango/views.py
>>
>> tbh I don't really understand what you are using the JSON  
>> serializer for.
>> Could you may be explain, if the links above dont help?
>>
>> -- 
>> cu
>>
>> Wolfram
>>
>> http://uxebu.com - the AJAX experts
>> You need AJAX, RIA, JavaScript and all this modern stuff? We got it!


>> On Sat, Nov 1, 2008 at 11:31 PM, Rob Goedman <[EMAIL PROTECTED]> wrote:
>>
>> Hi,
>>
>> Just for Django & Dojo users.
>>
>> Working through the 'Mastering Dojo' book, updating the examples  
>> where
>> applicable to Dojo 1.2 (i.e. grids) and making them work with Django
>> svn has gone pretty smoothly. I wonder if below method is a  
>> reasonable
>> way to generate fairly generic xhr* responses?
>>
>> I use something like (e.g. from the dojo.data chapter on
>> QueryReadStore):
>>
>> @json_response
>> def send_toxids_list(request):
>>   """
>>   Creates a JSON/Dojo hash with the filtered contents
>>   for a grid. This method is called by Dojo xhr*.
>>
>>   To do:
>>
>>   1)  Change ...all() into ...filter()  
>> according to qDict info.
>>
>>   """
>>
>>   qDict = request.GET
>>   print qDict['user'], qDict.get('query', None)
>>
>>   queryset = Toxid.objects.all()
>>   json_serializer = serializers.get_serializer("json")()
>>   toxids_json = json_serializer.serialize(queryset,  
>> ensure_ascii=True)
>>   t = eval(toxids_json)
>>   a = []
>>   for i in t: a.append(i['fields'])
>>   ret = {
>>   "identifier": "docno",
>>   "label": "substance",
>>   "items": a,
>>   }
>>   return ret
>>
>> It seems a frequently recurring pattern in my views, so I would like
>> to do it right and efficient. Particularly the 'eval' step feels  
>> weird.
>>
>> I did have a look at dojox.dtl (Django Templating Language) but
>> haven't (yet?) figured out if that is applicable for this.
>>
>> Thanks,
>> Rob
>>
>>
>>
>>>
>>
>
> >


--~--~-~--~~~---~--~~
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: Dojango question

2008-11-01 Thread Wolfram Kriesing

Hi Rob,

aehm, maybe what you were looking for was this:

@json_response
def send_toxids_list(request):
ret = Toxid.objects.all()
return to_dojo_data(ret, identifier='docno')

the json_response decorator takes care of extrcting only the
fields form the model, you dont have to do this
by hand. And the to_dojo_data() function converts the
data into a dojo.data store compatible format.

See also this blog post about more info
about the json_response decorator/function
and insight details.
http://wolfram.kriesing.de/blog/index.php/2007/json-serialization-for-django


-- 
cu

Wolfram

http://uxebu.com - the AJAX experts
You need AJAX, RIA, JavaScript and all this modern stuff? We got it!



On Sat, Nov 1, 2008 at 11:31 PM, Rob Goedman <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> Just for Django & Dojo users.
>
> Working through the 'Mastering Dojo' book, updating the examples where
> applicable to Dojo 1.2 (i.e. grids) and making them work with Django
> svn has gone pretty smoothly. I wonder if below method is a reasonable
> way to generate fairly generic xhr* responses?
>
> I use something like (e.g. from the dojo.data chapter on
> QueryReadStore):
>
> @json_response
> def send_toxids_list(request):
>"""
>Creates a JSON/Dojo hash with the filtered contents
>for a grid. This method is called by Dojo xhr*.
>
>To do:
>
>1)  Change ...all() into ...filter() according to 
> qDict info.
>
>"""
>
>qDict = request.GET
>print qDict['user'], qDict.get('query', None)
>
>queryset = Toxid.objects.all()
>json_serializer = serializers.get_serializer("json")()
>toxids_json = json_serializer.serialize(queryset, ensure_ascii=True)
>t = eval(toxids_json)
>a = []
>for i in t: a.append(i['fields'])
>ret = {
>"identifier": "docno",
>"label": "substance",
>"items": a,
>}
>return ret
>
> It seems a frequently recurring pattern in my views, so I would like
> to do it right and efficient. Particularly the 'eval' step feels weird.
>
> I did have a look at dojox.dtl (Django Templating Language) but
> haven't (yet?) figured out if that is applicable for this.
>
> Thanks,
> Rob
>
>
>
> >
>

--~--~-~--~~~---~--~~
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: Dojango question

2008-11-01 Thread Wolfram Kriesing

Hi Rob,

did you see the blog article
http://blog.uxebu.com/2008/07/26/ajax-with-dojango/
and the examples in
http://code.google.com/p/dojango/source/browse/trunk/dojango/views.py

tbh I don't really understand what you are using the JSON serializer for.
Could you may be explain, if the links above dont help?

-- 
cu

Wolfram

http://uxebu.com - the AJAX experts
You need AJAX, RIA, JavaScript and all this modern stuff? We got it!



On Sat, Nov 1, 2008 at 11:31 PM, Rob Goedman <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> Just for Django & Dojo users.
>
> Working through the 'Mastering Dojo' book, updating the examples where
> applicable to Dojo 1.2 (i.e. grids) and making them work with Django
> svn has gone pretty smoothly. I wonder if below method is a reasonable
> way to generate fairly generic xhr* responses?
>
> I use something like (e.g. from the dojo.data chapter on
> QueryReadStore):
>
> @json_response
> def send_toxids_list(request):
>"""
>Creates a JSON/Dojo hash with the filtered contents
>for a grid. This method is called by Dojo xhr*.
>
>To do:
>
>1)  Change ...all() into ...filter() according to 
> qDict info.
>
>"""
>
>qDict = request.GET
>print qDict['user'], qDict.get('query', None)
>
>queryset = Toxid.objects.all()
>json_serializer = serializers.get_serializer("json")()
>toxids_json = json_serializer.serialize(queryset, ensure_ascii=True)
>t = eval(toxids_json)
>a = []
>for i in t: a.append(i['fields'])
>ret = {
>"identifier": "docno",
>"label": "substance",
>"items": a,
>}
>return ret
>
> It seems a frequently recurring pattern in my views, so I would like
> to do it right and efficient. Particularly the 'eval' step feels weird.
>
> I did have a look at dojox.dtl (Django Templating Language) but
> haven't (yet?) figured out if that is applicable for this.
>
> Thanks,
> Rob
>
>
>
> >
>

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



Template inheritance

2008-11-01 Thread fremder

Hello,

I feel I have learned a lot about Django, and am loving it, but I seem
to be missing something quite fundamental about template inheritance.

Should templates be a set up only for "straight line" inheritance? My
thinking about them leads to a "tree" where a template renders a
"chunk" of a page (e.g. a sidebar, a content area) and that many
"leaf" templates might extends a part of the same parent template.

If that not the wrong way to "think", then how do "siblings" get
rendered? I realize I can render many templates into variables in a
single view function, but that seems to defeat the purpose of template
inheritance...

I feel like I'm missing something obvious, so I appreciate any
guidance!

Alaric

(I saw one post that suggested that custom template tags, and context
processors might be involved. True? I get how to write tags, but the
docs, while being clear on how to _write_ them, seem a bit sketchy on
how to _use_ them, esp. context processors.)

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



access request.user in class Meta

2008-11-01 Thread Merrick

I am trying to dynamically generate a form, the fields will vary if
the user is logged in. Here is where I am so far

forms.py
==
class LinkForm(ModelForm):

def __init__(self, *args, **kw):
self.request = kw.pop('request')
super(LinkForm, self).__init__(*args, **kw)

class Meta:
model = Link
if self.request.user:
exclude = ['ip_address', 'timestamp', 'user', 'method', ]
else:
exclude = ['ip_address', 'timestamp', 'user', 'method',
'notes', 'private_stats',]

views.py
==
def index(request):
form = LinkForm(request=request)

The error I get makes it clear I don't have access to request within
class Meta:

NameError at /
name 'self' is not defined

Thanks,

Merrick

--~--~-~--~~~---~--~~
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: Deploying multiple django applications in a single apache server

2008-11-01 Thread Graham Dumpleton

Just be aware that by default mod_python assigns sub interpreters per
name based virtual host and doesn't take into consideration the
listener port. Therefore, if having two listener ports on the same
host name, the same sub interpreter will be used for both, which means
that Django instances will not be separated and will not work
properly.

In mod_python you will need to use PythonInterpreter directive to
override name of sub interpreter in each VirtualHost for which only
difference is listener port.

Better still, use mod_wsgi instead as it is more sensible and by
default separates the applications by default as it delegates to sub
interpreters on the basis of combination of server name and port. The
only except being that 80/443 are merged into same sub interpreter as
they would generally be the same application.

Graham

On Nov 2, 1:00 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Sat, Nov 1, 2008 at 9:03 AM, bluefireredsky <[EMAIL PROTECTED]>wrote:
>
>
>
>
>
> > Hello,
>
> > I have followed the link from django documentation on deploying an
> > application to apache2.
>
> >http://docs.djangoproject.com/en/dev/howto/deployment/modpython/
>
> > I have two applications, which I would like to run on two different
> > ports on the server. Basically one being an administrative website
> > (not the django inbuilt admin website) and the other the user front
> > end.
>
> > Currently I have the following on my ports.conf:
>
> > ===
> > Listen 80
>
> > 
> >    Listen 443
> > 
> > ===
>
> > My httpd.conf is as follows:
>
> > 
> > 
> >    SetHandler python-program
> >    PythonHandler django.core.handlers.modpython
> >    SetEnv DJANGO_SETTINGS_MODULE mysitename.settings
> >    PythonOption django.root /mysitename
> >    PythonDebug On
> >    PythonPath "['/usr/local/'] + sys.path"
> > 
> > 
> >    SetHandler None
> > 
> > 
> >    SetHandler None
> > 
> > 
>
> > What changes should I do on these files to run my second django
> > application on a different port, say 8080, on the same apache server?
>
> This is really more an Apache question than a Django one.  First you'll need
> to add a Listen for the second port in your ports.conf, the doc for that is
> here:
>
> http://httpd.apache.org/docs/2.2/bind.html
>
> At the bottom of that page they point to the VirtualHost directive, which is
> the second thing you'll need to do.  You need to enclose your existing
> directives for the app on port 80 in a VirtualHost block for port 80, and
> create a second VirtualHost with directives for the new app that you want on
> the second port.
>
> 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
-~--~~~~--~~--~--~---



Dojango question

2008-11-01 Thread Rob Goedman

Hi,

Just for Django & Dojo users.

Working through the 'Mastering Dojo' book, updating the examples where  
applicable to Dojo 1.2 (i.e. grids) and making them work with Django  
svn has gone pretty smoothly. I wonder if below method is a reasonable  
way to generate fairly generic xhr* responses?

I use something like (e.g. from the dojo.data chapter on  
QueryReadStore):

@json_response
def send_toxids_list(request):
"""
Creates a JSON/Dojo hash with the filtered contents
for a grid. This method is called by Dojo xhr*.

To do:

1)  Change ...all() into ...filter() according to 
qDict info.

"""

qDict = request.GET
print qDict['user'], qDict.get('query', None)

queryset = Toxid.objects.all()
json_serializer = serializers.get_serializer("json")()
toxids_json = json_serializer.serialize(queryset, ensure_ascii=True)
t = eval(toxids_json)
a = []
for i in t: a.append(i['fields'])
ret = {
"identifier": "docno",
"label": "substance",
"items": a,
}
return ret

It seems a frequently recurring pattern in my views, so I would like  
to do it right and efficient. Particularly the 'eval' step feels weird.

I did have a look at dojox.dtl (Django Templating Language) but  
haven't (yet?) figured out if that is applicable for this.

Thanks,
Rob



--~--~-~--~~~---~--~~
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: Overriding admin templates

2008-11-01 Thread Karen Tracey
On Sat, Nov 1, 2008 at 5:54 PM, Lars Stavholm <[EMAIL PROTECTED]> wrote:

>
> Low Kian Seong wrote:
> > http://www.djangobook.com/en/1.0/chapter17/
>
> Yes, thank you, that's it.
>
> It worked nicely for the change_form.html example given in that
> chapter. However, for the change_list.html it still doesn't work.
> Seems to me I've hit a django bug. Anyone else?
>

I just tried this, and it works for me for change_list.html. So I'm not sure
what is going on in your case.  For me it just works, overriding change_list
on a per-model basis using a file:

templates/admin///change_list.html

Karen


> /L
>
> > On Sat, Nov 1, 2008 at 6:20 PM, Lars Stavholm <[EMAIL PROTECTED]> wrote:
> >> Low Kian Seong wrote:
> >>> You are supposed to put the admin template you want to override in
> >>> your own template directory definition in settings.py
> >>>
> >>> So, if you defined it as /home/stava/ >>> name>/template/admin/change_list.html
> >> Huh?
> >> /L
> >>
> >>> On Sat, Nov 1, 2008 at 5:32 PM, Lars Stavholm <[EMAIL PROTECTED]>
> wrote:
>  I'd like to override part of an admin change_list template.
> 
>  Reading the documentation, my understanding is that I can place
>  a template in a certain place in the templates directory hierarchy,
>  and django will look for it and use it, i.e.:
> 
>  templates/admin/build/job/change_list.html
> 
>  ...where "build" is my application and "job" is my model class.
> 
>  The change_list.html file only contains the part I want to override,
>  i.e. the extrahead block. It contains:
> 
>  {% extends "admin/change_list.html" %}
>  {% block extrahead %}
>    
>  {% endblock %}
> 
>  However, this does not work for me, so I'm expecting it to be some
>  mistake on my part, I just can't figure out what the mistake is.
> 
>  Now, if I put the file in ./templates/admin/build/change_list.html
>  it still wont work. On the other hand, this would be overriding all
>  "build" application change lists, which is not what I was looking for.
> 
>  Only way I've found is to copy the change_list.html from the django
>  installation in contrib/admin/templates/admin, and then modify it to
>  my needs, using "if" statements to figure out which application model
>  class is being rendered, and the put the change_list.html in my app's
>  templates/admin directory, which doesn't feel right.
> 
>  Any input appreciated
>  /Lars Stavholm
> 
> 
> >>
> >>
> >
> >
> >
>
>
>
> >
>

--~--~-~--~~~---~--~~
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: Dev & Production difference: escaping html in admin

2008-11-01 Thread Ramiro Morales

On Sat, Nov 1, 2008 at 4:21 PM, Alexey Moskvin <[EMAIL PROTECTED]> wrote:
>
> Hi, I have developer (win) & production (debian) installations of
> Django 0.97.

There is not such thing as a 0.97 release, are you sure you are using
the same SVN revisions in both environments?

>  [...]
> But on my production stage there is a problem: no pictures are
> displayed, all tags, returned by show_thumb method are escaped, and I
> have raw HTMl in corespondend column.

Auto-escaping was added in revision 6671, read

http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Auto-escapingintemplates

to see if you are being affected by it.

-- 
 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: Overriding admin templates

2008-11-01 Thread Lars Stavholm

Low Kian Seong wrote:
> http://www.djangobook.com/en/1.0/chapter17/

Yes, thank you, that's it.

It worked nicely for the change_form.html example given in that
chapter. However, for the change_list.html it still doesn't work.
Seems to me I've hit a django bug. Anyone else?
/L

> On Sat, Nov 1, 2008 at 6:20 PM, Lars Stavholm <[EMAIL PROTECTED]> wrote:
>> Low Kian Seong wrote:
>>> You are supposed to put the admin template you want to override in
>>> your own template directory definition in settings.py
>>>
>>> So, if you defined it as /home/stava/>> name>/template/admin/change_list.html
>> Huh?
>> /L
>>
>>> On Sat, Nov 1, 2008 at 5:32 PM, Lars Stavholm <[EMAIL PROTECTED]> wrote:
 I'd like to override part of an admin change_list template.

 Reading the documentation, my understanding is that I can place
 a template in a certain place in the templates directory hierarchy,
 and django will look for it and use it, i.e.:

 templates/admin/build/job/change_list.html

 ...where "build" is my application and "job" is my model class.

 The change_list.html file only contains the part I want to override,
 i.e. the extrahead block. It contains:

 {% extends "admin/change_list.html" %}
 {% block extrahead %}
   
 {% endblock %}

 However, this does not work for me, so I'm expecting it to be some
 mistake on my part, I just can't figure out what the mistake is.

 Now, if I put the file in ./templates/admin/build/change_list.html
 it still wont work. On the other hand, this would be overriding all
 "build" application change lists, which is not what I was looking for.

 Only way I've found is to copy the change_list.html from the django
 installation in contrib/admin/templates/admin, and then modify it to
 my needs, using "if" statements to figure out which application model
 class is being rendered, and the put the change_list.html in my app's
 templates/admin directory, which doesn't feel right.

 Any input appreciated
 /Lars Stavholm


>>
>>
> 
> 
> 



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



Keeping track of online users

2008-11-01 Thread [EMAIL PROTECTED]


I have found some post of 2007 on this argument but maybe with django
1.0 something is changed.

how do you do that ?

thanks everyone :)
--~--~-~--~~~---~--~~
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 Model key limits

2008-11-01 Thread Jorge Bastida
Hello !I'm working in a project using django an postgresql and probably i
will manage a big model table.
I have a few questions about the limits of the primary key in django model.

By default the pk was defined in postgresql as a SERIAL NOT NULL with the
integer data type.
I search for the limits of this type and this postgresql page [1] puts the
limit at (range -2147483648 to +2147483647).

This is a big table, but first estimations make this number not really big.

As I can read in the same page, if we use a bigint the limit will be
(-9223372036854775808
to 9223372036854775807) , this is a really big number :D

So... i change the type of the id column in my database to bigint and i
insert a new row with the id 277147483647 ( big for int , good por bigint).
I start testing the admin of my model and... it works great with this
numbers.

What consequences will have this change in the future ?
This will work ?
Django is ready to this pk numbers?

Thanks a lot

PD : Sorry about my bad english


[1] http://www.postgresql.org/docs/7.4/interactive/sql-createsequence.html


-- 
neo2001[at]gmail.com
neo[at]art-xtreme.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
-~--~~~~--~~--~--~---



Dev & Production difference: escaping html in admin

2008-11-01 Thread Alexey Moskvin

Hi, I have developer (win) & production (debian) installations of
Django 0.97. There is one difference in admin app.
I have a photogallery, and Picture model has this method:

def show_thumb(self) :
return '%s' %
(self.get_image_url(), self.get_image_thumb_url(), self.image)

also I have this:
class Admin:
list_display = ('description', 'show_thumb', 'quality')
in admin section.
This stuff allows me to see previews of the pictures in admin panel.
But on my production stage there is a problem: no pictures are
displayed, all tags, returned by show_thumb method are escaped, and I
have raw HTMl in corespondend column.
How can I change this behaviour?
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
-~--~~~~--~~--~--~---



Formset in template with extra per form

2008-11-01 Thread Steve Bergman

I have a formset, each form representing a row in a table. I also have
a list of dictionaries, each list item providing additional data to
print on that row.  The formset and list of dictionaries are of
arbitrary lengths, and potentially in the hundreds or even low
thousands, so efficiency counts.  I also want to keep the logic as
simple and clear as possible.

I would like to be able to loop over both at once in the template
while rendering the table, but I don't see a good way to do that with
Django templates.  And I don't see an obvious way to efficiently zip
up 'formset.forms' with 'items' to do things that way, But I don't
have the deepest understanding of formsets, so perhaps that is
possible.

Any thoughts?

Thanks,
Steve Bergman
--~--~-~--~~~---~--~~
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: HttpRequest with chunked encoding is not buffered

2008-11-01 Thread Karen Tracey
On Sat, Nov 1, 2008 at 11:37 AM, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:

>
> I actually am seeing some input, but it is divided into several, well,
> chunks. I guess it's the same problem as seeing no input - I'd say
> you're right and chunked encoding is silently unsupported (it would be
> nice if Django said something though).
> However, could you please suggest any workaround? If mod_python does
> not work, what should I use? (My goal is to be able to receive chunked
> requests in some normal way in my django application).
>

Here's a workaround if you must used chunked requests with servers
(apparently many) that don't support it:  you can send a chunked request
through Apache's mod_proxy and force it to unchunk and add a
content-length.  Described here:

http://www.atnan.com/2008/8/8/transfer-encoding-chunked-chunky-http

Karen


>
> On Nov 1, 10:28 am, Graham Dumpleton <[EMAIL PROTECTED]>
> wrote:
> > On Nov 1, 10:40 am, "Tomáš Brambora" <[EMAIL PROTECTED]> wrote:
> >
> > > I have a standard Django installation without any changes in the
> > > settings (except adding mysql db to the settings.py) and I'm sending
> > > the message to localhost:8000, so there is no proxy or anything else
> > > in the way. Still, the request body comes after me sending the
> > > response...
> >
> > As I said in the other similar thread you created about this.
> >
> > If you are getting empty input on read, then you are using hosting
> > mechanism that doesn't properly filter out chunked request content as
> > not being supported and instead assumes that content length of
> > request  was 0.
> >
> > In other words, chunked request content is not supported. Most hosting
> > mechanisms will flag it as an error. The internal Django development
> > server appears just to assume that content length on request is 0
> > since Content-Length header wouldn't be set. Thus why you are seeing
> > no input.
> >
> > Graham
> >
> >
> >
> > > On Fri, Oct 31, 2008 at 11:50 PM, Graham Dumpleton
> >
> > > <[EMAIL PROTECTED]> wrote:
> >
> > > > [EMAIL PROTECTED] wrote:
> > > >> Hello,
> > > >> I'm trying to receive a possibly large XML message via HttpRequest
> > > >> (POST method) with chunked encoding. However, when I send a
> response,
> > > >> I found out (using Wireshark) that the response is being sent before
> > > >> the whole POST request body is available. I expected Django to be
> > > >> buffering the chunks and that the request would be complete, but
> > > >> that's apparently not happening...
> >
> > > >> I'm reading the body like this:
> > > >> request.POST.values()[0]
> >
> > > >> (Which is probably a wrong way, but I don't know how to do it
> > > >> otherwise.)
> >
> > > > What hosting mechanism are you using. Anything that uses WSGI (eg,
> > > > mod_wsgi, fastcgi/flup) or mod_python will not work as neither WSGI
> > > > specification or mod_python support chunked transfer encoding on
> > > > request content. Certainly for mod_python and mod_wsgi, it should
> give
> > > > an error back before even gets to Django saying that content length
> > > > required to be set.
> >
> > > > Graham
> >
>

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



Re: Why is my string not auto escaped?

2008-11-01 Thread Karen Tracey
On Wed, Oct 29, 2008 at 8:35 AM, shabda <[EMAIL PROTECTED]> wrote:

>
> I need to create a custom filter which displays some data from db
> depending on its data type.
>
> My code is something like,
>
> from django.template.defaultfilters import linebreaks, urlize
>
> def filterxx(data)
> return linebreaks(urlize(data.value))
>
> My data.value is
>
> Asdfghjkl
>
> alert('hole')
>
> This is used in templates, and shows up unescaped, which allows users
> to run arbitrary scripts. What am I doing wrong?
>

You are calling built-in filters that rely on being told the current
autoescape setting without passing along the current autoescape setting in
effect.   I think you want something more like:

def filterxx(data, autoescape=None):
return linebreaks(urlize(data.value, autoescape), autoescape)
filterxx.needs_autoescape = True

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: HttpRequest with chunked encoding is not buffered

2008-11-01 Thread [EMAIL PROTECTED]

I actually am seeing some input, but it is divided into several, well,
chunks. I guess it's the same problem as seeing no input - I'd say
you're right and chunked encoding is silently unsupported (it would be
nice if Django said something though).
However, could you please suggest any workaround? If mod_python does
not work, what should I use? (My goal is to be able to receive chunked
requests in some normal way in my django application).

On Nov 1, 10:28 am, Graham Dumpleton <[EMAIL PROTECTED]>
wrote:
> On Nov 1, 10:40 am, "Tomáš Brambora" <[EMAIL PROTECTED]> wrote:
>
> > I have a standard Django installation without any changes in the
> > settings (except adding mysql db to the settings.py) and I'm sending
> > the message to localhost:8000, so there is no proxy or anything else
> > in the way. Still, the request body comes after me sending the
> > response...
>
> As I said in the other similar thread you created about this.
>
> If you are getting empty input on read, then you are using hosting
> mechanism that doesn't properly filter out chunked request content as
> not being supported and instead assumes that content length of
> request  was 0.
>
> In other words, chunked request content is not supported. Most hosting
> mechanisms will flag it as an error. The internal Django development
> server appears just to assume that content length on request is 0
> since Content-Length header wouldn't be set. Thus why you are seeing
> no input.
>
> Graham
>
>
>
> > On Fri, Oct 31, 2008 at 11:50 PM, Graham Dumpleton
>
> > <[EMAIL PROTECTED]> wrote:
>
> > > [EMAIL PROTECTED] wrote:
> > >> Hello,
> > >> I'm trying to receive a possibly large XML message via HttpRequest
> > >> (POST method) with chunked encoding. However, when I send a response,
> > >> I found out (using Wireshark) that the response is being sent before
> > >> the whole POST request body is available. I expected Django to be
> > >> buffering the chunks and that the request would be complete, but
> > >> that's apparently not happening...
>
> > >> I'm reading the body like this:
> > >> request.POST.values()[0]
>
> > >> (Which is probably a wrong way, but I don't know how to do it
> > >> otherwise.)
>
> > > What hosting mechanism are you using. Anything that uses WSGI (eg,
> > > mod_wsgi, fastcgi/flup) or mod_python will not work as neither WSGI
> > > specification or mod_python support chunked transfer encoding on
> > > request content. Certainly for mod_python and mod_wsgi, it should give
> > > an error back before even gets to Django saying that content length
> > > required to be set.
>
> > > Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Cascading List List Boxes

2008-11-01 Thread Caisys

Hi,
Is it possible to populate a list depending on another list choice?

I am working on an event guide, when creating the event the user will
need to select a place from a drop down list, some places have
different rooms, so I want another drop down list containing the rooms
that relate to the place selected in the first drop down list.

Any ideas?
--~--~-~--~~~---~--~~
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: Splitting models.py won't install models

2008-11-01 Thread Alistair Marshall

Right I managed to fix it and feel really stupid at the same time but
I thought I would post here in case anyone else has the same issue

my mistake was using
class meta:

and not
class Meta:

doh! got to love case sensitivity.

Thanks to all that offered suggestions
Alistair

---
Alistair Marshall
http://www.thatscottishengineer.co.uk
--~--~-~--~~~---~--~~
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: Accessing Model field from ModelForm?

2008-11-01 Thread killsto

Thanks, that's a big help.

On Nov 1, 5:14 am, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Nov 1, 5:33 am, killsto <[EMAIL PROTECTED]> wrote:
>
>
>
> > I have a basic form that shows what a person entered when it is
> > submitted.  However, it shows up as a form.CharField (textbox) instead
> > of model.CharField. Is there a way to access the model's saved data
> > from the Forms? Also does form_for_model (http://www.djangobook.com/en/
> > 1.0/chapter07/) no longer exist? I can't get it to load.
>
> 
>
> > from qotd.models import *
> > from django.shortcuts import render_to_response
> > from django.http import HttpResponseRedirect
>
> > def contact(request, question):
> >     if request.method == 'POST': # If the form has been submitted...
> >         form = Questionform(request.POST) # A form bound to the POST
> > data
> >         if form.is_valid():
> >                 form.save()
> >                 #return HttpResponseRedirect('results.html', {'form': form}
>
> >     else:
> >         form = Questionform()
> >     return render_to_response('contact.html', {
> >         'form': form
> >     })
>
> The only thing you need to do that you're not doing is to actually
> pass the instance of Question (or Choice) to the form when you
> instantiate it.
>
> Assuming that 'question' is the PK of the Question object:
>
> def contact(request, question):
>     question_obj = Question.objects.get(pk=question)
>     if request.method == 'POST':
>         form = Questionform(request.POST, instance=question_obj)
>         if form.is_valid():
>                 form.save()
>                 return HttpResponseRedirect('/submission/')
>     else:
>         form = Questionform(instance=question_obj)
>     return render_to_response('contact.html', {
>         'form': form
>     })
>
> Note that HttpResponseRedirect takes a *URL*, not a template/context.
> It tells the user's browser to request a different URL so that they
> can't submit the form twice.
> --
> 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: Why is my string not auto escaped?

2008-11-01 Thread varikin



On Oct 31, 8:28 am, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
> > > > So if these built in filters are marking my strings safe, inspite of
> > > > unsafe data being passed in, should they not handle escaping as well?
>
> > > The problem seems to be that your filter function doesn't mark itself
> > > with an is_safe attribute (defaulting it to False). So try marking
> > > your filter with is_safe=True which means that your filter doesn't
> > > introduce any HTML unsafe characters by itself (not including the ones
> > > that are already in the input):
>
> > > filterxx.is_safe = True
>
> > > Also, it's easier for people to follow a discussion thread if you
> > > don't top post your responses.
>
> > > -RD
>
> > I don't think setting is_safe is the solution, in fact is sounds like
> > the exact opposite.
>
> It might sound confusing, but is_safe=True is a way for you to
> indicate to Django that your filter does not introduce any unwanted
> characters. See point #1 in the below doc for a more thorough
> explanation:
>
> http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#filt...
>
> > Shabda *wants* Django to escape the results.
>
> Here's an excerpt from the docs for that case:
>
> "1. Your filter does not introduce any HTML-unsafe characters (<, >,
> ', " or &) into the result that were not already present. In this
> case, you can let Django take care of all the auto-escaping handling
> for you. All you need to do is put the is_safe attribute on your
> filter function and set it to True, like so:
>
> This attribute tells Django that if a "safe" string is passed into
> your filter, the result will still be "safe" and if a non-safe string
> is passed in, Django will automatically escape it, if necessary."
>
> -RD

But Shadba's example filter is calling urlize which does introduce
HTML unsafe characters.
--~--~-~--~~~---~--~~
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: can't delete many-to-many related record from admin inline

2008-11-01 Thread ndarkduck

I'm no guru, Im  stuck  also with some many-to-many features.

1.- why whould you need a  3rd  table if you are not using attributes
in the relationship? (Variant).
2.- have you tried to add an models.AutoField(primary=True) to your
model Variant ? I knew django does that if no is specified in order to
preserve the 3rd normal form, but it would be a first aproach.

Hope this helped out a little.

Regards
ndarkduck

On Oct 30, 7:40 am, chris <[EMAIL PROTECTED]> wrote:
> Hi there,
>
> I am still pretty new to django and just trying to figure out how it
> is all supposed to work.
>
> I have the following models:
>
> *models.py:
>
> class Char(models.Model):
>     char = models.CharField(max_length=10)
>     variants = models.ManyToManyField("self", symmetrical=False,
> through="Variant", related_name="varchars", blank=True, null=True)
>
> class Variant(models.Model):
>      char = models.ForeignKey(Char)
>      variant = models.ForeignKey(Char, related_name="vars")
>
> *admin.py:
>
> class CharVarInline(admin.StackedInline):
>       model = Variant
>       fk_name = "char"
>       raw_id_fields=("variant", "char",)
>       extra = 1
>
> class CharAdmin(admin.ModelAdmin):
>     inlines = (CharVarInline,)
>
> This causes the variants part to be displayed with a char record in
> admin.  I also get a check-box there, which can be checked to delete
> the inlined related recorded.   However, when I try to used this to
> delete the record and click save, the following error occurs:
>
> ValueError at /admin/chardb/char/70524/
>
> 'Variant' instance needs to have a primary key value before a many-to-
> many relationship can be used.
>
> Apparently, something is going wrong with the deletion, which lets
> part of the record hang in empty air.  But I have no idea where to
> look or how to fix this.  Does anybody has any idea?
>
> Any help appreciated,
>
> Chris
--~--~-~--~~~---~--~~
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: Deploying multiple django applications in a single apache server

2008-11-01 Thread Karen Tracey
On Sat, Nov 1, 2008 at 9:03 AM, bluefireredsky <[EMAIL PROTECTED]>wrote:

>
> Hello,
>
> I have followed the link from django documentation on deploying an
> application to apache2.
>
> http://docs.djangoproject.com/en/dev/howto/deployment/modpython/
>
> I have two applications, which I would like to run on two different
> ports on the server. Basically one being an administrative website
> (not the django inbuilt admin website) and the other the user front
> end.
>
> Currently I have the following on my ports.conf:
>
> ===
> Listen 80
>
> 
>Listen 443
> 
> ===
>
> My httpd.conf is as follows:
>
> 
> 
>SetHandler python-program
>PythonHandler django.core.handlers.modpython
>SetEnv DJANGO_SETTINGS_MODULE mysitename.settings
>PythonOption django.root /mysitename
>PythonDebug On
>PythonPath "['/usr/local/'] + sys.path"
> 
> 
>SetHandler None
> 
> 
>SetHandler None
> 
> 
>
> What changes should I do on these files to run my second django
> application on a different port, say 8080, on the same apache server?
>
>
This is really more an Apache question than a Django one.  First you'll need
to add a Listen for the second port in your ports.conf, the doc for that is
here:

http://httpd.apache.org/docs/2.2/bind.html

At the bottom of that page they point to the VirtualHost directive, which is
the second thing you'll need to do.  You need to enclose your existing
directives for the app on port 80 in a VirtualHost block for port 80, and
create a second VirtualHost with directives for the new app that you want on
the second port.

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: populating forms using models

2008-11-01 Thread Jorge Bastida
To populate select field you have many options.
First is using ModelChoiceField.
The ModelChoiceField have an argument named queryset, you can use like this
example
provincia = forms.ModelChoiceField(queryset=Provincia.objects.all() ..)

If you can't have a FK of Provincia table you can use a Choice Field and
populate externaly like this

provincia = forms.ChoiceField( ... )

and inside the form declare a new method named populate(self,
list_of_provincias):   (for example)
and inside this method you can do this...

self.fields['provincia'].choices = list_of_provincias

In other situations you can populate a ModelcoiceField externaly too:
example: You need to populate a modelchoice field with a queryset depending
in the user loged ...

def populate(self,user):
self.fields['boards'].queryset = Board.objects.filter( guild =
Guild.objects.get(owner=user) )

When you create a form yo need to call the .populate method with
request.user as argument.




2008/11/1 Rock <[EMAIL PROTECTED]>

>
> In brief, your forms field for province does not have to have anything
> to do with your corresponding model field.
> Just make a forms.ChoiceField with the data filled in that you need
> (or else look up the pattern for loading dynamic data into a
> forms.ChoiceField and do something like that.) If you go the dynamic
> route, make sure your form gets initialized properly when you create
> it for initial use and also when you create it for POST processing.
>
>
> >
>


-- 
neo2001[at]gmail.com
neo[at]art-xtreme.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: updating a single field / attribute, is it possible? or better practices?

2008-11-01 Thread Rock

In the meantime, creating and executing your own update command is not
difficult.
Here is a snippet for a custom PositionField that updates itself when
necessary with an SQL UPDATE:

http://www.djangosnippets.org/snippets/884/


--~--~-~--~~~---~--~~
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 forms using models

2008-11-01 Thread Rock

In brief, your forms field for province does not have to have anything
to do with your corresponding model field.
Just make a forms.ChoiceField with the data filled in that you need
(or else look up the pattern for loading dynamic data into a
forms.ChoiceField and do something like that.) If you go the dynamic
route, make sure your form gets initialized properly when you create
it for initial use and also when you create it for POST processing.


--~--~-~--~~~---~--~~
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: Overriding admin templates

2008-11-01 Thread Low Kian Seong

http://www.djangobook.com/en/1.0/chapter17/

On Sat, Nov 1, 2008 at 6:20 PM, Lars Stavholm <[EMAIL PROTECTED]> wrote:
>
> Low Kian Seong wrote:
>> You are supposed to put the admin template you want to override in
>> your own template directory definition in settings.py
>>
>> So, if you defined it as /home/stava/> name>/template/admin/change_list.html
>
> Huh?
> /L
>
>> On Sat, Nov 1, 2008 at 5:32 PM, Lars Stavholm <[EMAIL PROTECTED]> wrote:
>>> I'd like to override part of an admin change_list template.
>>>
>>> Reading the documentation, my understanding is that I can place
>>> a template in a certain place in the templates directory hierarchy,
>>> and django will look for it and use it, i.e.:
>>>
>>> templates/admin/build/job/change_list.html
>>>
>>> ...where "build" is my application and "job" is my model class.
>>>
>>> The change_list.html file only contains the part I want to override,
>>> i.e. the extrahead block. It contains:
>>>
>>> {% extends "admin/change_list.html" %}
>>> {% block extrahead %}
>>>   
>>> {% endblock %}
>>>
>>> However, this does not work for me, so I'm expecting it to be some
>>> mistake on my part, I just can't figure out what the mistake is.
>>>
>>> Now, if I put the file in ./templates/admin/build/change_list.html
>>> it still wont work. On the other hand, this would be overriding all
>>> "build" application change lists, which is not what I was looking for.
>>>
>>> Only way I've found is to copy the change_list.html from the django
>>> installation in contrib/admin/templates/admin, and then modify it to
>>> my needs, using "if" statements to figure out which application model
>>> class is being rendered, and the put the change_list.html in my app's
>>> templates/admin directory, which doesn't feel right.
>>>
>>> Any input appreciated
>>> /Lars Stavholm
>>>
>>>
>>
>> >
>>
>
>
>
> >
>



-- 
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: Installing an app in a sub-directory of another site (urls question)

2008-11-01 Thread bluefireredsky

Hi,

The reason is because of the preceding "/" in your
HttpResponseRedirect.

You could try to redirect to "success/" or to "../success/" based on
which may be applicable to you.

Cheers

On Nov 1, 5:51 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hi guys,
>
> I installed my app on a subdir of another site (just for staging).
>
> www.example.org/djangoapp
>
> Now my urls keep pointing back to the root of the other site, breaking
> navigation.
>
> So for example if i POST some form to
>
> www.example.org/djangoapp/subscribe/
>
> and then from there issue an HttpResponseRedirect('/success/')
> pretending to be redirected to
>
> www.example.org/djangoapp/success/
>
> i instead get redirected to
>
> www.example.org/success/
>
> What should i look into to fix this, without going through the code
> and changing all my redirects just for staging?
>
> Thanks,
> Lorenzo
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Deploying multiple django applications in a single apache server

2008-11-01 Thread bluefireredsky

Hello,

I have followed the link from django documentation on deploying an
application to apache2.

http://docs.djangoproject.com/en/dev/howto/deployment/modpython/

I have two applications, which I would like to run on two different
ports on the server. Basically one being an administrative website
(not the django inbuilt admin website) and the other the user front
end.

Currently I have the following on my ports.conf:

===
Listen 80


Listen 443

===

My httpd.conf is as follows:



SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysitename.settings
PythonOption django.root /mysitename
PythonDebug On
PythonPath "['/usr/local/'] + sys.path"


SetHandler None


SetHandler None




What changes should I do on these files to run my second django
application on a different port, say 8080, on the same apache server?

Thank you.

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



Installing an app in a sub-directory of another site (urls question)

2008-11-01 Thread [EMAIL PROTECTED]

Hi guys,

I installed my app on a subdir of another site (just for staging).

www.example.org/djangoapp

Now my urls keep pointing back to the root of the other site, breaking
navigation.

So for example if i POST some form to

www.example.org/djangoapp/subscribe/

and then from there issue an HttpResponseRedirect('/success/')
pretending to be redirected to

www.example.org/djangoapp/success/

i instead get redirected to

www.example.org/success/

What should i look into to fix this, without going through the code
and changing all my redirects just for staging?

Thanks,
Lorenzo
--~--~-~--~~~---~--~~
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: PROFANITIES_LIST for comments

2008-11-01 Thread Tim Chase

> I use default comments form, set in settings.py:
> 
> COMMENTS_ALLOW_PROFANITIES = True

Uh...while I speak without looking at any code, or documentation, 
prima facie, this looks backwards...it sounds like you want 
"Allow profanities = False"

-tim




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



PROFANITIES_LIST for comments

2008-11-01 Thread slav0nic

I use default comments form, set in settings.py:

COMMENTS_ALLOW_PROFANITIES = True
PROFANITIES_LIST = ('viagra', 'porno')

But when i post comment with this words - it posted =\

--~--~-~--~~~---~--~~
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: Overriding admin templates

2008-11-01 Thread Lars Stavholm

Low Kian Seong wrote:
> You are supposed to put the admin template you want to override in
> your own template directory definition in settings.py
> 
> So, if you defined it as /home/stava/ name>/template/admin/change_list.html

Huh?
/L

> On Sat, Nov 1, 2008 at 5:32 PM, Lars Stavholm <[EMAIL PROTECTED]> wrote:
>> I'd like to override part of an admin change_list template.
>>
>> Reading the documentation, my understanding is that I can place
>> a template in a certain place in the templates directory hierarchy,
>> and django will look for it and use it, i.e.:
>>
>> templates/admin/build/job/change_list.html
>>
>> ...where "build" is my application and "job" is my model class.
>>
>> The change_list.html file only contains the part I want to override,
>> i.e. the extrahead block. It contains:
>>
>> {% extends "admin/change_list.html" %}
>> {% block extrahead %}
>>   
>> {% endblock %}
>>
>> However, this does not work for me, so I'm expecting it to be some
>> mistake on my part, I just can't figure out what the mistake is.
>>
>> Now, if I put the file in ./templates/admin/build/change_list.html
>> it still wont work. On the other hand, this would be overriding all
>> "build" application change lists, which is not what I was looking for.
>>
>> Only way I've found is to copy the change_list.html from the django
>> installation in contrib/admin/templates/admin, and then modify it to
>> my needs, using "if" statements to figure out which application model
>> class is being rendered, and the put the change_list.html in my app's
>> templates/admin directory, which doesn't feel right.
>>
>> Any input appreciated
>> /Lars Stavholm
>>
>>
> 
> > 
> 



--~--~-~--~~~---~--~~
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: Accessing Model field from ModelForm?

2008-11-01 Thread Daniel Roseman

On Nov 1, 5:33 am, killsto <[EMAIL PROTECTED]> wrote:
> I have a basic form that shows what a person entered when it is
> submitted.  However, it shows up as a form.CharField (textbox) instead
> of model.CharField. Is there a way to access the model's saved data
> from the Forms? Also does form_for_model (http://www.djangobook.com/en/
> 1.0/chapter07/) no longer exist? I can't get it to load.
>

>
> from qotd.models import *
> from django.shortcuts import render_to_response
> from django.http import HttpResponseRedirect
>
> def contact(request, question):
>     if request.method == 'POST': # If the form has been submitted...
>         form = Questionform(request.POST) # A form bound to the POST
> data
>         if form.is_valid():
>                 form.save()
>                 #return HttpResponseRedirect('results.html', {'form': form}
>
>     else:
>         form = Questionform()
>     return render_to_response('contact.html', {
>         'form': form
>     })

The only thing you need to do that you're not doing is to actually
pass the instance of Question (or Choice) to the form when you
instantiate it.

Assuming that 'question' is the PK of the Question object:

def contact(request, question):
question_obj = Question.objects.get(pk=question)
if request.method == 'POST':
form = Questionform(request.POST, instance=question_obj)
if form.is_valid():
form.save()
return HttpResponseRedirect('/submission/')
else:
form = Questionform(instance=question_obj)
return render_to_response('contact.html', {
'form': form
})

Note that HttpResponseRedirect takes a *URL*, not a template/context.
It tells the user's browser to request a different URL so that they
can't submit the form twice.
--
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: Help to Upload image

2008-11-01 Thread Low Kian Seong

Yeah, if in doubt you can use the forms.as_p first to see what kind of
html form it outputs and use that as the basis for creating your form.

On Thu, Oct 30, 2008 at 7:05 PM, Giles Thomas
<[EMAIL PROTECTED]> wrote:
>
> please smile wrote:
>> Can anybody please tell how to upload a image ?
>
> I'm new to this myself, but I got something working using Django's forms
> mechanism.
>
> My view function looks something like this:
>
> ---
> class MyForm(ModelForm):
>class Meta:
>model = photos
>
> def upload(request):
>if request.method == "POST":
>form = MyForm(request.POST, request.FILES)
>if form.is_valid():
>sheet = form.save()
>return HttpResponseRedirect(reverse('upload_thanks'))
>
>return render_to_response(
>"upload.html",
>{
>"form" : MyForm(),
>}
>)
> ---
>
> This is then rendered by a template, upload.html, that looks something
> like this:
>
> ---
> 
>  
>{% for field in form %}
>  
>
>
>
>{{ field.errors }}
>
>  
>  
>
>  {{ field.label_tag }}:
>
>
>  {{ field }}
>
>  
>{% endfor %}
>  
>
>  
> 
> ---
>
> Finally, my urls.py specifies "names" for both the upload and the
> upload_thanks pages:
>
> ---
> urlpatterns = patterns('',
># ...
>url(
>r'^upload/$',
>'my.app.views.upload',
>name="upload"
>),
>url(
>r'^upload/thanks/$',
> 'django.views.generic.simple.direct_to_template',
>{ 'template' : 'upload_thanks.html' },
>name="upload_thanks"
>),
> )
> ---
>
> Hope this helps.
>
>
> Cheers,
>
> Giles
>
> --
> Giles Thomas
> MD & CTO, Resolver Systems Ltd.
> [EMAIL PROTECTED]
> +44 (0) 20 7253 6372
>
> Try out Resolver One! 
>
> 17a Clerkenwell Road, London EC1M 5RD, UK
> VAT No.: GB 893 5643 79
> Registered in England and Wales as company number 5467329.
> Registered address: 843 Finchley Road, London NW11 8NA, UK
>
>
>
> >
>



-- 
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: Using Django

2008-11-01 Thread Low Kian Seong

Finding out a bit about urls.py and how it functions would do a world
of good. It is very flexible and powerful once you learn how to wield
it.

Low Kian Seong

http://lowkster.blogspot.com

On Sat, Nov 1, 2008 at 5:20 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> I'm new to Django and it's taken me a while to get things setup
> correctly on Dreamhost. I've done the tutorials on my local machine
> prior to setting things up on Dreamhost but it seems like I'm missing
> instructions on how to actually use Django. Yes, I've read the "Using
> Django" section of the website but I don't even know how/where my
> pages should reside. If I request http://www.mysite.com, how do I
> route that to my "projects" directory where the "mysite" directory
> resides, a symbolic link? - which I tried but just returns a 403
> error. I'm still used to the traditional "mysite.com" directory which
> contains index.php, contact.php, etc., and I don't understand how the
> directory structure for Django works. It seems like the tutorials just
> show you how to start a project under test conditions and show off the
> built-in admin tools, without really explaining how things are setup
> for an actual website. Maybe this system is over my head...
>
> Thanks,
>
> Jason
> >
>



-- 
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: multiselect populated by another app

2008-11-01 Thread Low Kian Seong

I think this might be useful:

http://www.zoia.org/blog/2007/04/23/using-dynamic-choices-with-django-newforms-and-custom-widgets/

On Fri, Oct 31, 2008 at 5:36 AM, webcomm <[EMAIL PROTECTED]> wrote:
>
> Bump.
>
> There must be a way to do this, right?  I have looked all over... the
> documentation seems to indicate that there is no way to do this in
> django, which is surprising, since this is a necessary part of so many
> programs.
>
> Is there really no way to populate a mutiselect with values from
> another app?
>
> The Definitive Guide to Django says that a ManyToManyField will take
> as its one argument only the name of a class from the same app.  If
> that's true, I don't see how anyone could develop a categories app in
> django... perhaps I'm missing something?
>
> Thanks in advance for your help,
> Ryan
>
>
>
> On Oct 27, 11:03 am, webcomm <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> I have created a simple categories app, and now I want to be able to
>> categorize my articles, which are handled by a different app.  I'd
>> like to create a multiselect categories field in my articles admin
>> that is populated by the category entries from my categories app.
>>
>> In my categories app, I have to ability to create category groups.
>> This is the models.py for the categories app...
>>
>> from django.db import models
>>
>> class Group(models.Model):
>> name = models.CharField(max_length=200)
>>
>> def __str__(self):
>> return self.name
>>
>> class Category(models.Model):
>> group = models.ForeignKey(Group)
>> name = models.CharField(max_length=200)
>>
>> def __str__(self):
>> return self.name
>>
>> class Meta:
>> verbose_name_plural = 'categories'
>>
>> I want to set up my articles admin interface so there is a different
>> multiselect box for each category group, or one large multiselect with
>> the categories organized in groups.
>>
>> I am not quite sure what to do in articles/admin.py and/or elsewhere
>> to achieve this.
>>
>> Any ideas?
>>
>> 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: Overriding admin templates

2008-11-01 Thread Low Kian Seong

You are supposed to put the admin template you want to override in
your own template directory definition in settings.py

So, if you defined it as /home/stava//template/admin/change_list.html



On Sat, Nov 1, 2008 at 5:32 PM, Lars Stavholm <[EMAIL PROTECTED]> wrote:
>
> I'd like to override part of an admin change_list template.
>
> Reading the documentation, my understanding is that I can place
> a template in a certain place in the templates directory hierarchy,
> and django will look for it and use it, i.e.:
>
> templates/admin/build/job/change_list.html
>
> ...where "build" is my application and "job" is my model class.
>
> The change_list.html file only contains the part I want to override,
> i.e. the extrahead block. It contains:
>
> {% extends "admin/change_list.html" %}
> {% block extrahead %}
>   
> {% endblock %}
>
> However, this does not work for me, so I'm expecting it to be some
> mistake on my part, I just can't figure out what the mistake is.
>
> Now, if I put the file in ./templates/admin/build/change_list.html
> it still wont work. On the other hand, this would be overriding all
> "build" application change lists, which is not what I was looking for.
>
> Only way I've found is to copy the change_list.html from the django
> installation in contrib/admin/templates/admin, and then modify it to
> my needs, using "if" statements to figure out which application model
> class is being rendered, and the put the change_list.html in my app's
> templates/admin directory, which doesn't feel right.
>
> Any input appreciated
> /Lars Stavholm
>
>
> >
>

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



Overriding admin templates

2008-11-01 Thread Lars Stavholm

I'd like to override part of an admin change_list template.

Reading the documentation, my understanding is that I can place
a template in a certain place in the templates directory hierarchy,
and django will look for it and use it, i.e.:

templates/admin/build/job/change_list.html

...where "build" is my application and "job" is my model class.

The change_list.html file only contains the part I want to override,
i.e. the extrahead block. It contains:

{% extends "admin/change_list.html" %}
{% block extrahead %}
   
{% endblock %}

However, this does not work for me, so I'm expecting it to be some
mistake on my part, I just can't figure out what the mistake is.

Now, if I put the file in ./templates/admin/build/change_list.html
it still wont work. On the other hand, this would be overriding all
"build" application change lists, which is not what I was looking for.

Only way I've found is to copy the change_list.html from the django
installation in contrib/admin/templates/admin, and then modify it to
my needs, using "if" statements to figure out which application model
class is being rendered, and the put the change_list.html in my app's
templates/admin directory, which doesn't feel right.

Any input appreciated
/Lars Stavholm


--~--~-~--~~~---~--~~
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: HttpRequest with chunked encoding is not buffered

2008-11-01 Thread Graham Dumpleton



On Nov 1, 10:40 am, "Tomáš Brambora" <[EMAIL PROTECTED]> wrote:
> I have a standard Django installation without any changes in the
> settings (except adding mysql db to the settings.py) and I'm sending
> the message to localhost:8000, so there is no proxy or anything else
> in the way. Still, the request body comes after me sending the
> response...

As I said in the other similar thread you created about this.

If you are getting empty input on read, then you are using hosting
mechanism that doesn't properly filter out chunked request content as
not being supported and instead assumes that content length of
request  was 0.

In other words, chunked request content is not supported. Most hosting
mechanisms will flag it as an error. The internal Django development
server appears just to assume that content length on request is 0
since Content-Length header wouldn't be set. Thus why you are seeing
no input.

Graham

> On Fri, Oct 31, 2008 at 11:50 PM, Graham Dumpleton
>
> <[EMAIL PROTECTED]> wrote:
>
> > [EMAIL PROTECTED] wrote:
> >> Hello,
> >> I'm trying to receive a possibly large XML message via HttpRequest
> >> (POST method) with chunked encoding. However, when I send a response,
> >> I found out (using Wireshark) that the response is being sent before
> >> the whole POST request body is available. I expected Django to be
> >> buffering the chunks and that the request would be complete, but
> >> that's apparently not happening...
>
> >> I'm reading the body like this:
> >> request.POST.values()[0]
>
> >> (Which is probably a wrong way, but I don't know how to do it
> >> otherwise.)
>
> > What hosting mechanism are you using. Anything that uses WSGI (eg,
> > mod_wsgi, fastcgi/flup) or mod_python will not work as neither WSGI
> > specification or mod_python support chunked transfer encoding on
> > request content. Certainly for mod_python and mod_wsgi, it should give
> > an error back before even gets to Django saying that content length
> > required to be set.
>
> > Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Templaite:display li items alternatively using for

2008-11-01 Thread Karen Tracey
On Sat, Nov 1, 2008 at 1:58 AM, Xian Chen <[EMAIL PROTECTED]> wrote:

> Hi,
>
> I want to display a list of items by using {% for item in items %}.
>
> To make the web pages look better, I want to use two kinds of 
> alternatively.
>
> E.G item
>item
>
> My question is how can i use the tags to implement this requirement?
>
> Any build-in tags for this?
>

Yes:

http://docs.djangoproject.com/en/dev/ref/templates/builtins/#cycle

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



Accessing Model field from ModelForm?

2008-11-01 Thread killsto

I have a basic form that shows what a person entered when it is
submitted.  However, it shows up as a form.CharField (textbox) instead
of model.CharField. Is there a way to access the model's saved data
from the Forms? Also does form_for_model (http://www.djangobook.com/en/
1.0/chapter07/) no longer exist? I can't get it to load.

models.py:
from django.db import models
from django.forms import ModelForm

class Question(models.Model):
question = models.CharField('Question', max_length = '200',
primary_key = True)
pub_date = models.DateField(auto_now_add = True)
def __unicode__(self):
return self.question

class Choice(models.Model):
Question = models.ForeignKey(Question)
choice = models.CharField(max_length = '200')

class Questionform(ModelForm):
class Meta:
model = Question
class Choiceform(ModelForm):
class Meta:
model = Choice

view:
from qotd.models import *
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect

def contact(request, question):
if request.method == 'POST': # If the form has been submitted...
form = Questionform(request.POST) # A form bound to the POST
data
if form.is_valid():
form.save()
#return HttpResponseRedirect('results.html', {'form': form}

else:
form = Questionform()
return render_to_response('contact.html', {
'form': form
})
template:


{% if not form.is_valid %}

{{ form.as_p }}

{% endif %}
{% if form.is_valid %}
{{ form.question }}
{% endif %}




--~--~-~--~~~---~--~~
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: S3Storage, FileField -- default_storage.exists() has unwanted side-effects

2008-11-01 Thread Liam

Actually, it turns out there is a bug in Amazon's S3.py module.
The Date field in the header is formatted with AM/PM notation - it
should, i.e. MUST, be in 24hr notation.
Change the %X to %T and you're good to go.

On Oct 30, 6:27 pm, Info Cascade <[EMAIL PROTECTED]> wrote:
> I have a model that has a FileField storage field.
> The default_storage system is S3Storage.
> I noticed that I was getting unusual results when I simply tried to
> verify whether the file existed on disk using the
> default_storage.exists() method.
> If I call it with the FileField object, it causes Django to actually try
> to *get* the file, which is not what I intend.  The S3Storage module
> implements exists() as a simple http HEAD request. That part works
> fine.  But then Django starts getting the file which eventually results
> in an error, so it appears the file doesn't exist when really it does.
> (The file is an audio file, which triggers a series of byte-range
> requests, the final one having incorrect value, so I'm getting a series
> of 206 codes followed by 416 error code. It causes a key error in
> S3Storage or S3 on 'etag'.)
>
> I was able to work around it by using the str() function, which results
> in the correct behavior.
>
> Anyway, it was non-intuitive for me that checking whether a file exists
> would make Django do a GET on it!  Is this a bug or do I just not
> understand what's going on beneath the surface?  (Which is the case,
> actually.)  Can someone explain this?
>
> Liam
>
>
>
> > section_objects =
> > Section.objects.in_bulk(section_ids).values()
> > if len(section_ids) != len(section_objects):
> > print "section count mismatch for article '%d'" %
> > (art.id)
> > idx = 0
> > for sec in section_objects:
> > idx += 1
> > if sec.url:
> > try:
> > if not default_storage.exists(*str*(sec.url)):
> > print "\tarticle '%s' missing content
> > for section %d" % (art.id, idx)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---