Re: Having trouble overriding template_object_name for the list_detail in generic view

2011-02-11 Thread Chen Xu
Thanks a lot..
That does solve my problem.

On Fri, Feb 11, 2011 at 7:39 AM, JHeasly  wrote:

> You need to closely read the second sentence of template_object_name item
> in the *Optional arguments* section of the generic view bject_list 
> docs.
> Based on the template_object_name in your code, I think you'll find that
> your template object name is now "latest_poll_list_list". That appending
> "_list" to the variable name has bitten me (at least once!) too.
>
> Cheers,
> 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.
>



-- 
⚡ Chen Xu ⚡

-- 
You received this message because you are subscribed to the Google 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: maintenance mode UI

2011-02-11 Thread Cal Leeming [Simplicity Media Ltd]
Hi,

Maintenance mode pages should be completely self contained. You could even
go to the extent of storing the images in base64 within the HTML (I have
seen this done somewhere), but personally I have them hosted on a CDN
somewhere.

Cal

On Sat, Feb 12, 2011 at 4:20 AM, vamsy krishna wrote:

> Hi,
>
> I've set up the django maintenance mode for my site to display a
> custom message to the users. The message gets picked up fine but all
> the relevant styling does not get loaded. It would be really nice if
> it can load the styling info. Any suggestions?
>
> Regards,
> Vamsy
>
> --
> You received this message because you are subscribed to the Google 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.
>
>

-- 
You received this message because you are subscribed to the Google 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: compiled regex as attribute

2011-02-11 Thread Doug Ballance
Have you done any performance testing?  From what I understand pythons
re.compile caches internally, so after the first call subsequent calls
will use the pre-compiled expression.  Serializing the compiled
expression using pickle isn't 'free', so I'm wondering how much
difference there is in practice. Maybe a compromise of a normal model
text field storing the regular expression string you build when the
model is saved, and then a propery to simulate a read-only/don-demand
the compiled version when you need it.

ie something like:

class Product(models.Model):
   # ...
canonical_name = models.CharField(max_length=200)
spelling_variants = models.CharField(max_length=1, blank=True)
lexical_variants = models.CharField(max_length=1, blank=True)
excluded = models.CharField(max_length=1, blank=True)
permutations = models.CharField(max_length=1000, blank=True)
re_str=models.TextField()

compiled_re=property(lambda p: re.compile(p.re_str))

def save(self,*args,**kwargs):
# do your regular expression string build here and store in
self.re_str


Although it seems to me like each variant propably belongs as a
separate model, linking to your product.  That way you can search on
it, and add/remove variants fairly easily.  To match now, you'd have
to pull a bunch of products in a query and test each one.  The
database server isn't going to sweat a few hundred or even thousand
names.

class Variant(models.Model):
name=models.CharField(db_index=True)
product=models.ForeignKey(Product)

Product.objects.filter(variant__name='oha android 1.1')

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



Google App Engine supports Django 1.2!

2011-02-11 Thread Shawn Milochik
http://code.google.com/p/googleappengine/wiki/SdkReleaseNotes

Almost in time for Django 1.3's release. ;o)

-- 
You received this message because you are subscribed to the Google 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.



maintenance mode UI

2011-02-11 Thread vamsy krishna
Hi,

I've set up the django maintenance mode for my site to display a
custom message to the users. The message gets picked up fine but all
the relevant styling does not get loaded. It would be really nice if
it can load the styling info. Any suggestions?

Regards,
Vamsy

-- 
You received this message because you are subscribed to the Google 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.



Login, Password Recovery, etc

2011-02-11 Thread Mike Seidle
Quick question - is there an application or examples of completely implemented 
user authentication templates?  It's getting old trying to devine how to set 
up templates for password recovery and registration. Seems to me that this 
should (and probably is) included with the rest of the batteries.

-- 
You received this message because you are subscribed to the Google 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 forum/group for Django Help

2011-02-11 Thread Mike Seidle
On Thursday, February 10, 2011 03:40:24 am SimpleDimple wrote:
> Not a prank, it was just what I thought..., it is always better to ask
> than assume...thanks for confirmation that this is the best one
> around.

You might want to check your settings for the group - there are literally 
hundreds of posts every day here.

-- 
You received this message because you are subscribed to the Google 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.



_id cannot be null

2011-02-11 Thread keeper
Hello guys,

executing this code below from shell is ok, updates database and
inserts the proper values:

sub_domains(user_id=user_list.objects.get(user_id=1001),
domain=domains.objects.get(domain='domain'),
sub_domain='boqo8').save()

But, trying to call the same code within a django views. I'm getting
"1048, "Column 'user_id_id' cannot be null""

models:

class sub_domains(models.Model):
user_id = models.ForeignKey(user_list, to_field='user_id')
domain = models.ForeignKey(domains, to_field='domain')
sub_domain = models.CharField(max_length=64)

What am I doing wrong ?

-- 
You received this message because you are subscribed to the Google 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: compiled regex as attribute

2011-02-11 Thread Javier Guerra Giraldez
On Fri, Feb 11, 2011 at 11:18 AM, Santiago Caracol
 wrote:
> There is no point in storing the regex strings in a pickle field. I
> already have the regex strings in ordinary django fields. What I want
> to store is *compiled* regular expressions in order to be able to use
> them without having to compile them first.

hum...  i wonder which takes more time, compiling the regex, or
unpickling it?  also, i guess the compiled+pickled regex is likely
much bigger than the original regex, so loading it means more disk
access

-- 
Javier

-- 
You received this message because you are subscribed to the Google 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: Looking for IDE + FTP

2011-02-11 Thread stevenelliott . py
I'd have to agree, I think PyCharm is far superior to the competition. I was 
using Aptana 3 Beta for awhile but I think PyCharm is outstanding.
Sent from my Verizon Wireless BlackBerry

-Original Message-
From: Axel Bock 
Sender: django-users@googlegroups.com
Date: Fri, 11 Feb 2011 23:56:59 
To: 
Reply-To: django-users@googlegroups.com
Subject: Re: Looking for IDE + FTP

hm, I'm using pycharm right now, and I really think it "kicks ass" ;)
havent looked at the other "usual" ones (komodo, wing, eclipse, etc.) for a
long time, though.

about ftp ... looks like it:
http://www.jetbrains.com/pycharm/webhelp/deployment-connection-tab.html

cheers,
axel.



2011/2/11 jose antunes 

> Try Komodo Edit 5
> It suports ftp/sftp, it's free and supports python
> Great editor just no design view.
>
>
> On Fri, Feb 11, 2011 at 9:55 PM, Jon J  wrote:
>
>> As for a suggestion with an editor, I've been using gedit + extensions
>> for my whole career. It's fast, lightweight, and supports some great
>> syntax highlighting. Auto complete isn't quite as good as DW but it's
>> a tradeoff for linux compatibility and less bloat.
>>
>> On Fri, Feb 11, 2011 at 1:29 PM, Jon J 
>> wrote:
>> > Personally, I haven't really found an editor that satisfies all of my
>> needs.
>> >
>> > However, I can recommend using SSH/SFTP and editing directly on the
>> > remote system. Since I'm assuming you're a django developer, you
>> > should be working primarily in the *NIX world anyway. I've always had
>> > problems with FTP anyway.
>> >
>> > If you do this, it will remove the FTP support requirement.
>> >
>> > On Fri, Feb 11, 2011 at 11:52 AM, Mike Ramirez 
>> wrote:
>> >> On Friday, February 11, 2011 07:16:31 am Osiaq wrote:
>> >>
>> >>> Aptana Studio
>> >>
>> >>>
>> >>
>> >>>
>> >>
>> >> Do you know the future of Aptana now that it's been aquired by
>> >> appacelerator? (I don't know, though granted titanium is not a web
>> building
>> >> tool, which does bode well for the future of aptana outside of
>> titanium.)
>> >>
>> >> Mike
>> >>
>> >> --
>> >>
>> >> Have no friends not equal to yourself.
>> >>
>> >> -- Confucius
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> 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.
>> >>
>> >
>>
>> --
>> You received this message because you are subscribed to the Google 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.
>>
>>
>  --
> You received this message because you are subscribed to the Google 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.
>

-- 
You received this message because you are subscribed to the Google 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.


-- 
You received this message because you are subscribed to the Google 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: Looking for IDE + FTP

2011-02-11 Thread Axel Bock
hm, I'm using pycharm right now, and I really think it "kicks ass" ;)
havent looked at the other "usual" ones (komodo, wing, eclipse, etc.) for a
long time, though.

about ftp ... looks like it:
http://www.jetbrains.com/pycharm/webhelp/deployment-connection-tab.html

cheers,
axel.



2011/2/11 jose antunes 

> Try Komodo Edit 5
> It suports ftp/sftp, it's free and supports python
> Great editor just no design view.
>
>
> On Fri, Feb 11, 2011 at 9:55 PM, Jon J  wrote:
>
>> As for a suggestion with an editor, I've been using gedit + extensions
>> for my whole career. It's fast, lightweight, and supports some great
>> syntax highlighting. Auto complete isn't quite as good as DW but it's
>> a tradeoff for linux compatibility and less bloat.
>>
>> On Fri, Feb 11, 2011 at 1:29 PM, Jon J 
>> wrote:
>> > Personally, I haven't really found an editor that satisfies all of my
>> needs.
>> >
>> > However, I can recommend using SSH/SFTP and editing directly on the
>> > remote system. Since I'm assuming you're a django developer, you
>> > should be working primarily in the *NIX world anyway. I've always had
>> > problems with FTP anyway.
>> >
>> > If you do this, it will remove the FTP support requirement.
>> >
>> > On Fri, Feb 11, 2011 at 11:52 AM, Mike Ramirez 
>> wrote:
>> >> On Friday, February 11, 2011 07:16:31 am Osiaq wrote:
>> >>
>> >>> Aptana Studio
>> >>
>> >>>
>> >>
>> >>>
>> >>
>> >> Do you know the future of Aptana now that it's been aquired by
>> >> appacelerator? (I don't know, though granted titanium is not a web
>> building
>> >> tool, which does bode well for the future of aptana outside of
>> titanium.)
>> >>
>> >> Mike
>> >>
>> >> --
>> >>
>> >> Have no friends not equal to yourself.
>> >>
>> >> -- Confucius
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> 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.
>> >>
>> >
>>
>> --
>> You received this message because you are subscribed to the Google 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.
>>
>>
>  --
> You received this message because you are subscribed to the Google 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.
>

-- 
You received this message because you are subscribed to the Google 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: Looking for IDE + FTP

2011-02-11 Thread jose antunes
Try Komodo Edit 5
It suports ftp/sftp, it's free and supports python
Great editor just no design view.

On Fri, Feb 11, 2011 at 9:55 PM, Jon J  wrote:

> As for a suggestion with an editor, I've been using gedit + extensions
> for my whole career. It's fast, lightweight, and supports some great
> syntax highlighting. Auto complete isn't quite as good as DW but it's
> a tradeoff for linux compatibility and less bloat.
>
> On Fri, Feb 11, 2011 at 1:29 PM, Jon J  wrote:
> > Personally, I haven't really found an editor that satisfies all of my
> needs.
> >
> > However, I can recommend using SSH/SFTP and editing directly on the
> > remote system. Since I'm assuming you're a django developer, you
> > should be working primarily in the *NIX world anyway. I've always had
> > problems with FTP anyway.
> >
> > If you do this, it will remove the FTP support requirement.
> >
> > On Fri, Feb 11, 2011 at 11:52 AM, Mike Ramirez 
> wrote:
> >> On Friday, February 11, 2011 07:16:31 am Osiaq wrote:
> >>
> >>> Aptana Studio
> >>
> >>>
> >>
> >>>
> >>
> >> Do you know the future of Aptana now that it's been aquired by
> >> appacelerator? (I don't know, though granted titanium is not a web
> building
> >> tool, which does bode well for the future of aptana outside of
> titanium.)
> >>
> >> Mike
> >>
> >> --
> >>
> >> Have no friends not equal to yourself.
> >>
> >> -- Confucius
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> 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.
> >>
> >
>
> --
> You received this message because you are subscribed to the Google 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.
>
>

-- 
You received this message because you are subscribed to the Google 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: Looking for IDE + FTP

2011-02-11 Thread Jon J
As for a suggestion with an editor, I've been using gedit + extensions
for my whole career. It's fast, lightweight, and supports some great
syntax highlighting. Auto complete isn't quite as good as DW but it's
a tradeoff for linux compatibility and less bloat.

On Fri, Feb 11, 2011 at 1:29 PM, Jon J  wrote:
> Personally, I haven't really found an editor that satisfies all of my needs.
>
> However, I can recommend using SSH/SFTP and editing directly on the
> remote system. Since I'm assuming you're a django developer, you
> should be working primarily in the *NIX world anyway. I've always had
> problems with FTP anyway.
>
> If you do this, it will remove the FTP support requirement.
>
> On Fri, Feb 11, 2011 at 11:52 AM, Mike Ramirez  wrote:
>> On Friday, February 11, 2011 07:16:31 am Osiaq wrote:
>>
>>> Aptana Studio
>>
>>>
>>
>>>
>>
>> Do you know the future of Aptana now that it's been aquired by
>> appacelerator? (I don't know, though granted titanium is not a web building
>> tool, which does bode well for the future of aptana outside of titanium.)
>>
>> Mike
>>
>> --
>>
>> Have no friends not equal to yourself.
>>
>> -- Confucius
>>
>> --
>> You received this message because you are subscribed to the Google 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.
>>
>

-- 
You received this message because you are subscribed to the Google 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: Integrating existing soap based applications

2011-02-11 Thread Arun K.Rajeevan
I tried SOAPpy and pysimplesoap in terminal.

I only got later to work.

from SOAPpy import WSDL
WSDLFILE = "https://api.bullhornstaffing.com/webservices-1.1/?wsdl";
_server = WSDL.Proxy(WSDFILE)
#it throws an exception here. wsdl is a complex one

#other library
from pysimplesoap.client import SoapClient, SoapFault  
client = SoapClient(WSDFILE, cache='.')
#works ok

Most likely I'm doing something wrong!!

-- 
You received this message because you are subscribed to the Google 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: Need to combine 2 QuerySets without losing ability to order_by foreign key afterwards

2011-02-11 Thread Tom Evans
On Fri, Feb 11, 2011 at 9:19 PM, Shawn Milochik  wrote:
> On Fri, Feb 11, 2011 at 4:15 PM, Tom Evans  wrote:
>>
>> Have a read of this:
>>
>> http://www.secnetix.de/olli/Python/lambda_functions.hawk
>>
>
> That's funny -- I did a quick Google search and that's one I found
> also. I chose to give a quick sample instead of sending the link
> because I thought an example relevant to the OP might be easier to
> grok.
>
> Interestingly, the Google search didn't let me easily find the
> official Python docs on it, or I missed it.
>
> Shawn
>

Heh :)

I checked out a couple of them, the secnetix one to me seemed the best
written, and clearly indicated the what, how and why of lambda
functions. Looked a lot like an extended version of yours!

For me, "python lambda" had the python docs at 2nd in the list.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google 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: Need to Find Examples of How to Define BooleanFields in DB Tables

2011-02-11 Thread hank23
Ok below is my tables which has the "emailcomments" boolean field
defined for it:

class Comment(models.Model):
title = models.CharField(max_length=1,choices=TITLE_CHOICES)
firstname = models.CharField(max_length=15)
lastname = models.CharField(max_length=25)
commenttext = models.TextField()
emailcomments = models.BooleanField()
emailaddress = models.CharField(max_length=30)
commentdate = models.DateTimeField()

and here is the way I have the "emailcomments" field defined on my
form:

emailcomments = forms.BooleanField(required=False, label='Send
Comments To Your Email?',
widget=forms.CheckboxInput(attrs={ 'name': 'emailcomments',
'id': 'emailcomments', 'type': 'checkbox' }))

When I go to the screen and submit it then I get the error that the
polls_comment table does not have a column named "emailcomments". I
have another question to, kind of related to this table in particular.
The table itself has 7 columns defined by me(not counting the id field
which is automatically generated), and I was wondering how one codes
the __unicode__ method(s) for a table like this? Do you just code the
__unicode__ method multiple times, once for each column, and just vary
the column data to be returned to be the name each column or how is it
done? I appreciate any help you can provide. Thanks.



On Feb 11, 9:32 am, Tom Evans  wrote:
> On Fri, Feb 11, 2011 at 3:21 PM, hank23  wrote:
> > Still not sure why this is not working. I went back and set a value in
> > my form field definition for the boolean field and the value I set is
> > now coming back in the Traceback, whereas before the value None was
> > being returned as the value for this field, regardless of whether I
> > had it checked or not. So this makes me think I still don't have
> > something setup right. Would it help if I posted my code somewhere so
> > you could take a look at it?
>
> Can't hurt…
>
> Cheers
>
> Tom

-- 
You received this message because you are subscribed to the Google 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: Need to combine 2 QuerySets without losing ability to order_by foreign key afterwards

2011-02-11 Thread Shawn Milochik
On Fri, Feb 11, 2011 at 4:15 PM, Tom Evans  wrote:
>
> Have a read of this:
>
> http://www.secnetix.de/olli/Python/lambda_functions.hawk
>

That's funny -- I did a quick Google search and that's one I found
also. I chose to give a quick sample instead of sending the link
because I thought an example relevant to the OP might be easier to
grok.

Interestingly, the Google search didn't let me easily find the
official Python docs on it, or I missed it.

Shawn

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Need to combine 2 QuerySets without losing ability to order_by foreign key afterwards

2011-02-11 Thread Tom Evans
On Fri, Feb 11, 2011 at 9:06 PM, kyleduncan  wrote:
> I dont understand what the x is, but thank you so much for fixing this
> for me in a matter of minutes!

Have a read of this:

http://www.secnetix.de/olli/Python/lambda_functions.hawk

Cheers

Tom

-- 
You received this message because you are subscribed to the Google 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: Need to combine 2 QuerySets without losing ability to order_by foreign key afterwards

2011-02-11 Thread Shawn Milochik
On Fri, Feb 11, 2011 at 4:06 PM, kyleduncan  wrote:
> I dont understand what the x is, but thank you so much for fixing this
> for me in a matter of minutes!
>


You're welcome.

The 'key' kwarg to the sort function expects a value. Instead of
giving it a single value, you can pass a function.

So, you could have done this:

def return_last_login(record):

return record.user.last_login

Then: my_list.sort(key = return_last_login(x))

But you can use a shortcut and use the 'lambda' keyword, which just
returns an anonymous function.

So, these two are equivalent:

my_function = return_last_login

my_function = lambda x: x.user.last_login

I hope this helps.

Shawn

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Need to combine 2 QuerySets without losing ability to order_by foreign key afterwards

2011-02-11 Thread kyleduncan
this seems to work:

results = sorted(results, key=lambda x: x.user.last_login,
reverse=True)

I dont understand what the x is, but thank you so much for fixing this
for me in a matter of minutes!

On Feb 11, 8:36 pm, Shawn Milochik  wrote:
> Something like this:
>
> key = lambda x: x.last_login

-- 
You received this message because you are subscribed to the Google 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: Need to combine 2 QuerySets without losing ability to order_by foreign key afterwards

2011-02-11 Thread Shawn Milochik
On Fri, Feb 11, 2011 at 3:59 PM, kyleduncan  wrote:
> Thank you! Not sure how to work it just yet though. do I replace x
> with user?  i tried this:
>
> results = results.sort(key=lambda x: x.last_login, reverse=True)
>
> and got an error  that the Profile object didn't have the attribute
> last_login


If some of the objects in your list have the attribute last_login and
others do not then you'll have to make a custom cmp function and pass
it to the sort call.

If not, and each object in your list has a user which has a
last_login, then replace x.last_login with x.user.last_login and it
should work.

The 'x' is insignificant. You can replace it in both cases with
'profile' if it makes your code more readable.

Shawn

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Need to combine 2 QuerySets without losing ability to order_by foreign key afterwards

2011-02-11 Thread kyleduncan
Thank you! Not sure how to work it just yet though. do I replace x
with user?  i tried this:

results = results.sort(key=lambda x: x.last_login, reverse=True)

and got an error  that the Profile object didn't have the attribute
last_login

On Feb 11, 8:36 pm, Shawn Milochik  wrote:
> Something like this:
>
> key = lambda x: x.last_login

-- 
You received this message because you are subscribed to the Google 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: Need to combine 2 QuerySets without losing ability to order_by foreign key afterwards

2011-02-11 Thread Shawn Milochik
Something like this:

key = lambda x: x.last_login

-- 
You received this message because you are subscribed to the Google 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.



Customize flatpage

2011-02-11 Thread galago
I found that link: 
http://linfiniti.com/2011/01/bending-django-flatpages-to-your-will. I want 
to make some customization in flatpage. Where should I put this extra module 
and form?
I want to add 2 fields to custom flatpage.

-- 
You received this message because you are subscribed to the Google 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: validation "warnings" in the admin?

2011-02-11 Thread Tom Evans
On Fri, Feb 11, 2011 at 7:53 PM, Greg Humphreys  wrote:
> I can do this easily enough with my own custom object creation view, but I'd 
> like to let my people still use the admin interface.
>
> I'd like to be able to do some validation of a created or changed object and 
> issue a WARNING before allowing the user to commit the object to the database.
>
> For example, let's say you have a calendar app, and if someone tries to 
> create a new event that conflicts with an existing event (but is otherwise 
> well formed), you want to pop up a javascript dialog that says "hey, this 
> conflicts with this other thing, are you sure?" and if they hit "yes", then 
> go ahead and store it, and if not, let them fix it.
>
> I'd rather not have to tell my users "hey if you want full error checking and 
> warnings and safeguards you have to leave the admin and use my custom object 
> creation link" -- is there a way to accomplish this inside the admin without 
> too much hassle?
>

I've never used this technique, but I see no reason why it shouldn't work.

Provide a your own form form the ModelAdmin, and in that forms clean
method, do something like this:

def clean(self)
  force = self.cleaned_data.get('force_save')
  if not force and not self.check_event_is_valid(self.cleaned_data):
self.fields['force_save'] = forms.BooleanField(initial=True,
widget=HiddenInput())
raise forms.ValidationError('You gotta check something')
  return cleaned_data

So, if it fails the check, we add a new hidden field, so the form can
be resubmitted. The next time through, force will be set, and it won't
matter if the check passes or fails.

