Re: Open source Django websites

2011-07-02 Thread Kenneth Gonsalves
On Thu, 2011-06-30 at 22:57 +0200, Gerhard Hoogterp wrote:
> Did  you actually manage to get any of those sites to work?  (and if
> yes,which 
> one?) 

I have only tried mine. Try this one:
https://bitbucket.org/lawgon/ipss/overview

a small site, but up and running.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

-- 
You received this message because you are subscribed to the Google 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 AJAX polling: Best practice?

2011-07-02 Thread Shawn Milochik

On 07/01/2011 05:05 PM, Andreas Pfrengle wrote:

Thanks so far for showing me that I was on the completely wrong
track ;-)

I found that there is really not much official information available
about Hookbox:. That doesn't make an easy
decision for Hookbox.

Has anyone experience with socket.io and gevent instead? Looks
interesting at first glance:





There are other options, such as Orbited, and another on I can't 
remember the name of but I think 'gorilla' had something to do with it.


Hookbox was presented at PyCon this year, and although hookbox.org seems 
to be having an issue the github page shows activity from March of this 
year, and has active forks, including this one:

https://github.com/raikage/hookbox


--
You received this message because you are subscribed to the Google 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: create open office docs with django - best way to format text?

2011-07-02 Thread Andre Terra
This is a python question, really. Whether you are running a cli
script or coding logic for your django form, the code will most likely
use a python library to do the doc writing, much like xlwt is used for
writing excel spreadsheets.

Try not including django as a keyword for your google search.


Cheers,
André Terra

