Django forms and relationships

2009-03-16 Thread tdelam

Hi,

I am using the User model and trying to store additional information
about the person registering. I have a model called UserProfile with a
few additional fields and a FK to the User model. I now have a
forms.py for my forms which consists of:

http://dpaste.com/hold/15470/

My question is how do I store the additional information on save() do
I need to move this save() method out of forms.py? or can I still do
it in here and also store the extra information in the UserProfile
table?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Sending attachments with django-contact-form

2009-03-16 Thread John Hensley

On Mar 16, 2009, at 3:46 PM, Dana wrote:

> I am wondering what the simplest way to send an attachment with  
> django-
> contact-form (http://code.google.com/p/django-contact-form/) is.
[...]
> Im interested in just a simple example of sending a file along with
> the other email information. I have subclassed the contact form and
> just need to add an "attachment" field to the form.

I haven't worked with django-contact-form, but if you add a FileField  
to its ContactForm...

 attachment = forms.FileField(required=False)

... the modified save method could look something like:

 def save(self, fail_silently=False):
 email = EmailMessage(to = self.recipient_list, from_email =  
self.from_email, body = self.message(), subject = self.subject())

 if self.cleaned_data['attachment']:
 file = self.cleaned_data['attachment']
 if hasattr(file, 'path'):
 email.attach_file(file.path)
 else:
 email.attach(file.name, file.read())

 email.send(fail_silently)

That's an untested example; the point is you'll need to look at using  
the EmailMessage directly instead of via send_mail. Have a look at:

http://docs.djangoproject.com/en/dev/topics/email/#the-emailmessage-and-smtpconnection-classes

John


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



Re: best way to organize models that store businesses/hours?

2009-03-16 Thread Alex Gaynor
On Mon, Mar 16, 2009 at 11:26 PM, luxagraf  wrote:

>
> Hello all-
>
> I'm working of a site that will store various business listings
> (restaurants, bars, clubs etc) and then I'd like to also track the
> hours each business is open... The ultimate goal being something like
> lawrence.com's "open now" feature and other time-related queries of
> that type. I'm trying to figure out the best way to store the hours
> data and was wondering if anyone had any suggestions...
>
> Because the open and close times vary by day of the week, storing them
> directly in the business model (or the models inheriting from it in
> this case) isn't possible.
>
> My instinct is to use a separate model for the hours and then tie it
> to the business model using generic relations to span various models.
> I know that would work, but I can't shake the feeling that there's a
> better way and I'm just not seeing it, so I thought I'd throw it out
> there and see what others think.
>
> I also should note that I'm not terribly concerned with the admin
> interface aspect (I don't plan to enter most of this data through the
> admin, it's already in a spreadsheet so I'll likely just load it all
> at once using a script and make the occasional update via the admin).
> My primary concern is optimizing for speed, i.e. the less joins, multi-
> table and other expensive database queries the better.
>
> If anyone has any suggestions or tips I'd love to hear them.
>
> cheers
> Scott Gilbertson
> luxag...@gmail
>
> >
>
I designed something like this a while back(but never had to implement it).
Basically I had a DayHour model that had a foreign key to the "store" model
and kept the start hour and close hour for a given day of the week.  So a
query like what is open now would look like:

Model.objects.filter(hours__day="M",
hours__open__lte=datetime.datetime.now().hour,
hours__close__gte=datetime.datetime.now().hour)

I guess technically you could just have 14 fields on the mode(open and close
for each day of the week), which is fine since days of the week are a static
number of things but that felt bulky to me(though it's probably more
preformant).

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



best way to organize models that store businesses/hours?

2009-03-16 Thread luxagraf

Hello all-

I'm working of a site that will store various business listings
(restaurants, bars, clubs etc) and then I'd like to also track the
hours each business is open... The ultimate goal being something like
lawrence.com's "open now" feature and other time-related queries of
that type. I'm trying to figure out the best way to store the hours
data and was wondering if anyone had any suggestions...

Because the open and close times vary by day of the week, storing them
directly in the business model (or the models inheriting from it in
this case) isn't possible.

My instinct is to use a separate model for the hours and then tie it
to the business model using generic relations to span various models.
I know that would work, but I can't shake the feeling that there's a
better way and I'm just not seeing it, so I thought I'd throw it out
there and see what others think.

I also should note that I'm not terribly concerned with the admin
interface aspect (I don't plan to enter most of this data through the
admin, it's already in a spreadsheet so I'll likely just load it all
at once using a script and make the occasional update via the admin).
My primary concern is optimizing for speed, i.e. the less joins, multi-
table and other expensive database queries the better.

If anyone has any suggestions or tips I'd love to hear them.

cheers
Scott Gilbertson
luxag...@gmail

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



Re: Aggregation Questions

2009-03-16 Thread koranthala



On Mar 16, 11:44 pm, Alex Gaynor  wrote:
> On Mon, Mar 16, 2009 at 11:52 AM, koranthala  wrote:
>
> > On Mar 16, 8:14 pm, Alex Gaynor  wrote:
> > > On Mon, Mar 16, 2009 at 11:07 AM, koranthala 
> > wrote:
>
> > > > Hi,
> > > >    I downloaded Django 1.1 due to aggregation support.
> > > >    But I am facing one issue which I cannot seem to overcome.
> > > >    I have two fields which represents two different times.
> > > >    I want to get the sum of difference of times - and I am unable to
> > > > do so.
> > > > Basically, I want to do as follows:
> > > > SELECT SUM (time2 - time1) FROM _TABLE_ WHERE __XXX___
>
> > > >    I tried 2 options:
> > > > 1. self.filter( XXX).aggregate(diff=Sum('time2 - time1'))
> > > > 2. self.filter (XXX).aggregate(t2=Sum('time2'), t1= Sum('time1')) - so
> > > > that I can do t2 - t1 later.
>
> > > >    Both is not supported in Django. I have raw SQL code in model
> > > > Manager for the same. I thought using Django Aggregation is better. Is
> > > > such operations going to be supported in Django 1.1 ?
>
> > > > Regards
> > > > Koran
>
> > > Right now that isn't possible, is there any reason you couldn't just
> > bring
> > > the seperate SUMs into python and do the subtraction there, I realize it
> > > isn't quite as clean but the overhead should be minimal?
>
> > > Alex
>
> > > --
> > > "I disapprove of what you say, but I will defend to the death your right
> > to
> > > say it." --Voltaire
> > > "The people's good is the highest law."--Cicero
>
> > If I understand correctly:
> > Separate SUMs as in the 2nd option which I mentioned above?
> > It was not possible because currently aggregation methods does not
> > support SUM - I think because Python itself does not support SUM of
> > datetime objects.
>
> > Or was it:
> > Separate SUM as in bring all the tuples to Python and then calculate?
> > It is quite big because there are more than 1 Million tuples so I dont
> > want to bring everything to Python.
>
> > Please let me know whether I have understood correctly.
>
> Sorry, I missed that these were dates/times.  Right now there isn't complete
> support for aggregating on dates/times.  I think here the easiest route is
> just to do:
>
> self.extra(select={'diff': "SUM(field1-field2"}).values('diff')
>
> Which I believe will work.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero

Thank you very much Alex.
I wrote the raw SQL code yesterday - took me about >1 hr to get it
correct (it was quite a complex one). :-(
But this seems to be much MUCH easier.
Thank you again. I will work using this method.


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



Re: schema to model

2009-03-16 Thread hc w
Thank you. Alex 

--- 09年3月17日,周二, Alex Gaynor  写道:

发件人: Alex Gaynor 
主题: Re: schema to model
收件人: django-users@googlegroups.com
日期: 2009年3月17日,周二,上午10:54



On Mon, Mar 16, 2009 at 10:42 PM, skysoaring1  wrote:



Hi,All,



We plan to develop an application on an existing database with Django.

So is there any tool to generate model class from schema like such

tools with hibernate? 聽Thanks a lot!



Regards



/sky






Yep, checkout the "inspectdb" management command:
http://docs.djangoproject.com/en/dev/ref/django-admin/?from=olddocs#inspectdb


Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to say 
it." --Voltaire
"The people's good is the highest law."--Cicero









  ___ 
  好玩贺卡等你发,邮箱贺卡全新上线! 
http://card.mail.cn.yahoo.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: schema to model

2009-03-16 Thread Alex Gaynor
On Mon, Mar 16, 2009 at 10:42 PM, skysoaring1 wrote:

>
> Hi,All,
>
> We plan to develop an application on an existing database with Django.
> So is there any tool to generate model class from schema like such
> tools with hibernate?  Thanks a lot!
>
> Regards
>
> /sky
>
> >
>
Yep, checkout the "inspectdb" management command:
http://docs.djangoproject.com/en/dev/ref/django-admin/?from=olddocs#inspectdb

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



schema to model

2009-03-16 Thread skysoaring1

Hi,All,

We plan to develop an application on an existing database with Django.
So is there any tool to generate model class from schema like such
tools with hibernate?  Thanks a lot!

Regards

/sky

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



Re: Django bug that should be addressed: Idle timeouts do not clear session information

2009-03-16 Thread Huuuze

Care to elaborate with some sample code?

On Mar 16, 9:12 pm, Paulo Köch  wrote:
> A background sleeper (as opposed to worker) that would fire a signal
> upon timer expiration seems like a nice mechanism.
>
> Cheers,
> Paulo Köch
>
> On Tue, Mar 17, 2009 at 01:04, Jeff FW  wrote:
>
> > When you say "audit"--what do you mean?  By that, I mean, what do you
> > plan to do with the data?  Do you need to know the second someone
> > times out, or can you check later?
>
> > If you need to know immediately, I think you may need to do something
> > terrible with JavaScript.  If not, or you can at least wait a little
> > while--run a cron job (every minute, if you'd like) that finds all of
> > the sessions that are past their expiration date.  You can log them as
> > you'd like, and then clear them out.
>
> > -Jeff
>
> > On Mar 16, 8:56 pm, Huuuze  wrote:
> >> Jeff (and Jacob)...
>
> >> I appreciate your responses and I stand corrected.  With that being
> >> said, are either of you (or anyone reading this) aware of a method
> >> that would allow me to track idle session timeouts?  I'd like to audit
> >> when a user has been logged out due to a timeout.
>
> >> Huuuze
>
> >> On Mar 16, 7:49 pm, Jeff FW  wrote:
>
> >> > It's not a bug.  When a cookie expires, the browser stops sending it
> >> > with its requests--therefore, there is *no* way for Django to know
> >> > that the cookie (and therefore, the session) has expired.  There is no
> >> > "timeout" happening on the server side, so the session can't get
> >> > cleared out.  Hence, why the documented method for clearing out old
> >> > sessions.
>
> >> > Maybe you're used to something like PHP's behavior, which cleans old
> >> > old sessions automatically.  However, it only does this by deciding to
> >> > clear out the old sessions (by default) 1 out of every 100 requests--
> >> > which is kind of a nasty thing to do that 100th person.
>
> >> > -Jeff
>
> >> > On Mar 16, 6:38 pm, Jacob Kaplan-Moss 
> >> > wrote:
>
> >> > > On Mon, Mar 16, 2009 at 4:46 PM, Huuuze  wrote:
> >> > > > Does anyone else agree with my viewpoints on this matter?  If so,
> >> > > > please post your comments in the ticket.
>
> >> > > Actually, the right way to get your viewpoint heard is to take the
> >> > > matter to the django-developers mailing list, where topics related to
> >> > > Django's development are discussed. You'll have more luck posting
> >> > > suggestions and criticism there than here or on the ticket tracker.
>
> >> > > However, please keep in mind that we're currently running up to Django
> >> > > 1.1, so it's likely that anything that's not an outright bug might be
> >> > > left by the wayside while we close bugs for the final release. If you
> >> > > don't get an immediate response, be patient and wait until a bit after
> >> > > the release when we all have a bit more time.
>
> >> > > Jacob
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: override render_to_response

2009-03-16 Thread Malcolm Tredinnick

On Mon, 2009-03-16 at 18:34 -0700, Preston Timmons wrote:
> I am wondering if render_to_response is really the proper function you
> are looking for.
> 
> For instance, here is a simple view that returns json using
> HttpResponse without need of a template:

He was wanting to hijack the output from existing views in other
applications for some reason, from what I gathered.

Regards,
Malcolm



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



Re: override render_to_response

2009-03-16 Thread Preston Timmons

I am wondering if render_to_response is really the proper function you
are looking for.

For instance, here is a simple view that returns json using
HttpResponse without need of a template:

import simplejson
from django.http import HttpResponse
def output_json(request):
data = [
dict(name='joe', weight=165),
dict(name='roger', weight=130),
]
return HttpResponse(simplejson.dumps(data), mimetype="application/
json")


More docs on the HttpResponse is available here:
http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpResponse.__init__


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



Re: Saving model with raw=True

2009-03-16 Thread Preston Timmons

Thanks, Alex,

I must misunderstand what it is for then. I got the idea from a post
where Russ Magee mentioned it as being a way to prevent auto_now
fields from being executed:

http://groups.google.com/group/django-users/browse_thread/thread/167ee7bddccb4354/069a59146423d013?lnk=gst=auto_now#069a59146423d013

I needed to create a test that depended upon a 'date modified' field
of a model. That field used auto_now and it did not seem possible to
force a date. I have since solved the problem by moving the logic into
a custom save method but afterwards came upon the above post and
wondered if I wasn't missing something simple.

Preston




On Mar 16, 5:59 pm, Alex Gaynor  wrote:
> On Mon, Mar 16, 2009 at 6:55 PM, Preston Timmons
> wrote:
>
>
>
>
>
> > At one time it seems there was an intention to have the save method on
> > models accept a keyword argument named raw which would allowed the
> > model to be saved without pre-processing. This argument is available
> > in the save_base method but not available in the save method.
>
> > Am I right to conclude that I should call save_base directly when I
> > want to use this?
>
> > Thanks.
>
> > Preston
>
> What do you mena skipping the processing, right now what raw does is very
> internal and doesn't seem like behavior you'd ever want to 
> chnage:http://code.djangoproject.com/browser/django/trunk/django/db/models/b...
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django bug that should be addressed: Idle timeouts do not clear session information

2009-03-16 Thread Paulo Köch

And it's clearly a feature request. Bug implies defect in
implementation, not formulation.

Cheers.

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



Re: Django bug that should be addressed: Idle timeouts do not clear session information

2009-03-16 Thread Paulo Köch

A background sleeper (as opposed to worker) that would fire a signal
upon timer expiration seems like a nice mechanism.

Cheers,
Paulo Köch



On Tue, Mar 17, 2009 at 01:04, Jeff FW  wrote:
>
> When you say "audit"--what do you mean?  By that, I mean, what do you
> plan to do with the data?  Do you need to know the second someone
> times out, or can you check later?
>
> If you need to know immediately, I think you may need to do something
> terrible with JavaScript.  If not, or you can at least wait a little
> while--run a cron job (every minute, if you'd like) that finds all of
> the sessions that are past their expiration date.  You can log them as
> you'd like, and then clear them out.
>
> -Jeff
>
> On Mar 16, 8:56 pm, Huuuze  wrote:
>> Jeff (and Jacob)...
>>
>> I appreciate your responses and I stand corrected.  With that being
>> said, are either of you (or anyone reading this) aware of a method
>> that would allow me to track idle session timeouts?  I'd like to audit
>> when a user has been logged out due to a timeout.
>>
>> Huuuze
>>
>> On Mar 16, 7:49 pm, Jeff FW  wrote:
>>
>> > It's not a bug.  When a cookie expires, the browser stops sending it
>> > with its requests--therefore, there is *no* way for Django to know
>> > that the cookie (and therefore, the session) has expired.  There is no
>> > "timeout" happening on the server side, so the session can't get
>> > cleared out.  Hence, why the documented method for clearing out old
>> > sessions.
>>
>> > Maybe you're used to something like PHP's behavior, which cleans old
>> > old sessions automatically.  However, it only does this by deciding to
>> > clear out the old sessions (by default) 1 out of every 100 requests--
>> > which is kind of a nasty thing to do that 100th person.
>>
>> > -Jeff
>>
>> > On Mar 16, 6:38 pm, Jacob Kaplan-Moss 
>> > wrote:
>>
>> > > On Mon, Mar 16, 2009 at 4:46 PM, Huuuze  wrote:
>> > > > Does anyone else agree with my viewpoints on this matter?  If so,
>> > > > please post your comments in the ticket.
>>
>> > > Actually, the right way to get your viewpoint heard is to take the
>> > > matter to the django-developers mailing list, where topics related to
>> > > Django's development are discussed. You'll have more luck posting
>> > > suggestions and criticism there than here or on the ticket tracker.
>>
>> > > However, please keep in mind that we're currently running up to Django
>> > > 1.1, so it's likely that anything that's not an outright bug might be
>> > > left by the wayside while we close bugs for the final release. If you
>> > > don't get an immediate response, be patient and wait until a bit after
>> > > the release when we all have a bit more time.
>>
>> > > Jacob
> >
>

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



Re: Django bug that should be addressed: Idle timeouts do not clear session information

2009-03-16 Thread Jeff FW

When you say "audit"--what do you mean?  By that, I mean, what do you
plan to do with the data?  Do you need to know the second someone
times out, or can you check later?

If you need to know immediately, I think you may need to do something
terrible with JavaScript.  If not, or you can at least wait a little
while--run a cron job (every minute, if you'd like) that finds all of
the sessions that are past their expiration date.  You can log them as
you'd like, and then clear them out.

-Jeff

On Mar 16, 8:56 pm, Huuuze  wrote:
> Jeff (and Jacob)...
>
> I appreciate your responses and I stand corrected.  With that being
> said, are either of you (or anyone reading this) aware of a method
> that would allow me to track idle session timeouts?  I'd like to audit
> when a user has been logged out due to a timeout.
>
> Huuuze
>
> On Mar 16, 7:49 pm, Jeff FW  wrote:
>
> > It's not a bug.  When a cookie expires, the browser stops sending it
> > with its requests--therefore, there is *no* way for Django to know
> > that the cookie (and therefore, the session) has expired.  There is no
> > "timeout" happening on the server side, so the session can't get
> > cleared out.  Hence, why the documented method for clearing out old
> > sessions.
>
> > Maybe you're used to something like PHP's behavior, which cleans old
> > old sessions automatically.  However, it only does this by deciding to
> > clear out the old sessions (by default) 1 out of every 100 requests--
> > which is kind of a nasty thing to do that 100th person.
>
> > -Jeff
>
> > On Mar 16, 6:38 pm, Jacob Kaplan-Moss 
> > wrote:
>
> > > On Mon, Mar 16, 2009 at 4:46 PM, Huuuze  wrote:
> > > > Does anyone else agree with my viewpoints on this matter?  If so,
> > > > please post your comments in the ticket.
>
> > > Actually, the right way to get your viewpoint heard is to take the
> > > matter to the django-developers mailing list, where topics related to
> > > Django's development are discussed. You'll have more luck posting
> > > suggestions and criticism there than here or on the ticket tracker.
>
> > > However, please keep in mind that we're currently running up to Django
> > > 1.1, so it's likely that anything that's not an outright bug might be
> > > left by the wayside while we close bugs for the final release. If you
> > > don't get an immediate response, be patient and wait until a bit after
> > > the release when we all have a bit more time.
>
> > > Jacob
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django bug that should be addressed: Idle timeouts do not clear session information

2009-03-16 Thread Alex Gaynor
On Mon, Mar 16, 2009 at 8:56 PM, Huuuze  wrote:

>
> Jeff (and Jacob)...
>
> I appreciate your responses and I stand corrected.  With that being
> said, are either of you (or anyone reading this) aware of a method
> that would allow me to track idle session timeouts?  I'd like to audit
> when a user has been logged out due to a timeout.
>
> Huuuze
>
> On Mar 16, 7:49 pm, Jeff FW  wrote:
> > It's not a bug.  When a cookie expires, the browser stops sending it
> > with its requests--therefore, there is *no* way for Django to know
> > that the cookie (and therefore, the session) has expired.  There is no
> > "timeout" happening on the server side, so the session can't get
> > cleared out.  Hence, why the documented method for clearing out old
> > sessions.
> >
> > Maybe you're used to something like PHP's behavior, which cleans old
> > old sessions automatically.  However, it only does this by deciding to
> > clear out the old sessions (by default) 1 out of every 100 requests--
> > which is kind of a nasty thing to do that 100th person.
> >
> > -Jeff
> >
> > On Mar 16, 6:38 pm, Jacob Kaplan-Moss 
> > wrote:
> >
> > > On Mon, Mar 16, 2009 at 4:46 PM, Huuuze  wrote:
> > > > Does anyone else agree with my viewpoints on this matter?  If so,
> > > > please post your comments in the ticket.
> >
> > > Actually, the right way to get your viewpoint heard is to take the
> > > matter to the django-developers mailing list, where topics related to
> > > Django's development are discussed. You'll have more luck posting
> > > suggestions and criticism there than here or on the ticket tracker.
> >
> > > However, please keep in mind that we're currently running up to Django
> > > 1.1, so it's likely that anything that's not an outright bug might be
> > > left by the wayside while we close bugs for the final release. If you
> > > don't get an immediate response, be patient and wait until a bit after
> > > the release when we all have a bit more time.
> >
> > > Jacob
> >
>
One possibility would be to use 2 cookies, one the normal session cookie,
and a second with a *way* longer expire date.  Then when a user has the long
one but not the other one clear out the corresponding session(which you'd
keep track of obviously).

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: Django bug that should be addressed: Idle timeouts do not clear session information

2009-03-16 Thread Huuuze

Jeff (and Jacob)...

I appreciate your responses and I stand corrected.  With that being
said, are either of you (or anyone reading this) aware of a method
that would allow me to track idle session timeouts?  I'd like to audit
when a user has been logged out due to a timeout.

Huuuze

On Mar 16, 7:49 pm, Jeff FW  wrote:
> It's not a bug.  When a cookie expires, the browser stops sending it
> with its requests--therefore, there is *no* way for Django to know
> that the cookie (and therefore, the session) has expired.  There is no
> "timeout" happening on the server side, so the session can't get
> cleared out.  Hence, why the documented method for clearing out old
> sessions.
>
> Maybe you're used to something like PHP's behavior, which cleans old
> old sessions automatically.  However, it only does this by deciding to
> clear out the old sessions (by default) 1 out of every 100 requests--
> which is kind of a nasty thing to do that 100th person.
>
> -Jeff
>
> On Mar 16, 6:38 pm, Jacob Kaplan-Moss 
> wrote:
>
> > On Mon, Mar 16, 2009 at 4:46 PM, Huuuze  wrote:
> > > Does anyone else agree with my viewpoints on this matter?  If so,
> > > please post your comments in the ticket.
>
> > Actually, the right way to get your viewpoint heard is to take the
> > matter to the django-developers mailing list, where topics related to
> > Django's development are discussed. You'll have more luck posting
> > suggestions and criticism there than here or on the ticket tracker.
>
> > However, please keep in mind that we're currently running up to Django
> > 1.1, so it's likely that anything that's not an outright bug might be
> > left by the wayside while we close bugs for the final release. If you
> > don't get an immediate response, be patient and wait until a bit after
> > the release when we all have a bit more time.
>
> > Jacob
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Creating objects with references

2009-03-16 Thread nivhab

hi,

I need to create 2 objects, one containing a reference to the other,
in one shot. I get an IntegrityError exception while trying to do so,
claiming that the foreign key is None on creation. Hope someone can
help...
(when I refresh the browser and rePOST the data it works as the
Product object is already there and is not created at the same time)

Thanks, Yaniv

I have the following models:
Class Product
productId   = models.AutoField(primary_key=True)
name= models.CharField(max_length=200,
unique=True)
description= models.CharField(max_length=200, blank=True)
Class Manufacturer
manId= models.AutoField(primary_key=True)
product  = models.ForeignKey(Product)
contact  = models.ForeignKey(User)
price = models.PositiveIntegerField()
I created a form containing fields for both, with a 'save' function:
class ProductForm(forms.Form):
name = forms.CharField(max_length=200)
description = forms.CharField(max_length=200)
price = forms.IntegerField(min_value=0)
def save(self):
  prod = Product(name=self.cleaned_data['name'],
description=self.cleaned_data['description'])
  prod.save()
  ma = Manufacturer(product=prod,
  contact=self.data
['user'],  # this is being passed by
the view
  price=self.cleaned_data['price'])
   ma.save();
The problem: the new product is being saved but on the
manufacturer.save() I get the following exception:
Exception Type: IntegrityError
Exception Value:(1048, "Column 'product_id' cannot be null")
Exception Location: C:\Development\Python25\Lib\site-packages
\django
\db\backends\mysql\base.py in execute, line 88
Environment:
Request Method: POST
Request URL: http://localhost:8000/addproduct/
Django Version: 1.0.2 final
Python Version: 2.5.4
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'django.views.generic',
 'mysite.myapp',
 'registration']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware')

Traceback:
File "C:\Development\Python25\Lib\site-packages\django\core\handlers
\base.py" in get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "C:\Development\Python25\Lib\site-packages\django\contrib\auth
\decorators.py" in __call__
  67. return self.view_func(request, *args, **kwargs)
File "C:\Development\googleapp_projects\busa\..\mysite\myapp\views.py"
in registerProduct
  63. f.save()
File "C:\Development\googleapp_projects\busa\..\mysite\myapp\forms.py"
in save
  76. ma.save();
File "C:\Development\Python25\Lib\site-packages\django\db\models
\base.py" in save
  311. self.save_base(force_insert=force_insert,
force_update=force_update)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django bug that should be addressed: Idle timeouts do not clear session information

2009-03-16 Thread Jeff FW

It's not a bug.  When a cookie expires, the browser stops sending it
with its requests--therefore, there is *no* way for Django to know
that the cookie (and therefore, the session) has expired.  There is no
"timeout" happening on the server side, so the session can't get
cleared out.  Hence, why the documented method for clearing out old
sessions.

Maybe you're used to something like PHP's behavior, which cleans old
old sessions automatically.  However, it only does this by deciding to
clear out the old sessions (by default) 1 out of every 100 requests--
which is kind of a nasty thing to do that 100th person.

-Jeff

On Mar 16, 6:38 pm, Jacob Kaplan-Moss 
wrote:
> On Mon, Mar 16, 2009 at 4:46 PM, Huuuze  wrote:
> > Does anyone else agree with my viewpoints on this matter?  If so,
> > please post your comments in the ticket.
>
> Actually, the right way to get your viewpoint heard is to take the
> matter to the django-developers mailing list, where topics related to
> Django's development are discussed. You'll have more luck posting
> suggestions and criticism there than here or on the ticket tracker.
>
> However, please keep in mind that we're currently running up to Django
> 1.1, so it's likely that anything that's not an outright bug might be
> left by the wayside while we close bugs for the final release. If you
> don't get an immediate response, be patient and wait until a bit after
> the release when we all have a bit more time.
>
> Jacob
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django critter helps us code at the speed of light.

2009-03-16 Thread Scott Lyons

Based on mrts' drawings, I made two backgrounds. I'm open to
suggestions or requests.

http://www.flickr.com/photos/damagedgenius/3361587194/

and

http://www.flickr.com/photos/damagedgenius/3361587300/in/photostream/

On Mar 16, 6:27 pm, bruno desthuilliers
 wrote:
> On 11 mar, 19:10, Eric Walstad  wrote:
>
>
>
> > It occurred to me that my 9yr old daughter has been listening to me
> > talk about Django for almost half of her life.  She sees me reading
> > books and blogs about Django.  She sees me wear my green DjangoCon t-
> > shirt.  For the last 4 years Django's had some influence on her, too.
>
> > Last night she was creating critters with her water color crayons.
> > Some are strong, some are mischievous, some are kind.  She created the
> > Django critter for me. As she puts it:
>
> > """
> > Django is a computer programming critter.  He is loyal only to
> > computer programmers and does all their work.  He types with the ball
> > on the end of his tail, at the speed of light.  He beeps when his work
> > is done and when you take him home, he flies around the house, doing
> > all your chores.  He's a helpful little fellow.
> > """
>
> > I don't think she realizes it, but Django also helps pay the bills and
> > puts a smile on her dad's face.
>
> > Now you can have your pony AND a Django 
> > Critter:http://starship.python.net/~ewalstad/django_critter.html
> > I hope you all enjoy Django as much as we have.
>
> Wow. I think this is one of the most wonderful rewards the Django team
> could ever get. And it's a really cute critter too - really love it.
>
> Thanks, really, to you both.

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



Re: override render_to_response

2009-03-16 Thread Malcolm Tredinnick

On Mon, 2009-03-16 at 20:05 -0400, Malinka Rellikwodahs wrote:
[...]
> Unless I'm mistaken it should be fairly simple in this case to create
> your own set of templates for each of the django apps you're using and
> then have them output the data you need as json text instead of as
> html

Ooh ... that's a clever idea. Could even be done with a simple template
tag, rendering everything in the context to json results.

For the original poster: If youdo this, don't forget to use middleware
to change the content type on the response.

Regards,
Malcolm



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



Re: override render_to_response

2009-03-16 Thread Malinka Rellikwodahs

On Mon, Mar 16, 2009 at 12:42, a b  wrote:
> Hi,
>
> I'm building a one page app with no page refresh.
> All the content is loaded as JSON dynamically and the UI is built using
> javascript.
>
> I'm using external django apps and I need them to send back the context dict
> as JSON instead
> of rendering the html template.
>
> Is it possible to override render_to_response so all the apps using it will
> respond with JSON without
> actually touching the apps code? I don't want to create a middleware that
> will modify the response because
> then I have the overhead of rendering the html template.

Unless I'm mistaken it should be fairly simple in this case to create
your own set of templates for each of the django apps you're using and
then have them output the data you need as json text instead of as
html

> Thanks
>
> >
>

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



Re: How do I determine when a user has an idle timeout in Django?

2009-03-16 Thread Malcolm Tredinnick

On Mon, 2009-03-16 at 12:36 -0700, Huuuze wrote:
> I would like to audit when a user has experienced an idle timeout in
> my Django application. In other words, if the user's session cookie's
> expiration date exceeds the SESSION_COOKIE_AGE found in settings.py,
> the user is redirected to the login page. When that occurs, an audit
> should also occur.
> 
> Currently, I have configured some middleware to capture these events.
> Unfortunately, Django generates a new cookie when the user is
> redirected to the login page, so I cannot determine if the user was
> taken to the login page via an idle timeout or some other event.
> 
> From what I can tell, I would need to work with the "django_session"
> table. However, the records in this table cannot be associated with
> that user because the sessionid value in the cookie is reset when the
> redirect occurs.

The fundamental problem you're facing here is that the browser won't
send the cookie once it's expired. So Django has no way of knowing the
information you're after.

Regards,
Malcolm



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



Re: override render_to_response

2009-03-16 Thread Malcolm Tredinnick

On Mon, 2009-03-16 at 18:42 +0200, a b wrote:
> Hi,
> 
> I'm building a one page app with no page refresh.
> All the content is loaded as JSON dynamically and the UI is built
> using javascript.
> 
> I'm using external django apps and I need them to send back the
> context dict as JSON instead
> of rendering the html template.
> 
> Is it possible to override render_to_response so all the apps using it
> will respond with JSON without
> actually touching the apps code?

Not really, no. Monkey-patching like that is generally discouraged, in
any case.

Regards,
Malcolm




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



Re: Lookup across relations

2009-03-16 Thread Malcolm Tredinnick

On Mon, 2009-03-16 at 17:29 +0100, Matías Costa wrote:
[...]
>  
> BTW,  this is Django 1.0, I had to rename your maxlength field
> parameter to max_length. Are you using 0.96?

Oh, dear. If the original poster is using 0.96, then this has little
chance of working. Complex queries involving many-to-many objects didn't
work well there at all. It was an area of many bugfixes between 0.96 and
1.0.

Regards,
Malcolm

> 


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



Re: Many to Many is empty when saving parent object

2009-03-16 Thread Malcolm Tredinnick

On Mon, 2009-03-16 at 08:48 -0700, Brandon Taylor wrote:
> Hi everyone,
> 
> I'm running Python 2.6.1, Django Trunk.
> 
> I have a model (Entry) with a ManyToMany (Categories). I need to be
> able to iterate over these categories whenever my parent model is
> saved.
> 
> I've tried overriding save_model in the admin, and adding a post_save
> signal to Entry in order to be able to iterate over the categories.
> The problem only occurs on an insert. If I do:
> 
> class Entry(models.Model):
> name = models.CharField(max_length=100)
> categories = models.ManyToManyField(Category)
> 
> class Meta:
> verbose_name_plural = 'Entries'
> 
> def __unicode__(self):
> return self.name
> 
> class EntryAdmin(admin.ModelAdmin):
> def save_model(self, request, obj, form, change):
> obj.save()
> print obj.categories.all()
> 
> obj.categories.all() = []
> 
> However, when performing an update, I have a list of Category objects.
> Is this a model lifecycle issue as far as when the ManyToMany gets
> saved? What can I do to be able to access the list of categories when
> the object is created?

Many-to-many relations cannot be saved until the object itself is saved,
since they need ot know the object's pk value to use in the relation
table. Consequently, many-to-many handling in forms is done after saving
the model itself. You're trying to look up the categories before they've
been saved.

Regards,
Malcolm



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



Re: How to say Hello "Somebody" in a Django form. Displaying data context values as non-input.

2009-03-16 Thread Brian Neal

On Mar 16, 2:14 pm, NoviceSortOf  wrote:
>
> So perhaps a better question would be is
>
> in view.py...
> ---
> thisusername = str(request.user.username)
> data = {'thisusername':username,}
> form = form_class(data)
>
> Why is it form_class(data) does not accept the data
> as declared and enable it to presented it in
> templates in any other form than a writable field
>  --  when render_to_response allows the data to be
>      presented as a string?

Forms don't work that way. They aren't used to display arbitrary data.
They are used to display form fields. It sounds like you don't want
the username as a form field, you just want it as normal text. You
need to pass non-form field data to the template, in the context
dictionary. Forms should be constructed with data to bind to the form
fields (such as request.POST data) or maybe initial values for the
form fields [1]. Please see:

http://docs.djangoproject.com/en/dev/topics/forms/#using-a-form-in-a-view

and especially:

http://docs.djangoproject.com/en/dev/ref/forms/api/#ref-forms-api

So you'll need something like this (for the non-POST case):

form = MyForm()
username = ...
return render_to_response(template_name,
   { 'form': form,
 'username': username,
   },
   context_instance=context)

And then in your template, this should get you started:

{{ username }}
{{ form.as_p }}

but realize there are many other ways to display a form as the docs
note.

Hope that helps,
BN

[1] Maybe I am missing something but I don't see the initial keyword
argument to the forms.Form class documented?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: multiple python versions

2009-03-16 Thread Malcolm Tredinnick

On Mon, 2009-03-16 at 08:43 -0700, TheIvIaxx wrote:
> Hello, on my dev machine I am running a django instance on its little
> dev server with python 2.5.2 32bit.  Works fine.  But all of our tool
> are written for python 2.5.x 64bit.  These are irrelevant to django.
> 
> Having both python versions installed causes and issue with django.
> How do I tell django what version to use?

You don't tell Django what version to use. Django doesn't execute the
"python" process. You have to tell whatever is running Python by
configuring the PATH and PYTHONPATH for the environment, or possibly
explicitly passing in the path to the Python binary. It depends upon how
you're running Django-based applications.

However, the obviously easier solution here is just use Django with the
64-bit Python. Why can't you do that? The only real C dependencies are
the database wrappers and they can all be built as 64-bit binaries.

Regards,
Malcolm



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



Re: legacy oracle database -w- existing schema

2009-03-16 Thread bruce

Yes, this resolve the issue.

Thank you!

On Mar 16, 2:29 pm, "Mad Sweeney"  wrote:
> - Original Message -
> From: "bruce" 
> To: "Django users" 
> Sent: Monday, March 16, 2009 9:00 PM
> Subject: legacy oracle database -w- existing schema
>
> > Hi-
> > I'm a new user to Django.  I've searched through the documentation and
> > other posted questions.  I'm currently attempting to setup the model
> > to access an Oracle 9 database.  I have access the database, yet the
> > tables and views are stored in another existing schema not owned by
> > me.
>
> > Other than creating custom sql queries, is there another way to
> > retrieve information found in this schema?
>
> Hi,
>
> How about creating synonyms in your own schema,
> one for each table in your model?
>
> --j
>
>
>
>
>
> > Bruce
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Verbose Error Logging

2009-03-16 Thread Malcolm Tredinnick

On Mon, 2009-03-16 at 07:27 -0700, PB wrote:
> Hi,
> 
> Is there any way to force tracebacks that are normally swallowed by
> the templating engine to be logged to the server's error logs?
> 

It's not possible to tell which errors are intended to be caught and
which aren't. Many AttributeError and KeyError exceptions are
intentional and not bugs, so the template engine has to catch them. We
can't know whent those cases are unexpected.

There is one issue we're thinking through at the moment with respect to
unicode decoding errors.

> Much of the time the superb error handling in the template engine
> means that little bugs can often fly under the radar. Additionally,
> when a site is deployed, error logs are the only indicator that
> something has broken.

Can you give some examples here? Most errors aren't caught by the
templating system and will raise exceptions. So which ones are causing
you problems?

> 
> Does such a capability exist in django?

No.

Regards,
Malcolm


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



Re: Overriding the HTML id in ModelForm

2009-03-16 Thread Romain

Thanks a lot for the great answers, and the information about the form
prefix (it is what I was looking for)!

Sorry, I missed the replies 1 week ago :(

Thanks again,

Romain

On Mar 6, 1:42 am, Eric Abrahamsen  wrote:
> On Mar 5, 2009, at 11:14 AM, Alex Gaynor wrote:
>
>
>
>
>
> > On 3/4/09, Eric Abrahamsen  wrote:
>
> >> On Mar 5, 2009, at 8:05 AM, Romain wrote:
>
> >>> Hello,
>
> >>> On the same page I have 2 ModelForm that happen to have an attribute
> >>> with the same name. Is it possible to choose the name of theHTMLid
> >>> generated by the form without having to change the real name of the
> >>> model attribute?
>
> >> A simple solution would be to instantiate your ModelForms with a  
> >> prefix:
> >>http://docs.djangoproject.com/en/dev/ref/forms/api/#prefixes-for-
> >> forms
>
> >> Another, finer-grained choice is using the auto_id argument:
> >>http://docs.djangoproject.com/en/dev/ref/forms/api/#configuring-html-...
>
> >> Hope that's what you're looking for,
>
> >> Eric
>
> >>> e.g.
> >>> class A(models.Model):
> >>> amount = models.IntegerField()
>
> >>> class B(models.Model):
> >>> amount = models.IntegerField()
>
> >>> class AForm(ModelForm):
> >>> class Meta:
> >>>   model = A
>
> >>> class BForm(ModelForm):
> >>> class Meta:
> >>>   model = B
>
> >>> Conflict of ids when forms printed:
> >>> ...
> >>> 
> >>> ...
> >>> 
> >>> ...
>
> >>> Thanks a lot,
>
> >>> Romain
>
> > Auto_I'd won't help. The issue is the names conflict in the POST so
> > this is an issue for prefix.
>
> Whoops, thanks for pointing that out!
>
> E
>
>
>
> > Alex
>
> > --
> > "I disapprove of what you say, but I will defend to the death your
> > right to say it." --Voltaire
> > "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: PositiveIntegerField returning a string?

2009-03-16 Thread Malcolm Tredinnick

On Mon, 2009-03-16 at 07:06 -0700, msoulier wrote:
[...]
> The code populating it looks like this
> 
>metrics.user_licenses_ca = int(
> details.get('Max_users', '0/0/0').split('/')[2])
> 
> The Max_users field contains a '/' delimited sting of three numbers,
> which is why I'm splitting like that.
> 
> The int() call should enforce an integer.

Since what you're basically saying is that Python's int() function is
broken, I would suggest you verify that that line really is being
executed. Log the value of metrics.user_licenses_ca before you execute
that line. Log it again afterwards. Include the type both times.

I claim that int() is not broken and does indeed return an integer. So
either you've redefined the function int() -- which would be a bad idea
-- or that line isn't being executed or is raising an exception that
you're overlooking (catching it with a bare "except" perhaps).

Regards,
Malcolm



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



Re: How to say Hello "Somebody" in a Django form. Displaying data context values as non-input.

2009-03-16 Thread Briel

First of all what you have written will most likely give syntax error,
in your dict you have reversed the key and value. You probably want it
to look like this: {"username": thisusername}. But you can't just
throw random data at forms and hope for it to work. There are some
different solutions, but if all you want to dø is to write hallo
username, you dont even need to do anything with forms, unless you
want the username to be displayed in an input field when the form
loads. Remember, django forms are not forms, but form elements. You
still have to suply the form and input tags yourself and thus can
write hallo username or whatever inside the form if you want it as an
headline or something else.

~Jakob

On 16 Mar., 20:14, NoviceSortOf  wrote:
> Thanks for your responses, they have helped.
>
> I've read the documentation many times, and only resort to groups
> after re-reading what I can find in the docs, testing various logical
> solutions, digging through groups and finally confering with a 3rd
> party book I've here on Django. If all else fails,
> then I post to groups.
>
> So that is why I'm puzzled when {{ var }} does not present var on my
> form.
>
> As mentioned above in views.py I'm passing data to the form_class in
> this example I'm using str to convert value to string.
>
> in view.py then
> ...
> thisusername = str(request.user.username)
> data = {'thisusername':username,}
> form = form_class(data)
>
> Now it seems form_class() would be adding the data to
> itself with form_class(data) but it isn't.
>
> Instead I have to add the context to the render_to_response
> despite the fact that this data has been added to form
> earlier.
>
> ie.
> return render_to_response(template_name, { 'form': form},
>                               context_instance=context)
>
> will either not display the item, or force it to be viewed
> only as a corresponding writable field as defined in forms.py
> or model.py.
>
> but loading it directly to render_to_response works...
>
> return render_to_response(template_name, { 'form': form,
> 'thisusername':username},
> context_instance=context)
>
> So perhaps a better question would be is
>
> in view.py...
> ---
> thisusername = str(request.user.username)
> data = {'thisusername':username,}
> form = form_class(data)
>
> Why is it form_class(data) does not accept the data
> as declared and enable it to presented it in
> templates in any other form than a writable field
>  --  when render_to_response allows the data to be
>      presented as a string?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Saving model with raw=True

2009-03-16 Thread Alex Gaynor
On Mon, Mar 16, 2009 at 6:55 PM, Preston Timmons
wrote:

>
> At one time it seems there was an intention to have the save method on
> models accept a keyword argument named raw which would allowed the
> model to be saved without pre-processing. This argument is available
> in the save_base method but not available in the save method.
>
> Am I right to conclude that I should call save_base directly when I
> want to use this?
>
> Thanks.
>
> Preston
>
>
> >
>
What do you mena skipping the processing, right now what raw does is very
internal and doesn't seem like behavior you'd ever want to chnage:
http://code.djangoproject.com/browser/django/trunk/django/db/models/base.py#L352

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Saving model with raw=True

2009-03-16 Thread Preston Timmons

At one time it seems there was an intention to have the save method on
models accept a keyword argument named raw which would allowed the
model to be saved without pre-processing. This argument is available
in the save_base method but not available in the save method.

Am I right to conclude that I should call save_base directly when I
want to use this?

Thanks.

Preston


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



Re: Django bug that should be addressed: Idle timeouts do not clear session information

2009-03-16 Thread Jacob Kaplan-Moss

On Mon, Mar 16, 2009 at 4:46 PM, Huuuze  wrote:
> Does anyone else agree with my viewpoints on this matter?  If so,
> please post your comments in the ticket.

Actually, the right way to get your viewpoint heard is to take the
matter to the django-developers mailing list, where topics related to
Django's development are discussed. You'll have more luck posting
suggestions and criticism there than here or on the ticket tracker.

However, please keep in mind that we're currently running up to Django
1.1, so it's likely that anything that's not an outright bug might be
left by the wayside while we close bugs for the final release. If you
don't get an immediate response, be patient and wait until a bit after
the release when we all have a bit more time.

Jacob

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



Re: Django critter helps us code at the speed of light.

2009-03-16 Thread bruno desthuilliers

On 11 mar, 19:10, Eric Walstad  wrote:
> It occurred to me that my 9yr old daughter has been listening to me
> talk about Django for almost half of her life.  She sees me reading
> books and blogs about Django.  She sees me wear my green DjangoCon t-
> shirt.  For the last 4 years Django's had some influence on her, too.
>
> Last night she was creating critters with her water color crayons.
> Some are strong, some are mischievous, some are kind.  She created the
> Django critter for me. As she puts it:
>
> """
> Django is a computer programming critter.  He is loyal only to
> computer programmers and does all their work.  He types with the ball
> on the end of his tail, at the speed of light.  He beeps when his work
> is done and when you take him home, he flies around the house, doing
> all your chores.  He's a helpful little fellow.
> """
>
> I don't think she realizes it, but Django also helps pay the bills and
> puts a smile on her dad's face.
>
> Now you can have your pony AND a Django 
> Critter:http://starship.python.net/~ewalstad/django_critter.html

> I hope you all enjoy Django as much as we have.

Wow. I think this is one of the most wonderful rewards the Django team
could ever get. And it's a really cute critter too - really love it.

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



Re: Switching database backends at runtime?

2009-03-16 Thread Alex Gaynor
On Mon, Mar 16, 2009 at 6:20 PM, Oliver Beattie  wrote:

>
> Does anyone know if it's possible to switch the database backend in
> Django at runtime (let's say I want to use dummy for something, but
> then switch it back to the original after I'm done).
>
> Is this possible using django.db.load_backend or something (I'm
> doubting it as I see there is some module-level code in there that
> takes info directly from settings).
>
> I know it's a bit of a cardinal sin, but would altering settings at
> runtime have any effect? Again probably no since there will still be
> things pointing to the old backend instance, but worth a shot.
> >
>
It sort of depends on what you're trying to do, if you want to work with a
queryset using a different database you can do something like this:
http://www.eflorenzano.com/blog/post/easy-multi-database-support-django/except
for if you're using django trunk you can use django.db.load_backend
and the new DatabaseWrapper constructor(which takes a dict of settings) to
do it, instead of futzing with the global settings.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Switching database backends at runtime?

2009-03-16 Thread Oliver Beattie

Does anyone know if it's possible to switch the database backend in
Django at runtime (let's say I want to use dummy for something, but
then switch it back to the original after I'm done).

Is this possible using django.db.load_backend or something (I'm
doubting it as I see there is some module-level code in there that
takes info directly from settings).

I know it's a bit of a cardinal sin, but would altering settings at
runtime have any effect? Again probably no since there will still be
things pointing to the old backend instance, but worth a shot.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django bug that should be addressed: Idle timeouts do not clear session information

2009-03-16 Thread Huuuze

I opened the following ticket which was unceremoniously closed by a
committer:

http://code.djangoproject.com/ticket/10518

Here is the text from the ticket:
>> I have set the SESSION_COOKIE_AGE value in my settings.py file to expire 
>> sessions after 1 hour. Django successfully logs the user out of the session, 
>> however, the backend does not behave as one would expect in this situation. 
>> If a user logged out under normal conditions (i.e., clicks a "Logout" link), 
>> the session information is cleared from the "django.sessions" table. As 
>> such, I would expect an idle timeout (which is just a timed logout) to 
>> behave in the same manner. Unfortunately, Django simply creates a new 
>> session entry in the "django.sessions" table and the old, expired session 
>> remains in the table. The end result is a bloated "django.sessions" table 
>> that needs to be maintained through an external script.

The reason for closing the ticket was the following:

>> This is the documented behavior. See 
>> http://docs.djangoproject.com/en/dev/topics/http/sessions/#clearing-the-session-table

And my response:

>> I completely disagree with this assessment. Just because it's "documented 
>> behavior" doesn't make it correct.

>> Django terminates the session based upon the expiring cookie. As such, the 
>> timeout process should call "django.contrib.auth.logout", which clears out 
>> records from the django.sessions table.

>> How is the process of idling out any different from the user explicitly 
>> clicking a logout link? One is an implicit logout, whereas the other is an 
>> explicit logout. At the end of the day, its the same net result -- a user's 
>> session has ended. This behavior should be fixed.

Does anyone else agree with my viewpoints on this matter?  If so,
please post your comments in the ticket.  IMO, this is a bug in Django.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: legacy oracle database -w- existing schema

2009-03-16 Thread bruce

I can look into that as an option.  I don't have access to
administrate this database.

On Mar 16, 2:29 pm, "Mad Sweeney"  wrote:
> - Original Message -
> From: "bruce" 
> To: "Django users" 
> Sent: Monday, March 16, 2009 9:00 PM
> Subject: legacy oracle database -w- existing schema
>
> > Hi-
> > I'm a new user to Django.  I've searched through the documentation and
> > other posted questions.  I'm currently attempting to setup the model
> > to access an Oracle 9 database.  I have access the database, yet the
> > tables and views are stored in another existing schema not owned by
> > me.
>
> > Other than creating custom sql queries, is there another way to
> > retrieve information found in this schema?
>
> Hi,
>
> How about creating synonyms in your own schema,
> one for each table in your model?
>
> --j
>
>
>
>
>
> > Bruce
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: legacy oracle database -w- existing schema

2009-03-16 Thread Mad Sweeney

- Original Message - 
From: "bruce" 
To: "Django users" 
Sent: Monday, March 16, 2009 9:00 PM
Subject: legacy oracle database -w- existing schema


>
> Hi-
> I'm a new user to Django.  I've searched through the documentation and
> other posted questions.  I'm currently attempting to setup the model
> to access an Oracle 9 database.  I have access the database, yet the
> tables and views are stored in another existing schema not owned by
> me.
>
> Other than creating custom sql queries, is there another way to
> retrieve information found in this schema?

Hi,

How about creating synonyms in your own schema,
one for each table in your model?

--j
>
> Bruce
>
> >
>
> 



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



legacy oracle database -w- existing schema

2009-03-16 Thread bruce

Hi-
I'm a new user to Django.  I've searched through the documentation and
other posted questions.  I'm currently attempting to setup the model
to access an Oracle 9 database.  I have access the database, yet the
tables and views are stored in another existing schema not owned by
me.

Other than creating custom sql queries, is there another way to
retrieve information found in this schema?

Bruce

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



Re: get_absolute_url not working on deployed site; exact same code works on dev site

2009-03-16 Thread Theme Park Photo, LLC

I have a feeling this is related (but I'm still stuck!)

Occasionally, when I start it up, I see this:

The URLCONF in settings.py looks OK

File "/usr/lib/python2.4/site-packages/django/core/urlresolvers.py",
line 198, in _get_urlconf_module
self._urlconf_module = __import__(self.urlconf_name, {}, {}, [''])
ValueError: Empty module name

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



Sending attachments with django-contact-form

2009-03-16 Thread Dana

Hello,

I am wondering what the simplest way to send an attachment with django-
contact-form (http://code.google.com/p/django-contact-form/) is. I
don't have much experience with sending emails with Python, so Im a
bit lost. I tried overriding the save method but couldn't get it
functioning.

Im interested in just a simple example of sending a file along with
the other email information. I have subclassed the contact form and
just need to add an "attachment" field to the form.

Any help would be greatly appreciated!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



django-registration - Unhandled Exception

2009-03-16 Thread neri...@gmail.com

Hello,

I successfully set up django-registration on my local machine to the
point of being able to load a url and attempt to load the template.
However, I'm trying to set it up on Dreamhost and keep getting "An
unhandled exception was thrown by the application." The only thing I
had to do differently was to add django-registration to my PYTHONPATH
which imports fine when running the python interpreter. when I comment
out registration from INSTALLED_APPS everything is fine, do I need to
add something else to my .bash_profile:

export PATH=$HOME/bin:$HOME/projects/django/trunk/django/bin:$PATH
export PYTHONPATH=$HOME/projects:$HOME/projects/django/trunk:$HOME/
projects/flup/trunk:$HOME/projects/django-registration:$PYTHONPATH

Thanks,

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



How do I determine when a user has an idle timeout in Django?

2009-03-16 Thread Huuuze

I would like to audit when a user has experienced an idle timeout in
my Django application. In other words, if the user's session cookie's
expiration date exceeds the SESSION_COOKIE_AGE found in settings.py,
the user is redirected to the login page. When that occurs, an audit
should also occur.

Currently, I have configured some middleware to capture these events.
Unfortunately, Django generates a new cookie when the user is
redirected to the login page, so I cannot determine if the user was
taken to the login page via an idle timeout or some other event.

>From what I can tell, I would need to work with the "django_session"
table. However, the records in this table cannot be associated with
that user because the sessionid value in the cookie is reset when the
redirect occurs.

I'm guessing I'm not the first to encounter this dilemma. Does anyone
have insight into how to resolve the problem?

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



Re: How to say Hello "Somebody" in a Django form. Displaying data context values as non-input.

2009-03-16 Thread Danny Brown

thisusername = str(request.user.username)
data = {'thisusername':username,}
form = form_class(data)

shouldn't this be data={'thisusername':thisusername,} or
{'thisusername': str(request.user.username)}


On Mon, Mar 16, 2009 at 2:14 PM, NoviceSortOf  wrote:
>
> Thanks for your responses, they have helped.
>
> I've read the documentation many times, and only resort to groups
> after re-reading what I can find in the docs, testing various logical
> solutions, digging through groups and finally confering with a 3rd
> party book I've here on Django. If all else fails,
> then I post to groups.
>
> So that is why I'm puzzled when {{ var }} does not present var on my
> form.
>
> As mentioned above in views.py I'm passing data to the form_class in
> this example I'm using str to convert value to string.
>
> in view.py then
> ...
> thisusername = str(request.user.username)
> data = {'thisusername':username,}
> form = form_class(data)
>
> Now it seems form_class() would be adding the data to
> itself with form_class(data) but it isn't.
>
> Instead I have to add the context to the render_to_response
> despite the fact that this data has been added to form
> earlier.
>
> ie.
> return render_to_response(template_name, { 'form': form},
>                              context_instance=context)
>
> will either not display the item, or force it to be viewed
> only as a corresponding writable field as defined in forms.py
> or model.py.
>
> but loading it directly to render_to_response works...
>
> return render_to_response(template_name, { 'form': form,
> 'thisusername':username},
> context_instance=context)
>
> So perhaps a better question would be is
>
> in view.py...
> ---
> thisusername = str(request.user.username)
> data = {'thisusername':username,}
> form = form_class(data)
>
> Why is it form_class(data) does not accept the data
> as declared and enable it to presented it in
> templates in any other form than a writable field
>  --  when render_to_response allows the data to be
>     presented as a string?
>
> >
>

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



Re: How to say Hello "Somebody" in a Django form. Displaying data context values as non-input.

2009-03-16 Thread NoviceSortOf

Thanks for your responses, they have helped.

I've read the documentation many times, and only resort to groups
after re-reading what I can find in the docs, testing various logical
solutions, digging through groups and finally confering with a 3rd
party book I've here on Django. If all else fails,
then I post to groups.

So that is why I'm puzzled when {{ var }} does not present var on my
form.

As mentioned above in views.py I'm passing data to the form_class in
this example I'm using str to convert value to string.

in view.py then
...
thisusername = str(request.user.username)
data = {'thisusername':username,}
form = form_class(data)

Now it seems form_class() would be adding the data to
itself with form_class(data) but it isn't.

Instead I have to add the context to the render_to_response
despite the fact that this data has been added to form
earlier.

ie.
return render_to_response(template_name, { 'form': form},
  context_instance=context)

will either not display the item, or force it to be viewed
only as a corresponding writable field as defined in forms.py
or model.py.

but loading it directly to render_to_response works...

return render_to_response(template_name, { 'form': form,
'thisusername':username},
context_instance=context)

So perhaps a better question would be is

in view.py...
---
thisusername = str(request.user.username)
data = {'thisusername':username,}
form = form_class(data)

Why is it form_class(data) does not accept the data
as declared and enable it to presented it in
templates in any other form than a writable field
 --  when render_to_response allows the data to be
 presented as a string?

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



get_absolute_url not working on deployed site; exact same code works on dev site

2009-03-16 Thread Theme Park Photo, LLC

I'm having problems with get_absolute_url not working.

It works fine on my development site, but when I tried to deploy it,
it fails, and I can't figure out why

I'm using the "basic.blog" app

>>> post = Post.objects.published()
>>> p = post[0]
>>> print p.get_absolute_url()
Traceback (most recent call last):
  File "", line 1, in ?
  File "/usr/lib/python2.4/site-packages/django/utils/functional.py",
line 55, in _curried
return _curried_func(*(args+moreargs), **dict(kwargs,
**morekwargs))
  File "/usr/lib/python2.4/site-packages/django/db/models/base.py",
line 515, in get_absolute_url
return settings.ABSOLUTE_URL_OVERRIDES.get('%s.%s' %
(opts.app_label, opts.module_name), func)(self, *args, **kwargs)
  File "/usr/lib/python2.4/site-packages/django/db/models/
__init__.py", line 30, in inner
return reverse(bits[0], None, *bits[1:3])
  File "/usr/lib/python2.4/site-packages/django/core/urlresolvers.py",
line 253, in reverse
return iri_to_uri(u'%s%s' % (prefix, get_resolver(urlconf).reverse
(viewname,
  File "/usr/lib/python2.4/site-packages/django/core/urlresolvers.py",
line 227, in reverse
possibilities = self.reverse_dict.getlist(lookup_view)
  File "/usr/lib/python2.4/site-packages/django/core/urlresolvers.py",
line 161, in _get_reverse_dict
for name in pattern.reverse_dict:
  File "/usr/lib/python2.4/site-packages/django/core/urlresolvers.py",
line 161, in _get_reverse_dict
for name in pattern.reverse_dict:
  File "/usr/lib/python2.4/site-packages/django/core/urlresolvers.py",
line 154, in _get_reverse_dict
if not self._reverse_dict and hasattr(self.urlconf_module,
'urlpatterns'):
  File "/usr/lib/python2.4/site-packages/django/core/urlresolvers.py",
line 198, in _get_urlconf_module
self._urlconf_module = __import__(self.urlconf_name, {}, {}, [''])
ValueError: Empty module name

I wondered about the return settings.ABSOLUTE_URL_OVERRIDES.get() in
the call stack. This is set to empty

>>> print settings.ABSOLUTE_URL_OVERRIDES
{}

(the default), so I'm not sure why it's there.


The exact same code running on another machine works fine:

In [13]: print p.get_absolute_url()
/blog/2009/mar/13/hello-0/


Two questions:

1. What does "ValueError: Empty Module Name" mean?
2. What environmental factors could make a simple get_absolute_url
method stop working? It's defined like this?

@permalink
def get_absolute_url(self):
return ('blog_detail', None, {
'year': self.publish.year,
'month': self.publish.strftime('%b').lower(),
'day': self.publish.day,
'slug': self.slug
})





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



Re: Aggregation Questions

2009-03-16 Thread Alex Gaynor
On Mon, Mar 16, 2009 at 11:52 AM, koranthala  wrote:

>
>
>
> On Mar 16, 8:14 pm, Alex Gaynor  wrote:
> > On Mon, Mar 16, 2009 at 11:07 AM, koranthala 
> wrote:
> >
> > > Hi,
> > >I downloaded Django 1.1 due to aggregation support.
> > >But I am facing one issue which I cannot seem to overcome.
> > >I have two fields which represents two different times.
> > >I want to get the sum of difference of times - and I am unable to
> > > do so.
> > > Basically, I want to do as follows:
> > > SELECT SUM (time2 - time1) FROM _TABLE_ WHERE __XXX___
> >
> > >I tried 2 options:
> > > 1. self.filter( XXX).aggregate(diff=Sum('time2 - time1'))
> > > 2. self.filter (XXX).aggregate(t2=Sum('time2'), t1= Sum('time1')) - so
> > > that I can do t2 - t1 later.
> >
> > >Both is not supported in Django. I have raw SQL code in model
> > > Manager for the same. I thought using Django Aggregation is better. Is
> > > such operations going to be supported in Django 1.1 ?
> >
> > > Regards
> > > Koran
> >
> > Right now that isn't possible, is there any reason you couldn't just
> bring
> > the seperate SUMs into python and do the subtraction there, I realize it
> > isn't quite as clean but the overhead should be minimal?
> >
> > Alex
> >
> > --
> > "I disapprove of what you say, but I will defend to the death your right
> to
> > say it." --Voltaire
> > "The people's good is the highest law."--Cicero
>
> If I understand correctly:
> Separate SUMs as in the 2nd option which I mentioned above?
> It was not possible because currently aggregation methods does not
> support SUM - I think because Python itself does not support SUM of
> datetime objects.
>
> Or was it:
> Separate SUM as in bring all the tuples to Python and then calculate?
> It is quite big because there are more than 1 Million tuples so I dont
> want to bring everything to Python.
>
> Please let me know whether I have understood correctly.
> >
>
Sorry, I missed that these were dates/times.  Right now there isn't complete
support for aggregating on dates/times.  I think here the easiest route is
just to do:

self.extra(select={'diff': "SUM(field1-field2"}).values('diff')

Which I believe will work.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: How to say Hello "Somebody" in a Django form. Displaying data context values as non-input.

2009-03-16 Thread johan . uhle

> How does Django enable the ability to pass variables to a Form or a
> Template whose purpose is only to be displayed?

Given that the input has been validated correctly and does not throw
an error you can access the value with
form.cleaned_data.username

If you want to pass a variable to a template, try
# view.py or whereever your code lives
return render_to_response('template.html' { 'templatevar': 'the
content of the var' })
# template.html
{{ templatevar }}


On 16 Mrz., 18:15, NoviceSortOf  wrote:
> I just want to say Hello Mary in my HTML code pulling Mary's username
> from the request.data.
>
> I've dug through the documentation and through this group, but am
> still baffled by
> what seems the inability of Django to allow someone to display a value
> in some format
> other than an input variable of a form.
>
> For instance if the users name is "Mary", and Mary has logged in...
>
> in view.py then
> ...
> thisusername = request.user.username
> data = {'thisusername':username,}
> form = form_class(data)
> 
>
> now in the hello.html how do you say Hello Mary?
>
> when I try {{ form.thisusername }}   - i get an input field
>
> when i try coding html like
>
>  maxlength="20" />
> - i get a writable input field
>
> when i try 
>  maxlength="20" READONLY />
> - i get a blank input / no value field
>
> How does Django enable the ability to pass variables to a Form or a
> Template whose purpose is only to be displayed?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Port in use Error

2009-03-16 Thread Daniel Roseman

On Mar 16, 5:16 pm, TP  wrote:
> Unfortunately the website doesnt work, just get  a blank web page.
>
> Im working from a University computer so im guessing it may be due to
> that problem as I have no other programs running apart from Firefox
>

So use a different port number - eg
./manage.py runserver 127.0.0.1:8001
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to say Hello "Somebody" in a Django form. Displaying data context values as non-input.

2009-03-16 Thread Daniel Roseman

On Mar 16, 5:15 pm, NoviceSortOf  wrote:
> I just want to say Hello Mary in my HTML code pulling Mary's username
> from the request.data.
>
> I've dug through the documentation and through this group, but am
> still baffled by
> what seems the inability of Django to allow someone to display a value
> in some format
> other than an input variable of a form.
>
> For instance if the users name is "Mary", and Mary has logged in...
>
> in view.py then
> ...
> thisusername = request.user.username
> data = {'thisusername':username,}
> form = form_class(data)
> 
>
> now in the hello.html how do you say Hello Mary?
>
> when I try {{ form.thisusername }}   - i get an input field
>
> when i try coding html like
>
>  maxlength="20" />
> - i get a writable input field
>
> when i try 
>  maxlength="20" READONLY />
> - i get a blank input / no value field
>
> How does Django enable the ability to pass variables to a Form or a
> Template whose purpose is only to be displayed?

Have you thought that maybe it isn't Django that has the inability,
when it comes to doing something as fundamental as displaying
variables in a template?

For a start, you haven't showed us what you are passing to the
template, or why you think this has anything to do with forms.
However, a simple reading of the documentation would show that
Django's templates allow you to display any variable you pass using
the {{ var }} syntax.

So, for example, if you did this in your view:
return render_to_response(template_name, {'username': username})

then you can do:
{{ username }}
to output the value of username.

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



Re: Django critter helps us code at the speed of light.

2009-03-16 Thread Klowner

That's just awesome.

Quick and dirty 3D version done in blender :)
http://img.skitch.com/20090316-82bsdnfjm15xarx3t9c1e4a7q9.png

- Mark

On Mar 11, 1:10 pm, Eric Walstad <ewals...@gmail.com> wrote:
> It occurred to me that my 9yr old daughter has been listening to me
> talk about Django for almost half of her life.  She sees me reading
> books and blogs about Django.  She sees me wear my green DjangoCon t-
> shirt.  For the last 4 years Django's had some influence on her, too.
>
> Last night she was creating critters with her water color crayons.
> Some are strong, some are mischievous, some are kind.  She created the
> Django critter for me. As she puts it:
>
> """
> Django is a computer programming critter.  He is loyal only to
> computer programmers and does all their work.  He types with the ball
> on the end of his tail, at the speed of light.  He beeps when his work
> is done and when you take him home, he flies around the house, doing
> all your chores.  He's a helpful little fellow.
> """
>
> I don't think she realizes it, but Django also helps pay the bills and
> puts a smile on her dad's face.
>
> Now you can have your pony AND a Django 
> Critter:http://starship.python.net/~ewalstad/django_critter.html
>
> I hope you all enjoy Django as much as we have.
>
> Eric.

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



Re: Port in use Error

2009-03-16 Thread TP

Unfortunately the website doesnt work, just get  a blank web page.

Im working from a University computer so im guessing it may be due to
that problem as I have no other programs running apart from Firefox

On Mar 16, 5:13 pm, Dougal Matthews  wrote:
> It means another program is using the port you are trying to use. Do you
> have another server running? or skype by any chance?
> If you can still view the website in the browser, its not a problem. If you
> can't you should use another port or close the program using the same port.
>
> Dougal
>
> ---
> Dougal Matthews - @d0ugalhttp://www.dougalmatthews.com/
>
> 2009/3/16 TP 
>
>
>
> > After creating a new project, when running manage.py i get the
> > following:
>
> > Validating models...
> > 0 errors found
>
> > Django version 1.0.2 final, using settings 'mylu.settings'
> > Development server is running athttp://127.0.0.1:8000/
> > Quit the server with CONTROL-C.
> > Error: That port is already in use.
>
> > Despite saying 0 errors at the top, is this still a problem?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to say Hello "Somebody" in a Django form. Displaying data context values as non-input.

2009-03-16 Thread NoviceSortOf


I just want to say Hello Mary in my HTML code pulling Mary's username
from the request.data.

I've dug through the documentation and through this group, but am
still baffled by
what seems the inability of Django to allow someone to display a value
in some format
other than an input variable of a form.

For instance if the users name is "Mary", and Mary has logged in...

in view.py then
...
thisusername = request.user.username
data = {'thisusername':username,}
form = form_class(data)


now in the hello.html how do you say Hello Mary?

when I try {{ form.thisusername }}   - i get an input field

when i try coding html like


- i get a writable input field

when i try 

- i get a blank input / no value field

How does Django enable the ability to pass variables to a Form or a
Template whose purpose is only to be displayed?



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



How to say Hello "Somebody" in a Django form. Displaying data context values as non-input.

2009-03-16 Thread NoviceSortOf


I just want to say Hello Mary in my HTML code pulling Mary's username
from the request.data.

I've dug through the documentation and through this group, but am
still baffled by
what seems the inability of Django to allow someone to display a value
in some format
other than an input variable of a form.

For instance if the users name is "Mary", and Mary has logged in...

in view.py then
...
thisusername = request.user.username
data = {'thisusername':username,}
form = form_class(data)


now in the hello.html how do you say Hello Mary?

when I try {{ form.thisusername }}   - i get an input field

when i try coding html like


- i get a writable input field

when i try 

- i get a blank input / no value field

How does Django enable the ability to pass variables to a Form or a
Template whose purpose is only to be displayed?



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



Re: Port in use Error

2009-03-16 Thread Dougal Matthews
It means another program is using the port you are trying to use. Do you
have another server running? or skype by any chance?
If you can still view the website in the browser, its not a problem. If you
can't you should use another port or close the program using the same port.

Dougal

---
Dougal Matthews - @d0ugal
http://www.dougalmatthews.com/




2009/3/16 TP 

>
> After creating a new project, when running manage.py i get the
> following:
>
>
> Validating models...
> 0 errors found
>
> Django version 1.0.2 final, using settings 'mylu.settings'
> Development server is running at http://127.0.0.1:8000/
> Quit the server with CONTROL-C.
> Error: That port is already in use.
>
>
>
> Despite saying 0 errors at the top, is this still a problem?
>
> >
>

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



Port in use Error

2009-03-16 Thread TP

After creating a new project, when running manage.py i get the
following:


Validating models...
0 errors found

Django version 1.0.2 final, using settings 'mylu.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Error: That port is already in use.



Despite saying 0 errors at the top, is this still a problem?

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



Re: Strip empty lines in rendered templates?

2009-03-16 Thread Benjamin Buch

Yes, you're right.

But as the SpacelessMiddleware uses djangos' strip_spaces_between_tags,
which strips all whitespace between tags and not just empty lines,
I think it would have been fiddly to adapt it without touching django  
internals.
In this case it seemed easier for me to use StripWhitespaceMiddleware,  
which did what I wanted.

benjamin

Am 16.03.2009 um 17:37 schrieb Dougal Matthews:

> You could adapt that middlewear to make it only stop blank lines I'm  
> sure.
>
> I use it for one website and its only used in the production  
> version, in my settings for the dev version it doesn't include that  
> middlewear so it doesn't effect any front end development.
>
> Only thing to be aware of is it messes up some tags, like   
> and 
>
> Dougal

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



override render_to_response

2009-03-16 Thread a b
Hi,

I'm building a one page app with no page refresh.
All the content is loaded as JSON dynamically and the UI is built using
javascript.

I'm using external django apps and I need them to send back the context dict
as JSON instead
of rendering the html template.

Is it possible to override render_to_response so all the apps using it will
respond with JSON without
actually touching the apps code? I don't want to create a middleware that
will modify the response because
then I have the overhead of rendering the html template.

Thanks

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



Re: Strip empty lines in rendered templates?

2009-03-16 Thread Dougal Matthews
You could adapt that middlewear to make it only stop blank lines I'm sure.
I use it for one website and its only used in the production version, in my
settings for the dev version it doesn't include that middlewear so it
doesn't effect any front end development.

Only thing to be aware of is it messes up some tags, like  and


Dougal

---
Dougal Matthews - @d0ugal
http://www.dougalmatthews.com/




2009/3/16 Benjamin Buch 

>
> Thank you for your replies!
>
> What I essentially want to do is:
> 1: Keep the template output readable for the frontend coder I'm
> working with
> 2: Keep the templates readable for me.
>
> @Dougal:
> I think the solution you suggested is great when someone wants to keep
> the size of the rendered template to a minimum.
> But as it strips really all whitespace, all linebreaks and everything,
> the result is perfectly machine readable
> but nothing that would make my frontend coder be happy.
>
> @Tim:
> This solution would give me the desired output, but the templates get
> less readable for me this way.
>
> What I figured out:
>
> I gave the StripWhitespaceMiddleware I mentioned a try,
> and it works reasonably well.
> It just strips empty lines but keeps the indentation the tags have in
> the template,
> so you've got reasonable control over how the rendered templates look
> like.
>
> The downsides I see so far are:
> - You can't add empty lines to structure the rendered template
> - Multiline output from template variables are not indented (e.g.
> something like {{ entry.body|markdown }})
>
> I have no solution for the add-empty-line-problem,
> but I wrote a template tag that indents the output of a multiline
> variable.
> It's not perfect (it destroys all indentation that is output by
> markdown..) but it works for me:
>
> class IndentNode(Node):
> def __init__(self, nodelist, indent_level):
> self.indent_level = indent_level
> self.nodelist = nodelist
>
> def render(self, context):
> rendered = self.nodelist.render(context)
> lines = rendered.split('\n')
> for i in range(len(lines)):
> if lines[i]:
> lines[i] = ' ' * int(self.indent_level) +
> lines[i].strip(' ')
> rendered = ''
> for line in lines:
> rendered += line + '\n'
> return rendered
>
> def do_indent(parser, token):
> bits = token.contents.split()
> try:
> indent_level = bits[1]
> except IndexError:
> indent_level = 0
> nodelist = parser.parse(('endindent',))
> parser.delete_first_token()
> return IndentNode(nodelist, indent_level)
>
> You would use it like this:
>
> {% indent 8 %}
> {{ entry.body|markdown }}
> {% endindent %}
>
> An other solution I tried but rejected was to use Beatiful Soups
> 'prettify'-method in a middleware:
>
> class BeautifulSoupMiddleware:
> def process_response(self, request, response):
> new_content = BeautifulSoup(response.content).prettify()
> response.content = new_content
> return response
>
> But the output was a little to shaky, so I can't recommend it.
>
>
> benjamin
>
>
>
>
>
> >
>

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



Strategy for extending DB tables with additional columns

2009-03-16 Thread Trey

Hello everyone, I am hoping someone has some experience in this
already. I have a rough idea of how to do it, but I am hoping to
discover a better way.

What I have:
A contact manager. A contact has a set of data that makes sense on
anyone's version of a contact, things like name, email address, etc.

Depending on the use of the contact manager, special fields may be
required. Something like, birthplace or SSN.

I would like to build the contact manager for all purposes and have
those extra fields configured through the CRM's admin.

My Plan:
What I have in mind is a standard columnar table that holds all the
basic fields. And then two additional tables, one for the customized
field names and one to related the custom fields to the contact. I can
foresee tons of performance issues and problems updating data.

Does anyone have any advice, working example, snippet or other general
comment?

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



Re: Lookup across relations

2009-03-16 Thread Matías Costa
2009/3/16 Matías Costa 

> On Sun, Mar 15, 2009 at 2:54 PM, 3xM <3...@detfalskested.dk> wrote:
>
>>
>> Gees... It messed with my link. I'll try again:
>> http://blackfin.cannedtuna.org/django-testcase.tar.gz
>> >>
>>
> It works OK here. I have added __rerpr__ method to models to get a clear
> output:


BTW,  this is Django 1.0, I had to rename your maxlength field parameter to
max_length. Are you using 0.96?

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



Re: Aggregation Questions

2009-03-16 Thread koranthala



On Mar 16, 8:14 pm, Alex Gaynor  wrote:
> On Mon, Mar 16, 2009 at 11:07 AM, koranthala  wrote:
>
> > Hi,
> >    I downloaded Django 1.1 due to aggregation support.
> >    But I am facing one issue which I cannot seem to overcome.
> >    I have two fields which represents two different times.
> >    I want to get the sum of difference of times - and I am unable to
> > do so.
> > Basically, I want to do as follows:
> > SELECT SUM (time2 - time1) FROM _TABLE_ WHERE __XXX___
>
> >    I tried 2 options:
> > 1. self.filter( XXX).aggregate(diff=Sum('time2 - time1'))
> > 2. self.filter (XXX).aggregate(t2=Sum('time2'), t1= Sum('time1')) - so
> > that I can do t2 - t1 later.
>
> >    Both is not supported in Django. I have raw SQL code in model
> > Manager for the same. I thought using Django Aggregation is better. Is
> > such operations going to be supported in Django 1.1 ?
>
> > Regards
> > Koran
>
> Right now that isn't possible, is there any reason you couldn't just bring
> the seperate SUMs into python and do the subtraction there, I realize it
> isn't quite as clean but the overhead should be minimal?
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero

If I understand correctly:
Separate SUMs as in the 2nd option which I mentioned above?
It was not possible because currently aggregation methods does not
support SUM - I think because Python itself does not support SUM of
datetime objects.

Or was it:
Separate SUM as in bring all the tuples to Python and then calculate?
It is quite big because there are more than 1 Million tuples so I dont
want to bring everything to Python.

Please let me know whether I have understood correctly.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Strip empty lines in rendered templates?

2009-03-16 Thread Benjamin Buch

Thank you for your replies!

What I essentially want to do is:
1: Keep the template output readable for the frontend coder I'm  
working with
2: Keep the templates readable for me.

@Dougal:
I think the solution you suggested is great when someone wants to keep  
the size of the rendered template to a minimum.
But as it strips really all whitespace, all linebreaks and everything,  
the result is perfectly machine readable
but nothing that would make my frontend coder be happy.

@Tim:
This solution would give me the desired output, but the templates get  
less readable for me this way.

What I figured out:

I gave the StripWhitespaceMiddleware I mentioned a try,
and it works reasonably well.
It just strips empty lines but keeps the indentation the tags have in  
the template,
so you've got reasonable control over how the rendered templates look  
like.

The downsides I see so far are:
- You can't add empty lines to structure the rendered template
- Multiline output from template variables are not indented (e.g.  
something like {{ entry.body|markdown }})

I have no solution for the add-empty-line-problem,
but I wrote a template tag that indents the output of a multiline  
variable.
It's not perfect (it destroys all indentation that is output by  
markdown..) but it works for me:

class IndentNode(Node):
 def __init__(self, nodelist, indent_level):
 self.indent_level = indent_level
 self.nodelist = nodelist

 def render(self, context):
 rendered = self.nodelist.render(context)
 lines = rendered.split('\n')
 for i in range(len(lines)):
 if lines[i]:
 lines[i] = ' ' * int(self.indent_level) +  
lines[i].strip(' ')
 rendered = ''
 for line in lines:
 rendered += line + '\n'
 return rendered

def do_indent(parser, token):
 bits = token.contents.split()
 try:
 indent_level = bits[1]
 except IndexError:
 indent_level = 0
 nodelist = parser.parse(('endindent',))
 parser.delete_first_token()
 return IndentNode(nodelist, indent_level)

You would use it like this:

{% indent 8 %}
{{ entry.body|markdown }}
{% endindent %}

An other solution I tried but rejected was to use Beatiful Soups  
'prettify'-method in a middleware:

class BeautifulSoupMiddleware:
 def process_response(self, request, response):
 new_content = BeautifulSoup(response.content).prettify()
 response.content = new_content
 return response

But the output was a little to shaky, so I can't recommend it.


benjamin





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



Many to Many is empty when saving parent object

2009-03-16 Thread Brandon Taylor

Hi everyone,

I'm running Python 2.6.1, Django Trunk.

I have a model (Entry) with a ManyToMany (Categories). I need to be
able to iterate over these categories whenever my parent model is
saved.

I've tried overriding save_model in the admin, and adding a post_save
signal to Entry in order to be able to iterate over the categories.
The problem only occurs on an insert. If I do:

class Entry(models.Model):
name = models.CharField(max_length=100)
categories = models.ManyToManyField(Category)

class Meta:
verbose_name_plural = 'Entries'

def __unicode__(self):
return self.name

class EntryAdmin(admin.ModelAdmin):
def save_model(self, request, obj, form, change):
obj.save()
print obj.categories.all()

obj.categories.all() = []

However, when performing an update, I have a list of Category objects.
Is this a model lifecycle issue as far as when the ManyToMany gets
saved? What can I do to be able to access the list of categories when
the object is created?

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



multiple python versions

2009-03-16 Thread TheIvIaxx

Hello, on my dev machine I am running a django instance on its little
dev server with python 2.5.2 32bit.  Works fine.  But all of our tool
are written for python 2.5.x 64bit.  These are irrelevant to django.

Having both python versions installed causes and issue with django.
How do I tell django what version to use?

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



Re: ImproperlyConfigured: MySQLdb-1.2.1p2 or newer is required; you have 1.2.1 But I HAVE 1.2.2!

2009-03-16 Thread Theme Park Photo, LLC

Thanks, Malcolm! The problem was an old django. I was setting up a new
machine, and I didn't realize that easy_install put an old django on
my machine. When I downloaded the latest 1.0.2 trunk and installed it,
the problem went away

On Mar 15, 9:12 pm, Malcolm Tredinnick 
wrote:
> On Sun, 2009-03-15 at 21:08 -0700, Theme Park Photo, LLC wrote:
> > I'm getting this message when trying to start Django (from mod_python)
>
> > (From my apache log)
>
> > [Sun Mar 15 22:07:28 2009] [error] [client 67.188.95.50] PythonHandler
> > django.core.handlers.modpython: ImproperlyConfigured: MySQLdb-1.2.1p2
> > or newer is required; you have 1.2.1
>
> > BUT! I have 1.2.2 installed, see:
>
> > bash-3.1$ python manage.py shell
> > Python 2.4.4 (#1, Oct 23 2006, 13:58:00)
> > [GCC 4.1.1 20061011 (Red Hat 4.1.1-30)] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
> > (InteractiveConsole)
> > >>> import MySQLdb
> > >>> print MySQLdb
> >  > MySQL_python-1.2.2-py2.4-linux-i686.egg/MySQLdb/__init__.py'>
>
> What does MySQLdb.version_info say? That's what Django is looking at,
> not the name of the package.
>
> Also, what version of Django are you using?
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Simple sites framework question

2009-03-16 Thread Baxter

D'oh. I knew I was missing something simple and obvious. Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination problem with "Next" and saving results as a dictionary

2009-03-16 Thread Jesse

Hello Paul,

Thanks!! I'll try it.

On Mar 13, 2:21 pm, pkenjora  wrote:
> Uhm maybe this post will help its a tag that handles thepaginationon 
> query objects.  I've used it in a few of my projects and
> its quite handy.
>
> http://blog.awarelabs.com/?p=29
>
> -Paul
>
> On Mar 13, 12:13 pm, Jesse  wrote:
>
> > Hello Micah,
>
> > I can get the q with GET, but I have too complicated of a search and I
> > need to use POST.  I'm having much difficulty with my template code
> > with POST to work with paginator.  I'll keep trying.  Thanks for your
> > patience and 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Simple sites framework question

2009-03-16 Thread Alex Gaynor
On Mon, Mar 16, 2009 at 11:19 AM, bax...@gretschpages.com <
mail.bax...@gmail.com> wrote:

>
> In my model, I've got
>
>sites = models.ManyToManyField(Site)
>
> In a signal, I want to check which site(s) that model has been
> assigned to, not which site their currently on. I need something like
>
> if instance.sites.id == 1:
>   do stuff
>
> Of course, that doesn't work. How do I do this?
> >
>
So a given instance can have more than 1 site attached to it, do you want to
say, if 1 is the id of one of it's sites do this, if so it looks like:

if instance.sites.filter(id=1):
do stuff

which is hopefully clear in what it does, if you're trying to do something
else you'll have to clarify.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: Simple sites framework question

2009-03-16 Thread Dougal Matthews
I think these are the relevant docs you need;
http://docs.djangoproject.com/en/dev/topics/db/queries/#related-objects

Dougal

---
Dougal Matthews - @d0ugal
http://www.dougalmatthews.com/




2009/3/16 bax...@gretschpages.com 

>
> In my model, I've got
>
>sites = models.ManyToManyField(Site)
>
> In a signal, I want to check which site(s) that model has been
> assigned to, not which site their currently on. I need something like
>
> if instance.sites.id == 1:
>   do stuff
>
> Of course, that doesn't work. How do I do this?
> >
>

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



Simple sites framework question

2009-03-16 Thread bax...@gretschpages.com

In my model, I've got

sites = models.ManyToManyField(Site)

In a signal, I want to check which site(s) that model has been
assigned to, not which site their currently on. I need something like

if instance.sites.id == 1:
   do stuff

Of course, that doesn't work. How do I do this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Aggregation Questions

2009-03-16 Thread Alex Gaynor
On Mon, Mar 16, 2009 at 11:07 AM, koranthala  wrote:

>
> Hi,
>I downloaded Django 1.1 due to aggregation support.
>But I am facing one issue which I cannot seem to overcome.
>I have two fields which represents two different times.
>I want to get the sum of difference of times - and I am unable to
> do so.
> Basically, I want to do as follows:
> SELECT SUM (time2 - time1) FROM _TABLE_ WHERE __XXX___
>
>I tried 2 options:
> 1. self.filter( XXX).aggregate(diff=Sum('time2 - time1'))
> 2. self.filter (XXX).aggregate(t2=Sum('time2'), t1= Sum('time1')) - so
> that I can do t2 - t1 later.
>
>Both is not supported in Django. I have raw SQL code in model
> Manager for the same. I thought using Django Aggregation is better. Is
> such operations going to be supported in Django 1.1 ?
>
> Regards
> Koran
>
>
>
> >
>
Right now that isn't possible, is there any reason you couldn't just bring
the seperate SUMs into python and do the subtraction there, I realize it
isn't quite as clean but the overhead should be minimal?

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Aggregation Questions

2009-03-16 Thread koranthala

Hi,
I downloaded Django 1.1 due to aggregation support.
But I am facing one issue which I cannot seem to overcome.
I have two fields which represents two different times.
I want to get the sum of difference of times - and I am unable to
do so.
Basically, I want to do as follows:
SELECT SUM (time2 - time1) FROM _TABLE_ WHERE __XXX___

I tried 2 options:
1. self.filter( XXX).aggregate(diff=Sum('time2 - time1'))
2. self.filter (XXX).aggregate(t2=Sum('time2'), t1= Sum('time1')) - so
that I can do t2 - t1 later.

Both is not supported in Django. I have raw SQL code in model
Manager for the same. I thought using Django Aggregation is better. Is
such operations going to be supported in Django 1.1 ?

Regards
Koran



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



on delete set null

2009-03-16 Thread Thomas Guettler

Hi,

I have a foreign key from MyModel to contrib.auth.models.User which can
be null.

Unfortunately if you delete the user, the MyModel instance gets deleted, too.

I found an open ticket[1], but nevertheless don't know how to get the "on 
delete set null"
done.

One solution would be this: subclass User and override delete() and use this 
class for
as foreign key.
But I would prefer a different solution.


[1] http://code.djangoproject.com/ticket/7539
Add ON DELETE and ON UPDATE support to Django

  Thomas

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

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



Re: Django critter helps us code at the speed of light.

2009-03-16 Thread mrts

On Mar 16, 3:53 pm, Torsten Bronger 
wrote
> No, I mean "contained in the original critter".  As far as I can
> see, you added the glory.  I simply wonder why.

Ah, sorry for the misunderstanding :). It looked nice, conveys the
"helpful fellow" message and -- last not least -- helps me to add 3D-
depth to the figure.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Verbose Error Logging

2009-03-16 Thread PB

Hi,

Is there any way to force tracebacks that are normally swallowed by
the templating engine to be logged to the server's error logs?

Much of the time the superb error handling in the template engine
means that little bugs can often fly under the radar. Additionally,
when a site is deployed, error logs are the only indicator that
something has broken.

Does such a capability exist in django?

Thanks,

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



Re: Snap and SCT - any reviews?

2009-03-16 Thread John Crawford

Sorry, I wasn't trying to be rude or take anyone for granted. I
noticed that the post had dropped back several pages on the forum, and
just wanted to to bump it up, which I guess isn't a good idea. And the
line is from "Ferris Bueller's Day Off', which I thought would be
funny :)

Sorry again.
John C>

Jacob Kaplan-Moss wrote:
> On Sun, Mar 15, 2009 at 5:40 PM, John Crawford  wrote:
> > Anyone? Anyone? Bueller?
>
> That's rude.
>
> Please don't take the amazing work of the volunteers on this board for
> granted. Nobody here is required to update your question, and if you
> don't get an answer that's just the way it goes. Further, you posted
> your on Friday afternoon; expecting to hear back by Sunday ignores the
> fact that many of us like to experience that place called "outdoors"
> or at least "away from the keyboard" for the weekend.
>
> Jacob
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



beginner model question - two tables without foreign keys (myslq - myisam)

2009-03-16 Thread Norman

How to perform such simple query:

select p.text, b.title from books b, phrase p where p.book_id = b.id

on tables

books{
id : int,
title: varchar
}

phrase{
id : int,
book_id : int,
text: varchar
}

but using django models?


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



Re: PositiveIntegerField returning a string?

2009-03-16 Thread msoulier

On Mar 14, 1:35 am, Russell Keith-Magee 
wrote:
> It's possible that this is a known bug that has been fixed since v0.96
> was released. Where exactly did metrics object come from? Is is a
> newly created object, or was it obtained as the result of a query?

It was created as a result of a query.

> If metrics isn't a newly created object, then it would help if you
> could provide a test case that would let us reproduce the problem.

I'm not sure that I can reliably reproduce it, but I can provide what
code I have.

There's a background process that is receiving messages as an IPC
mechanism, and storing the numbers in the metrics table via the
TugMetrics class. The numbers are all strings initially but the daemon
casts them before calling save().

The code populating it looks like this

   metrics.user_licenses_ca = int(
details.get('Max_users', '0/0/0').split('/')[2])

The Max_users field contains a '/' delimited sting of three numbers,
which is why I'm splitting like that.

The int() call should enforce an integer.

What's really odd is that when I use a django shell, all of the
properties seems to be integers instead of this one. I'm not sure why.

I'm currently working around it by calling int() when I pull the value
out again.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django critter helps us code at the speed of light.

2009-03-16 Thread Torsten Bronger

Hallöchen!

mrts writes:

> On Mar 16, 2:55 pm, Torsten Bronger 
> wrote:
>
>> mrts writes:
>>
>>> On Mar 15, 5:56 pm, mrts  wrote:
>>
 I don't, therefore I'm all for the critter and my (styled) take
 is here:http://mrts-foo.appspot.com/
>>
>>> For anyone still interested in the critter, there are some
>>> banners now athttp://mrts-foo.appspot.com/.
>>
>> But the glory is not authentic, is it?
>
> If by "authentic" you mean "endorsed by core devs"

No, I mean "contained in the original critter".  As far as I can
see, you added the glory.  I simply wonder why.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: torsten.bron...@jabber.rwth-aachen.de


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



Starting custom settings with django-admin.py failed

2009-03-16 Thread Joshua Partogi

Dear all,

I have a custom setting which I would like to run with django-admin as such:

django-admin.py runserver --settings=portal.settings

The name of my project is 'portal' and in my project directory there's
already __init__.py so I assume that python will already recognize
this as a python module.

But instead I receive this error:
Error: Could not import settings 'portal.settings' (Is it on sys.path?
Does it have syntax errors?): No module named portal.settings

Have I missed on something here that needs to be configured?

Thank you very much in advance

-- 
If you can't believe in God the chances are your God is too small.

Read my blog: http://joshuajava.wordpress.com/
Follow me on twitter: http://twitter.com/jpartogi

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



Re: Django critter helps us code at the speed of light.

2009-03-16 Thread mrts

On Mar 16, 2:55 pm, Torsten Bronger 
wrote:
> Hallöchen!
>
> mrts writes:
> > On Mar 15, 5:56 pm, mrts  wrote:
>
> >> I don't, therefore I'm all for the critter and my (styled) take
> >> is here:http://mrts-foo.appspot.com/
>
> > For anyone still interested in the critter, there are some banners
> > now athttp://mrts-foo.appspot.com/.
>
> But the glory is not authentic, is it?

If by "authentic" you mean "endorsed by core devs" -- no. That is
explicitly stated at http://mrts-foo.appspot.com/ (and I made it even
more explicit just now). But neither is the pony "authentic" in that
sense, Django does not have an official mascot AFAICT.

That's the reason why the name "Django" is not used in neither the
critter nor the pony banners.

If there are any issues with the current wording in that regard at
http://mrts-foo.appspot.com/ , please let me know.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django critter helps us code at the speed of light.

2009-03-16 Thread Geobase Isoscale
Encouraging to new guys in the block, there hope of longevity here...no more
hop and jump to other languages.

On Mon, Mar 16, 2009 at 1:32 PM, mrts  wrote:

>
> On Mar 15, 5:56 pm, mrts  wrote:
> > I don't, therefore I'm all for the critter and my (styled) take is
> > here:http://mrts-foo.appspot.com/
>
> For anyone still interested in the critter, there are some banners now
> at http://mrts-foo.appspot.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Conditional row coloring in django-admin changelist

2009-03-16 Thread Blake M. Sisco
one thing that i should point out is that the column is "prettified" so it
uses the "on" image instead of the value of the db field.  don't know if
this makes a difference or not cuz the value is the img alt.
Blake M. Sisco
LOR Manufacturing Co., Inc
Web Presence • Graphic Design
www.lormfg.com
(866) 644-8622
(888) 524-6292 FAX

The information transmitted by Blake Sisco herewith is intended only for the
person or entity to which it is addressed and may contain confidential
and/or privileged material.  Any review, retransmission, dissemination or
other use of, or taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is prohibited.  If you
received this in error, please contact the sender and delete the material
from any computer



On Mon, Mar 16, 2009 at 8:55 AM, Blake M. Sisco wrote:

> okmy jquery knowledge is severely lacking and I can't figure out how
> the heck to get this to work...i've spent the last 2+ hours on it :-/  Could
> you give me an example of how i would set this up?
> Blake M. Sisco
> LOR Manufacturing Co., Inc
> Web Presence • Graphic Design
> www.lormfg.com
> (866) 644-8622
> (888) 524-6292 FAX
>
> The information transmitted by Blake Sisco herewith is intended only for
> the person or entity to which it is addressed and may contain confidential
> and/or privileged material.  Any review, retransmission, dissemination or
> other use of, or taking of any action in reliance upon, this information by
> persons or entities other than the intended recipient is prohibited.  If you
> received this in error, please contact the sender and delete the material
> from any computer
>
>
>
> On Mon, Mar 16, 2009 at 6:43 AM, Blake M. Sisco wrote:
>
>> Malcom,
>> awesome i'll give it a try this morning and let you know how it
>> workedthanks a ton
>>
>> Blake M. Sisco
>> LOR Manufacturing Co., Inc
>> Web Presence • Graphic Design
>> www.lormfg.com
>> (866) 644-8622
>> (888) 524-6292 FAX
>>
>> The information transmitted by Blake Sisco herewith is intended only for
>> the person or entity to which it is addressed and may contain confidential
>> and/or privileged material.  Any review, retransmission, dissemination or
>> other use of, or taking of any action in reliance upon, this information by
>> persons or entities other than the intended recipient is prohibited.  If you
>> received this in error, please contact the sender and delete the material
>> from any computer
>>
>>
>>
>> On Fri, Mar 13, 2009 at 8:05 PM, Malcolm Tredinnick <
>> malc...@pointy-stick.com> wrote:
>>
>>>
>>> On Fri, 2009-03-13 at 15:39 -0400, Blake M. Sisco wrote:
>>> > Here's my problem.  I have set up a django app for my company to make
>>> > it easier for our warranty manager to track warranties.  It's working
>>> > great (it's the first thing I've done w/ django and I love it) with
>>> > one exception.  I have a boolean field (recieved_vendor) in my
>>> > warranty model that, when checked, needs to modify the row color in
>>> > the change_list view so he knows that we have received the product
>>> > back from our vendor.  I've been through everything (docs, groups,
>>> > irc) that I can think of, all to no avail. I apologize if this is a
>>> > very noobish question, but hey, I'm a relative django virgin here.
>>> > Any help or insight you guys/gals could give would be greatly
>>> > appreciated...
>>>
>>> Out-of-the-box, this isn't an option that exists.
>>>
>>> However, it wouldn't be particularly tricky to implement with something
>>> like jQuery or other preferred Javascript library of choice: when the
>>> document DOM is ready, iterate through the rows in the table and change
>>> the CSS property on the tr element if the boolean widget is checked. In
>>> jQuery it's just about a one-line, in fact.
>>>
>>> Regards,
>>> Malcolm
>>>
>>>
>>>
>>> >>>
>>>
>>
>

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



Re: Django critter helps us code at the speed of light.

2009-03-16 Thread Torsten Bronger

Hallöchen!

mrts writes:

> On Mar 15, 5:56 pm, mrts  wrote:
>
>> I don't, therefore I'm all for the critter and my (styled) take
>> is here:http://mrts-foo.appspot.com/
>
> For anyone still interested in the critter, there are some banners
> now at http://mrts-foo.appspot.com/ .

But the glory is not authentic, is it?

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: torsten.bron...@jabber.rwth-aachen.de


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



Re: Conditional row coloring in django-admin changelist

2009-03-16 Thread Blake M. Sisco
okmy jquery knowledge is severely lacking and I can't figure out how the
heck to get this to work...i've spent the last 2+ hours on it :-/  Could you
give me an example of how i would set this up?
Blake M. Sisco
LOR Manufacturing Co., Inc
Web Presence • Graphic Design
www.lormfg.com
(866) 644-8622
(888) 524-6292 FAX

The information transmitted by Blake Sisco herewith is intended only for the
person or entity to which it is addressed and may contain confidential
and/or privileged material.  Any review, retransmission, dissemination or
other use of, or taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is prohibited.  If you
received this in error, please contact the sender and delete the material
from any computer



On Mon, Mar 16, 2009 at 6:43 AM, Blake M. Sisco wrote:

> Malcom,
> awesome i'll give it a try this morning and let you know how it
> workedthanks a ton
>
> Blake M. Sisco
> LOR Manufacturing Co., Inc
> Web Presence • Graphic Design
> www.lormfg.com
> (866) 644-8622
> (888) 524-6292 FAX
>
> The information transmitted by Blake Sisco herewith is intended only for
> the person or entity to which it is addressed and may contain confidential
> and/or privileged material.  Any review, retransmission, dissemination or
> other use of, or taking of any action in reliance upon, this information by
> persons or entities other than the intended recipient is prohibited.  If you
> received this in error, please contact the sender and delete the material
> from any computer
>
>
>
> On Fri, Mar 13, 2009 at 8:05 PM, Malcolm Tredinnick <
> malc...@pointy-stick.com> wrote:
>
>>
>> On Fri, 2009-03-13 at 15:39 -0400, Blake M. Sisco wrote:
>> > Here's my problem.  I have set up a django app for my company to make
>> > it easier for our warranty manager to track warranties.  It's working
>> > great (it's the first thing I've done w/ django and I love it) with
>> > one exception.  I have a boolean field (recieved_vendor) in my
>> > warranty model that, when checked, needs to modify the row color in
>> > the change_list view so he knows that we have received the product
>> > back from our vendor.  I've been through everything (docs, groups,
>> > irc) that I can think of, all to no avail. I apologize if this is a
>> > very noobish question, but hey, I'm a relative django virgin here.
>> > Any help or insight you guys/gals could give would be greatly
>> > appreciated...
>>
>> Out-of-the-box, this isn't an option that exists.
>>
>> However, it wouldn't be particularly tricky to implement with something
>> like jQuery or other preferred Javascript library of choice: when the
>> document DOM is ready, iterate through the rows in the table and change
>> the CSS property on the tr element if the boolean widget is checked. In
>> jQuery it's just about a one-line, in fact.
>>
>> Regards,
>> Malcolm
>>
>>
>>
>> >>
>>
>

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



Re: Django critter helps us code at the speed of light.

2009-03-16 Thread mrts

On Mar 15, 5:56 pm, mrts  wrote:
> I don't, therefore I'm all for the critter and my (styled) take is
> here:http://mrts-foo.appspot.com/

For anyone still interested in the critter, there are some banners now
at http://mrts-foo.appspot.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: latitude/longitude field type

2009-03-16 Thread Dougal Matthews
That looks very cool for me and quite useful but I don't think the
django-googlemap supports the DMS format.
Also its not Django 1.0 ready.

Sergio, Don't you just want to create a custom field with a regular
expression validator for DMS?

Dougal

---
Dougal Matthews - @d0ugal
http://www.dougalmatthews.com/




2009/3/16 Javier Santana 

>
> GLatLng looks a good start:
> http://django-googlemap.googlecode.com/svn/trunk/geo/googlemap/models.py
>
> On Sun, Mar 15, 2009 at 11:32 PM, Sergio  wrote:
> >
> > Hello,
> >
> > I'm working on field validation for latitude and longitude. I need to
> > validate them according to the DMS (degree, minutes, seconds) format.
> > I was wondering if there is already a django field model extension for
> > this. I know about geodjango, but that is too much for my needs.
> >
> > Cheers, Sergio
> > >
> >
>
> >
>

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



Re: Lookup across relations

2009-03-16 Thread Matías Costa
On Sun, Mar 15, 2009 at 2:54 PM, 3xM <3...@detfalskested.dk> wrote:

>
> Gees... It messed with my link. I'll try again:
> http://blackfin.cannedtuna.org/django-testcase.tar.gz
> >
>
It works OK here. I have added __rerpr__ method to models to get a clear
output:

for p in Project.objects.all():
print p.name, p.persons.all()
Corporate website [James, Sean, Jennifer]
Customer x website [James, Jennifer]
Customer y website [Sean, Jennifer]

james = Person.objects.get(pk=1)

jennifer = Person.objects.get(pk=3)

Project.objects.filter(persons=james).filter(persons=jennifer)
[Corporate website, Customer x website]

Project.objects.filter(persons=james).filter(persons=jeniffer).query.as_sql()

('SELECT "stuff_project"."id", "stuff_project"."name" FROM "stuff_project"
INNER JOIN "stuff_project_persons" ON ("stuff_project"."id" =
"stuff_project_persons"."project_id") INNER JOIN "stuff_project_persons" T4
ON ("stuff_project"."id" = T4."project_id") WHERE
("stuff_project_persons"."person_id" = %s  AND T4."person_id" = %s
)',

 (1, 3))

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



Re: latitude/longitude field type

2009-03-16 Thread Javier Santana

GLatLng looks a good start:
http://django-googlemap.googlecode.com/svn/trunk/geo/googlemap/models.py

On Sun, Mar 15, 2009 at 11:32 PM, Sergio  wrote:
>
> Hello,
>
> I'm working on field validation for latitude and longitude. I need to
> validate them according to the DMS (degree, minutes, seconds) format.
> I was wondering if there is already a django field model extension for
> this. I know about geodjango, but that is too much for my needs.
>
> Cheers, Sergio
> >
>

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



Re: Conditional row coloring in django-admin changelist

2009-03-16 Thread Blake M. Sisco
Malcom,
awesome i'll give it a try this morning and let you know how it
workedthanks a ton

Blake M. Sisco
LOR Manufacturing Co., Inc
Web Presence • Graphic Design
www.lormfg.com
(866) 644-8622
(888) 524-6292 FAX

The information transmitted by Blake Sisco herewith is intended only for the
person or entity to which it is addressed and may contain confidential
and/or privileged material.  Any review, retransmission, dissemination or
other use of, or taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is prohibited.  If you
received this in error, please contact the sender and delete the material
from any computer



On Fri, Mar 13, 2009 at 8:05 PM, Malcolm Tredinnick <
malc...@pointy-stick.com> wrote:

>
> On Fri, 2009-03-13 at 15:39 -0400, Blake M. Sisco wrote:
> > Here's my problem.  I have set up a django app for my company to make
> > it easier for our warranty manager to track warranties.  It's working
> > great (it's the first thing I've done w/ django and I love it) with
> > one exception.  I have a boolean field (recieved_vendor) in my
> > warranty model that, when checked, needs to modify the row color in
> > the change_list view so he knows that we have received the product
> > back from our vendor.  I've been through everything (docs, groups,
> > irc) that I can think of, all to no avail. I apologize if this is a
> > very noobish question, but hey, I'm a relative django virgin here.
> > Any help or insight you guys/gals could give would be greatly
> > appreciated...
>
> Out-of-the-box, this isn't an option that exists.
>
> However, it wouldn't be particularly tricky to implement with something
> like jQuery or other preferred Javascript library of choice: when the
> document DOM is ready, iterate through the rows in the table and change
> the CSS property on the tr element if the boolean widget is checked. In
> jQuery it's just about a one-line, in fact.
>
> Regards,
> Malcolm
>
>
>
> >
>

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