Doesn't do it in javascript, but its quite neat and elegant.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google 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.



Render objects on the index page depending on geolocation

2011-02-11 Thread gweltaz
I everyone !

I'd like to render stuff on the index page depending on the user's
location but (being a total beginner in web development) i'm not sure
about the right way to do this.

This is how i intend to do it :

In the index's view function :
- Check if the location is set in the GET request object
- if the location is set :
retrieve the appropriate stuff to render from the database
put them in the Context variable
render the 'index.html' page with the context
- if not :
render a page containing a geolocation script

The geolocation script would detect the user's location (i'd use
functions from the google maps API's tutorial) and immediately
redirect to the site's index with the user's geographical coordinates
properly set with the GET method (or with default values if the
geolocation failed).

Am i on the right path ? Is there a cleverer/more optimized way ?

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.



Need to combine 2 QuerySets without losing ability to order_by foreign key afterwards

2011-02-11 Thread kyleduncan
Hi, I have the following code:

results = list(results.filter(**location_distance_kwargs))

for trip in possible_trips:
try:
trip = Trip.objects.get(id=trip.id, **trip_kwargs)
profile = Profile.objects.get(user=trip.user)
if profile not in results:
results.append(profile)
except Trip.DoesNotExist:
pass

In the above, "results" is a GeoQuerySet of Profile objects, converted
to a list so that i can append more profiles in the code below... I
then check a totally separate array (of Trip objects) against their
own kwargs, then for each match I pull out the Profile object
associated with the User of each Trip, and append it to the "results"
list, if it's not already there (to avoid duplication).

As an aside: I first tried appending profiles without having converted
"results" to a list, but append() couldnt be used on the "results"
querySet. so i forced "results" to be a list using the list()
function, which made it possible to append the second profiles onto
the end of results.

All seemed ok so far. However, i finally wanted to order the profiles
in results by "user__last_login" (profiles have a ForeignKey of user,
and user has a property "last login". When i tried doing this using
python's sorted() function it didnt work as it seemed unable to delve
beyond the user foreign key and into the last_login attribute. this is
what failed:

results = sorted(results, key=attrgetter('user__last_login'),
reverse=True)

as obviously "user__last_login" doesnt exist at this stage as an
attribute. i tried "user.last_login" and varous combinations, but
nothing worked. at the moment the code just reads like this, which
works:

results = sorted(results, key=attrgetter('user'), reverse=True)

any idea how, after merging two query sets by turning them into lists,
i can sort them by an attribute of a foreign key for the objects in
the list?

Thanks in advance to anybody who can help!

Kyle

-- 
You received this message because you are subscribed to the Google 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: Newbie problems with "get"

2011-02-11 Thread Greg
Thanks for heading me in the right direction.  I had several errors in
my urls.py.

On Feb 11, 11:46 am, Shawn Milochik  wrote:
> Without testing it, I suspect the period in your 'request.GET' is the
> problem. Try replacing it with request_get and see what happens.
>
> Shawn

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



validation "warnings" in the admin?

2011-02-11 Thread Greg Humphreys
I can do this easily enough with my own custom object creation view, but I'd 
like to let my people still use the admin interface.

I'd like to be able to do some validation of a created or changed object and 
issue a WARNING before allowing the user to commit the object to the database.

For example, let's say you have a calendar app, and if someone tries to create 
a new event that conflicts with an existing event (but is otherwise well 
formed), you want to pop up a javascript dialog that says "hey, this conflicts 
with this other thing, are you sure?" and if they hit "yes", then go ahead and 
store it, and if not, let them fix it.

I'd rather not have to tell my users "hey if you want full error checking and 
warnings and safeguards you have to leave the admin and use my custom object 
creation link" -- is there a way to accomplish this inside the admin without 
too much hassle?

-- 
You received this message because you are subscribed to the Google 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: Looking for IDE + FTP

2011-02-11 Thread Jon J
Personally, I haven't really found an editor that satisfies all of my needs.

However, I can recommend using SSH/SFTP and editing directly on the
remote system. Since I'm assuming you're a django developer, you
should be working primarily in the *NIX world anyway. I've always had
problems with FTP anyway.

If you do this, it will remove the FTP support requirement.

On Fri, Feb 11, 2011 at 11:52 AM, Mike Ramirez  wrote:
> On Friday, February 11, 2011 07:16:31 am Osiaq wrote:
>
>> Aptana Studio
>
>>
>
>>
>
> Do you know the future of Aptana now that it's been aquired by
> appacelerator? (I don't know, though granted titanium is not a web building
> tool, which does bode well for the future of aptana outside of titanium.)
>
> Mike
>
> --
>
> Have no friends not equal to yourself.
>
> -- Confucius
>
> --
> You received this message because you are subscribed to the Google 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.
>

-- 
You received this message because you are subscribed to the Google 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: Admin interface Integer field with select box?

2011-02-11 Thread vnv

Tnx for quick 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: Admin interface Integer field with select box?

2011-02-11 Thread romain
On Feb 11, 6:53 pm, vnv  wrote:
> Hi,
>
> could anyone say is there easy way to have select box for integer
> values.
>
> I model I have group field which identifies specific group by integer
> value inside.
> If it's possible I would like to have select box inside admin
> interface for this so user could just select values.
>
> Thanks for help in advance.


You can do it with the "choices" field option [1]

[1] 
http://docs.djangoproject.com/en/1.2/ref/models/fields/#django.db.models.Field.choices

--
Romain

-- 
You received this message because you are subscribed to the Google 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: Admin interface Integer field with select box?

2011-02-11 Thread Tom Evans
On Fri, Feb 11, 2011 at 5:53 PM, vnv  wrote:
> Hi,
>
> could anyone say is there easy way to have select box for integer
> values.
>
> I model I have group field which identifies specific group by integer
> value inside.
> If it's possible I would like to have select box inside admin
> interface for this so user could just select values.
>
> Thanks for help in advance.
>

Sure, define choices on the model field definition:

http://docs.djangoproject.com/en/1.2/ref/models/fields/#choices

Cheers

Tom

-- 
You received this message because you are subscribed to the Google 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: High performance exception/traceback reporting system

2011-02-11 Thread Cal Leeming [Simplicity Media Ltd]
Oh nice!!! I didn't even realise this existed. I'll take a look and see if
this matches the same kinda end result I'm looking for.

Cheers!

On Fri, Feb 11, 2011 at 6:49 PM, MarcMarc  wrote:

> Hey, take a look at django-sentry,
> https://github.com/dcramer/django-sentry
>
> On Feb 11, 6:17 pm, "Cal Leeming [Simplicity Media Ltd]"
>  wrote:
> > Hey all,
> >
> > For the last two years, I've been meaning to write a reporting server
> which
> > allows webapps to post their exception tracebacks, which are then
> viewable
> > from a centralized location. After having Thunderbird corrupt my mailbox
> due
> > to over 250 thousand debug emails, this project has now been given a bit
> > more priority ;)
> >
> > The current prototype stores basic exception information (the file path,
> > line number, exception type, exception value, originating webapp, node
> > hostname etc) in the database, and the traceback details are then
> > serialized, dumped into a file, and the path to that file stored against
> the
> > row. A web interface then allows you to browse through these exceptions
> > (currently via Django admin), and view them using the same prettified
> > exception page which it shows for actual exceptions. This prettified page
> > also shows the variables within each frame in the stack, which is very
> > handy!
> >
> > From a developers point of view, this makes life extremely easy, because
> all
> > your webapps report to a single place, you can do sphinx searches,
> alerts,
> > custom reports etc, and it looks pretty lol.
> >
> > The entire thing is going to be open source, and will eventually be a
> > one-click install with a set up page etc.
> >
> > Here are some of the features I am planning on adding, but if anyone has
> any
> > suggestions as to what they would like to see in this, please feel free
> to
> > mention them!
> >
> >- Tracebacks can be sent to the server primarily via POST request, but
> >custom plugins will allow it to pull in via other means (such as mail
> >attachments)
> >- Alerts can be given different classifications (for example, you
> could
> >configure specific nodes, webapps, or exception types to alert you via
> >BulkSMS)
> >- Prettified traceback page should initially support Python/PHP, other
> >languages can be added as and when.
> >- Basic authentication / IP restrictions for the admin login
> >- Authentication support for when the tracebacks are POST'd to the
> server
> >- Tar source should pre-package a lightweight nginx/uwsgi/python
> >environment, so it is self sufficient (this will need to be security
> >maintained obviously).
> >- A nice, pretty, easy to use interface, because this just makes
> people
> >feel all nice and warm inside ^_^
> >
> > I don't want to go as far as to say that it should be used to collect
> > error_log outputs, I think that would be going a bit too far, the main
> > reason for having a system like this is simply due to the sheer amount of
> > information usually contained within a traceback dump, and the Django
> > prettifier makes it so much easier to debug with!
> >
> > Thoughts/criticisms welcome!
> >
> > Cal
>
> --
> You received this message because you are subscribed to the Google 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.
>
>

-- 
You received this message because you are subscribed to the Google 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: High performance exception/traceback reporting system

2011-02-11 Thread MarcMarc
Hey, take a look at django-sentry, https://github.com/dcramer/django-sentry

On Feb 11, 6:17 pm, "Cal Leeming [Simplicity Media Ltd]"
 wrote:
> Hey all,
>
> For the last two years, I've been meaning to write a reporting server which
> allows webapps to post their exception tracebacks, which are then viewable
> from a centralized location. After having Thunderbird corrupt my mailbox due
> to over 250 thousand debug emails, this project has now been given a bit
> more priority ;)
>
> The current prototype stores basic exception information (the file path,
> line number, exception type, exception value, originating webapp, node
> hostname etc) in the database, and the traceback details are then
> serialized, dumped into a file, and the path to that file stored against the
> row. A web interface then allows you to browse through these exceptions
> (currently via Django admin), and view them using the same prettified
> exception page which it shows for actual exceptions. This prettified page
> also shows the variables within each frame in the stack, which is very
> handy!
>
> From a developers point of view, this makes life extremely easy, because all
> your webapps report to a single place, you can do sphinx searches, alerts,
> custom reports etc, and it looks pretty lol.
>
> The entire thing is going to be open source, and will eventually be a
> one-click install with a set up page etc.
>
> Here are some of the features I am planning on adding, but if anyone has any
> suggestions as to what they would like to see in this, please feel free to
> mention them!
>
>    - Tracebacks can be sent to the server primarily via POST request, but
>    custom plugins will allow it to pull in via other means (such as mail
>    attachments)
>    - Alerts can be given different classifications (for example, you could
>    configure specific nodes, webapps, or exception types to alert you via
>    BulkSMS)
>    - Prettified traceback page should initially support Python/PHP, other
>    languages can be added as and when.
>    - Basic authentication / IP restrictions for the admin login
>    - Authentication support for when the tracebacks are POST'd to the server
>    - Tar source should pre-package a lightweight nginx/uwsgi/python
>    environment, so it is self sufficient (this will need to be security
>    maintained obviously).
>    - A nice, pretty, easy to use interface, because this just makes people
>    feel all nice and warm inside ^_^
>
> I don't want to go as far as to say that it should be used to collect
> error_log outputs, I think that would be going a bit too far, the main
> reason for having a system like this is simply due to the sheer amount of
> information usually contained within a traceback dump, and the Django
> prettifier makes it so much easier to debug with!
>
> Thoughts/criticisms welcome!
>
> Cal