On 7/2/11, andreas  wrote:
> Hi all,
>
> i am trying to generate open office docs (bulk letters) from my django
> app.
> I am using django-webodt (http://pypi.python.org/pypi/django-webodt)
> and basically it works really smooth.
>
> The only point i am unsure about is how to 'transfer' the text
> formatting from django to an odt doc.
> Currently my texts in django are html formatted (using TinyMCE) and i
> wonder how to best continue from here.
>
> A simple option is obviously to strip the html and render plain text
> in the generated open office docs.
> This works, but it would be really nice if my editors could use some
> basic formatting (lists, bold etc.)
>
> So what are good options to achieve this?
>
> Is there a way to render html (transform html to rich-text) in an open
> office doc?
> Or would i be better of to switch to another format for editing the
> texts in django (ResT, markup) as there seem to be conversion
> libraries?
>
> I'd love to hear how others solved the creation of open office docs
> from django.
>
> Thanks!
> Andreas
>
> --
> You received this message because you are subscribed to the Google 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.
>
>

-- 
Sent from my mobile device

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

2011-07-02 Thread Matthew Gardner
Thanks for the suggestion, but I do that and I still see the same problem.
 This is pretty weird to me, because it seems like this should work, and I'm
pretty sure I've done this in other projects and it worked just fine.  I
have no idea why it's not working now.

On Sat, Jul 2, 2011 at 7:42 PM, Javier Guerra Giraldez
wrote:

> On Sat, Jul 2, 2011 at 8:07 AM, Matthew Gardner  wrote:
> > a = A.objects.get(pk=some_id)
> > b_set = a.b_set.select_related().all() # recommended in the Django
> > documentation for some queries
> > And b_set comes up empty, for some reason that I can't explain.
>
>
> a.b_set  isn't a QuerySet; it's a RelatedManager.  For most uses, it's
> almost the same; but not exactly.  try reversing the select_related()
> and all() calls (all() returns a QuerySet):
>
> b_set = a.b_set.all().select_related()
>
> --
> 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.
>
>

-- 
You received this message because you are subscribed to the Google 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: error on django-admin.py startproject

2011-07-02 Thread Andre Terra
As always, please post the full traceback.

Do you get different results if you add/remove "python" to the start
of the command?


Cheers,
André Terra

On 7/2/11, Phil  wrote:
> Hi,
>
> I recently installed the latest development version of Django from
> subversion. I followed all steps on site, got no errors. When I type
> "import django" in Python interpreter I get no errors.
>
> But when I try run "django-admin.py startproject mysite" I get the
> following error...
>
> "ImportError: No module named functools"
>
> Any idea's on what the problem could be?
>
> I am running python2.7 and latest django.
>
> Many 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.
>
>

-- 
Sent from my mobile device

-- 
You received this message because you are subscribed to the Google 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: Implementing a User Search Feature

2011-07-02 Thread Andre Terra
You can use Alex Gaynor's great app called django-filter available at

https://github.com/alex/django-filter

It's the best app for the job, hands down.


Sincerely,
André Terra

On 7/2/11, raj  wrote:
> Thanks, when I get back to my production comp, ill give this a try.
> Did know about this queryset thing. Thanks again.
> Just a quick question, the **filters thing u placed, i would put
> something like first_name last_name or something right?
>
> On Jun 30, 11:25 pm, Doug Ballance  wrote:
>> If you just want a simple user search (which seems to be what you are
>> asking for), it really depends on your models - but a basic approach I
>> usually use is to define a django form to use for the search, and
>> instead of defining a save method, make a method that returns a
>> queryset. As an off the top of my head example for a django auth user
>> (untested, I might have screwed something up):
>>
>> class UserSearchForm(forms.Form):
>>     first_name__istartswith=forms.CharField(label="First name",
>> required=False)
>>     last_name__istartswith=forms.CharField(label="Last name",
>> required=False)
>>
>>     def queryset(self):
>>         from django.contrib.auth.models import User
>>         filters={}
>>         for k,v in self.cleaned_data.items():
>>             val=v.strip()
>>             if val: filters[k]=val
>>         return User.objects.filter(**filters)
>>
>> Then use it in your view like any other form:
>>
>> def user_search(request):
>>     usf=UserSearchForm(request.GET or
>> request.POST,prefix='usersearch')
>>     users=usf.queryset()
>>     return render_to_response('sometemplate.html',{'users':users})
>>
>> Now if you really do want to do text indexing and have full text
>> search capabilities then you should look at the other suggestions.
>> For many things those are either overkill or too generic.
>
> --
> You received this message because you are subscribed to the Google 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.
>
>

-- 
Sent from my mobile device

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

2011-07-02 Thread Javier Guerra Giraldez
On Sat, Jul 2, 2011 at 8:07 AM, Matthew Gardner  wrote:
> a = A.objects.get(pk=some_id)
> b_set = a.b_set.select_related().all() # recommended in the Django
> documentation for some queries
> And b_set comes up empty, for some reason that I can't explain.


a.b_set  isn't a QuerySet; it's a RelatedManager.  For most uses, it's
almost the same; but not exactly.  try reversing the select_related()
and all() calls (all() returns a QuerySet):

b_set = a.b_set.all().select_related()

-- 
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: Implementing a User Search Feature

2011-07-02 Thread Doug Ballance
**filters is python for expand the dict 'filters' into keyword
arguments.

ie
filters={'foo':1}
model.objects.filter(**filters)

is the same as
model.objects.filter(foo=1)

The filters variable is just temporary dictionary for building the
keyword arguments from the form data, electing to omit any empty
values (no point for a search), and then expanding that temp
dictionary into the keyword search arguments needed for the filter()
method.  The names on the form correspond to the lookup names you'd
use for the query.

If you use that form to search for first name 'raj', the filters
dictionary should end up looking like:

{'first_name__istartswith':'raj'}
which would expand (**) to the equivalent of
User.objects.filter(first_name__istartswith='raj')


On Jul 2, 11:53 am, raj  wrote:
> Just a quick question, the **filters thing u placed, i would put
> something like first_name last_name or something right?

-- 
You received this message because you are subscribed to the Google 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: error on django-admin.py startproject

2011-07-02 Thread Phil
Well I already have subversion installed, that's how I got django in
the first place. When I type "import functools" into the python
interpreter I get no errors back either. I can't make it out.

On Jul 2, 7:31 pm, ravinder singh  wrote:
> @
>   plz try this
>     sudo apt-get install subversion
> than
>       django-admin.py startproject mysite.ok

-- 
You received this message because you are subscribed to the Google 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: error on django-admin.py startproject

2011-07-02 Thread ravinder singh
@
  plz try this
sudo apt-get install subversion
than
  django-admin.py startproject mysite.ok

-- 
You received this message because you are subscribed to the Google 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: Weird join conditions

2011-07-02 Thread peroksid
Thank you, Gianluca.

Unfortunately, filter() has no direct impact on joins configuration
and conditions described in filter() go to WHERE clause.
When you refer another table it will be joined somehow but with only
one equality expression in the condition.
We were discussing join consitions here, which go in ON() in FROM
clause.

Alexander.

On 2 июл, 14:53, Gianluca Sforna  wrote:
> On Thu, Jun 30, 2011 at 5:19 PM, peroksid  
> wrote:
>
> > I need to have for the "ON" expression slighlty more complex
> > expression, something like
> > "left_table.left_column=right_table.right_column AND
> > right_table.another_column=42". Method join() obviously  can not be
> > used for this purpose because it tuple defining join connection
> > consists off 4 elements.
> > I suspect there is no way to create such a double join condition at
> > all, event without constant involved instead of column.
>
> Maybe you can use F objects to create the correct filters? It would be
> something like:
>
> object_list = 
> ObjectModel.filter(sometable__leftcolumn=F('right_table__right_column'))
>
> and then you can use Q objects to combine two of them:
>
> q1 = Q(sometable__leftcolumn=F('right_table__right_column'))
> q2 = Q(right_table__another_column=42)
>
> object_list = ObjectModel.filter(q1 & q2)
>
> more info 
> at:https://docs.djangoproject.com/en/dev/topics/db/queries/#filters-can-...https://docs.djangoproject.com/en/dev/topics/db/queries/#complex-look...
>
> --
> Gianluca Sforna
>
> http://morefedora.blogspot.comhttp://identi.ca/giallu-http://twitter.com/giallu

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



error on django-admin.py startproject

2011-07-02 Thread Phil
Hi,

I recently installed the latest development version of Django from
subversion. I followed all steps on site, got no errors. When I type
"import django" in Python interpreter I get no errors.

But when I try run "django-admin.py startproject mysite" I get the
following error...

"ImportError: No module named functools"

Any idea's on what the problem could be?

I am running python2.7 and latest django.

Many 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: Weird join conditions

2011-07-02 Thread peroksid
I do not really get what you mean under reusable raw query factory.
But object manager's method raw() returns RawQueryManager, which is
pretty useless.
When you first mentioned raw SQL I considered it and made method I
write to get SQL query after all join() and extra() calls were done
and return raw() called with modified SQL query.

But the whole point of my work now is to change object manager method
implementation, leaving it's interface untampered. Otherwise there
will be really a lot of work.

I commented it, the method is covered with tests, so I hope for a
best.

On 2 июл, 01:31, Michal Petrucha  wrote:
> > Example, yes. As Haroon said, it is LEFT OUTER JOIN.
>
> Yeah, of course, must have been the lack of caffeine as I said. (-:
>
> > Unfortunately, join and friends  are off use because SQLCompiler's
> > get_from_clause() creates join conditions on dumb string template.
> > I monkeypatched compiler's get_from_clause in connection.ops._cache.
> > Now it calls original method saved under another name on compiler and
> > after that replaces join condition with required one in one of data
> > chunks.
>
> > How do you think, will there be problems?
>
> First, if you look at the extent of changes required to force the ORM
> to solve your problem, a question that comes to mind: Was it worth the
> effort? I mean, if it were me, I'd probably try to do something like
> this only if I needed it quite often, like, half of the queries I make
> require this or something like that, otherwise I'd just stick to a raw
> query. And even then, it might be easier to just create a reusable raw
> query factory, if you get what I mean... But, of course, I don't know
> your app nor what problem you're dealing with, so I may be off by
> miles.
>
> Second, the mechanisms you're altering aren't part of the public API;
> they may change between versions just like that. Though this doesn't
> usually happen, I already had to make some changes in this area in my
> branch and I'll definitely have to also modify the joining code in
> question. All I'm saying is, once you go this route, you shouldn't be
> surprised if stuff breaks upon upgrade.
>
> Michal
>
>  signature.asc
> < 1KбПросмотретьЗагрузить

-- 
You received this message because you are subscribed to the Google 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: Setting up EC2 for Django

2011-07-02 Thread Soviet
Yeah, I guess I did posted it with a bit of bitterness, since I
couldn't find exactly what i was looking for :). I'll keep trying on
my own!

ty for help Cal :).

On Jul 2, 7:02 pm, "Cal Leeming [Simplicity Media Ltd]"
 wrote:
> Hi OP,
>
> Is this requirement for a client, or some sort of paid work? If so,
> quit the job and find something else.
>
> If this requirement is for your own learning, then do exact that, and
> figure these things out for yourself (django-users is not your
> personal tutor, but Google is). For example, would it have killed to
> type "linux howto" or "linux howto" or "linux for beginners" as a
> search result?
>
> Next time posting here, please use this as a guide:
>
> https://code.djangoproject.com/wiki/UsingTheMailingList
>
> Cal
>
>
>
>
>
>
>
> On Sat, Jul 2, 2011 at 3:14 PM, Soviet  wrote:
> > Hello
> > I need to set up EC2 instance to run Django+Python+PostgreSQL+Apache
> > +Solr+nginx+Mercurial etc. This is all black magic for me - I was only
> > using shared hosting like webfaction, where everything is dumb-
> > friendly :). But you know, "the customer is always right", and I have
> > to run it on Amazon. I did hours of googling, but everything is either
> > old/outdated or doesn't cover the tools I have to install. So far I'm
> > stuck on connecting to my instance through PuTTY :D.
>
> > Can anyone provide some useful link or step by step tutorial? I have
> > no experience using Unix command-line-stuff, but im a fast learner :).
> > Any help would be appreciated. Also, beer is on me when we meet! :)
>
> > --
> > You received this message because you are subscribed to the Google 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 
> > athttp://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: Setting up EC2 for Django

