Re: database API filter() vs get()

2007-12-17 Thread Brian Rosner

On 2007-12-17 22:41:08 -0700, Kenneth Gonsalves <[EMAIL PROTECTED]> said:

> 
> 
> On 18-Dec-07, at 10:33 AM, MrJogo wrote:
> 
>> What's the practical difference between calling
>> DB.objects.filter(**kwargs) and DB.objects.get(**kwargs) (where
>> **kwargs can be whichever paramenters)? I understand that filter
>> returns a QuerySet, but I don't really get how that affects me or my
>> code.
> 
> get will return precisely one object. whereas filter will return a
> list of objects (list may contain only one object or be empty. So the
> difference is that if you do
> 
> a = ...get()
> you can write a.id
> a= ...filter()
> you would have to write a[0].id (if you are expecting only one object
> to be returned)

One other thing to note is .filter returns a QuerySet object. What this 
means is that the database won't be hit until it is evaluated. Ex. it 
is iterated over in a for loop, you do a[0].id, or you provide a step 
in the slice a[::2]. .get will actually hit the database when called.

-- 
Brian Rosner
http://oebfare.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: Templates, filesystem, caching?

2007-12-17 Thread Udi

Manually call get_template() or select_template(), and stuff the
>resulting Template object into a module-global variable somewhere.
>Then just re-use it, calling render() with different contexts, each
>time you need it.

Along those lines, I recently noticed this bit of code that swaps the
get_template fn out with one that does some caching:
http://www.djangosnippets.org/snippets/507/



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



determining newforms field type in a template

2007-12-17 Thread MrJogo

If I pass a form into my template as a variable, is there a way to
tell what input type a field is in the template? My template creates
pretty boxes for the form fields, but I don't want them around hidden
inputs. I was hoping for something like {% ifequal field.type "hidden"
%} but I can't seem to find an equivalent of field.type.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



newadmin: where is 'limit_choices_to'

2007-12-17 Thread René Schneider

Hello
I am a newbe on this list. With the oldforms-admin i made a model with 
some fields with 'limit_choices_to' options. Then i tried it with the 
newadmin. There is no error message but also no effect. The list is not 
'limited' but 'full'. Is this option gone in newadmin or have i to 
program it in another way?
Thanks for your answer
René


--~--~-~--~~~---~--~~
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: database API filter() vs get()

2007-12-17 Thread MrJogo

I understand now. Thanks.

On Dec 17, 9:11 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 18-Dec-07, at 10:33 AM, MrJogo wrote:
>
> > What's the practical difference between calling
> > DB.objects.filter(**kwargs) and DB.objects.get(**kwargs) (where
> > **kwargs can be whichever paramenters)? I understand that filter
> > returns a QuerySet, but I don't really get how that affects me or my
> > code.
>
> get will return precisely one object. whereas filter will return a
> list of objects (list may contain only one object or be empty. So the
> difference is that if you do
>
> a = ...get()
> you can write a.id
> a= ...filter()
> you would have to write a[0].id (if you are expecting only one object
> to be returned)
>
> --
>
> regards
> kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/web/
> Foss Conference for the common man:http://registration.fossconf.in/web/
--~--~-~--~~~---~--~~
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: database API filter() vs get()

2007-12-17 Thread Kenneth Gonsalves


On 18-Dec-07, at 10:33 AM, MrJogo wrote:

> What's the practical difference between calling
> DB.objects.filter(**kwargs) and DB.objects.get(**kwargs) (where
> **kwargs can be whichever paramenters)? I understand that filter
> returns a QuerySet, but I don't really get how that affects me or my
> code.

get will return precisely one object. whereas filter will return a  
list of objects (list may contain only one object or be empty. So the  
difference is that if you do

a = ...get()
you can write a.id
a= ...filter()
you would have to write a[0].id (if you are expecting only one object  
to be returned)

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/
Foss Conference for the common man: http://registration.fossconf.in/web/



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



database API filter() vs get()

2007-12-17 Thread MrJogo

What's the practical difference between calling
DB.objects.filter(**kwargs) and DB.objects.get(**kwargs) (where
**kwargs can be whichever paramenters)? I understand that filter
returns a QuerySet, but I don't really get how that affects me or my
code.
--~--~-~--~~~---~--~~
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: RequestContext in Generic Views?

2007-12-17 Thread gtaylor

Sorry for the spam, looks like I can just grab the messages via
{{request.messages}} from within the templates.
--~--~-~--~~~---~--~~
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: RequestContext in Generic Views?

2007-12-17 Thread gtaylor

I know this has been asked a few times and the answer seems to be that
this is already included in generic views by default, but it's just
not showing anything in my {{messages}} variable on all of my generic
views. If i send messages and go to a regular page that's rendered
with render_to_response() and supplied a RequestContext, it works.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



RequestContext in Generic Views?

2007-12-17 Thread gtaylor

Hello,

I'm fairly certain this is a really easy thing I'm just not
understanding. I have some generic views that I want to pass a
RequestContext(request) object, but I'm not exactly sure how to do so.
I've been passing a RequestContext to all of my other pages using
render_to_response(), but I don't see any obvious way to do so with
the generic views for CRUD. Here's the code:

@login_required
def location_list(request):
   """
   Generic view for listing locations.
   """
   loc_set = Location.objects.all()

   pagevars = {
  "page_title": "Location List",
   }

   context_instance = RequestContext(request)
   return listviews.object_list(request, queryset=loc_set,
paginate_by=100,
  extra_context=pagevars,
  template_name='assets/
location_list.html')

So how do I stuff this context_instance variable until there? The
reason for this is to render messages, right now I don't have access
to them in generic views.

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 CheckboxSelectMultiple

2007-12-17 Thread Alex Ezell
I have several fields define in my models like this:
CREDENTIALS_CHOICES = (
('LM', "Commercial Driver's License"),
('IN', 'Insured'),
('DR', 'DOT Registered (Interstate)'),
('FI', 'Fragile Item Qualified'),
)
credentials = models.CharField(max_length=2, blank=True,
choices=CREDENTIALS_CHOICES)

Then, I have them described in my form class as this:

credentials = forms.ChoiceField(choices=Truckshare.CREDENTIALS_CHOICES)

What I would like to do is use a CheckboxSelectMultiple for this field.
However, when I do that like this:

credentials = forms.ChoiceField(choices=Truckshare.CREDENTIALS_CHOICES
,widget=CheckboxSelectMultiple)

but that will fail because it will submit multiple values to the model and
since it's ChoiceField, it will complain.

How can I set this up so that I can use choices in my model and use a
CheckboxSelectMultiple field via newforms?

Thanks!

/alex

--~--~-~--~~~---~--~~
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 admin: Is this possible with 'list_filter'??

2007-12-17 Thread weathermess

Seems someone has already given this way better thought than I did.
See: "newforms-admin enable registering custom FilterSpecs" [1]

Very interesting indeed.

[1] http://code.djangoproject.com/ticket/5833


On Dec 18, 4:45 am, weathermess <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I have a question about the use of 'list_filter' in the Django admin:
>
> Is it possible to filter a list of records ('Chapters') of model 'B'
> by a field ('language') of model 'A' (to which a ForeignKey field in
> model 'B' is referring)?
>
> For example:
> ---
> #model 'B'
> class Book(models.Model):
> title = models.CharField(max_length=100)
> author = models.CharField(max_length=100)
> language = models.CharField(max_length=30)  # << filter
>
> # model 'B'
> class Chapter(models.Model):
> title = models.CharField(max_length=100)
> book = models.ForeignKey(Book)
> ---
>
> Overriding default manager 'objects' seems too rigid, since all
> records must be listed when I desire so.
>
> I gave the issue a very slow thought just ago and I wondered: Wouldn't
> it be nice if you could specify dedicated managers to be used for a
> certain 'list_filter'?
>
> You could then attach an advanced (or not so advanced) manager to each
> filter criterion.
>
> Like:
> ---
> list_filter = (
> ('language', {
> 'english': ('objects_en',),
> 'french': ('objects_fr',)
> }),
> )
> ---
>
> Would this make any sense at all?
>
> Maybe newforms-admin already provides hooks for similar functionality.
>
> My initial question and the subsequent proposal diverge a bit. Any
> help or comments on either are greatly appreciated. Really!
>
> So long,
> Weather
--~--~-~--~~~---~--~~
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 admin: Is this possible with 'list_filter'??

2007-12-17 Thread weathermess

Hello,

I have a question about the use of 'list_filter' in the Django admin:

Is it possible to filter a list of records ('Chapters') of model 'B'
by a field ('language') of model 'A' (to which a ForeignKey field in
model 'B' is referring)?

For example:
---
#model 'B'
class Book(models.Model):
title = models.CharField(max_length=100)
author = models.CharField(max_length=100)
language = models.CharField(max_length=30)  # << filter

# model 'B'
class Chapter(models.Model):
title = models.CharField(max_length=100)
book = models.ForeignKey(Book)
---

Overriding default manager 'objects' seems too rigid, since all
records must be listed when I desire so.

I gave the issue a very slow thought just ago and I wondered: Wouldn't
it be nice if you could specify dedicated managers to be used for a
certain 'list_filter'?

You could then attach an advanced (or not so advanced) manager to each
filter criterion.

Like:
---
list_filter = (
('language', {
'english': ('objects_en',),
'french': ('objects_fr',)
}),
)
---

Would this make any sense at all?

Maybe newforms-admin already provides hooks for similar functionality.

My initial question and the subsequent proposal diverge a bit. Any
help or comments on either are greatly appreciated. Really!

So long,
Weather
--~--~-~--~~~---~--~~
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 admin: Is this possible with 'list_filter'??

2007-12-17 Thread weathermess

Hello,

I have a question about the use of 'list_filter' in the Django admin:

Is it possible to filter a list of records ('Chapters') of model 'B'
by a field ('language') of model 'A' (to which a ForeignKey field in
model 'B' is referring)?

For example:
---
#model 'B'
class Book(models.Model):
title = models.CharField(max_length=100)
author = models.CharField(max_length=100)
language = models.CharField(max_length=30)  # << filter

# model 'B'
class Chapter(models.Model):
title = models.CharField(max_length=100)
book = models.ForeignKey(Book)
---

Overriding default manager 'objects' seems too rigid, since all
records must be listed when I desire so.

I gave the issue a very slow thought just ago and I wondered: Wouldn't
it be nice if you could specify dedicated managers to be used for a
certain 'list_filter'?

You could then attach an advanced (or not so advanced) manager to each
filter criterion.

Like:
---
list_filter = (
('language', {
'english': ('objects_en',),
'french': ('objects_fr',)
}),
)
---

Would this make any sense at all?

Maybe newforms-admin already provides hooks for similar functionality.

My initial question and the subsequent proposal diverge a bit. Any
help or comments on either are greatly appreciated. Really!

So long,
Weather
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Easy to use web load/profiler testing

2007-12-17 Thread mamcxyz

I'm close to launch a redesing of www.paradondevamos.com, with social
& multimedia capabilities.

I wonder what kind of tool let me do load testing against the site.
This is my base config:

- I'm running under joyent "M" virtual server, so Solaris 10, 256 RAM.
- I plan to use nginx as server for everything
- Postgressql last version
- Site with: last django trunk, comments_utils, voting, blogging,
news, events system similar to imthere.com but simpler, photos &
videos offloading to divshare, search engine with pyLucene, mootools,
small graphics all pngs low size.

I run this site before with a small 1.000 visitors/month. So I don't
have a strong baseline for performance and really, I don't have
presure on this. However, I think is valuable for learning & for build
a more robust framework on top of django for reuse if I start to care
about how this could lead to a high load.

I wanna to calculate the memory and hits/seconds this could handle,
working up-start from zero optimization, obviosu then in the end
profiling.

I try in the past tools like Apahce JMeter but really, I don't make
sense of it :(. I wanna walk all the links, check for 500 &404, do
form processing, and simulate concurrent users.

What tool do you use for this? I prefer something simple and best if
can give me a couple of charts. Could be windows or linux. I don't
mind a command line one.
--~--~-~--~~~---~--~~
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 do you add the edit of another object from another object's admin view

2007-12-17 Thread Brian Rosner

On 2007-12-17 11:34:47 -0700, "[EMAIL PROTECTED]" 
<[EMAIL PROTECTED]> said:

> 
> Dear all,
> 
> I have two object :
> 
> 1. contacts
> 2. phone number
> 
> contacts and phone number is linked via a primary key foreign key
> connection with the primary key in contacts. The way the admin
> interface is done now is that the contact object has an add function
> and the contacts too has an add function. My question is instead of
> having the phone object seperate can i add the adding of phone numbers
> from the contacts admin form ?

Yes, you can. This is called edit_inline in Django. Check out [1] and 
read that section. It will show you how to accomplish edit_inline.

[1]: 
http://www.djangoproject.com/documentation/model-api/#many-to-one-relationships


Thanks.


-- 
Brian Rosner
http://oebfare.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: Limit Spam

2007-12-17 Thread rskm1

> On Sun, 2007-12-16 at 10:56 -0500, Tim Riley wrote:
> > Is there a way that the admins can limit the amount of spam coming
> > from this mailing list?

I've never moderated a google group, but it seems like a nice feature
would be the ability to require moderator approval of the FIRST post
made by any new subscriber.  Full moderation would be ridiculous for a
list with this much traffic, but clearly the current automated
screening&approval process for new subscribers isn't good enough to
keep spammers out.

But forcing the *first* post from any new subscriber to be approved by
a moderator would be the best of both worlds.  I know I should
probably submit the idea to the google-group folks, but I doubt they'd
pay any heed to suggestions coming from someone who wasn't even a
moderator of one of their groups.

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



Choices from table vs. Foreign Key relationship.

2007-12-17 Thread radioflyer

So the recommendation seems to be when your selection choices are not
static you should go ahead and use a Foreign Key relationship. You get
the automatic loading of the table into a select widget etc.

But there's this issue of the cascade on delete.

I have a Student model with a Foreign Key relationship to Teacher.
When a teacher is removed, so go the students. Too dangerous for my
particular scenario. There doesn't seem to be a Django feature that
allows for adjusting the cascade.

I thought to uncouple the relationship and use the Teacher model
strictly as a 'lookup table.'

What are best practices on this? What will I be losing if I just load
the teachers as 'choices' on the student forms? Is it worth creating
my own cascade protection to keep the Foreign Key relationship?
--~--~-~--~~~---~--~~
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 forloop.counter0 on a variable

2007-12-17 Thread Martin Conte Mac Donell
What about

$
{% filter floatformat:2 %}
{% get_element secondprice forloop.counter0 %}
{% endfilter %}


Regards,
-- 
Martín Conte Mac Donell

On Dec 17, 2007 6:53 PM, Greg <[EMAIL PROTECTED]> wrote:

>
> Martin,
> Yep...that worked.  Thanks!
>
> However, now I'm not using the '|floatformat:2'.  Is there anyway that
> I can use that in my template with the new way:
>
> ${% get_element secondprice forloop.counter0 %}
>
> For an example...currently I'm getting back 124.1...I would like to
> have it be 124.10
>
>
> On Dec 17, 1:54 pm, "Martin Conte Mac Donell" <[EMAIL PROTECTED]>
> wrote:
> > You can do that with a very simple template tag
> >
> > register = template.Library()
> >
> > @register.simple_tag
> > def get_element(list, index):
> > # You should catch IndexError here.
> > return list[index]
> >
> > Template side:
> >
> > {% get_element secondprice forloop.counter0 %}
> >
> > Regards,
> > Martin Conte Mac Donell
> >
> >
> >
> >
> >
> > > On Dec 17, 2007 3:06 PM, Greg < [EMAIL PROTECTED]> wrote:
> >
> > > > Hello,
> > > > I have the following in my template:
> >
> > > > {% for a in thespinfo %}
> > > > {{ secondprice.forloop.counter0|floatformat:2 }}
> > > > {% endfor %}
> >
> > > > However, nothing appears when I run this code
> >
> > > > ///
> >
> > > > My secondprice variable contians a list like ['25', '14', '56'].
>  Each
> > > > time that my for loop is run through then I want to display that
> > > > current element in the secondprice element.  So the first time my
> loop
> > > > is run through then I want it to loop like:
> >
> > > > {{ secondprice.0|floatformat:2 }}...then next time like {{
> secondprice.
> > > > 1|floatformat:2 }}...etc- Hide quoted text -
> >
> > - Show quoted text -
> >
>

--~--~-~--~~~---~--~~
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: Changing sort order of admin select object

2007-12-17 Thread borntonetwork

Thank you Malcom.

Could you tell me: when the functionality is available, do you know
what the steps to create the sort order will be?


On Dec 17, 7:38 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2007-12-16 at 17:42 -0800,borntonetworkwrote:
> > Hello.
>
> > Does anyone have an idea how to create a specific sort order for a
> > select box that represents a foreign key field in a django admin
> > change form.
>
> > For example, when adding a new "book" object via the django admin
> > change form, one may see "Name", "Author", and "Category" inputs. The
> > "Category" input is a select box, filled with data from a foreign key
> > that maps to a table named "categories".
>
> > The problem with my form is that the list of categories in the select
> > box are not ordered by name (perhaps they are ordered by the primary
> > key -- I'm not sure). I've played with the ordering() method but that
> > only seems to work in my custom pages, not the admin form.
>
> > Any help is appreciated.
>
> I think the situation at the moment is that what you're after isn't
> easily achievable on trunk. In the near future this will be possible,
> though (it's fixed on the queryset-refactor branch). The default
> ordering on a related model will be used to order the results returned
> for that model (and cross-model ordering will be easier, too). This
> isn't ready for use yet, but it's something to look forwards to.
>
> Regards,
> Malcolm
>
> --
> If it walks out of your refrigerator, LET IT 
> GO!!http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
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: Templates, filesystem, caching?

2007-12-17 Thread James Bennett

On Dec 17, 2007 4:03 PM, Rob Hudson <[EMAIL PROTECTED]> wrote:
> If I understand correctly, these cache the templates after they have
> been rendered.  What I'm curious about is if there is a way to cache
> templates before they are rendered so you can provide different
> contexts to them.  It seems like there would still be some gains
> involved -- a filesystem read, parsing the template into nodes, etc.

Manually call get_template() or select_template(), and stuff the
resulting Template object into a module-global variable somewhere.
Then just re-use it, calling render() with different contexts, each
time you need it.


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



Re: Templates, filesystem, caching?

2007-12-17 Thread Michael Elsdörfer

Rob Hudson schrieb:
> If I understand correctly, these cache the templates after they have 
> been rendered.  What I'm curious about is if there is a way to cache 
> templates before they are rendered so you can provide different 
> contexts to them.  It seems like there would still be some gains 
> involved -- a filesystem read, parsing the template into nodes, etc.

I've been wondernig the same thing. If I do {% include "item.html" %} 
for 200 items, will item.html be re-read each time? Glancing at the 
code, it appears so.

Michael

--~--~-~--~~~---~--~~
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: get_absolute_url not working as expected

2007-12-17 Thread Jan Rademaker

> If that does not get you any further, could you paste your complete
> model on dpaste.com?

Never mind dpaste, just post to this group.
--~--~-~--~~~---~--~~
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: Dynamic template loader

2007-12-17 Thread Enoch

Hello

Could u share your code of the new template extends tag? I have very
similar problems here.

Kind Regards

Enoch Qin

On Nov 27, 5:58 pm, jorjun <[EMAIL PROTECTED]> wrote:
> OK, managed to do this in the end, by creating a new template tag and
> node derived from django.template.loader_tag.ExtendsNode
> overriding the get_parent method.
>
> Now we have total white labeling of all our templates, including base
> templates.
>
> Django rocks.
> On 27 Nov, 12:20, jorjun <[EMAIL PROTECTED]> wrote:
>
>
>
> > I am trying to work out the best way to allow dynamic template
> > substitution based on RequestContext
>
> > Could anybody point me in the right direction? I don't know if I need
> > a new template loader, or I need to create new tags.
>
> > But in this case :
>
> > {%extends"myapp/base.html" %}
>
> > I would like it to look in "client1_overlay/base.html" if found,
> > otherwise to default to the normal template loading mechanism.
> > If client2 requests a page, then I need to use a different template
> > "client2_overlay/base.html" if found.
>
> > Basically I want to customiseTEMPLATE_DIRSdepending on information
> > in the RequestContext. This way I can implement 'dynamic skinning'.
>
> > Suggestions, comments, advice greatly welcomed.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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: get_absolute_url not working as expected

2007-12-17 Thread Florian Lindner


Am 17.12.2007 um 23:03 schrieb Jan Rademaker:

>
>
> On Dec 17, 6:36 pm, Florian Lindner <[EMAIL PROTECTED]> wrote:
>>
>> my code in the model:
>>
>>def get_absolute_url(self):
>>return self.id
>>
>> Anyone else got an idea? I would send anyone any code he requests...
>>
> Are you sure your code is indented right, e.g. did you mix spaces and
> tabs? Did you try to raise an exception in the method? A simple
> `assert False` before `return self.id` should do.

Yes, it was really a tab/whitespace problem. I've switched to Mac OS  
about a month ago and I'm not yet familiar with the editor I choose.

Thanks a lot!

Florian

--~--~-~--~~~---~--~~
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: Templates, filesystem, caching?

2007-12-17 Thread Rob Hudson

On 12/17/07, Alex Koshelev <[EMAIL PROTECTED]> wrote:
>
> http://www.djangoproject.com/documentation/cache/

If I understand correctly, these cache the templates after they have
been rendered.  What I'm curious about is if there is a way to cache
templates before they are rendered so you can provide different
contexts to them.  It seems like there would still be some gains
involved -- a filesystem read, parsing the template into nodes, etc.

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: get_absolute_url not working as expected

2007-12-17 Thread Jan Rademaker


On Dec 17, 6:36 pm, Florian Lindner <[EMAIL PROTECTED]> wrote:
>
> my code in the model:
>
> def get_absolute_url(self):
> return self.id
>
> Anyone else got an idea? I would send anyone any code he requests...
>
Are you sure your code is indented right, e.g. did you mix spaces and
tabs? Did you try to raise an exception in the method? A simple
`assert False` before `return self.id` should do.

If that does not get you any further, could you paste your complete
model on dpaste.com?

Regards,

Jan Rademaker


--~--~-~--~~~---~--~~
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 forloop.counter0 on a variable

2007-12-17 Thread Greg

Martin,
Yep...that worked.  Thanks!

However, now I'm not using the '|floatformat:2'.  Is there anyway that
I can use that in my template with the new way:

${% get_element secondprice forloop.counter0 %}

For an example...currently I'm getting back 124.1...I would like to
have it be 124.10


On Dec 17, 1:54 pm, "Martin Conte Mac Donell" <[EMAIL PROTECTED]>
wrote:
> You can do that with a very simple template tag
>
> register = template.Library()
>
> @register.simple_tag
> def get_element(list, index):
> # You should catch IndexError here.
> return list[index]
>
> Template side:
>
> {% get_element secondprice forloop.counter0 %}
>
> Regards,
> Martin Conte Mac Donell
>
>
>
>
>
> > On Dec 17, 2007 3:06 PM, Greg < [EMAIL PROTECTED]> wrote:
>
> > > Hello,
> > > I have the following in my template:
>
> > > {% for a in thespinfo %}
> > > {{ secondprice.forloop.counter0|floatformat:2 }}
> > > {% endfor %}
>
> > > However, nothing appears when I run this code
>
> > > ///
>
> > > My secondprice variable contians a list like ['25', '14', '56'].  Each
> > > time that my for loop is run through then I want to display that
> > > current element in the secondprice element.  So the first time my loop
> > > is run through then I want it to loop like:
>
> > > {{ secondprice.0|floatformat:2 }}...then next time like {{ secondprice.
> > > 1|floatformat:2 }}...etc- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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: Templates, filesystem, caching?

2007-12-17 Thread Alex Koshelev

http://www.djangoproject.com/documentation/cache/

On 17 дек, 23:49, "Rob Hudson" <[EMAIL PROTECTED]> wrote:
> Howdy,
>
> A thought occurred to me today and I'm not 100% sure what Django does
> by default...
>
> Similar to the idea that PHP parses scripts for each request and
> having an opcode cache can increase performance, I'm wondering if
> Django reads templates from the file system, parses them, and then
> does the context replacement on them for each and every request.  And
> if so, would there be some optimization to be gleaned by caching the
> parsed templates?  (Maybe optionally tied to DEBUG=False?)
>
> 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: Problem trying to configure Django with FastCGI and Lighttpd

2007-12-17 Thread Chris Moffitt
In your mysite.fcgi script, just pass in the variable "prefork" instead of
threaded.

The other thing you could try is to use the ip address instead of 127.0.0.1.

-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: My MiniCity

2007-12-17 Thread esmail al-hasni
I would like you to stop sending messages to me. 
   
  Thanks.

"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
  
Check this game out! This is my city: http://mikeyopolis.myminicity.com

Whenever someone clicks on it, I get points! Start one up for
yourself!



   
-
Looking for last minute shopping deals?  Find them fast with Yahoo! Search.
--~--~-~--~~~---~--~~
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: Need help with book tutorial

2007-12-17 Thread intercoder

Thanks Jim for your help.  I have decided to set up one of the
database engines.

:-)

On Dec 17, 11:13 am, intercoder <[EMAIL PROTECTED]> wrote:
> So, should I make a file in the settings.py file called
> django_session, or something like that?
>
> Thanks again.:-)
>
> On Dec 13, 2:01 pm, jim <[EMAIL PROTECTED]> wrote:
>
> > Even if your simple app dosen't do anything with the database, django
> > still needs those values populated in the settings.py file as the
> > applications inside the INSTALLED_APPS requires it.
>
> > e.g. by default your settings.py will contain:
>
> > INSTALLED_APPS = (
> > 'django.contrib.auth',
> > 'django.contrib.contenttypes',
> > 'django.contrib.sessions',
> > 'django.contrib.sites',
> > )
>
> > python goes and builds tables for these e.g. it will create a table
> > called django_session.
>
> > Jim
>
> > On Dec 13, 3:39 pm, intercoder <[EMAIL PROTECTED]> wrote:
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Templates, filesystem, caching?

2007-12-17 Thread Rob Hudson

Howdy,

A thought occurred to me today and I'm not 100% sure what Django does
by default...

Similar to the idea that PHP parses scripts for each request and
having an opcode cache can increase performance, I'm wondering if
Django reads templates from the file system, parses them, and then
does the context replacement on them for each and every request.  And
if so, would there be some optimization to be gleaned by caching the
parsed templates?  (Maybe optionally tied to DEBUG=False?)

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: Problem trying to configure Django with FastCGI and Lighttpd

2007-12-17 Thread simonjwoolf

0.97-pre-SVN-6940
Nothing much in the logs.
I just tried telnet 127.0.0.1 3303 and I get connection refused, so
maybe that is where the problem lies . . .

On Dec 17, 7:54 pm, "Martin Conte Mac Donell" <[EMAIL PROTECTED]>
wrote:
> Which version of django are you using? What do you see on lighttpd logs? Is
> port 3303 open with fcgi process?
>
> Regards,
>
> Martin Conte Mac Donell
>
> On Dec 17, 2007 4:23 PM, Chris Moffitt <[EMAIL PROTECTED]> wrote:
>
>
>
> > Take a look in the lighttpd server logs to see if there are any errors
> > that might point you in the right direction.
>
> > The other thing is that you're running this threaded but you're spawning
> > multiple processes.  I suspect that could be causing problems too.  Trying
> > running it prefork and see if that helps.
>
> > -Chris- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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: Problem trying to configure Django with FastCGI and Lighttpd

2007-12-17 Thread simonjwoolf

How would I "run it prefork"? Sorry to be a dunce - I'm a bit new to
this!
I checked the logs, nothing in the error logs since I made a couple of
changes, thus:

fastcgi.server = (
"/mysite.fcgi" => (
"main" => (
# Use host / port instead of socket for TCP fastcgi
   "bin-path" => "/home/myuser_stage/mysite_project/www/mysite.fcgi",
   "socket" => "/home/myuser_stage/mysite_project/www/
mysite.sock",
   "check-local" => "disable",
)
),
)


On Dec 17, 7:23 pm, "Chris Moffitt" <[EMAIL PROTECTED]> wrote:
> Take a look in the lighttpd server logs to see if there are any errors that
> might point you in the right direction.
>
> The other thing is that you're running this threaded but you're spawning
> multiple processes.  I suspect that could be causing problems too.  Trying
> running it prefork and see if that helps.
>
> -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: Problem trying to configure Django with FastCGI and Lighttpd

2007-12-17 Thread Martin Conte Mac Donell
Which version of django are you using? What do you see on lighttpd logs? Is
port 3303 open with fcgi process?

Regards,

Martin Conte Mac Donell

On Dec 17, 2007 4:23 PM, Chris Moffitt <[EMAIL PROTECTED]> wrote:

> Take a look in the lighttpd server logs to see if there are any errors
> that might point you in the right direction.
>
> The other thing is that you're running this threaded but you're spawning
> multiple processes.  I suspect that could be causing problems too.  Trying
> running it prefork and see if that helps.
>
> -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: Using forloop.counter0 on a variable

2007-12-17 Thread Martin Conte Mac Donell
You can do that with a very simple template tag

register = template.Library()

@register.simple_tag
def get_element(list, index):
# You should catch IndexError here.
return list[index]


Template side:

{% get_element secondprice forloop.counter0 %}


Regards,
Martin Conte Mac Donell


>
> On Dec 17, 2007 3:06 PM, Greg < [EMAIL PROTECTED]> wrote:
>
> >
> > Hello,
> > I have the following in my template:
> >
> > {% for a in thespinfo %}
> > {{ secondprice.forloop.counter0|floatformat:2 }}
> > {% endfor %}
> >
> > However, nothing appears when I run this code
> >
> > ///
> >
> > My secondprice variable contians a list like ['25', '14', '56'].  Each
> > time that my for loop is run through then I want to display that
> > current element in the secondprice element.  So the first time my loop
> > is run through then I want it to loop like:
> >
> > {{ secondprice.0|floatformat:2 }}...then next time like {{ secondprice.
> > 1|floatformat:2 }}...etc
> >
> >
> >
> > > >
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: New user having trouble with First View

2007-12-17 Thread newDjangoer

Thanks,

I changed that and my path in urls.py and it worked. I appreciate the
help.



On Dec 17, 2:37 pm, "Tim Riley" <[EMAIL PROTECTED]> wrote:
> you are missing the beginning quote in the html line.
>
> On Dec 17, 2007 2:27 PM, newDjangoer <[EMAIL PROTECTED]> wrote:
>
>
>
> > That is the html line
>
> > from django.http import HttpResponse
> > import datetime
>
> > def current_datetime(request):
> > now = datetime.datetime.now()
> > html = :It is now %s." % now
> > return HttpResponse(html)
>
> > On Dec 17, 2:13 pm, Christian Joergensen <[EMAIL PROTECTED]> wrote:
> > > newDjangoer wrote:
> > > > Hello,
>
> > > > I am a new user to Django and developing apps at that. I ran the
> > > > server successfully . Once I created the "First View" tutorial
> > > > (datetime page17) in the book and changed the settings.py and urls.py,
> > > > I get the following:
>
> > > [...]
>
> > > > Exception Type:SyntaxError
> > > > Exception Value:   invalid syntax (views.py, line 6)
>
> > > What's on that line?
>
> > > --
> > > Christian Joergensen | Linux, programming or web 
> > > consultancyhttp://www.razor.dk| Visit us at:http://www.gmta.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: New user having trouble with First View

2007-12-17 Thread Tim Riley

you are missing the beginning quote in the html line.

On Dec 17, 2007 2:27 PM, newDjangoer <[EMAIL PROTECTED]> wrote:
>
> That is the html line
>
>
> from django.http import HttpResponse
> import datetime
>
> def current_datetime(request):
> now = datetime.datetime.now()
> html = :It is now %s." % now
> return HttpResponse(html)
>
> On Dec 17, 2:13 pm, Christian Joergensen <[EMAIL PROTECTED]> wrote:
> > newDjangoer wrote:
> > > Hello,
> >
> > > I am a new user to Django and developing apps at that. I ran the
> > > server successfully . Once I created the "First View" tutorial
> > > (datetime page17) in the book and changed the settings.py and urls.py,
> > > I get the following:
> >
> > [...]
> >
> > > Exception Type:SyntaxError
> > > Exception Value:   invalid syntax (views.py, line 6)
> >
> > What's on that line?
> >
> > --
> > Christian Joergensen | Linux, programming or web 
> > consultancyhttp://www.razor.dk | Visit us at:http://www.gmta.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: New user having trouble with First View

2007-12-17 Thread newDjangoer

That is the html line


from django.http import HttpResponse
import datetime

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

On Dec 17, 2:13 pm, Christian Joergensen <[EMAIL PROTECTED]> wrote:
> newDjangoer wrote:
> > Hello,
>
> > I am a new user to Django and developing apps at that. I ran the
> > server successfully . Once I created the "First View" tutorial
> > (datetime page17) in the book and changed the settings.py and urls.py,
> > I get the following:
>
> [...]
>
> > Exception Type:SyntaxError
> > Exception Value:   invalid syntax (views.py, line 6)
>
> What's on that line?
>
> --
> Christian Joergensen | Linux, programming or web 
> consultancyhttp://www.razor.dk | Visit us at:http://www.gmta.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: Problem trying to configure Django with FastCGI and Lighttpd

2007-12-17 Thread Chris Moffitt
Take a look in the lighttpd server logs to see if there are any errors that
might point you in the right direction.

The other thing is that you're running this threaded but you're spawning
multiple processes.  I suspect that could be causing problems too.  Trying
running it prefork and see if that helps.

-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: New user having trouble with First View

2007-12-17 Thread Christian Joergensen

newDjangoer wrote:
> Hello,
> 
> I am a new user to Django and developing apps at that. I ran the
> server successfully . Once I created the "First View" tutorial
> (datetime page17) in the book and changed the settings.py and urls.py,
> I get the following:

[...]

> Exception Type:   SyntaxError
> Exception Value:  invalid syntax (views.py, line 6)

What's on that line?

-- 
Christian Joergensen | Linux, programming or web consultancy
http://www.razor.dk  | Visit us at: http://www.gmta.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
-~--~~~~--~~--~--~---



Problem trying to configure Django with FastCGI and Lighttpd

2007-12-17 Thread simonjwoolf

HI,

Does anyone have recent experience of setting of a Django site with
FastCGI and Lighttpd?
We have a new dedicated server and have been trying to set this up
without succcess.

Software:

Lighttpd 1.4.18
Flup 0.5
Django 0.97 pre-SVN (ie: current SVN trunk)

Excerpt from Lighttpd config:
--
fastcgi.debug = 1

fastcgi.server = (
"/mysite_project.fcgi" => (
"main" => (
# Use host / port instead of socket for TCP fastcgi
 "bin-path" => "/home/myuser/mysite_project/www/mysite.fcgi",
 "host" => "127.0.0.1",
 "port" => 3303,
   #"socket" => "/home/myuser/mysite_project/www/mysite.sock",
"check-local" => "disable",
 "min-procs" => 2,
 "max-procs" => 4,
)
),
)
alias.url = (
"/media/" => "/usr/local/django/contrib/admin/media/",
)

url.rewrite-once = (
#"^(/media.*)$" => "$1",
#"^/favicon\.ico$" => "/media/favicon.ico",
"^(/.*)$" => "/mysite_project.fcgi$1",
)
--

mysite.fcgi file looks like this:

--
#!/usr/bin/python2.4
import sys, os

# Add a custom Python path.
sys.path.insert(0, "/home/myuser_stage/mysite_project")

# Switch to the directory of your project. (Optional.)
os.chdir("/home/myuser_stage/mysite_project/")

# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "mysite_project.settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded")

--

When we start lighttd, it spawns 4 fastcgi processes, but on visiting
the site url we just see:

---
Unhandled Exception

An unhandled exception was thrown by the application.

--



We've verified that Django is properly installed by testing it with
its built in webserver - which works fine.

What are we doing wrong?

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



My MiniCity

2007-12-17 Thread [EMAIL PROTECTED]

Check this game out!  This is my city: http://mikeyopolis.myminicity.com

Whenever someone clicks on it, I get points!  Start one up for
yourself!
--~--~-~--~~~---~--~~
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 do you add the edit of another object from another object's admin view

2007-12-17 Thread [EMAIL PROTECTED]

Dear all,

I have two object :

1. contacts
2. phone number

contacts and phone number is linked via a primary key foreign key
connection with the primary key in contacts. The way the admin
interface is done now is that the contact object has an add function
and the contacts too has an add function. My question is instead of
having the phone object seperate can i add the adding of phone numbers
from the contacts admin form ?

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: Performance of a django website

2007-12-17 Thread lgr888999

Whats really interesting in this discussion is that there are no words
about the django application it self have you coded your
application in a django effencient way?
--~--~-~--~~~---~--~~
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: newforms-admin: allow_tags and autoescape

2007-12-17 Thread Karen Tracey
On Dec 17, 2007 12:31 PM, Michel Thadeu Sabchuk <[EMAIL PROTECTED]> wrote:

>
> Hi!
>
> I could not find an open ticket so I open it myself ;)
> http://code.djangoproject.com/ticket/6226
>
> I could write the patch, but I don't know what is the best approach,
> if we must port allow_tags or if the function should return a
> SafeString instance. Even breaking backward compatibility, I think to
> return a SafeString smarter ;)
>

Patch just need to do the same thing as was done for the problem on trunk.
You can see that changeset here:

http://code.djangoproject.com/changeset/6703

It's pretty simple, and the code is in the same place (same file anyway,
line numbers may be slightly different) in newforms-admin.

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: Need help with book tutorial

2007-12-17 Thread intercoder

So, should I make a file in the settings.py file called
django_session, or something like that?

Thanks again.:-)

On Dec 13, 2:01 pm, jim <[EMAIL PROTECTED]> wrote:
> Even if your simple app dosen't do anything with the database, django
> still needs those values populated in the settings.py file as the
> applications inside the INSTALLED_APPS requires it.
>
> e.g. by default your settings.py will contain:
>
> INSTALLED_APPS = (
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.sites',
> )
>
> python goes and builds tables for these e.g. it will create a table
> called django_session.
>
> Jim
>
> On Dec 13, 3:39 pm, intercoder <[EMAIL PROTECTED]> wrote:
>

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



New user having trouble with First View

2007-12-17 Thread newDjangoer

Hello,

I am a new user to Django and developing apps at that. I ran the
server successfully . Once I created the "First View" tutorial
(datetime page17) in the book and changed the settings.py and urls.py,
I get the following:

Request Method: GET
Request URL:http://127.0.0.1:8000/
Exception Type: SyntaxError
Exception Value:invalid syntax (views.py, line 6)
Exception Location: /System/Library/Frameworks/Python.framework/
Versions/2.3/lib/python2.3/site-packages/django/core/urlresolvers.py
in _get_urlconf_module, line 177

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



Using forloop.counter0 on a variable

2007-12-17 Thread Greg

Hello,
I have the following in my template:

{% for a in thespinfo %}
{{ secondprice.forloop.counter0|floatformat:2 }}
{% endfor %}

However, nothing appears when I run this code

///

My secondprice variable contians a list like ['25', '14', '56'].  Each
time that my for loop is run through then I want to display that
current element in the secondprice element.  So the first time my loop
is run through then I want it to loop like:

{{ secondprice.0|floatformat:2 }}...then next time like {{ secondprice.
1|floatformat:2 }}...etc



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

2007-12-17 Thread msoulier

On Dec 2, 8:27 pm, Darryl Ross <[EMAIL PROTECTED]> wrote:
> I've done this is CSS files before, so it should work just fine. Just
> make sure you set the correct Content-Type header in your JS view.

FTR, this works fine. I couldn't use render_to_response() as I had to
supply the mimetype, but otherwise it works fine.

Mike
--~--~-~--~~~---~--~~
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 requires db access to dump sql that it would use in syncdb

2007-12-17 Thread msoulier

I'm trying to write db initialization code for an existing db
framework on a product that I work on. To do this I'm "asking" django
to show SQL that it would use to create its db, so I can copy it into
the initialization code.

I can't though, as I haven't created the db yet, and for some reason
it requires access to the db, even though it's not actually performing
any operations on the db.

[EMAIL PROTECTED] servermanager]# python manage.py sql main
BEGIN;
Traceback (most recent call last):
  File "manage.py", line 12, in ?