-- 
You received this message because you are subscribed to the Google 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: validate changes in m2m field in admin panel

2011-02-11 Thread bagheera

Dnia 11-02-2011 o 19:36:16 Piotr Zalewa  napisał(a):


I would use signals for that purpose

On 11-02-11 10:18, bagheera wrote:
Hi, i would like to perform validation on m2m field to control, if user  
made any changes. I'd like to disallow removing relations from m2m  
field, only adding them.


example:

model Product(models.Model):
name = models.TextField()
model Order(models.Model):
products = models.ManyToManyField(Product)


If user creates an order with three products, he can't remove any  
product from order after object has been saved.


Is there any way to do that on model level?

if i put in clean() method:
current_products = self.products.all() i will get list of products  
currently assigned to order. Can i get list of objects that was chosen  
in form, so i could compare them and raise validation error if needed?









Witch signal would You suggest? And where should i use it?

--
Linux user

--
You received this message because you are subscribed to the Google 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: validate changes in m2m field in admin panel

2011-02-11 Thread Piotr Zalewa

I would use signals for that purpose

On 11-02-11 10:18, bagheera wrote:
Hi, i would like to perform validation on m2m field to control, if 
user made any changes. I'd like to disallow removing relations from 
m2m field, only adding them.


example:

model Product(models.Model):
name = models.TextField()
model Order(models.Model):
products = models.ManyToManyField(Product)


If user creates an order with three products, he can't remove any 
product from order after object has been saved.


Is there any way to do that on model level?

if i put in clean() method:
current_products = self.products.all() i will get list of products 
currently assigned to order. Can i get list of objects that was chosen 
in form, so i could compare them and raise validation error if needed?







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

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



validate changes in m2m field in admin panel

2011-02-11 Thread bagheera
Hi, i would like to perform validation on m2m field to control, if user  
made any changes. I'd like to disallow removing relations from m2m field,  
only adding them.


example:

model Product(models.Model):
name = models.TextField()
model Order(models.Model):
products = models.ManyToManyField(Product)


If user creates an order with three products, he can't remove any product  
from order after object has been saved.


Is there any way to do that on model level?

if i put in clean() method:
current_products = self.products.all() i will get list of products  
currently assigned to order. Can i get list of objects that was chosen in  
form, so i could compare them and raise validation error if needed?




--
Linux user

--
You received this message because you are subscribed to the Google 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.



Admin interface Integer field with select box?

2011-02-11 Thread vnv
Hi,

could anyone say is there easy way to have select box for integer
values.

I model I have group field which identifies specific group by integer
value inside.
If it's possible I would like to have select box inside admin
interface for this so user could just select values.

Thanks for help in advance.

-- 
You received this message because you are subscribed to the Google 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: Filtering Queryset by Foreign Key Properties

2011-02-11 Thread josch
Thank 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: Filtering Queryset by Foreign Key Properties

2011-02-11 Thread Axel Bock
Hi,

try this, I guess this should workd (being new here myself :):
OrderPositions.objects.filter(order__type = "A")


and maybe have a look here:
http://docs.djangoproject.com/en/1.2/ref/models/querysets/#field-lookups


Cheers,
Axel.


2011/2/11 josch 

> Hi,
>
> I`m searching for a solution for the following problem:
>
> I have, for example, those two classes:
>
> class Order(self):
>type = models.CharField(1)
>
> class OrderPositions(self):
>order = ForeignKey(Order)
>
>
> Now I want to get every Order Position, whoose order has the type, for
> example 'A'.
>
> queryset = OrderPositions.objects.filter(order.type='A')
>
> Of course this does not work, I just wanted to make clear what I want
> to to.
>
> What is the best way to handle a demand like this.
>
> Thank you!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Filtering Queryset by Foreign Key Properties

2011-02-11 Thread Tom Evans
On Fri, Feb 11, 2011 at 5:20 PM, josch  wrote:
> Hi,
>
> I`m searching for a solution for the following problem:
>
> I have, for example, those two classes:
>
> class Order(self):
>        type = models.CharField(1)
>
> class OrderPositions(self):
>        order = ForeignKey(Order)
>
>
> Now I want to get every Order Position, whoose order has the type, for
> example 'A'.
>
> queryset = OrderPositions.objects.filter(order.type='A')
>
> Of course this does not work, I just wanted to make clear what I want
> to to.
>
> What is the best way to handle a demand like this.
>
> Thank you!
>

http://docs.djangoproject.com/en/1.2/topics/db/queries/#lookups-that-span-relationships

queryset = OrderPositions.objects.filter(order__type='A')

Cheers

Tom

-- 
You received this message because you are subscribed to the Google 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: Stuck with foreign keys

2011-02-11 Thread Tom Evans
On Fri, Feb 11, 2011 at 5:36 PM, Coen  wrote:
> Thanks Tom and Shawn. I read that some weeks ago, but it didn't make
> sense at the time. It works, just what I needed
> Tom, re. naming: After 30 years (on and off) of programming, I've
> ended up with my own coding standards :-)  I'll change it if/when I
> work with others
>
> Coen
>

And of course, you are entirely free to do so. My warning was more due
to things like this:

>>> class Foo(object):
...   Foo = 'hello'
...   @classmethod
...   def bar(klass):
... print "hi"
...   quuz = Foo.bar # FAIL
...
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 6, in Foo
AttributeError: 'str' object has no attribute 'bar'

The python interpreter will fail to parse this class, because 'Foo'
inside the class definition will refer to the member 'Foo.Foo' rather
than the class 'Foo'.

My warning wasn't about following convention, only that having the
same convention for class names and member names, and having a member
with the exact same name as the class - well, if it isn't exactly
shooting yourself in the foot, it is loading and aiming the shotgun
there, whilst stroking the trigger.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google 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: Looking for IDE + FTP

2011-02-11 Thread Mike Ramirez
On Friday, February 11, 2011 07:16:31 am Osiaq wrote:
> Aptana Studio
> 
> 

Do you know the future of Aptana now that it's been aquired by appacelerator? 
(I don't know, though granted titanium is not a web building tool, which does 
bode well for the future of aptana outside of titanium.)

Mike

-- 
Have no friends not equal to yourself.
-- Confucius

-- 
You received this message because you are subscribed to the Google 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: Stuck with foreign keys

2011-02-11 Thread Coen
Thanks Tom and Shawn. I read that some weeks ago, but it didn't make
sense at the time. It works, just what I needed
Tom, re. naming: After 30 years (on and off) of programming, I've
ended up with my own coding standards :-)  I'll change it if/when I
work with others

Coen

-- 
You received this message because you are subscribed to the Google 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 dynamic form with additional meta data

2011-02-11 Thread ju
I found my mistake i made ___init__ function instead of __init__ :)

On Feb 11, 7:06 pm, Shawn Milochik  wrote:
> You could be missing something, but I don't have enough to go on. Did
> you add the field to your template? What do your view and template
> look like?

-- 
You received this message because you are subscribed to the Google 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.



Filtering Queryset by Foreign Key Properties

2011-02-11 Thread josch
Hi,