2011-07-02 Thread ravinder singh
plz try it
http://www.basicconfig.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: Setting up EC2 for Django

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

Is this requirement for a client, or some sort of paid work? If so,
quit the job and find something else.

If this requirement is for your own learning, then do exact that, and
figure these things out for yourself (django-users is not your
personal tutor, but Google is). For example, would it have killed to
type "linux howto" or "linux howto" or "linux for beginners" as a
search result?

Next time posting here, please use this as a guide:

https://code.djangoproject.com/wiki/UsingTheMailingList

Cal

On Sat, Jul 2, 2011 at 3:14 PM, Soviet  wrote:
> Hello
> I need to set up EC2 instance to run Django+Python+PostgreSQL+Apache
> +Solr+nginx+Mercurial etc. This is all black magic for me - I was only
> using shared hosting like webfaction, where everything is dumb-
> friendly :). But you know, "the customer is always right", and I have
> to run it on Amazon. I did hours of googling, but everything is either
> old/outdated or doesn't cover the tools I have to install. So far I'm
> stuck on connecting to my instance through PuTTY :D.
>
> Can anyone provide some useful link or step by step tutorial? I have
> no experience using Unix command-line-stuff, but im a fast learner :).
> Any help would be appreciated. Also, beer is on me when we meet! :)
>
> --
> You received this message because you are subscribed to the Google 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: Implementing a User Search Feature