execute_manager(settings)
  File "/var/tmp/django-0.96-root/usr/lib/python2.3/site-packages/
django/core/management.py", line 1672, in execute_manager
  File "/var/tmp/django-0.96-root/usr/lib/python2.3/site-packages/
django/core/management.py", line 1632, in execute_from_command_line
  File "/var/tmp/django-0.96-root/usr/lib/python2.3/site-packages/
django/core/management.py", line 123, in get_sql_create
  File "/var/tmp/django-0.96-root/usr/lib/python2.3/site-packages/
django/core/management.py", line 68, in _get_table_list
  File "/var/tmp/django-0.96-root/usr/lib/python2.3/site-packages/
django/db/backends/postgresql_psycopg2/base.py", line 48, in cursor
psycopg2.OperationalError: FATAL:  Password authentication failed for
user "smeserver"

Seems like a bit of a chicken and egg problem. I'll create the db and
user now, but I don't see why it should be required when it's not
being used by the command. I suppose it might not be fixable, as it
may be in the psycopg2 module.

Mike
--~--~-~--~~~---~--~~
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: get_absolute_url not working as expected

2007-12-17 Thread Florian Lindner

Am 16.12.2007 um 18:09 schrieb yml:

>
> Hello,
> This exact situation happens to me sometimes ago and the root cause is
> that either you have an error in your urls.py or you are using the
> decorator "user_passes_test".