I`m searching for a solution for the following problem:

I have, for example, those two classes:

class Order(self):
type = models.CharField(1)

class OrderPositions(self):
order = ForeignKey(Order)


Now I want to get every Order Position, whoose order has the type, for
example 'A'.

queryset = OrderPositions.objects.filter(order.type='A')

Of course this does not work, I just wanted to make clear what I want
to to.

What is the best way to handle a demand like this.

Thank you!

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



High performance exception/traceback reporting system

2011-02-11 Thread Cal Leeming [Simplicity Media Ltd]
Hey all,

For the last two years, I've been meaning to write a reporting server which
allows webapps to post their exception tracebacks, which are then viewable
from a centralized location. After having Thunderbird corrupt my mailbox due
to over 250 thousand debug emails, this project has now been given a bit
more priority ;)

The current prototype stores basic exception information (the file path,
line number, exception type, exception value, originating webapp, node
hostname etc) in the database, and the traceback details are then
serialized, dumped into a file, and the path to that file stored against the
row. A web interface then allows you to browse through these exceptions
(currently via Django admin), and view them using the same prettified
exception page which it shows for actual exceptions. This prettified page
also shows the variables within each frame in the stack, which is very
handy!

>From a developers point of view, this makes life extremely easy, because all
your webapps report to a single place, you can do sphinx searches, alerts,
custom reports etc, and it looks pretty lol.

The entire thing is going to be open source, and will eventually be a
one-click install with a set up page etc.

Here are some of the features I am planning on adding, but if anyone has any
suggestions as to what they would like to see in this, please feel free to
mention them!

   - Tracebacks can be sent to the server primarily via POST request, but
   custom plugins will allow it to pull in via other means (such as mail
   attachments)
   - Alerts can be given different classifications (for example, you could
   configure specific nodes, webapps, or exception types to alert you via
   BulkSMS)
   - Prettified traceback page should initially support Python/PHP, other
   languages can be added as and when.
   - Basic authentication / IP restrictions for the admin login
   - Authentication support for when the tracebacks are POST'd to the server
   - Tar source should pre-package a lightweight nginx/uwsgi/python
   environment, so it is self sufficient (this will need to be security
   maintained obviously).
   - A nice, pretty, easy to use interface, because this just makes people
   feel all nice and warm inside ^_^

I don't want to go as far as to say that it should be used to collect
error_log outputs, I think that would be going a bit too far, the main
reason for having a system like this is simply due to the sheer amount of
information usually contained within a traceback dump, and the Django
prettifier makes it so much easier to debug with!

Thoughts/criticisms welcome!

Cal

-- 
You received this message because you are subscribed to the Google 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 dynamic form with additional meta data

2011-02-11 Thread ju
View
=

def detail(request, event_id):
event = get_object_or_404(Event, pk = event_id)

if request.POST :
purchaseForm = PurchaseForm(request.POST)
#...
else:
purchaseForm = PurchaseForm()

return render_to_response('events/detail.html', {'event': event,
'form' : purchaseForm})

Template:
=

{% csrf_token %}
{{ form.as_p }}



=

Do I have to add the new fields also in Template or they will be shown
automatically?

On Feb 11, 7:06 pm, Shawn Milochik  wrote:
> You could be missing something, but I don't have enough to go on. Did
> you add the field to your template? What do your view and template
> look like?

-- 
You received this message because you are subscribed to the Google 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 dynamic form with additional meta data

2011-02-11 Thread Shawn Milochik
You could be missing something, but I don't have enough to go on. Did
you add the field to your template? What do your view and template
look like?

-- 
You received this message because you are subscribed to the Google 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 dynamic form with additional meta data

2011-02-11 Thread ju
I tried to make this small example form

from django import forms

class PurchaseForm(forms.Form):
email = forms.EmailField()
#agree = forms.BooleanField()

def ___init__(self, *args, **kwargs):
super(PurchaseForm, self).__init__(*args, **kwargs)
self.fields['agree'] = forms.BooleanField()

but this new field agree doesn't shows if it's added after calling
super...

Am I missing something?


On Feb 11, 5:31 pm, Shawn Milochik  wrote:
> This is pretty easy. Instead of thinking about making dynamic forms,
> think about making dynamic fields.
>
> You'll have one form. When you initialize it, you'll pass it
> information about the tickets available. In the __init__ of your form
> you will dynamically add field objects to the form by appending to
> self.fields.
> example:
>
>     self.fields['this_field_I_just_made_up'] = forms.CharField()
>
> Notes:
>
>     1. The first thing you'll need to do in your __init__ is to pop
> off your custom values.
>     2. The second thing you'll need to do in your __init__ is to call
> the __init__ of the superclass with *args and **kwargs.
>
> If you don't do those two things, in that order, you will get errors.
>
> Shawn

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

2011-02-11 Thread Shawn Milochik
Without testing it, I suspect the period in your 'request.GET' is the
problem. Try replacing it with request_get and see what happens.

Shawn

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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.core.cache._cache error in returning dict

2011-02-11 Thread Tom Evans
On Fri, Feb 11, 2011 at 4:37 PM, Raoul  wrote:
> Hi,
>
> I am not sure if this is a bug, but currently not usable as it should,
> at least in my case?
>
> Having similar in my in-memory statistic collector:
>
 from django.core.cache import cache
 cache.set('testA', 0)
 cache.set('testB', 1)
 cache.incr('testA')
> 1
 cache.incr('testB')
> 2
 cache.get('testA')
> 1
 cache.get('testB')
> 2

>
> Now, when I try to fetch a dict using _cache, my values are no longer
> integers:

Who/what said you should do this? The '_' prefix denotes that this is
private to django.core.cache.cache.

>
 cache._cache
> {'testA': 'I1\n.', 'testB': 'I2\n.'}
 cache._cache['testA']
> 'I1\n.'
 type(cache._cache['testA'])
> 
>
> whereas the stored value is still of type INT:
 type(cache.get('testA'))
> 

Yes, they are pickled, thats how values are put into the cache. If you
use the public API, then that is all worked out for you.

>
> I would use pickle.dumps(cache._cache) to serialize the output and
> download to my Cacti server to have some nice graphs, but instead I
> had to use something like:
>
> map = {}
> for key in cache._cache.keys():
>    map[key] = cache.get(key)
>    # Serialise map
>    stats = pickle.dumps(map)
>
> If more people share my opinion, I will file a bug.
>
> Thanks
> Raoul
>

A bug report for django.core.cache.cache._cache not behaving how you
like would probably not go down well. It behaves as it should.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google 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: Newbie problems with "get"

2011-02-11 Thread Greg
Shawn see below.

from django.conf.urls.defaults import *
from mysite.my_clts import views
#from mysite.books import views


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

urlpatterns = patterns('',
(r'^my_clts/$', 'my_clts.views.index'),
(r'^my_clts/(?P\d+)/$', 'my_clts.views.detail'),
(r'^my_clts/record/$', 'my_clts.views.record'),
(r'^my_clts/display_meta/$', 'my_clts.views.display_meta'),
(r'^my_clts/search-form/$', 'books.views.search_form'),
(r'^my_clts/search/(?P\d+)/$', 'books.views.search'),
(r'^admin/', include(admin.site.urls)),
)

On Feb 11, 11:36 am, Shawn Milochik  wrote:
> Would you post your urls.py? It looks like the problem is in there.

-- 
You received this message because you are subscribed to the Google 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: TemplateSyntaxError at /polls/updatepath/ Caught AttributeError while rendering: 'RawQuerySet' object has no attribute 'all'

2011-02-11 Thread Ian Clelland
On Thu, Feb 10, 2011 at 9:10 AM, hank23  wrote:
> So when I go to build the entries for my drop down list then I would
> iterate over the query results like you suggested and at that point
> where I iterate over the results then I can also set the different
> select option attributes (html option tag attributes - value and
> visible-choice)  to the various values contained in each object
> returned in the queryset. Right?

I don't see why not. Of course, I don't see what your models look
like, either, but you should be able to do something like this:


{% for obj in my_raw_queryset %}
{{ obj.visible_choice }}
{% endfor %}


-- 
Regards,
Ian Clelland


-- 
You received this message because you are subscribed to the Google 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.core.cache._cache error in returning dict

2011-02-11 Thread Raoul
Hi,

I am not sure if this is a bug, but currently not usable as it should,
at least in my case?

Having similar in my in-memory statistic collector:

>>> from django.core.cache import cache
>>> cache.set('testA', 0)
>>> cache.set('testB', 1)
>>> cache.incr('testA')
1
>>> cache.incr('testB')
2
>>> cache.get('testA')
1
>>> cache.get('testB')
2
>>>

Now, when I try to fetch a dict using _cache, my values are no longer
integers:

>>> cache._cache
{'testA': 'I1\n.', 'testB': 'I2\n.'}
>>> cache._cache['testA']
'I1\n.'
>>> type(cache._cache['testA'])


whereas the stored value is still of type INT:
>>> type(cache.get('testA'))


I would use pickle.dumps(cache._cache) to serialize the output and
download to my Cacti server to have some nice graphs, but instead I
had to use something like:

map = {}
for key in cache._cache.keys():
map[key] = cache.get(key)
# Serialise map
stats = pickle.dumps(map)

If more people share my opinion, I will file a bug.

Thanks
Raoul

-- 
You received this message because you are subscribed to the Google 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: Newbie problems with "get"

2011-02-11 Thread Shawn Milochik
Would you post your urls.py? It looks like the problem is in there.

-- 
You received this message because you are subscribed to the Google 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.



Newbie problems with "get"

2011-02-11 Thread Greg
I am getting the bad charecter in group name error when using a form.

Environment:

Request Method: GET
Request URL: http://localhost:8000/search-form/
Django Version: 1.2.3
Python Version: 2.7.1
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'my_clts',
 'books',
 'django.contrib.admin']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in
get_response
  91. request.path_info)
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in
resolve
  215. for pattern in self.url_patterns:
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in
_get_url_patterns
  244. patterns = getattr(self.urlconf_module, "urlpatterns",
self.urlconf_module)
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in
_get_urlconf_module
  239. self._urlconf_module =
import_module(self.urlconf_name)
File "C:\Python27\lib\site-packages\django\utils\importlib.py" in
import_module
  35. __import__(name)
File "C:\Python27\Projects\mysite\..\mysite\urls.py" in 
  27. (r'^admin/', include(admin.site.urls)),
File "C:\Python27\lib\site-packages\django\conf\urls\defaults.py" in
patterns
  24. t = url(prefix=prefix, *t)
File "C:\Python27\lib\site-packages\django\conf\urls\defaults.py" in
url
  41. return RegexURLPattern(regex, view, kwargs, name)
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in
__init__
  89. self.regex = re.compile(regex, re.UNICODE)
File "C:\Python27\lib\re.py" in compile
  190. return _compile(pattern, flags)
File "C:\Python27\lib\re.py" in _compile
  245. raise error, v # invalid expression

Exception Type: error at /search-form/
Exception Value: bad character in group name

Below is my code.



Search









I am lost any help would be great.

-- 
You received this message because you are subscribed to the Google 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: compiled regex as attribute

2011-02-11 Thread Tom Evans
On Fri, Feb 11, 2011 at 4:18 PM, Santiago Caracol
 wrote:
>> Since the pickled value is a string, it should work in fixtures.
>
> There is no point in storing the regex strings in a pickle field. I
> already have the regex strings in ordinary django fields. What I want
> to store is *compiled* regular expressions in order to be able to use
> them without having to compile them first.
>

It doesn't store the regex string, it stores the compiled regular
expression as a python object, pickled, and then packed into an ascii
string. When it pulls it out again, it unpacks it, un-pickles it and
it has a compiled regular expression, not a string.

Why don't you try it out and see, instead of just telling us it doesn't work.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google 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: compiled regex as attribute

2011-02-11 Thread Shawn Milochik
You're forgetting the pickle part. That's what the getter and setter
are for in my previous description.

import re
import pickle

pattern = re.compile(r'^\w{3}\s+\d{3}')

x = pickle.dumps(pattern)

type(x)


If you store 'x' in your database you won't have any difficulty with fixtures.

Shawn

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



DateTime entry like in the admin interface

2011-02-11 Thread Axel Bock
Hi again,

I have in my model a DateTime input, which the admin interface automatically
displays as two separate DATE and TIME input fields. I would like to do
that, too.

Can anyone tell me how? :)


Thanks & greetings,
Axel.

-- 
You received this message because you are subscribed to the Google 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: compiled regex as attribute

2011-02-11 Thread Santiago Caracol
> Since the pickled value is a string, it should work in fixtures.

There is no point in storing the regex strings in a pickle field. I
already have the regex strings in ordinary django fields. What I want
to store is *compiled* regular expressions in order to be able to use
them without having to compile them first.

-- 
You received this message because you are subscribed to the Google 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: Templatetag - using date and join together?

2011-02-11 Thread Shawn Milochik
If you don't find a better solution, and you're going to need this
feature frequently, you can always make a custom template tag. It's
not too much work.
http://docs.djangoproject.com/en/1.2/howto/custom-template-tags/

-- 
You received this message because you are subscribed to the Google 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: Help on displaying related-object details on ModelForm

2011-02-11 Thread Shawn Milochik
You can change the form's label to contain self.instance.promotion.description.

-- 
You received this message because you are subscribed to the Google 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: compiled regex as attribute

2011-02-11 Thread Shawn Milochik
The picklefield stores strings. So when you say  "regexes can't be
stored in  fixtures," it implies that you're dealing with something
other than strings at that point. Have you tried the pickle field? As
I understand it, it's equivalent to this manual process:

Create a normal text field.

Make a property in your model that has getter and setter functions
which handle the pickling and unpickling.

(Recommended) Name the text field with an underscore as a prefix
to indicate that it's for internal use.

Since the pickled value is a string, it should work in fixtures.

Shawn

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: custom media just doesnt work

2011-02-11 Thread Shawn Milochik
The feature works -- you just don't understand it. You probably know
what, but be aware that e-mailing a list and suggesting that their
software is fundamentally broken is not the best way to get friendly
help.

Have a look at the docs for settings.py:
http://docs.djangoproject.com/en/1.2/ref/settings/

The ADMIN_MEDIA_PREFIX has nothing to do with your project's directory
structure. Your code directories are not exposed to the public via
your Web server (unless you've done something horribly wrong). This
setting lets you specify an absolute or relative path to the admin
media as seen by the client's browser. If your Web server isn't
serving it at the path you specify then you're not going to see your
changes.

Shawn

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Having trouble overriding template_object_name for the list_detail in generic view

2011-02-11 Thread JHeasly
You need to closely read the second sentence of template_object_name item in 
the *Optional arguments* section of the generic view bject_list 
docs.
 
Based on the template_object_name in your code, I think you'll find that 
your template object name is now "latest_poll_list_list". That appending 
"_list" to the variable name has bitten me (at least once!) too.

Cheers,
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: Integrating existing soap based applications

2011-02-11 Thread Shawn Milochik
Start by searching Google for Django and SOAP. If you can't figure out
what the prevailing solution is, name them specifically on this list
and ask if anyone suggests one over the others.

-- 
You received this message because you are subscribed to the Google 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: Stuck with foreign keys

2011-02-11 Thread Shawn Milochik
Enclose the name of the foreign key class in quotes. This way the file
will validate.

-- 
You received this message because you are subscribed to the Google 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: Need to Find Examples of How to Define BooleanFields in DB Tables

2011-02-11 Thread Tom Evans
On Fri, Feb 11, 2011 at 3:21 PM, hank23  wrote:
> Still not sure why this is not working. I went back and set a value in
> my form field definition for the boolean field and the value I set is
> now coming back in the Traceback, whereas before the value None was
> being returned as the value for this field, regardless of whether I
> had it checked or not. So this makes me think I still don't have
> something setup right. Would it help if I posted my code somewhere so
> you could take a look at it?
>

Can't hurt…

Cheers

Tom

-- 
You received this message because you are subscribed to the Google 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 dynamic form with additional meta data

2011-02-11 Thread Shawn Milochik
This is pretty easy. Instead of thinking about making dynamic forms,
think about making dynamic fields.

You'll have one form. When you initialize it, you'll pass it
information about the tickets available. In the __init__ of your form
you will dynamically add field objects to the form by appending to
self.fields.
example:

self.fields['this_field_I_just_made_up'] = forms.CharField()


Notes:

1. The first thing you'll need to do in your __init__ is to pop
off your custom values.
2. The second thing you'll need to do in your __init__ is to call
the __init__ of the superclass with *args and **kwargs.

If you don't do those two things, in that order, you will get errors.

Shawn

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

2011-02-11 Thread Tom Evans
On Fri, Feb 11, 2011 at 3:09 PM, Coen  wrote:
> For an email discussion list application I'm setting up the following
> model:
>
> Members and EmailAddress(es)
> Each Member has multiple EmailAddress(es), and one PostingAddress
>
> Definition (abbreviated):
>
> class Member(models.Model):
>    PostingAddress = models.ForeignKey(EmailAddress)   #  error in
> this line
>    FirstName = models.CharField(blank = True, max_length = 255)
>    # Snip #
>
> class EmailAddress(models.Model):
>    EmailAddress = models.EmailField()
>    Member = models.ForeignKey(Member)
>    # Snip #
>
> This gives "NameError: name 'EmailAddress' is not defined". When I
> swap these two classes around I get the same thing, but for the
> EmailAddress.Member field
>
> One alternative is to add a boolean field to the EmailAddress class to
> say it is the posting field, i.e. change the database structure. But
> is there a way to get this structure to work?
>
> Thanks
>

http://docs.djangoproject.com/en/1.2/ref/models/fields/#django.db.models.ForeignKey

"""
If you need to create a relationship on a model that has not yet been
defined, you can use the name of the model, rather than the model
object itself:
"""

Eg:


class Member(models.Model):
   PostingAddress = models.ForeignKey('EmailAddress')

Also, its bad form to have members named exactly the same as the
class. Typically, you should use lower_case_with_underscores or
mixedCapCamelCase for members and CamelCase for class names.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google 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 dynamic form with additional meta data

2011-02-11 Thread ju
Hello

I want to make an form for purchasing tickets. The problem is that for
every event there can be diferent types of ticket with diferent price.

For every kind of ticket I will have to create an edit box where user
can select how much tickets he wants.

Then in view class I will just display the dynamicly created form ...
the only problem that I see now is that I don't know where to save an
information for each ticket price so I can easy display it in the the
same row where the edit box is?

P.S. I'm also not sure how can I dynamicly create a form using
Django ... but this have to be easy ;)

P.S. Form have to be something like this:


| Tiket Type  | Price   | How much? | Price|

| Tiket Type Name | Price $1.00 | [   ] | Price... | [tiketkind.id
=  1]
| Tiket Type Name | Price $2.00 | [   ] | Price... | [tiketkind.id
= 12]
| Tiket Type Name | Price $3.00 | [   ] | Price... | [tiketkind.id
= 18]
| Tiket Type Name | Price $4.00 | [   ] | Price... | [tiketkind.id
= 21]

|  TOTAL PRICE: | ...  |

| Email: [   ] |


-- 
You received this message because you are subscribed to the Google 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.



Stuck with foreign keys

2011-02-11 Thread Coen
For an email discussion list application I'm setting up the following
model:

Members and EmailAddress(es)
Each Member has multiple EmailAddress(es), and one PostingAddress

Definition (abbreviated):

class Member(models.Model):
PostingAddress = models.ForeignKey(EmailAddress)   #  error in
this line
FirstName = models.CharField(blank = True, max_length = 255)
# Snip #

class EmailAddress(models.Model):
EmailAddress = models.EmailField()
Member = models.ForeignKey(Member)
# Snip #

This gives "NameError: name 'EmailAddress' is not defined". When I
swap these two classes around I get the same thing, but for the
EmailAddress.Member field

One alternative is to add a boolean field to the EmailAddress class to
say it is the posting field, i.e. change the database structure. But
is there a way to get this structure to work?

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: Need to Find Examples of How to Define BooleanFields in DB Tables

2011-02-11 Thread hank23
Still not sure why this is not working. I went back and set a value in
my form field definition for the boolean field and the value I set is
now coming back in the Traceback, whereas before the value None was
being returned as the value for this field, regardless of whether I
had it checked or not. So this makes me think I still don't have
something setup right. Would it help if I posted my code somewhere so
you could take a look at it?

On Feb 11, 8:32 am, Tom Evans  wrote:
> On Fri, Feb 11, 2011 at 2:23 PM, hank23  wrote:
> > I've been through the documentation and have been unable to find an
> > example of how to define a BooleanField when writing the code for a
> > table in my models.py file. Specifically are there any required
> > parameters when coding a BooleanField in a table definition? Thanks
> > for the help.
>
> These didn't help?
>
> http://docs.djangoproject.com/en/1.2/ref/models/fields/#field-optionshttp://docs.djangoproject.com/en/1.2/ref/models/fields/#booleanfield
>
> Cheers
>
> Tom

-- 
You received this message because you are subscribed to the Google 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: Looking for IDE + FTP

2011-02-11 Thread Osiaq
Aptana Studio


On Feb 10, 11:09 pm, "Cal Leeming [Simplicity Media Ltd]"
 wrote:
> Looks interesting, but the interface is ugly :/ I'll try it out tho :)
>
> On Thu, Feb 10, 2011 at 8:39 PM, Mike Ramirez  wrote:
> >  On Wednesday, February 09, 2011 11:31:07 pm Cal Leeming [Simplicity Media
> > Ltd] wrote:
>
> > > There is one thing for sure. As it stands, there is an open market for a
>
> > > 'do it all' product that manages CI (continuous integration), workflow,
>
> > > development, SVN etc. I think Google Apps and Cherokee came close, but I
>
> > > don't much care for google apps, and cherokee has nasty performance
>
> > > related bugs.
>
> > > Personally, I use the following setup:
>
> > > - SVN with uSVN frontend
>
> > > - dev / staging / prod environments (I don't bother with local
>
> > > environments any more), with dev.*/staging.* domains aliases.
>
> > > - Seperate databases for each environment.
>
> > > - WinSCP to sync my local dir with the remote dev.* dir.
>
> > > - All prod.* deployments are done using command line on the server to
> > pull
>
> > > the latest stable branch (with a temporary maintenance page placed up).
>
> > > - Netbeans with absolutely no IDE integration with SVN/SCP.
>
> > > - Pre-shared keys for every single shell account for added security.
>
> > Should check out eric4, through plugins it has django (1.2 or 1.0.2) api
> > support. Project based management, Multi-Project is ok, but still can't open
> > two projects at once. SVN/CVC support (mercurial in eric5, 5 adds a chat
> > server and ticket tracker for internal development, but no django support
> > yet). With paramiko and a bit of working out the plugin system, you can add
> > any ssh based support you would like (including scp/sftp). Seperate
> > databases can be managed by the projects.
>
> > I think it might work fine for most of your needs.
>
> > It's pure python and written in pyqt, the big difference between eric4 and
> > eric5 is 4 is built in python 2.x and no support for 3, eric5 is the py3
> > version. paramiko in 5 is a problem, the crypto package it depends on is
> > iffy at best for python 3, though paramiko itself (as far as I could tell)
> > needs only a couple modifications to 3 compatible.
>
> >  Mike
>
> > --
>
> >  Knghtbrd: Hey, perl has the power grace and elegance of a sledge
>
> > hammer. (=:]
>
> > <|Rain|> certainly the grace and elegance, anyway
>
> >  --
> > You received this message because you are subscribed to the Google 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.

-- 
You received this message because you are subscribed to the Google 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 forum/group for Django Help

2011-02-11 Thread SimpleDimple
agree on stackoverflow, not just for django but for many other
platforms too... I got a lot of help on rails and others there.

On Feb 10, 3:20 pm, Daniel Roseman  wrote:
> On Wednesday, February 9, 2011 9:06:54 PM UTC, SimpleDimple wrote:
>
> > Guys, Need to know which is the best forum/group for Django help ?  I
> > thought this is the one but I don't see much activity here despite of
> > the fact that there are 19000+ members...where do you go for
> > discussing your django issues with people ?
>
> No doubt I'm biased, but IMO StackOverflow is 
> excellent:http://stackoverflow.com/questions/tagged/django
> --
> 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.



Integrating existing soap based applications

2011-02-11 Thread Arun K.Rajeevan
Hi,

I got a query to integrate BullHorn (Staffing solution) (http://bullhorn.com) 
and VerticalResponse (Email-Marketing)  (http://www.verticalresponse.com/) 
together into their existing application.
On investigating I found out that, both uses soap services. 
How do you recommend me to consume SOAP services in django.
I'm new to SOAP and will not say myself as a  django expert.

Thanks,
Arun

-- 
You received this message because you are subscribed to the Google 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: Need to Find Examples of How to Define BooleanFields in DB Tables

2011-02-11 Thread Tom Evans
On Fri, Feb 11, 2011 at 2:23 PM, hank23  wrote:
> I've been through the documentation and have been unable to find an
> example of how to define a BooleanField when writing the code for a
> table in my models.py file. Specifically are there any required
> parameters when coding a BooleanField in a table definition? Thanks
> for the help.
>

These didn't help?

http://docs.djangoproject.com/en/1.2/ref/models/fields/#field-options
http://docs.djangoproject.com/en/1.2/ref/models/fields/#booleanfield

Cheers

Tom

-- 
You received this message because you are subscribed to the Google 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.



Default Site for each flatpage

2011-02-11 Thread galago
Hi,
how can I assign a default siteID to my flatpages during saving it?
I use only 1 Site and want to attach ID=1 to each added flatpage

-- 
You received this message because you are subscribed to the Google 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.



Need to Find Examples of How to Define BooleanFields in DB Tables

2011-02-11 Thread hank23
I've been through the documentation and have been unable to find an
example of how to define a BooleanField when writing the code for a
table in my models.py file. Specifically are there any required
parameters when coding a BooleanField in a table definition? Thanks
for the 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: change file upload filename, store the orignal, and postback on download the original filename

2011-02-11 Thread Tom Evans
On Fri, Feb 11, 2011 at 2:05 PM, Gabriel - Iulian Dumbrava
 wrote:
> I found a solution on the second part, sending the file back to the
> user with the original filename here:
> http://stackoverflow.com/questions/1156246/having-django-serve-downloadable-files
>
> I would still need some help on the first part.
>
> Thanks,
> Gabriel
>

http://docs.djangoproject.com/en/1.2/ref/models/fields/#django.db.models.FileField.upload_to

"""
This may also be a callable, such as a function, which will be called
to obtain the upload path, including the filename. This callable must
be able to accept two arguments, and return a Unix-style path (with
forward slashes) to be passed along to the storage system. The two
arguments that will be passed are…
"""

Cheers

Tom

-- 
You received this message because you are subscribed to the Google 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: change file upload filename, store the orignal, and postback on download the original filename

2011-02-11 Thread Gabriel - Iulian Dumbrava
I found a solution on the second part, sending the file back to the
user with the original filename here:
http://stackoverflow.com/questions/1156246/having-django-serve-downloadable-files

I would still need some help on the first part.

Thanks,
Gabriel

On 11 feb., 14:57, Gabriel - Iulian Dumbrava
 wrote:
> Hi guys,
>
> I want to do this:
> 1. from admin I want to upload a file, store the original filename but
> change it on the storage device, based on the current date, for
> example 20110211144900.file
> 2. if at a later time someone wants to download that file, it should
> get it back and saved to the local computer with the original
> filename.
>
> I believe I have to make an admin class and override
> get_valid_name(name) somewhere.
>
> On download, I'll have a view for /download/123/original-file-name.doc
> but how do I return the file to the client, using the original
> filename?
>
> I did this in PHP perfectly, but I don't know how to tied it all up in
> Django.
>
> Many thanks,
> Gabriel

-- 
You received this message because you are subscribed to the Google 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.



change file upload filename, store the orignal, and postback on download the original filename

2011-02-11 Thread Gabriel - Iulian Dumbrava
Hi guys,

I want to do this:
1. from admin I want to upload a file, store the original filename but
change it on the storage device, based on the current date, for
example 20110211144900.file
2. if at a later time someone wants to download that file, it should
get it back and saved to the local computer with the original
filename.

I believe I have to make an admin class and override
get_valid_name(name) somewhere.

On download, I'll have a view for /download/123/original-file-name.doc
but how do I return the file to the client, using the original
filename?

I did this in PHP perfectly, but I don't know how to tied it all up in
Django.

Many thanks,
Gabriel

-- 
You received this message because you are subscribed to the Google 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 off URL normalisation

2011-02-11 Thread Graham Dumpleton


On Friday, February 11, 2011 12:08:25 AM UTC+11, Torsten Bronger wrote:
>
> Hall�chen!
>
> Torsten Bronger writes:
>
> > [...]
> >
> > Currently, a URL like "http://www.example.com/super%2F/edit/"; is
> > normalised to "http://www.example.com/super/edit/";.  This is bad
> > because the entity to be edited is called "super/"(sic!) but this
> > way, you edit "super".
> >
> > [...]
> >
> > Somewhere in mod_wsgi or Django the URL is normalised, but where?
> > And can I switch it off?
>
> This *seems* to be a mod_wsgi qirk, see
> <
> http://code.google.com/p/modwsgi/source/browse/trunk/mod_wsgi/mod_wsgi.c#8140
> >.
> If this is true, you can't switch it off without recompiling.
>

The collapsing is done in Apache not mod_wsgi, at least with Apache 2.X. 
That bit of code you reference would only actually apply for Apache 1.3 and 
in 2.X should be an effective noop. That code is there simply to make older 
Apache 1.3 behave in same was as Apache 2.X. With Apache 1.3 support being 
dropped soon, likely that the code will be removed and you would still find 
that slashes get collapsed.

Graham

> Tsch�,
> Torsten.
>
> -- 
> Torsten BrongerJabber ID: torsten...@jabber.rwth-aachen.de
>   or http://bronger-jmp.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: Queryset cloning is very expensive

2011-02-11 Thread kurvenschubser
Hi myx,

cloning is useful for chaining of filters, e.g.
User.objects.filter(name="Harry").exclude(lastname="Potter").filter(somethingelse="bla")

But most of the time, I found I can construct querysets using a
dictionary for collecting the query conditions:

d = {name:"Harry", lastname:"Potter", somethingelse:"bla"}
User.objects.filter(**d)

For more complex queries, e.g.

if not d:
return


q0 = Q(**dict(d.popitem()))

for i, (k, v) in enumerate(d.items()):
qx = Q(**{k:v})
if i % 2:
q0 | qx
else:
q0 & qx

User.objects.filter(q0)

On 10 Feb., 10:55, myx  wrote:
> Almost every method of QuerySet clones it. Sometimes it is very
> ineficcient, for example when querysets are constructed in loops. I
> have a function, which makes about 20 queries, and its execution time
> is about 100ms. After profiling the function, I saw that clone() takes
> most of the time: 70ms. It is called about 60 times, 1ms per call. The
> queries themselves are very fast (about 15ms for all queries). So
> constructing the query takes much longer time than executing it.
> What cloning is needed for? Can I prevent queryset from cloning, or do
> something else to reduce cpu consumption?

-- 
You received this message because you are subscribed to the Google 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.



memcached + fcgi prefork = wrong value for a given key

2011-02-11 Thread MarcMarc
Hi,

My problem looks like this: when using memcached with fcgi on prefork
mode I`m getting wrong values for a given keys. Values are
dictionaries with keys, so I`m logging those erros like this:

Memcached error: shops_categories.get_count.5942 -> {'version': None,
'value': 1328, 'key': 'shops_categories.get_count.5935', 'vkey':
None}

As shown above requested key was
shops_categories.get_available_items_count.5942 and fetched value is
wrong, key for given value is
shops_categories.get_available_items_count.5935. Strange. This log is
generated by custom method 'get', which contains no magic, its just a
wrapper over django.core.cache.cache.get to log a key that was asked
for and value that django.core.cache.cache.get fetched.

There are some clues about this strange behaviour:

- problem seems to be related to start/stop of the fcgi child process.
When testing with 'ab -n 1000 -c 10' and runfcgi maxchildren=5 and
maxrequests parameter set to 10 those errors are visible and almost
constant, but set maxrequests to, let`s say, 100 000 and there are
none of them.