2011-07-02 Thread raj
Thanks, when I get back to my production comp, ill give this a try.
Did know about this queryset thing. Thanks again.
Just a quick question, the **filters thing u placed, i would put
something like first_name last_name or something right?

On Jun 30, 11:25 pm, Doug Ballance  wrote:
> If you just want a simple user search (which seems to be what you are
> asking for), it really depends on your models - but a basic approach I
> usually use is to define a django form to use for the search, and
> instead of defining a save method, make a method that returns a
> queryset. As an off the top of my head example for a django auth user
> (untested, I might have screwed something up):
>
> class UserSearchForm(forms.Form):
>     first_name__istartswith=forms.CharField(label="First name",
> required=False)
>     last_name__istartswith=forms.CharField(label="Last name",
> required=False)
>
>     def queryset(self):
>         from django.contrib.auth.models import User
>         filters={}
>         for k,v in self.cleaned_data.items():
>             val=v.strip()
>             if val: filters[k]=val
>         return User.objects.filter(**filters)
>
> Then use it in your view like any other form:
>
> def user_search(request):
>     usf=UserSearchForm(request.GET or
> request.POST,prefix='usersearch')
>     users=usf.queryset()
>     return render_to_response('sometemplate.html',{'users':users})
>
> Now if you really do want to do text indexing and have full text
> search capabilities then you should look at the other suggestions.
> For many things those are either overkill or too generic.

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