Never heard of this decorator therefore I suppose I don't use it. ;-)

>
> In order to solve the first one you should comments all the lines in
> urls.py and uncomment line after line. This is the the method I have
> used so far. If someone have a better one I would be happy to read it.

I've tried that. Stripped down the urls.py to the minimum but nothing  
changed.
This is my complete urls.py:

from django.conf.urls.defaults import *
from models import *

info_dict = { "queryset": BlogEntry.objects.all().order_by("- 
creationDate"), }

urlpatterns = patterns("",
 (r'^$', 'django.views.generic.list_detail.object_list',  
dict(info_dict, allow_empty=True, paginate_by=3)),
 (r'^page(?P[0-9]+)/$',  
'django.views.generic.list_detail.object_list', dict(info_dict,  
allow_empty=True, paginate_by=3)),
 (r'^newComment/$',  
'django.views.generic.create_update.create_object',  
dict(model=BlogComment)),
 (r'^(?P\d+)/$',  
'django.views.generic.list_detail.object_detail', dict(info_dict))
)

the part of the template that is called by list_detail.object_list:

 {{ entry.title }}

is evaluated to:

 vierter eintrag

my code in the model:

def get_absolute_url(self):
return self.id

Anyone else got an idea? I would send anyone any code he requests...

Thanks!

Florian


>
> Regarding the second issue comment the line with the decorator, more
> details on that pb can be found there:
>  * http://code.djangoproject.com/ticket/5925
>
> I hope that help
>
> On 15 déc, 12:30, Florian Lindner <[EMAIL PROTECTED]> wrote:
>> Am 15.12.2007 um 05:03 schrieb Alex Koshelev:
>>
>>
>>
>>> 1) May be string is needed
>>
>> As I said, even when I return a constant string (return "foo") it
>> changing nothing.
>>
>>
>>
>>> 2) Absolute url not uri. So domain name is not needed.
>>
>>> On 15 дек, 01:29, Florian Lindner <[EMAIL PROTECTED]> wrote:
 Hello,
 I have two question regarding get_absolute_url:
>>
 1) I have the template code:
>>
 {% for entry in object_list %}
  {{ entry.title }}>>> h3>
 {% endfor %}
>>
 It's called from a .generic.list_detail.object_list. My
 get_absolute_url is implemented in my model:
>>
 class BlogEntry(Model):
   def get_absolute_url(self):
   return self.id
>>
 but the link in the template is alwayshttp://localhost:8000/blog/
 where blog is my application name and which is also the URL used to
 get to the template above. I can even return anything (like a
 constant
 string) but it's not being taken into account, the link is also the
 same. What is wrong there?
>>
 2) As the name says get_absolute_url should always return a  
 absolute
 URL (which I understand is a complete URL). Is there a standard way
 to
 produce such a URL? For example I need to my server (here is
 localhost:
 8000) and the path to application (blog/).
>>
 Thanks,
>>
 Florian
> >


--~--~-~--~~~---~--~~
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: newforms-admin: allow_tags and autoescape

2007-12-17 Thread Michel Thadeu Sabchuk

Hi!

I could not find an open ticket so I open it myself ;)
http://code.djangoproject.com/ticket/6226

I could write the patch, but I don't know what is the best approach,
if we must port allow_tags or if the function should return a
SafeString instance. Even breaking backward compatibility, I think to
return a SafeString smarter ;)