- most of the time mixed up values are similar, but this is not a
rule. For instance:

11-02-11 09:50 aktywni.cache.utilsERRORutils:  23
Memcached error: shops_categories.get_category_descendants.5650 ->
{'version': None, 'value': 122, 'key':
'shops_categories.get_available_items_count.5650', 'vkey': None}

11-02-11 09:50 aktywni.cache.utilsERRORutils:  23
Memcached error: shops_categories.get_available_items_count.5650 ->
{'version': None, 'value': 1328, 'key':
'shops_categories.get_available_items_count.5935', 'vkey': None}

11-02-11 09:50 aktywni.cache.utilsERRORutils:  23
Memcached error: shops_categories.get_category_descendants.5948 ->
{'version': None, 'value': 0, 'key':
'shops_categories.get_available_items_count.5795', 'vkey': None}

- single view generates around 25-50 cache requests, or even more.

- when using get_multi tracebacks looks like this one:

 File "/var/www/htdocs/serwisy/aktywni.pl/lib/django/core/cache/
backends/memcached.py", line 60, in get_many
   return self._cache.get_multi(map(smart_str,keys))

 File "/var/www/htdocs/serwisy/aktywni.pl/lib/memcache.py", line 738,
in get_multi
   retvals[prefixed_to_orig_key[rkey]] = val   # un-prefix returned