csrf token not working

2011-07-02 Thread Bobby Roberts
I'm looking at the docs at 
https://docs.djangoproject.com/en/dev/ref/contrib/csrf/
for CSRF implementation.  I've got steps 1 and 2 done but the csrf
token is not even showing in the form even though i have {%csrf_token
%} within the form html any ideas what would cause it not to
create a token?

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



Setting up EC2 for Django

2011-07-02 Thread Soviet
Hello
I need to set up EC2 instance to run Django+Python+PostgreSQL+Apache
+Solr+nginx+Mercurial etc. This is all black magic for me - I was only
using shared hosting like webfaction, where everything is dumb-
friendly :). But you know, "the customer is always right", and I have
to run it on Amazon. I did hours of googling, but everything is either
old/outdated or doesn't cover the tools I have to install. So far I'm
stuck on connecting to my instance through PuTTY :D.

Can anyone provide some useful link or step by step tutorial? I have
no experience using Unix command-line-stuff, but im a fast learner :).
Any help would be appreciated. Also, beer is on me when we meet! :)

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



Problem with select_related

2011-07-02 Thread Matthew Gardner
Hi all,

I'm seeing some funny behavior when using select_related to try to speed up
my code, and I'm wondering if I'm just misunderstanding something.

The basics of my code:

class A(models.Model):
# some stuff

class B(models.Model):
a = models.ForeignKey('A')
c = models.ForeignKey('C')
d = models.ForeignKey('D')
e = models.ForeignKey('E')
# some stuff

a = A.objects.get(pk=some_id)
b_set = a.b_set.all()

When I do this, b_set has about 8 things in it, and I can get to c, d, e,
and other things just fine.  But, presumably, accessing b.c, b.d, and b.e
are each database calls, and I would like to avoid those if I can.

So to get rid of those database calls and just get all of the related fields
in a single query, I do this:

a = A.objects.get(pk=some_id)
b_set = a.b_set.select_related().all() # recommended in the Django
documentation for some queries

And b_set comes up empty, for some reason that I can't explain.  The only
difference between the two blocks of code is the select_related() call, and
it changes the result by not giving me anything back.  Any ideas?

Thanks,
Matt

-- 
You received this message because you are subscribed to the Google 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: Possible interest in a webcast/presentation about Django site with 40mil+ rows of data??

2011-07-02 Thread Cal Leeming [Simplicity Media Ltd]
Oops, sorry guys, I pasted the wrong link.

Here you go:

https://spreadsheets0.google.com/spreadsheet/viewanalytics?formkey=dENyOVFSSkhSYnhBLVZGTktiN1Z3Y2c6MQ

On Sat, Jul 2, 2011 at 11:35 AM, Cal Leeming [Simplicity Media Ltd]
 wrote:
> Hi guys,
> Alright, vote is closed and here are the results:
> https://spreadsheets.google.com/spreadsheet/gform?key=0AiciLOVZqDWqdENyOVFSSkhSYnhBLVZGTktiN1Z3Y2c=en_GB=0#chart
> It looks like I might have to do two separate webcasts to cater for
> all timezones, but we'll see.
> I'll post up a fixed time/date (or two) shortly.
> Cal
>
> On Thu, Jun 30, 2011 at 2:02 PM, Benedict Verheyen
>  wrote:
>>
>> > Hey all,
>> >
>> > Last call for registering your interest in this webcast (28 votes so
>> > far).
>> >
>> > If you haven't done so already, please visit the following URL:
>> >
>> >
>> > https://spreadsheets.google.com/spreadsheet/viewform?hl=en_GB=dENyOVFSSkhSYnhBLVZGTktiN1Z3Y2c6MQ#gid=0
>> >
>> > 
>> >
>> > Poll ends tomorrow, at which point we will decide upon a fixed
>> > time/date(s).
>> >
>>
>> I'm interested, visited the URL above already.
>> Time isn't going to be that big of an issue for me as I'm only 1 timezone
>> away :)
>>
>> Cheers,
>> Benedict
>>
>> --
>> You received this message because you are subscribed to the Google 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.