Thanks for the help,
Best regards.

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



dynamic url use case

2007-12-17 Thread Faheem Mitha


Hi everyone,

I have the following situation, and I would value advice.

I have two classes, FolderUpload and FileUpload as given below. I want
a dynamic upload_to url in FileUpload, such that the upload to field
depends on the value of the folder field, specifically path field. I
realist that currently some workaround is necessary, since Django does
not yet support dynamic upload_to fields. I found the description of
some workarounds, but could not get any of them to work in the
described scenario. I'm hoping that someone will have dealt with a
similar situation, and will have some ideas.

Please cc me by email on any response.
Thanks, Faheem.

*
class FolderUpload(models.Model):
 upload_date = models.DateTimeField(auto_now_add=True)
 name = models.CharField(core=True, maxlength=100)
 description = models.CharField(blank=True, maxlength=200)
 parent_folder = models.ForeignKey('self', null=True, blank=True, 
related_name='subfolders')
 path = models.FilePathField(path='', editable=False)

class FileUpload(models.Model):
 upload_date = models.DateTimeField(default=datetime.now(), blank=True, 
editable=False)
 upload = models.FileField(upload_to=settings.BIXFILE_MEDIA)
 name = models.CharField(core=True, maxlength=100)
 description = models.CharField(blank=True, maxlength=200)
 folder = models.ForeignKey(FolderUpload, null=True, blank=True, 
related_name='parentfolder', edit_inline=models.TABULAR)
**

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