key.

KeyError: 'shops_categories.get_lowest_categories'

- I`ve tested my site on threaded fcgi, and there is no such problem
in

Maybe there is some problem with connection to memcached left open
after fcgi process is killed after set amount of requests? Maybe for
some reason another request from next process is getting values from
the already killed one? Of course there is no evidence of failure in
memcached logs in verbose mode.

Feel free to ask more questions, this is my first apperance on this
group, I`ve tried to show every piece of evidence : )

Env summary:
Ubuntu 10.10 minimal (but there was the same problem on Gentoo)
memcached 1.4.5
python-memcached 1.43
django 1.2.1
nginx 0.7.67

-- 
You received this message because you are subscribed to the Google 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: compiled regex as attribute

2011-02-11 Thread Santiago Caracol
> http://pypi.python.org/pypi/django-picklefield/0.1

Thanks for the tip. This works, but it has one great disadvantage: The
regexes can't be stored in fixtures. They are stored in the database
directly. So it seems I would have to insert all my several thousand
products manually again. And if I change some models and need to do a
"manage.py syncdb" all the work will be lost ...

Or is there a way of loading fixtures that includes that save() is
called for each loaded object?

-- 
You received this message because you are subscribed to the Google 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: compiled regex as attribute

2011-02-11 Thread Tom Evans
On Fri, Feb 11, 2011 at 9:47 AM, Santiago Caracol
 wrote:
> Hello,
>
> I have got objects with very large regular expressions:
>
> class Product(models.Model):
>   # ...
>    canonical_name = models.CharField(max_length=200)
>    spelling_variants = models.CharField(max_length=1, blank=True)
>    lexical_variants = models.CharField(max_length=1, blank=True)
>    excluded = models.CharField(max_length=1, blank=True)
>    permutations = models.CharField(max_length=1000, blank=True)
>
> When a product has values for all of the above attributes, it can
> calculate all its possible names. Example: the product 'google android
> 1.1' has several hundred possible names including these:
>
> google android-1.1, oha android-1.1, android-1.1, google android-1,1,
> oha android-1,1, android-1,1, google android-1-1, oha android-1-1,
> android-1-1, google android-11, oha android-11, android-11, google
> android-1 1, oha android-1 1, android-1 1, google android1.1, oha
> android1.1, android1.1, google android1,1, oha android1,1, android1,1,
> google android1-1, oha android1-1, android1-1, google android11, oha
> android11, android11, google android1 1, oha android1 1, android1 1,
> google android 1.1, oha android 1.1, android 1.1, google android 1,1,
> oha android 1,1,
>
> There are products with many more names. Consider the name of the
> mobile phone alcatatel one-touch-800-one-touch-chrome.
>
> Currently every product calculates all its possible names and a
> regular expression that includes the disjunction of all the possible
> names and compiles this regular expression at the time when the
> product is used. This is very inefficient. I would like to compile and
> store the regular expression only once: at the time when the new
> product is saved.
>
> However, there doesn't seem to be a models.RegexField. There is a
> forms.RegexField, but I don't understand how I could use it in the
> product model.
>
> Any tips how to store the compiled regex?
>
> Santiago
>

http://pypi.python.org/pypi/django-picklefield/0.1

Cheers

Tom

-- 
You received this message because you are subscribed to the Google 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.



compiled regex as attribute

2011-02-11 Thread Santiago Caracol
Hello,

I have got objects with very large regular expressions:

class Product(models.Model):
   # ...
canonical_name = models.CharField(max_length=200)
spelling_variants = models.CharField(max_length=1, blank=True)
lexical_variants = models.CharField(max_length=1, blank=True)
excluded = models.CharField(max_length=1, blank=True)
permutations = models.CharField(max_length=1000, blank=True)

When a product has values for all of the above attributes, it can
calculate all its possible names. Example: the product 'google android
1.1' has several hundred possible names including these:

google android-1.1, oha android-1.1, android-1.1, google android-1,1,
oha android-1,1, android-1,1, google android-1-1, oha android-1-1,
android-1-1, google android-11, oha android-11, android-11, google
android-1 1, oha android-1 1, android-1 1, google android1.1, oha
android1.1, android1.1, google android1,1, oha android1,1, android1,1,
google android1-1, oha android1-1, android1-1, google android11, oha
android11, android11, google android1 1, oha android1 1, android1 1,
google android 1.1, oha android 1.1, android 1.1, google android 1,1,
oha android 1,1,