create open office docs with django - best way to format text?

2011-07-02 Thread andreas
Hi all,

i am trying to generate open office docs (bulk letters) from my django
app.
I am using django-webodt (http://pypi.python.org/pypi/django-webodt)
and basically it works really smooth.

The only point i am unsure about is how to 'transfer' the text
formatting from django to an odt doc.
Currently my texts in django are html formatted (using TinyMCE) and i
wonder how to best continue from here.

A simple option is obviously to strip the html and render plain text
in the generated open office docs.
This works, but it would be really nice if my editors could use some
basic formatting (lists, bold etc.)

So what are good options to achieve this?

Is there a way to render html (transform html to rich-text) in an open
office doc?
Or would i be better of to switch to another format for editing the
texts in django (ResT, markup) as there seem to be conversion
libraries?

I'd love to hear how others solved the creation of open office docs
from django.

Thanks!
Andreas

-- 
You received this message because you are subscribed to the Google 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: Weird join conditions

2011-07-02 Thread Gianluca Sforna
On Thu, Jun 30, 2011 at 5:19 PM, peroksid  wrote:

>
> I need to have for the "ON" expression slighlty more complex
> expression, something like
> "left_table.left_column=right_table.right_column AND
> right_table.another_column=42". Method join() obviously  can not be
> used for this purpose because it tuple defining join connection
> consists off 4 elements.
> I suspect there is no way to create such a double join condition at
> all, event without constant involved instead of column.

Maybe you can use F objects to create the correct filters? It would be
something like:

object_list = 
ObjectModel.filter(sometable__leftcolumn=F('right_table__right_column'))

and then you can use Q objects to combine two of them:

q1 = Q(sometable__leftcolumn=F('right_table__right_column'))
q2 = Q(right_table__another_column=42)

object_list = ObjectModel.filter(q1 & q2)

more info at:
https://docs.djangoproject.com/en/dev/topics/db/queries/#filters-can-reference-fields-on-the-model
https://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects

-- 
Gianluca Sforna

http://morefedora.blogspot.com
http://identi.ca/giallu - http://twitter.com/giallu

-- 
You received this message because you are subscribed to the Google 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: Possible interest in a webcast/presentation about Django site with 40mil+ rows of data??

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

Alright, vote is closed and here are the results:

https://spreadsheets.google.com/spreadsheet/gform?key=0AiciLOVZqDWqdENyOVFSSkhSYnhBLVZGTktiN1Z3Y2c=en_GB=0#chart

It looks like I might have to do two separate webcasts to cater for
all timezones, but we'll see.

I'll post up a fixed time/date (or two) shortly.

Cal

On Thu, Jun 30, 2011 at 2:02 PM, Benedict Verheyen <
benedict.verhe...@gmail.com> wrote:

> > Hey all,
> >
> > Last call for registering your interest in this webcast (28 votes so
> far).
> >
> > If you haven't done so already, please visit the following URL:
> >
> >
> https://spreadsheets.google.com/spreadsheet/viewform?hl=en_GB=dENyOVFSSkhSYnhBLVZGTktiN1Z3Y2c6MQ#gid=0
> > <
> https://spreadsheets.google.com/spreadsheet/viewform?hl=en_GB=dENyOVFSSkhSYnhBLVZGTktiN1Z3Y2c6MQ#gid=0
> >
> >
> > Poll ends tomorrow, at which point we will decide upon a fixed
> time/date(s).
> >
>
> I'm interested, visited the URL above already.
> Time isn't going to be that big of an issue for me as I'm only 1 timezone
> away :)
>
> Cheers,
> Benedict
>
> --
> You received this message because you are subscribed to the Google 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: How to use the django-users mailing list properly and doing your homework..