Jsolait, Xmlrpc, Django == MalformedXmlRpc

2007-12-17 Thread Mason

Django Noobie
XMLRPC Noobie
JavaScript (AJAX) Noobie
Jsolait Noobie

Django 0.96
jsolait 1.1 full version
Windows XP


Hello All,

I'm trying to use JavaScript with Jsolait to invoke a Django view
through Xmlrpc, but I guess there is some problem with the parsing
(Unmashalling) of the XML. The Django code I am using is from the Wiki
Django source code page that can be found here:

http://code.djangoproject.com/wiki/XML-RPC

The Django code from Wiki works perfectly well when I make my call
from the IPyhton shell as follows:

In [1]: import sys
In [2]: import xmlrpclib
In [3]: rpc_srv = xmlrpclib.ServerProxy("http://10.3.0.86:8000/dmm/
xml_rpc_srv/")
In [4]: result = rpc_srv.multiply(30,4)
In [5]: result
Out[5]: 120

However when I try to call it from my JaveScript:

/**
 * Load the xmlrpc object and a proxy to the service
 */
var xmlrpc = null;
var server = null;

try{
var xmlrpc = importModule("xmlrpc");
var server = new xmlrpc.ServerProxy('http://10.3.0.86:8000/dmm/
xml_rpc_srv/', ['multiply']);
var response = server.multiply(2,3);
}catch(e){
reportException(e);
throw "importing of xmlrpc module failed.";
}

 I get the following error:

MalformedXmlRpc [module 'xmlrpc' version: 1.3.3]:
  Unmashalling of XML failed.

MalformedXmlRpc [module 'xmlrpc' version: 1.3.3]:
  No documentElement found.


Also, Firefox returns a runtime error on the line that makes the call,
var response = server.multiply(2,3);

I've spent hours, even days Googling and trying different ideas. Does
anyone know what I'm doing wrong?

Thanks,

Mason

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



Jsolait, Xmlrpc, Django == MalformedXmlRpc

2007-12-17 Thread Mason

Django Noobie
XMLRPC Noobie
JavaScript (AJAX) Noobie
Jsolait Noobie

Django 0.96
jsolait 1.1 full version
Windows XP


Hello All,

I'm using trying to use JavaScript with Jsolait to invoke a Django
view through Xmlrpc, but I guess there is some problem with the
parsing (Unmashalling) of the XML. The Django code I am using is from
the Wiki Django source code page that can be found here:

http://code.djangoproject.com/wiki/XML-RPC

The Django code from Wiki works perfectly well when I make my call
from the IPyhton shell as follows:

In [1]: import sys
In [2]: import xmlrpclib
In [3]: rpc_srv = xmlrpclib.ServerProxy("http://10.3.0.86:8000/dmm/
xml_rpc_srv/")
In [4]: result = rpc_srv.multiply(30,4)
In [5]: result
Out[5]: 120

However when I try to call it from my JaveScript:

/**
 * Load the xmlrpc object and a proxy to the service
 */
var xmlrpc = null;
var server = null;

try{
var xmlrpc = importModule("xmlrpc");
var server = new xmlrpc.ServerProxy('http://10.3.0.86:8000/dmm/
xml_rpc_srv/', ['multiply']);
var response = server.multiply(2,3);
}catch(e){
reportException(e);
throw "importing of xmlrpc module failed.";
}

 I get the following error:

MalformedXmlRpc [module 'xmlrpc' version: 1.3.3]:
  Unmashalling of XML failed.

MalformedXmlRpc [module 'xmlrpc' version: 1.3.3]:
  No documentElement found.


Also, Firefox returns a runtime error on the line that makes the call,
var response = server.multiply(2,3);

I've spent hours, even days Googling and trying different ideas. Does
anyone know what I'm doing wrong?

Thanks,

Mason

--~--~-~--~~~---~--~~
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: ModelForm and fields ordering

2007-12-17 Thread Vitaliy

Thanks Malcolm

But I have one little difference between form and model - only one new
field that needs to be on top of all other fields
example:

#model
class SomeModel(modles.Model):
field1
field2
...
field20

#form
class SomeModelForm(forms.ModelForm):
 some_new_field
 class Meta:
  model = SomeModel

thats it !
when form rendered - some_new_field is displayed on the bottom of all
model's fields, but I need to place it on top...


So i found only one way to solve my problem:
class SomeModelForm(forms.ModelForm):
 def __init__(self, *a, **kw):
  super(...)
  self.base_fields.keyOrder = ['some_new_field', 'field1',
'field2', ...]

I` gues nice, but it would be better if this behaviour will be in Meta
--~--~-~--~~~---~--~~
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: QuerySet refactor and IN? (was "How to get SQL "NOT IN" query from filter()")

2007-12-17 Thread Tim Chase

>> This: Model.objects.filter(...).exclude(id__in = processed)
>> gives me: Truncated incorrect DOUBLE value: 'Model object'

I've seen the above request on the ML several times now.

Is there any hope that, in the QuerySet refactor, the "__in" form 
can sniff the datatype of the parameter for other querysets?

Thus, you could have something like

   users = Users.objects.filter(...)
   things = Foo.objects.filter(owner_id__in=users)

it seems that this would just translate to an IN/EXISTS query, 
using the query definition from "users" to build the sub-query. 
It's far more efficient to do that all on the server and just 
return the correct results, rather than

   things = Foo.objects.filter(owner_id__in=[
 user.id for user in users])

which would force the entire set of users to be brought back and 
translated into a list, and then ship off a potentially-long list 
of IDs back in a 2nd query.  (Imagine len(users) > REALLY_BIG_NUM)

The pseudo-code as I'd imagine it would be something like

   if query_type = "in":
 if issubclass(paramenter, QuerySet):
   where_clause = 'IN (SELECT ID FROM %s WHERE %s)' % (
 param.from_clause(), param.where_clause()
 )
 else:
   where_clause = do_whatever_it_currently_does()

I haven't explored the QS refactor branch, but am looking forward 
to its arrival so I can get started on tinkering with the 
aggregate code.

-tkc





--~--~-~--~~~---~--~~
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: ModelForm and fields ordering

2007-12-17 Thread Malcolm Tredinnick


On Mon, 2007-12-17 at 05:13 -0800, Vitaliy wrote:
> How can I change fields order in form generated using ModelForm ?

I think you're approach the problem from the wrong angle. ModelForm is a
shortcut for converting a model directly to a form. If you want to alter
a lot of things, such as the order, then you're going to be writing the
names of all the fields anyway. So write your own little helper function
to construct a form from your models' fields. Base it on the code for
ModelForm or something similar, but just write something specialised.

I'd normally say something like "have a look at how newforms-admin does
this", but, in this case, that would make things worse because the Admin
interface needs to be able to handle all kinds of weird cases, so its
form construction is fairly involved.

Regards,
Malcolm

-- 
Two wrongs are only the beginning. 
http://www.pointy-stick.com/blog/


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



ModelForm and fields ordering

2007-12-17 Thread Vitaliy

How can I change fields order in form generated using ModelForm ?

--~--~-~--~~~---~--~~
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: Time.sleep & HttpResponse

2007-12-17 Thread Malcolm Tredinnick


On Mon, 2007-12-17 at 07:10 -0500, Ariel Calzada wrote:
> l5x wrote:
> > "I propose to design and implement an API to make Comet behavior
> > available to Django applications."
> > http://hosted.corp.it/django/full.html
> > >
> >
> >   
> Good Idea :-)

Keep in mind that that link was a proposal for the recently completed
Google Summer of Code. It wasn't one of the projects we accepted for
this year.

Regards,
Malcolm

-- 
Everything is _not_ based on faith... take my word for it. 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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: Time.sleep & HttpResponse

2007-12-17 Thread Malcolm Tredinnick


On Sun, 2007-12-16 at 16:14 -0800, azer wrote:
> Hi,
> 
> I'm trying to use Time.sleep function on printing, here is the code:
> 
> def sleep(request):
>   res = HttpResponse()
>   res.write("hello")
>   time.sleep(3)
>   res.write("hello");
>   return res
> 
> But it doesn't work (Page waits 3 seconds and prints "hellohello"),
> how can i solve this problem? If we can solve this problem, i think
> that we can create comet applications easily...

Based on your later, slightly cryptic reply in this thread, I gather you
are hoping that HttpResponse is acting as a streamable pipe back to the
browser. This isn't correct. You create an HttpResponse instance and
when you return from your view, Django will send all of the content back
to the user in one go. Nothing happens until you return from the view.

If you want to implement something streamable for Comet purposes, you'll
need to implement your own, slightly lower-level interaction with the
webserver and the downstream client. Django doesn't have built-in
support for that.

Regards,
Malcolm

-- 
Why be difficult when, with a little bit of effort, you could be
impossible. 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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: Changing sort order of admin select object

2007-12-17 Thread Malcolm Tredinnick


On Sun, 2007-12-16 at 17:42 -0800, borntonetwork wrote:
> Hello.
> 
> Does anyone have an idea how to create a specific sort order for a
> select box that represents a foreign key field in a django admin
> change form.
> 
> For example, when adding a new "book" object via the django admin
> change form, one may see "Name", "Author", and "Category" inputs. The
> "Category" input is a select box, filled with data from a foreign key
> that maps to a table named "categories".
> 
> The problem with my form is that the list of categories in the select
> box are not ordered by name (perhaps they are ordered by the primary
> key -- I'm not sure). I've played with the ordering() method but that
> only seems to work in my custom pages, not the admin form.
> 
> Any help is appreciated.

I think the situation at the moment is that what you're after isn't
easily achievable on trunk. In the near future this will be possible,
though (it's fixed on the queryset-refactor branch). The default
ordering on a related model will be used to order the results returned
for that model (and cross-model ordering will be easier, too). This
isn't ready for use yet, but it's something to look forwards to.

Regards,
Malcolm

-- 
If it walks out of your refrigerator, LET IT GO!! 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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: get_absolute_url not working as expected

2007-12-17 Thread Malcolm Tredinnick


On Fri, 2007-12-14 at 23:29 +0100, Florian Lindner wrote:
> Hello,
> I have two question regarding get_absolute_url:
> 
> 1) I have the template code:
> 
> {% for entry in object_list %}
>  {{ entry.title }}
> {% endfor %}
> 
> It's called from a .generic.list_detail.object_list. My  
> get_absolute_url is implemented in my model:
> 
> class BlogEntry(Model):
>   def get_absolute_url(self):
>   return self.id
> 
> but the link in the template is always http://localhost:8000/blog/  
> where blog is my application name and which is also the URL used to  
> get to the template above. I can even return anything (like a constant  
> string) but it's not being taken into account, the link is also the  
> same. What is wrong there?
> 
> 2) As the name says get_absolute_url should always return a absolute  
> URL (which I understand is a complete URL). Is there a standard way to  
> produce such a URL? For example I need to my server (here is localhost: 
> 8000) and the path to application (blog/).

I'm not sure what's going on with the first point. I'd try raising an
exception in that method, though, or writing out to sys.stderr, just to
confirm the method is actually being called without error.

With regards to your second question, the name is a little bit of a
misnomer, resulting from a misunderstanding in the prehistoric days of
Django. Changing it would cause massive upheaval, so we can live with
the misnaming. The scheme ("http" or "https") and site domain name will
be appended to the front of whatever get_absolute_url() returns, so you
need to return everything after the domain name (starting with a slash).
So, it's not really 'absolute'.

Regards,
Malcolm

-- 
Telepath required. You know where to apply... 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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: Limit Spam

2007-12-17 Thread Malcolm Tredinnick


On Sun, 2007-12-16 at 10:56 -0500, Tim Riley wrote:
> Is there a way that the admins can limit the amount of spam coming
> from this mailing list? I am subscribed to many mailing lists and I
> haven't received even a fraction of the spam that I am getting from
> this group.

The spam is already being limited. What isn't happening is that it's
being reduced to zero. This list counts as a very high volume list and
Django is a popular project with high visibility. As such, we're a
target for spammers wanting to appear in search engine. Google's
filtering catches a lot. The rest unfortunately, slips through. Life's
like that on the Internet.

Regards,
Malcolm

-- 
Always try to be modest and be proud of it! 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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: File upload on external server

2007-12-17 Thread Julien

Hi there,

NFS seemed like to easiest way, but the problem is that I'm using 2
different shared hosting services: one for the actual site
(Webfaction) and one for the media storage (Dreamhost). Apparently to
mount NFS directories you need to be root, so that doesn't quite work
in shared hosting situations.

At the moment the media server is already "plugged" via a subdomain
DNS override, i.e. every request to http://static.mydomain.com is
automatically redirected to the Dreamhost account. So it already works
for download.

But how can I manage uploads that are done through FileField? How can
I make uploaded files be stored on the remote media server?

Thanks a bunch!   :)

Julien



On Dec 12, 11:05 pm, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> Julien napisał(a):
>
> > My Django project is served my a certain hosting company, and all the
> > static data (videos, images, etc.) is served by anexternalserver in
> > another hosting company. The static data is access through an A ip
> > redirection for static.mydomain.com
>
> > I'd like to allow users of the website touploadfiles which would be
> > stored on theexternalserver?
> > Is that possible, and if so, how? From the documentation I have seen,
> > it seems like the FileField object can only save files on a local
> > absolute path...
>
> > Any idea?
>
> http://code.djangoproject.com/wiki/AmazonSimpleStorageServiceis good
> starting point (if it works for S3, you should be able to derive from it).
>
> --
> Jarek Zgoda
> Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101
>
> "We read Knuth so you don't have to." (Tim Peters)
--~--~-~--~~~---~--~~
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: Links not working after svn 6915

2007-12-17 Thread Malcolm Tredinnick


On Fri, 2007-12-14 at 16:31 +, Matt Davies wrote:
> Thanks Pete
> 
> You're a star

I don't understand the conclusion here. Does this mean you have to
change your site all over the place? The change in [6852] should have
been very close to backwards compatible except in some really odd
side-cases (flatpages is one we've subsequently discovered).

Do you have a strange static URL pattern and are using the development
server to serve static data?

Malcolm

-- 
I just got lost in thought. It was unfamiliar territory. 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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: newforms-admin: allow_tags and autoescape

2007-12-17 Thread Malcolm Tredinnick


On Fri, 2007-12-14 at 09:29 -0500, Karen Tracey wrote:
[...]

> Looks like a bug in newforms-admin to me. Seems that somehow the fix
> for this on trunk (changeset 6703) didn't get merged into the
> newforms-admin branch.  newforms-admin has code to check the setting
> of allow_tags, so I believe it is intended to work there.  If you
> can't find an already open ticket for this, I'd open one. 

Yeah, that's going to happen sometimes, unfortunately. We're trying hard
not to change (trunk) admin any more than necessary and only apply
non-showstopper fixes to the branch. The auto-escaping changes were one
of those cases where it couldn't be helped, though, and some things
(particularly ones like this where it was only fixed after the main
patch was applied) might have fallen through the cracks.

Definitely open a ticket for this so it doesn't get forgotten next time
Joseph wants to do some relatively easy patch application.

Regards,
Malcolm

-- 
What if there were no hypothetical questions? 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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: Time.sleep & HttpResponse

2007-12-17 Thread Ariel Calzada

l5x wrote:
> "I propose to design and implement an API to make Comet behavior
> available to Django applications."
> http://hosted.corp.it/django/full.html
> >
>
>   
Good Idea :-)

--~--~-~--~~~---~--~~
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: Time.sleep & HttpResponse

2007-12-17 Thread l5x

"I propose to design and implement an API to make Comet behavior
available to Django applications."
http://hosted.corp.it/django/full.html
--~--~-~--~~~---~--~~
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: Passing a dictionary as a query argument?

2007-12-17 Thread Ned Batchelder
If I understand what you're doing here, you need to be very careful.  
Converting a dictionary to a string (or pickle) does not guarantee that 
two equal dictionaries convert into two equal strings (or pickles), 
especially if your version of Python changes.  For example, your code 
below may create a pickle with the key 'foo' first, or it may create a 
pickle with the key 'bar' first.  Both pickles un-pickle to an 
equivalent dictionary, but the pickles won't compare as equal, and your 
queries will fail.

I could be wrong, and the pickle module provides some guarantee about 
the equivalency of pickles, but I don't think so.

--Ned.
http://nedbatchelder.com/blog

[EMAIL PROTECTED] wrote:
> I fixed this -- not Django's fault at all. For the full field code, go
> to http://www.djangosnippets.org/snippets/513/
>
> On Dec 13, 8:08 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>   
>> Hey All,
>>
>> I've just written a custom model field for storing anything which is
>> pickle-able (generally this will be used for storing dictionaries). It
>> all works great, apart from when I want to perform a query on objects
>> using the field as an argument. When doing something like:
>>
>> SomeModel.objects.filter(my_field={'foo': 'bar', 'bar': 'baz'})
>>
>> However, it seems to reduce my dictionary to an iterable containing
>> just the dictionary keys (so, in this case ['foo', 'bar']). I presume
>> Django is doing this by iterating over the dictionary, but obviously
>> this doesn't work for my field. Is there any way to stop Django from
>> doing this, away from overriding query methods in the manager to
>> convert the dictionary to something non-iterable?
>>
>> Any help much appreciated!
>>
>> Thanks,
>> O
>> 
> >
>
>   

-- 
Ned Batchelder, http://nedbatchelder.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: Completely disable auto-escape

2007-12-17 Thread Malcolm Tredinnick


On Fri, 2007-12-14 at 02:18 -0800, Udi wrote:
> Is there any way to turn this completely off?  It would be nice to be
> able to get the latest django src before I refactor all my code to
> handle this new stuff.
> 
> {% autoescape off %} works fine if all of your templates inherit from
> a base, but if you use lots of little tags and elements this may not
> be the case.
> 
> Is there something that I can put in my settings.py file to turn it
> off entirely?

No, and that's by design. Template authors and application writers have
no control over what is in the settings file and those two groups need
to be able to write applications that will work anywhere.

If you really, really need to make this change temporarily, edit your
Django source. In django/template/context.py, change the default value
of "autoescape" in the Context.__init__() parameter list to False.
However, I suspect you'll find there are unintended side-effects. In the
admin application, for example, so be careful.

Regards,
Malcolm

-- 
If Barbie is so popular, why do you have to buy her friends? 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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: Time.sleep & HttpResponse

2007-12-17 Thread azer

Comet:http://www.google.com/search?hl=en&q=comet
reverse ajax: http://www.google.com/search?hl=en&q=reverse ajax

On Dec 17, 3:35 am, l5x <[EMAIL PROTECTED]> wrote:
> If you put /print "hello"/, the server should print it with given
> delay (on the server side).
> I think that you should use JS/AJAX to update the page after it is
> sent to the user (script on the user side).
--~--~-~--~~~---~--~~
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 formtools.preview get AttributeError: 'ModelFormPreviewClass' object has no attribute 'has_header'

2007-12-17 Thread sector119

Hi all!

I try to reimplement django generic create_object and update_object
using newforms and formtools.preview. But I get some problems with
HttpResponseRedirect (can't redirect from model_post_save sub, but
why?) and preview (got strange errors).

When I try to use preview when I create an object I get this:

Traceback (most recent call last):
  File "/home/sector119/devel/django_src/django/core/servers/
basehttp.py", line 277, in run
self.result = application(self.environ, self.start_response)
  File "/home/sector119/devel/django_src/django/core/servers/
basehttp.py", line 619, in __call__
return self.application(environ, start_response)
  File "/home/sector119/devel/django_src/django/core/handlers/
wsgi.py", line 209, in __call__
response = middleware_method(request, response)
  File "/home/sector119/devel/django_src/django/middleware/locale.py",
line 21, in process_response
patch_vary_headers(response, ('Accept-Language',))
  File "/home/sector119/devel/django_src/django/utils/cache.py", line
129, in patch_vary_headers
if response.has_header('Vary'):
AttributeError: 'ModelFormPreviewClass' object has no attribute
'has_header'

# here is create_object  view

from django.core.exceptions import ImproperlyConfigured
#from django.core.urlresolvers import reverse
from django.template import loader, RequestContext
from django.contrib.auth.views import redirect_to_login
from django.http import HttpResponse, HttpResponseRedirect
from django.newforms import ModelForm
#from django.shortcuts import get_object_or_404

from django.contrib.auth.decorators import login_required

from django.utils.translation import ugettext as _

def create_object(request, model, template_name=None,
template_loader=loader, extra_context=None, post_save_redirect=None,
login_required=False, model_form=None, context_processors=None,
preview=False):
"""
Generic object-creation function.

Templates: ``/_form.html``
Context:
form
the form wrapper for the object
"""
# FIXME: 'model' variable is rewriting somewhere in the
ModelFormClass class. But where?
model_ = model

if extra_context is None:
extra_context = {}

if login_required and not request.user.is_authenticated():
return redirect_to_login(request.path)

if model_form is None:
class ModelFormClass(ModelForm):
class Meta:
model = model_
model_form = ModelFormClass

def model_post_save():
if request.user.is_authenticated():
request.user.message_set.create(message=_("The %(verbose_name)s
was created successfully.") % {"verbose_name":
model_._meta.verbose_name})
# Redirect to the new object: first by trying post_save_redirect,
# then by obj.get_absolute_url; fail if neither works.
if post_save_redirect:
return HttpResponseRedirect(post_save_redirect %
new_object.__dict__)
elif hasattr(new_object, 'get_absolute_url'):
return HttpResponseRedirect(new_object.get_absolute_url())
else:
raise ImproperlyConfigured("No URL to redirect to from generic
create view.")

# preview
# AND HERE WE GOT AN ERROR!!!
if preview:
from django.contrib.formtools.preview import FormPreview
class ModelFormPreviewClass(FormPreview):
def done(self, request, cleaned_data):
new_object = model_.objects.create(**cleaned_data)
model_post_save()
return ModelFormPreviewClass(model_form)

if request.method == 'POST':
if not request.FILES:
form = model_form(request.POST)
else:
form = model_form(request.POST, request.FILES)
if form.is_valid():
# No errors -- this means we can save the data!
new_object = form.save()
# This work fine!
#   if post_save_redirect:
#   return HttpResponseRedirect(post_save_redirect %
new_object.__dict__)

# But here, using model_post_save function I can't redirect, nothing
is happen
model_post_save()
else:
form = model_form()

if not template_name:
template_name = "%s/%s_form.html" % (model_._meta.app_label,
model_._meta.object_name.lower())
t = template_loader.get_template(template_name)
c = RequestContext(request, { 'form': form }, context_processors)
for key, value in extra_context.items():
if callable(value):
c[key] = value()
else:
c[key] = value
return HttpResponse(t.render(c))


--~--~-~--~~~---~--~~
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 modify every element in a list all at once

2007-12-17 Thread Andreas Pfrengle

You have to convert s.price.name to float (or .9 to a DecimalObject if
the float-precision should be a problem).
This should work:
for s in s2:
s.price.name = float(s.price.name) * .9
s.price.save()

On Dec 16, 8:43 pm, Greg <[EMAIL PROTECTED]> wrote:
> Shabda,
> I added the following code to my view:
>
> for s in s2:
> s.price.name *= s.price.name * .9
> s.price.save()
>
> 
>
> However, I now get the error:
>
> TypeError at /plush/chandra/antara/108/multi/
> unsupported operand type(s) for *: 'Decimal' and 'float'
>
> On Dec 16, 12:44 pm, shabda <[EMAIL PROTECTED]> wrote:
>
> > How about
>
> > for s in s2:
> > s.price.name *= s.price.name * .9
> > s.price.save()
> > You are getting a type error coz you can not mutlipy a Model object by
> > float, and that is what s.price is. BTW s2[0].price * .9 would not
> > have worked as well, because of the same reasons!
>
> > On Dec 16, 11:08 pm, Greg <[EMAIL PROTECTED]> wrote:
>
> > > Forest,
> > > Here are my models
>
> > > class Style(models.Model):
> > > name = models.CharField(maxlength=200, core=True)
> > > image = models.ForeignKey(Photo)
> > > collection = models.ForeignKey(Collection,
> > > edit_inline=models.TABULAR, num_in_admin=1, num_extra_on_change=3)
> > > sandp = models.ManyToManyField(Choice)
>
> > > class Choice(models.Model):
> > > choice = models.ForeignKey(Collection, edit_inline=models.TABULAR,
> > > num_in_admin=5)
> > > size = models.ForeignKey(Size, core=True)
> > > price = models.ForeignKey(Price, core=True)
> > > orderdisplay = models.IntegerField()
>
> > > class Price(models.Model):
> > > name = models.DecimalField(max_digits=6, decimal_places=2)
>
> > > def __str__(self,):
> > > return str(self.name)
>
> > > ///
>
> > > On Dec 16, 11:56 am, Forest Bond <[EMAIL PROTECTED]> wrote:
>
> > > > Hi,
>
> > > > On Sun, Dec 16, 2007 at 08:37:08AM -0800, Greg wrote:
> > > > > I've tried the following:
>
> > > > > for s in s2:
> > > > > s.price *= s.price * .9
>
> > > > > However, I still get the following error:
>
> > > > > TypeError at /plush/chandra/antara/108/multi/
> > > > > unsupported operand type(s) for *: 'Price' and 'float'
>
> > > > Can you post your models, please?
>
> > > > I take it price is a ForeignKey...
>
> > > > -Forest
> > > > --
> > > > Forest Bondhttp://www.alittletooquiet.net
>
> > > >  signature.asc
> > > > 1KDownload
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---