There are products with many more names. Consider the name of the
mobile phone alcatatel one-touch-800-one-touch-chrome.

Currently every product calculates all its possible names and a
regular expression that includes the disjunction of all the possible
names and compiles this regular expression at the time when the
product is used. This is very inefficient. I would like to compile and
store the regular expression only once: at the time when the new
product is saved.

However, there doesn't seem to be a models.RegexField. There is a
forms.RegexField, but I don't understand how I could use it in the
product model.

Any tips how to store the compiled regex?

Santiago

-- 
You received this message because you are subscribed to the Google 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: ManyToMany fields and ordering in the admin

2011-02-11 Thread Tom Evans
On Fri, Feb 11, 2011 at 8:54 AM, vanderkerkoff  wrote:
> A fried of mine told me the answer, couldn't find it anywhere online.
> Is this documented anywhere?
>
> In my document model I had to add this to order the document list in
> the publication admin page
>
> class Meta:
>    ordering = ('title',)
>
> I was under the impression all the Meta stuff had been moved into
> admin.py, obviously not :-)
>
> matt
>

http://docs.djangoproject.com/en/1.2/ref/models/options/#ordering

Cheers

Tom

-- 
You received this message because you are subscribed to the Google 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: ManyToMany fields and ordering in the admin

2011-02-11 Thread vanderkerkoff
A fried of mine told me the answer, couldn't find it anywhere online.
Is this documented anywhere?

In my document model I had to add this to order the document list in
the publication admin page

class Meta:
ordering = ('title',)

I was under the impression all the Meta stuff had been moved into
admin.py, obviously not :-)

matt





On Feb 11, 8:04 am, vanderkerkoff  wrote:
> django1.2.4
>
> I've got a document model
>
> class Document(models.Model):
>         LANG_CODE = (
>                 ('B', 'Both'),
>                 ('E', 'English'),
>                 ('C', 'Cymraeg'),
>         )
>         title = models.CharField(max_length=100)
>         slug = models.SlugField(max_length=100,
> unique_for_date='created_at')
>         created_at = models.DateTimeField('Date Published',
> default=datetime.now, editable=False)
>         the_file = models.FileField(upload_to='files/documents/%Y-%m-%d/')
>         lang_code = models.CharField(max_length=1, choices=LANG_CODE,
> default='B')
>
>         def __unicode__(self):
>                 return u'%s' % self.title
>
>         def get_absolute_url(self):
>                 url = u'/media/%s' % (self.the_file)
>                 return iri_to_uri(url)
>
> with a corresponding admin.py
>
> class DocumentAdmin(admin.ModelAdmin):
>         fields = ('title','slug','the_file','lang_code')
>         list_display = ('title',)
>         search_fields = ('title',)
>         prepopulated_fields = { 'slug': ('title',) }
>         ordering = ('title',)
> admin.site.register(Document, DocumentAdmin)
>
> I've also got a Publications model, in which I can add Documents to a
> publication
>
> class Publication(models.Model):
>         title = models.CharField(max_length=255)
>         slug = models.SlugField(max_length=255, unique_for_date='pub_date')
>         title_c = models.CharField('Welsh Title', max_length=255)
>         slug_c = models.SlugField('Welsh Slug', max_length=255,
> unique_for_date='pub_date')
>         created_at = models.DateTimeField('Date Published',
> default=datetime.now, editable=False)
>         amended_at = models.DateTimeField('Date Modified', blank=True,
> null=True)
>         pub_date = models.DateField('Publish Date')
>         body = models.TextField(help_text='Body')
>         body_html = models.TextField(blank=True, null=True)
>         body_c = models.TextField('Welsh Body', help_text='body_c')
>         body_c_html = models.TextField(blank=True, null=True)
>         the_file = models.FileField('Document', upload_to='files/documents/%Y-
> %m-%d/', blank=True, null=True)
>         the_file_c = models.FileField('Welsh Document', upload_to='files/
> documents/%Y-%m-%d/', blank=True, null=True)
>         tags = models.CharField(max_length=255, blank=True, null=True)
>         tags_c = models.CharField('Welsh tags', max_length=255, blank=True,
> null=True)
>         image = models.ForeignKey(Photo,
> limit_choices_to={'category__exact':'P'}, blank=True, null=True)
>         category = models.ForeignKey(Category, blank=True, null=True)
>         comments = models.BooleanField('Allow Comments', default=False)
>         documents = models.ManyToManyField(Document, related_name='pub_doc',
> limit_choices_to = {'lang_code__in': ('B', 'E')}, blank=True,
> null=True)
>         documents_c = models.ManyToManyField(Document, verbose_name="Welsh
> Documents", related_name='pub_doc_c', limit_choices_to =
> {'lang_code__in': ('B', 'C')}, blank=True, null=True)
>
> Here's the admin.py of the publicaitons
>
> class PublicationAdmin(admin.ModelAdmin):
>         fieldsets = (
>                 (None, {'fields':
> ('title','slug','title_c','slug_c','category','pub_date','body','body_c','c 
> omments','image','documents','documents_c')}),
>         ('Advanced options', {'classes': 'collapse', 'fields':
> ('tags','tags_c')}),
>         )
>         list_display = ('title','id','pub_date')
>         list_filter = ('pub_date','category')
>         search_fields = ('title','title_c')
>         prepopulated_fields = { 'slug': ('title',), 'slug_c': ('title_c',), }
>         ordering = ('title',)
>         date_hierarchy = 'pub_date'
>
> When I'm in the admin backed and I'm adding a document to a
> Publication, by selecting it from the box that displays the Documents
> that you can add, I want to order of that List of Documents shown in
> the box.  I keep thinking I should be putting the ordering in the
> ManyToManyField block in the documents description in the Publication
> model, but I can't find a way to do that, so I'm starting to think
> there is another solution.
>
> Any help, as always, 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.



custom media just doesnt work

2011-02-11 Thread Szabo, Patrick (LNG-VIE)
Hi, 

I want to change the look of the admin-site a little bit
My folder structure looks like this (Appname is timesheets):

timesheets/
admin/
media
css
img/
admin

I also set this: ADMIN_MEDIA_PREFIX = '/media/'
If i change something directly in the base_site.html it works just fine.
What doesn't work is changes in the css files oder the graphics.

Anything i missed ?!

Kind regards

. . . . . . . . . . . . . . . . . . . . . . . . . .
Patrick Szabo
 XSLT-Entwickler 
LexisNexis
Marxergasse 25, 1030 Wien

mailto:patrick.sz...@lexisnexis.at
Tel.: +43 (1) 534 52 - 1573 
Fax: +43 (1) 534 52 - 146 





-- 
You received this message because you are subscribed to the Google 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.



Having trouble overriding template_object_name for the list_detail in generic view

2011-02-11 Thread Chen Xu
Hi, everyone:
I am following the tutorial 4 on the Django official site.
so this is what I got:

info_dict = {
'queryset' : Poll.objects.all(),
}

urlpatterns = patterns('',
(r'^$', 'list_detail.object_list',
dict(info_dict,
 template_name='polls/index.html',
 template_object_name='latest_poll_list')),
)

I did successfully override template_name (it was poll_list by default), but
for template_object_name, I just have no idea, its still object_list by
default, and  what I did seems right, right?


Could someone please help me ??

Thanks a lot.


-- 
⚡ Chen Xu ⚡

-- 
You received this message because you are subscribed to the Google 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.



ManyToMany fields and ordering in the admin

2011-02-11 Thread vanderkerkoff
django1.2.4

I've got a document model

class Document(models.Model):
LANG_CODE = (
('B', 'Both'),
('E', 'English'),
('C', 'Cymraeg'),
)
title = models.CharField(max_length=100)
slug = models.SlugField(max_length=100,
unique_for_date='created_at')
created_at = models.DateTimeField('Date Published',
default=datetime.now, editable=False)
the_file = models.FileField(upload_to='files/documents/%Y-%m-%d/')
lang_code = models.CharField(max_length=1, choices=LANG_CODE,
default='B')

def __unicode__(self):
return u'%s' % self.title

def get_absolute_url(self):
url = u'/media/%s' % (self.the_file)
return iri_to_uri(url)

with a corresponding admin.py

class DocumentAdmin(admin.ModelAdmin):
fields = ('title','slug','the_file','lang_code')
list_display = ('title',)
search_fields = ('title',)
prepopulated_fields = { 'slug': ('title',) }
ordering = ('title',)
admin.site.register(Document, DocumentAdmin)

I've also got a Publications model, in which I can add Documents to a
publication

class Publication(models.Model):
title = models.CharField(max_length=255)
slug = models.SlugField(max_length=255, unique_for_date='pub_date')
title_c = models.CharField('Welsh Title', max_length=255)
slug_c = models.SlugField('Welsh Slug', max_length=255,
unique_for_date='pub_date')
created_at = models.DateTimeField('Date Published',
default=datetime.now, editable=False)
amended_at = models.DateTimeField('Date Modified', blank=True,
null=True)
pub_date = models.DateField('Publish Date')
body = models.TextField(help_text='Body')
body_html = models.TextField(blank=True, null=True)
body_c = models.TextField('Welsh Body', help_text='body_c')
body_c_html = models.TextField(blank=True, null=True)
the_file = models.FileField('Document', upload_to='files/documents/%Y-
%m-%d/', blank=True, null=True)
the_file_c = models.FileField('Welsh Document', upload_to='files/
documents/%Y-%m-%d/', blank=True, null=True)
tags = models.CharField(max_length=255, blank=True, null=True)
tags_c = models.CharField('Welsh tags', max_length=255, blank=True,
null=True)
image = models.ForeignKey(Photo,
limit_choices_to={'category__exact':'P'}, blank=True, null=True)
category = models.ForeignKey(Category, blank=True, null=True)
comments = models.BooleanField('Allow Comments', default=False)
documents = models.ManyToManyField(Document, related_name='pub_doc',
limit_choices_to = {'lang_code__in': ('B', 'E')}, blank=True,
null=True)
documents_c = models.ManyToManyField(Document, verbose_name="Welsh
Documents", related_name='pub_doc_c', limit_choices_to =
{'lang_code__in': ('B', 'C')}, blank=True, null=True)

Here's the admin.py of the publicaitons

class PublicationAdmin(admin.ModelAdmin):
fieldsets = (
(None, {'fields':
('title','slug','title_c','slug_c','category','pub_date','body','body_c','comments','image','documents','documents_c')}),
('Advanced options', {'classes': 'collapse', 'fields':
('tags','tags_c')}),
)
list_display = ('title','id','pub_date')
list_filter = ('pub_date','category')
search_fields = ('title','title_c')
prepopulated_fields = { 'slug': ('title',), 'slug_c': ('title_c',), }
ordering = ('title',)
date_hierarchy = 'pub_date'


When I'm in the admin backed and I'm adding a document to a
Publication, by selecting it from the box that displays the Documents
that you can add, I want to order of that List of Documents shown in
the box.  I keep thinking I should be putting the ordering in the
ManyToManyField block in the documents description in the Publication
model, but I can't find a way to do that, so I'm starting to think
there is another solution.

Any help, as always, 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.