2011-07-02 Thread Cal Leeming [Simplicity Media Ltd]
+1 on Piotr's post.

Although I do see the benefits of Andres's ideas, I do agree that some
things really should be kept separate.

Cal

On Sat, Jul 2, 2011 at 7:49 AM, Piotr Zalewa  wrote:

> Everything has its place. For me it looks like that:
>
> direct help - IRC
> searching for solutions - tutorials, documentation, django snippets
> discovering new stuff - email list, StackOverflow
>
> zalun
>
>
> On 07/02/11 01:11, Andre Terra wrote:
>
>> To be honest, I often think about how an e-mail list is actually one of
>> the worst media to help with coding.
>>
>> Here's some food for thought: wouldn't it be better if we had a
>> django-help project that combined django snippets, a stack overflow-like
>> ratings system (an incentive to both good questions and speedy answers),
>> code highlighting, moderation, open/closed questions, etc?
>>
>>
>>
>> Sincerely,
>>
>> André Terra
>>
>>
>> On Fri, Jul 1, 2011 at 6:51 PM, Cal Leeming [Simplicity Media Ltd]
>> 
>> >>
>> wrote:
>>
>>Also, I modified the wiki entry to include one good/one bad example
>>of a thread.
>>
>>Could others people also contribute some examples of what they
>>consider good/bad threads too? (maybe could even put some text
>>underneath to explain why)
>>
>>On Fri, Jul 1, 2011 at 10:46 PM, Cal Leeming [Simplicity Media Ltd]
>>
>> 
>>
>> >>
>> wrote:
>>
>>+1 on gists (i didn't even know this existed).
>>
>>Because to be honest, if github disappears, then something has
>>gone terribly wrong with the interwebs :X
>>
>>But also +1 on django web team deploying their own...
>>
>>
>>On Fri, Jul 1, 2011 at 5:46 PM, Micky Hulse >> wrote:
>>
>>Don't forget about GitHub Gists!
>>
>>https://gist.github.com/
>>
>>Considering a lot of Django projects are already hosted
>>there... Seems
>>like a natural fit to me. :)
>>
>>Also, Gist has the "fork" feature.
>>
>>--
>>You received this message because you are subscribed to the
>>Google 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+unsubscribe@**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+unsubscribe@**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+unsubscribe@**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+unsubscribe@**
> 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 

Re: How to use the django-users mailing list properly and doing your homework..

2011-07-02 Thread Piotr Zalewa

Everything has its place. For me it looks like that:

direct help - IRC
searching for solutions - tutorials, documentation, django snippets
discovering new stuff - email list, StackOverflow

zalun

On 07/02/11 01:11, Andre Terra wrote:

To be honest, I often think about how an e-mail list is actually one of
the worst media to help with coding.

Here's some food for thought: wouldn't it be better if we had a
django-help project that combined django snippets, a stack overflow-like
ratings system (an incentive to both good questions and speedy answers),
code highlighting, moderation, open/closed questions, etc?



Sincerely,

André Terra


On Fri, Jul 1, 2011 at 6:51 PM, Cal Leeming [Simplicity Media Ltd]
> wrote:

Also, I modified the wiki entry to include one good/one bad example
of a thread.

Could others people also contribute some examples of what they
consider good/bad threads too? (maybe could even put some text
underneath to explain why)

On Fri, Jul 1, 2011 at 10:46 PM, Cal Leeming [Simplicity Media Ltd]
> wrote:

+1 on gists (i didn't even know this existed).

Because to be honest, if github disappears, then something has
gone terribly wrong with the interwebs :X

But also +1 on django web team deploying their own...


On Fri, Jul 1, 2011 at 5:46 PM, Micky Hulse > wrote:

Don't forget about GitHub Gists!

https://gist.github.com/

Considering a lot of Django projects are already hosted
there... Seems
like a natural fit to me. :)

Also, Gist has the "fork" feature.

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