Re: django cache framework not work well on mod_python of apache

2009-07-01 Thread Graham Dumpleton

On Jul 2, 2:00 pm, Chhouk Voeun  wrote:
> no i use window

If this reply was truly about original caching issues with
multiprocess Apache, take note that it was said that it was a UNIX
platform issue. On Windows there is only one process, so it is not a
problem and you can use normal in process caching.

Please don't reply without context of previous emails so people can
understand what you are talking about.

Graham

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



Re: Tracking a bad import

2009-07-01 Thread Chhouk Voeun
i want to use map url (http:\\localhost:8080\main).oh i use window

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Tracking a bad import

2009-07-01 Thread Chhouk Voeun
i use window and i can start page .the sample code follow:# Copyright 2008
Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


"""Bootstrap for running a Django app under Google App Engine.

The site-specific code is all in other files: settings.py, urls.py,
models.py, views.py.  And in fact, only 'settings' is referenced here
directly -- everything else is controlled from there.

"""

# Standard Python imports.
import os
import sys
import logging
import __builtin__



# Google App Hosting imports.
from google.appengine.ext.webapp import util

import pickle
sys.modules['cPickle'] = pickle

# Enable info logging by the app (this is separate from appserver's
# logging).
logging.getLogger().setLevel(logging.INFO)

# Force sys.path to have our own directory first, so we can import from it.
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))

# Must set this env var *before* importing any part of Django.
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

# Make sure we can import Django.  We may end up needing to do this
# little dance, courtesy of Google third-party versioning hacks.  Note
# that this patches up sys.modules, so all other code can just use
# "from django import forms" etc.
try:
  from django import v0_96 as django
except ImportError:
  pass

# Import the part of Django that we use here.
import django.core.handlers.wsgi


def main():
  # Create a Django application for WSGI.
  application = django.core.handlers.wsgi.WSGIHandler()

  util.run_wsgi_app(application)

if __name__ == '__main__':
  main()

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Tracking a bad import

2009-07-01 Thread goodwinb

Fixed it by reinstalling all of my packages.

On Jul 1, 8:48 pm, goodwinb  wrote:
> I am setting up a server and when I run manage.py syncdb I get the
> error 'cannot import name pre_delete'.  How can I get more trace
> information about where the bad pre_delete is?
>
> Python 2.6; Django 1.1-beta; using comments, markdown, statlib
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 cache framework not work well on mod_python of apache

2009-07-01 Thread Chhouk Voeun
no i use window

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 cache framework not work well on mod_python of apache

2009-07-01 Thread Graham Dumpleton

Presumably use memcache.

On Jul 2, 12:09 pm, Hongyu Li  wrote:
> Thanks for your comment.
> What was you do when want add a global memory cache in your app with django?
>
> On Wed, Jul 1, 2009 at 8:08 PM, Graham Dumpleton 
>
>
>
>
> > wrote:
>
> > On Jul 1, 7:22 pm, Hongyu Li  wrote:
> > > #!/usr/bin/env python
> > > # -*- coding: utf-8     -*-
> > > import xmlrpclib
> > > import os
> > > import sys
> > > import time
> > > import math
> > > import optparse
> > > import tm.filecheck
> > > import service
> > > from django.http import HttpResponse
> > > from django.core.cache import cache
>
> > > def getCategoryAndDetail(request):
> > >         keyword = request.GET.__getitem__('keyword' )
> > >         result1 = keyword + str(cache.has_key('SC_MAPPER'))
> > >         if not (cache.has_key('SC_MAPPER')):
> > >                 cache.set('SC_MAPPER','SC',9)
> > >         else:
> > >                 sc = cache.get('SC_MAPPER')
> > >         result2 = keyword + str(cache.has_key('SC_MAPPER'))
> > >         return HttpResponse(result1 + result2)
> > > before is my testing code.
> > > When I call this mothod by http, it should retrun false when I first
> > visit,
> > > and return true all the other time, but it is not return true all time
> > after
> > > I first visit. any one meeting the same problem?  this code is work well
> > in
> > > local django development server.
>
> > Could it be because Apache is a multi process server on UNIX systems?
>
> > If this is changing per process state, then it will not affect other
> > concurrently running processes, so if subsequent requests go to a
> > different process, you will not see what you expect.
>
> > Graham
>
> []
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: postgres schemas and django admin

2009-07-01 Thread Chhouk Voeun
Page not found (404)  Request Method: GET  Request URL:
http://localhost:8080/main

Using the URLconf defined in urls, Django tried these URL patterns, in this
order:

   1. ^$
   2. ^new$
   3. ^edit/(\d+)$

The current URL, /main, didn't match any of these.
 You're seeing this error because you have DEBUG = True in your Django
settings file. Change that to False, and Django will display a standard 404
pa

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: postgres schemas and django admin

2009-07-01 Thread Unnamed_Hero

So, I think I found a solution.

But, in 
http://code.djangoproject.com/attachment/ticket/1051/ticket_1051_rev6669.diff
I've changed a string
"cursor.execute("SET search_path TO %s" % ','.join
(settings.DATABASE_SCHEMAS)) "
to
"cursor.execute("SET search_path TO %s" ,[settings.DATABASE_SCHEMAS])
"

And finally syncdb completed without any errors.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Tracking a bad import

2009-07-01 Thread Chhouk Voeun
 Page not found (404)  Request Method: GET  Request URL:
http://localhost:8080/main/

Using the URLconf defined in pollango.urls, Django tried these URL patterns,
in this order:

   1. ^$
   2. ^create/$
   3. ^poll/(?P[^\.^/]+)/$
   4. ^poll/(?P[^\.^/]+)/results/$

The current URL, /main/, didn't match any of these.

You're seeing this error because you have DEBUG = True in your Django
settings file. Change that to False, and Django will display a standard 404
page.

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



Tracking a bad import

2009-07-01 Thread goodwinb

I am setting up a server and when I run manage.py syncdb I get the
error 'cannot import name pre_delete'.  How can I get more trace
information about where the bad pre_delete is?

Python 2.6; Django 1.1-beta; using comments, markdown, statlib

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 cache framework not work well on mod_python of apache

2009-07-01 Thread Hongyu Li
Thanks for your comment.
What was you do when want add a global memory cache in your app with django?

On Wed, Jul 1, 2009 at 8:08 PM, Graham Dumpleton  wrote:

>
>
>
> On Jul 1, 7:22 pm, Hongyu Li  wrote:
> > #!/usr/bin/env python
> > # -*- coding: utf-8 -*-
> > import xmlrpclib
> > import os
> > import sys
> > import time
> > import math
> > import optparse
> > import tm.filecheck
> > import service
> > from django.http import HttpResponse
> > from django.core.cache import cache
> >
> > def getCategoryAndDetail(request):
> > keyword = request.GET.__getitem__('keyword' )
> > result1 = keyword + str(cache.has_key('SC_MAPPER'))
> > if not (cache.has_key('SC_MAPPER')):
> > cache.set('SC_MAPPER','SC',9)
> > else:
> > sc = cache.get('SC_MAPPER')
> > result2 = keyword + str(cache.has_key('SC_MAPPER'))
> > return HttpResponse(result1 + result2)
> > before is my testing code.
> > When I call this mothod by http, it should retrun false when I first
> visit,
> > and return true all the other time, but it is not return true all time
> after
> > I first visit. any one meeting the same problem?  this code is work well
> in
> > local django development server.
>
> Could it be because Apache is a multi process server on UNIX systems?
>
> If this is changing per process state, then it will not affect other
> concurrently running processes, so if subsequent requests go to a
> different process, you will not see what you expect.
>
> Graham
> >
>

[]

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



Getting the name of a matched URL pattern

2009-07-01 Thread Nick Fishman

Hey everyone,

I'm working with Django's named URL patterns, and was wondering how to
fetch the name of the URL pattern that triggered the view. For
example, with the following urlpatterns

urlpatterns = patterns('',
url(r'^archive/(\d{4})/$', archive, name="full-archive"),
url(r'^archive-summary/(\d{4})/$', archive, {'summary': True},
"arch-summary"),
)

is there any way to fetch the name="full-archive" and
name="arch-summary" parameter from inside the view?

I found a thread that talks about this same issue
(http://stackoverflow.com/questions/1042211/get-name-for-matched-url-pattern),
but the solution requires duplicating the URL pattern name in a
dictionary.

Thanks,

Nick

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 + user profile admin inlines = breakage

2009-07-01 Thread hagan

I'm using python 2.6.2, django 1.1-beta-1 with mod_wsgi 2.5 So
this very well could be a beta bug...

I'm having a strange problem, which I've tracked down to my
UserProfile model... well, the admin interface.

Basically I'm trying to do something like this  (Simplified from
working model)

---models.py
from datetime import datetime
from django.db import models
from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin

class UserProfile(models.Model):
someinfo = models.CharField(max_length=128)

def __unicode__(self):
return self.someinfo

class SomeModel(models.Model):
  date = models.DateField()

  @property
  def due_date(self):
return datetime.today()

admin.site.unregister(User)
class UserProfileInline(admin.StackedInline):
model=UserProfile

class UserProfileAdmin(UserAdmin):
inlines = [ UserProfileInline ]


admin.site.register(User, UserProfileAdmin)#<== That results
in errors

/
models.py---

So, I can get UserProfile included in the UserAdmin page.. That works,
however every time I load the wsgi thread I get an error:

"The model User is not registered"

And on the 2nd page refesh, that error goes away.  I had chalked that
up as an annoyance up until it became obvious something with my inline
is causing issues with datetime.today() as well.

Without the admin.site.register override datetime.today() works...
With it I get:

Exception Value:  'NoneType' object has no attribute 'today'
Exception Location: /home/webby/add/dilettante/models.py in due_date,
line 120

I'm hoping someone else has seen this error or recognizes that i've
done something obviously 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: changing apache mod python

2009-07-01 Thread Aaron Maxwell

Hm.  It involves this module Deportista.  I haven't heard of it, so I'm 
assuming it's either a third-party library you are using, or one a module 
made in house.

You might try this: (assuming unixy environment)

1) At a shell prompt, set PYTHONPATH to the value you included in the attached 
error report page.  (you know how to do this?  If not, look up setting and 
exporting environment variables.)
2) Also set DJANGO_SETTINGS_MODULE
3) Start a python interpreter 
4) type in "import entrenatech.views"

Does this reproduce the Deportista importerror?  If so, that is a good clue.

On Wednesday 01 July 2009 12:55:05 am Miguel wrote:
> The error is:
> ViewDoesNotExist at / Could not import entrenatech.views. Error was: No
> module named Deportista
> As you said, Django .96 might be incompatible somehow, but I have to keep
> it becasuse it is a little messy to updgrade the django version. Too much
> production code.


-- 
Aaron Maxwell
http://redsymbol.net/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 Sessions / Multidimensional List

2009-07-01 Thread bjoern_mainz

Hi,

what i try do do is (in plain python):

products = []
products.append({"product" : "foo","quantity": 5})
products.append({"product": "foz","quantity": 1})

---Django---

def add_to_basket(request):

if not 'products' in request.session:
request.session['products']=[]

product = {}
for k,v in request.POST.items():
product[k]=v

request.session['products'].append(product)

return render_to_response('addtobasket.html', {'products':
request.session['products']})

---/Django---

This is not working as i expected it.

Just two elements are added. When trying to add a third element - the
second one is overwritten.

i am using OS X 10.5, Python 2.5 and Django 1.0.2

Thx a lot,

Bjoern


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

2009-07-01 Thread Aaron Lee
Lately I have been seeing the following errors from memcached
[fa...@1246486554.949771] mcm_get_line():1542: memcache(4) protocol error:
no \r before \n
[fa...@1246486554.949771] mcm_get_line():1542: memcache(4) protocol error:
no \r before \n
[fa...@1246486554.949771] mcm_fetch_cmd():1154: memcache(4) protocol error:
protocol, expected a response
[fa...@1246486554.953771] mcm_server_send_cmd():2706: failed to send command
to the memcache server: Bad address: Bad address

I am using the latest Django from trunk, libmemcache-1.4.0.rc2,
cmemcache-0.95. I also searched over Google and it seems like a mystery of
how and why it happens. At then end they fall back to python-memcached even
though it's slower.

Anyone know what the problem is?
I wasn't able to reproduce it so it's hard to track down.

-Aaron

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: No css in Admin

2009-07-01 Thread Some Guy

Found the problem.  I was overriding change_list.html and somehow
base.css is not being included.

I manually linked it into my base.html and it works now.

I was seeing change_list.css, or whatever, and thought that was all
that was needed.




On Jul 1, 1:46 pm, Xavier Ordoquy  wrote:
> On Wed, 2009-07-01 at 13:01 -0700, Some Guy wrote:
> > Hi Group,
> > I've look all over to find the answer but am now posting out of
> > desperation :)
>
> > I have a dev and prod server (apache2, mod_python)
>
> > on the production server the css and js for the admin site does not
> > work. (except for the login page)
>
> > The images show up but no css styles are applied. Also, the save
> > function doesn't work (due to no Js?)
>
> > If I put the css file url in the browser, it shows up fine... Also,
> > firebug lists the css styles, but they are not applied.
>
> > Another weird thing is that firebug's "NET" tab shows only downloading
> > the html, and no css or js files.
>
> > Any ideas?
> > TIA
>
> Hi,
>
> Are you sure you configured correctly ADMIN_MEDIA_PREFIX ?
> What's your website url ?
>
> Regards,
> Xavier Ordoquy.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: sorting different in postgres than in sqlite

2009-07-01 Thread J

Coalesce() worked in postgres as well. Thank you.


On Jun 30, 10:34 pm, J  wrote:
> Thank you Tim, that worked perfectly in sqlite, and I imagine it will
> work well inpostgresas well. My server is down right now, so I can't
> say for sure, but I will definitely try this out.
>
> Thanks again,
> J

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



Re: How to filter out posts from friends?

2009-07-01 Thread Rajesh D



On Jul 1, 4:35 pm, Daniel Roseman  wrote:
> On Jul 1, 8:59 pm, Rajesh D  wrote:
>
>
>
>
>
> > On Jul 1, 9:50 am, Mathieu Leplatre  wrote:
> > > On 1 juil, 14:44, coan  wrote:
>
> > > > I have a friendship model for users and want to retrieve all the posts
> > > > my friends made.
>
> > > > class Friendship(models.Model):
> > > >  from_friend = models.ForeignKey( User, related_name='friend_set' )
> > > >  to_friend = models.ForeignKey( User, related_name='to_friend_set' )
>
> > > > class Post(models.Model):
> > > >  text = models.TextField()
> > > >  user = models.ForeignKey(User)
>
> > > > I retrieve my friends posts with this:
>
> > > > my_friendships = Friendship.objects.filter(from_friend=request.user)
> > > > list_of_my_friends_ids = []
>
> > > > for friendship in my_friendships:
> > > >  list_of_my_friends_ids.append(friendship.to_friend.id)
>
> > You can do the above with a one-liner:
>
> > list_of_my_friends_ids = Friendship.objects.filter
> > (from_friend=request.user).values_list('id', flat=True)
>
> No, not quite. The OP wanted - and Mathieu's method provided - a way
> to get the ids of the *friends*. Your query gets the ID of the
> *friendships*, which isn't the same thing at all.

Right, I missed that.

This would work:
> Friendship.objects.filter(from_friend=request.user).values_list
> ('to_friend_id', flat=True)
> since the 'to_friend' FK is stored in the Friendship model as
> 'to_friend_id'.
>
> However, the OP might be able to do the whole thing in one query.
> Without testing, this *might* work:
> Post.objects.filter(user__friend_set__to_friend=request.user)

The idea works but it should be:

Post.objects.filter(user__to_friend_set__from_friend=me)

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



ForeignKey within GenericForeignKey

2009-07-01 Thread PiGGeH

I'm pretty sure its not necessarily meant to work like this, however
one way it does, the other it doesnt.

I have the following (cut down slightly, but the important stuff is
here)

# image/models.py
class Image(models.Model):
type = models.ForeignKey('image.Type')
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey
('type__content_type','object_id')


class Type(models.Model):
slug = models.SlugField()
content_type = models.ForeignKey(ContentType)

class Size(models.Model):
type = models.ForeignKey('image.Type')
width = models.IntegerField()


# clan/models.py
class Clan(models.Model):
image = generic.GenericRelation(
Image,
content_type_field='type__content_type',
object_id_field='object_id'
)

For forward lookups using clan.image.all, works fine, however the
reverse image.content_object throws the following error

Image has no field named 'type__content_type'

I don't actually need to use it this way round, however deleting the
clan in this case also deletes the images, this is when that lookup
was called.

The reason for this possibly crazy idea as follows
The image has a type, and the type has multiple sizes
I build the url as follows

/uploads/TYPE_SLUG/SIZE_SLUG/IMAGE_ID.jpg
so maybe /uploads/user/medium/111.jpg

and template tags work in a similar way to as follows



I have a feeling I am going to need to re-write this lot anyway - far
too many lookups, but some input would be appreciated.

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: No css in Admin

2009-07-01 Thread Xavier Ordoquy

On Wed, 2009-07-01 at 13:01 -0700, Some Guy wrote:
> Hi Group,
> I've look all over to find the answer but am now posting out of
> desperation :)
> 
> I have a dev and prod server (apache2, mod_python)
> 
> on the production server the css and js for the admin site does not
> work. (except for the login page)
> 
> The images show up but no css styles are applied. Also, the save
> function doesn't work (due to no Js?)
> 
> If I put the css file url in the browser, it shows up fine... Also,
> firebug lists the css styles, but they are not applied.
> 
> Another weird thing is that firebug's "NET" tab shows only downloading
> the html, and no css or js files.
> 
> Any ideas?
> TIA

Hi,

Are you sure you configured correctly ADMIN_MEDIA_PREFIX ?
What's your website url ?

Regards,
Xavier Ordoquy.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 filter out posts from friends?

2009-07-01 Thread Daniel Roseman

On Jul 1, 8:59 pm, Rajesh D  wrote:
> On Jul 1, 9:50 am, Mathieu Leplatre  wrote:
> > On 1 juil, 14:44, coan  wrote:
>
> > > I have a friendship model for users and want to retrieve all the posts
> > > my friends made.
>
> > > class Friendship(models.Model):
> > >  from_friend = models.ForeignKey( User, related_name='friend_set' )
> > >  to_friend = models.ForeignKey( User, related_name='to_friend_set' )
>
> > > class Post(models.Model):
> > >  text = models.TextField()
> > >  user = models.ForeignKey(User)
>
> > > I retrieve my friends posts with this:
>
> > > my_friendships = Friendship.objects.filter(from_friend=request.user)
> > > list_of_my_friends_ids = []
>
> > > for friendship in my_friendships:
> > >  list_of_my_friends_ids.append(friendship.to_friend.id)
>
> You can do the above with a one-liner:
>
> list_of_my_friends_ids = Friendship.objects.filter
> (from_friend=request.user).values_list('id', flat=True)
>

No, not quite. The OP wanted - and Mathieu's method provided - a way
to get the ids of the *friends*. Your query gets the ID of the
*friendships*, which isn't the same thing at all. This would work:
Friendship.objects.filter(from_friend=request.user).values_list
('to_friend_id', flat=True)
since the 'to_friend' FK is stored in the Friendship model as
'to_friend_id'.

However, the OP might be able to do the whole thing in one query.
Without testing, this *might* work:
Post.objects.filter(user__friend_set__to_friend=request.user)
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using a dynamically created ImageField filename prior to save?

2009-07-01 Thread Rajesh D

>
> > This is an issue which, I believe, is related to Ticket #10788
> > (http://code.djangoproject.com/ticket/10788).
>
> > The following code snippet used to work with Django 1.0.2, but with
> > the latest svn version the slug is not being set to the filename
> > produced by get_path because, as I understand it, get_path will not be
> > called until the instance is saved to the database.
>
> > def get_path(instance, filename):
> >    salt = hashlib.sha1(str(random.random())).hexdigest()
> >    name = hashlib.sha1(salt+filename).hexdigest()[:16]
> >    return '%s.jpg' % (name)
>
> > class Photo(models.Model):
> >    photo = models.ImageField(upload_to=get_path, blank=False)
> >    ...
> >    slug = models.CharField(max_length=16, unique=True)
>
> >    def save(self):
> >        self.slug = self.photo.url.split('/')[-1:][0].split('.')[0]
> >        super(Photo, self).save()
>
> > I could call instance.save() twice in my view to force it to use the
> > correct name, but this feels a bit messy to me. What's the best way to
> > get the correct value for the slug field prior to saving it to the
> > database, given that the filename is 'randomly' generated?
>
> e.g. Generated filename:-
>
>     ebc151e5aad64f4b.jpg
>
> Derived url for Photo view:-
>
>    http://mydomain.com/photo/ebc151e5aad64f4b
>
> From reading the above mentioned ticket and it's referenced discussion
> threads, I can't see any way of generating a slug field from the
> filename before the instance is saved. At the moment I am saving the
> instance to generate the hashed filename, creating the slug based on
> the dynamically generated filename, and then saving to the database
> again.
>
> Doesn't seem ideal to me, especially as it worked without the extra
> save in 1.0.2, and I'm using this dynamic filename/slug method on
> several projects.

Judging by the discussions on the above mentioned ticket, it may be a
while before this behaviour is reverted back (if it is reverted back
at all.)

There's a subtle bug in this line of your code:

self.slug = self.photo.url.split('/')[-1:][0].split('.')[0]

It assumes that the expression will never result in a slug whose
length is more than 16. But that's not necessarily true because when
Django tries to save your photo file and finds another file with the
same name, it will append an underscore to the filename until it
generates a unique filename. In that case, your slug will extend
beyond its 16 character limit. Since your filenames are generated
randomly, it's not very likely that you will ever hit this edge case.
But just be aware.

As for your problem of computing a slug based on the filename, perhaps
the following will help:

def get_path(instance, filename):
salt = hashlib.sha1(str(random.random())).hexdigest()
name = hashlib.sha1(salt+filename).hexdigest()[:16]
# Save generated filename in an attribute of this model instance:
instance._my_filename = name
return '%s.jpg' % (name)

Then, in the model save do:

if not self.slug:
self.slug = self._my_filename

If this does work, you might still have to add some more defensive
code around there to check that the instance "hasattr" _my_filename
and if it doesn't, may be just generated a random 16 character slug.

-RD

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



No css in Admin

2009-07-01 Thread Some Guy

Hi Group,
I've look all over to find the answer but am now posting out of
desperation :)

I have a dev and prod server (apache2, mod_python)

on the production server the css and js for the admin site does not
work. (except for the login page)

The images show up but no css styles are applied. Also, the save
function doesn't work (due to no Js?)

If I put the css file url in the browser, it shows up fine... Also,
firebug lists the css styles, but they are not applied.

Another weird thing is that firebug's "NET" tab shows only downloading
the html, and no css or js files.

Any ideas?
TIA



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 filter out posts from friends?

2009-07-01 Thread Rajesh D



On Jul 1, 9:50 am, Mathieu Leplatre  wrote:
> On 1 juil, 14:44, coan  wrote:
>
>
>
>
>
> > I have a friendship model for users and want to retrieve all the posts
> > my friends made.
>
> > class Friendship(models.Model):
> >  from_friend = models.ForeignKey( User, related_name='friend_set' )
> >  to_friend = models.ForeignKey( User, related_name='to_friend_set' )
>
> > class Post(models.Model):
> >  text = models.TextField()
> >  user = models.ForeignKey(User)
>
> > I retrieve my friends posts with this:
>
> > my_friendships = Friendship.objects.filter(from_friend=request.user)
> > list_of_my_friends_ids = []
>
> > for friendship in my_friendships:
> >  list_of_my_friends_ids.append(friendship.to_friend.id)

You can do the above with a one-liner:

list_of_my_friends_ids = Friendship.objects.filter
(from_friend=request.user).values_list('id', flat=True)

See: 
http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-list-fields

Hope that helps.

-RD

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: file extensions for templates

2009-07-01 Thread Rajesh D



On Jul 1, 8:30 am, David De La Harpe Golden
 wrote:
> Hi,
>
> As far as I can see, django shouldn't care in the slightest about
> template file name extensions, but being a django newbie, I could have
> missed something (e.g. autosetting of a mime type somewhere based on
> extension), so just to verify - it doesn't?

Right.

http://docs.djangoproject.com/en/dev/ref/templates/api/#the-template-dirs-setting

Quote: They can have any extension you want, such as .html or .txt, or
they can have no extension at all.

-RD
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 write to the history

2009-07-01 Thread Rajesh D



On Jul 1, 12:10 pm, mettwoch  wrote:
> Hi group,
>
> What would be a good way to log changes made to models from outside
> the admin interface?

Look at the log_* methods in the Admin implementation:
http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/options.py#L377

You could replicate what those methods do using your own utility
functions. Then call your functions from the appropriate view or
forms.

-RD
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 code for multiple sub-types of a model

2009-07-01 Thread Randy Barlow

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Daniele Procida declared:
> Which of these is a more satisfactory solution? Is there another way?

Hey Daniele, I have a third suggestion for you that I think is best
suited for your problem, and this is the way we do it in our product.
Create a Group model, and place a many to many relationship between it
and your User model.  This way you can test for Group membership to see
if a person is a researcher, etc.  If you want to see all researchers,
you just query for all the Users in the research group.  This is nicer
than using inheritance, since Django doesn't do polymorphism the way you
would expect an ordinary Python class to do (i.e., there's no easy way
to find the most specific type of a User model*)

* We've solved this problem too, by creating a super class for all our
models, and storing the "final type" of all our models.  That way, if we
did have a User and a ResearchUser, if we had queried for the User, we
can call a special method we made on the user,
user.downcast_completely(), and it will give us back the ResearchUser
version of the object.  Neato, eh?

- --
Randy Barlow
Software Developer
The American Research Institute
http://americanri.com
919.228.4971
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpLsQwACgkQw3vjPfF7QfWR7gCgkpyI61HmqG7x89CqgyXQvdmK
ck8AoJpxOwkHwm762DDZ1zt6R4hBH2ll
=xQh1
-END PGP SIGNATURE-

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



Disabling admin pagination.

2009-07-01 Thread kurak

Hello,
I'd like to add another button "show all" after pagination numbers, so
I could optionally show all records on one page.
Is there any way to do this without patching django?

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



How to code for multiple sub-types of a model

2009-07-01 Thread Daniele Procida

I need to create a set of models to capture people's roles in an institution.

Every person is a Person, with a name, contact details, a member of one
or more departments, and so on.

Some people are also Researchers, and/or Lecturers, Students and so on
(there could be other categories that haven't been thought of yet).

It looks to me that I could do one of two things:

*   include *all* of the information that might be associated with a
person into one model (with boolean fields like is_a_researcher) and
gather together researcher fields, lecturer fields and so on into
appropriate fieldsets

This seems brute-forceish, and inelegant. It makes it more difficult to
work on the code (any new field will require a database reset,for example).

But at least it keeps the Admin in one place, and would be simple to code up.

*   create additional models for Rsearcher, Lecturer, etc, and connect
each one to a person in a one-to-one relationship

This looks more elegant and managable, but I can't work out how to lock
each Researcher record to the base Person record (all the details of the
researcher can be reassigned to another person, which obviously isn't
satisfactory). Also, without some comprehensive Admin rewriting, it will
mean travelling between sections of the Admin interface to change the
different sections.

Which of these is a more satisfactory solution? Is there another way?

Thanks,

Daniele


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Display Data From Multiple Tables

2009-07-01 Thread TiNo
On Wed, Jul 1, 2009 at 16:59, The Danny Bos  wrote:

>
> Hi there,
>
> Seems easy, but I'm having an ass of a time. I think once I wrap my
> head around how to do this, I'll be rolling through Django like it's
> building sprites on a Commodore 64.
>
> So, I have four tables. Book, Publisher, Author and Review. A classic
> scenario.
> I want to display a loop on the home page showing all Reviews, display
> the Book.Title, Publisher.Name and Author.Name(s) among other things.
> One thing to note is, Publisher, Author, Book live in the 'books' APP
> and Review lives in the 'reviews' APP.
>
> Am keen to hear how to create a view and a template to display all of
> this linked data in one set.


A simple way would be to use:

#views.py:
reviews = Review.objects.all()

#template:

{% for r in reviews %}
{{ r.item.title }}, {{ r.item.publisher.name }}
{% for author in r.item.authors %}
{{ author.name }}
{% endfor %}
{% endfor %}

but that would create a lot of queries (1 for all Reviews + 3 per Review).

I don't know if it is possible, but maybe you could annotate [1] your
reviews with the associated values through the F() object [2] ? Just a wild
guess...

[1]
http://docs.djangoproject.com/en/dev/ref/models/querysets/#annotate-args-kwargs
[2]
http://docs.djangoproject.com/en/dev/topics/db/queries/#filters-can-reference-fields-on-the-model

>
> Here are the models for each:
>
> class Publisher(models.Model):
>name = models.CharField(max_length=120)
>
> class Author(models.Model):
>name = models.CharField(max_length=120)
>
> class Book(models.Model):
>title = models.CharField(max_length=120)
>publication_date = models.DateField(blank=True, null=True)
>authors = models.ManyToManyField(Author)
>publisher = models.ForeignKey(Publisher)
>
> class Review(models.Model):
>pream = models.TextField(blank=True)
>body = models.TextField()
>item = models.ForeignKey('books.Book')
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: postgres schemas and django admin

2009-07-01 Thread Unnamed_Hero


> and you have 'django.contrib.admin' under INSTALLED_APPS, right?

Yes, I have.

I've also tried http://code.djangoproject.com/ticket/1051
and patch django/db/backends/postgresql_psycopg2/base.py with code in
http://code.djangoproject.com/attachment/ticket/1051/ticket_1051_rev6669.diff
but I'm getting another error - "schema 'o' doesn't exist "
(I put "DATABASE_SCHEMAS='odb'" in my settings.py)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to set up site admin page for my application

2009-07-01 Thread Damudar


Hi All,

I am trying to setup admin page for one of my application.

I have followed the following instruction from the Django admin site
document.

*) Set up page for gnats-admins to manage SitePrefs values.

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#ref-contrib-admin

1. settings.py:

# Add 'django.contrib.admin' to INSTALLED_APPS.

2. web/admin.py:

from django.contrib import admin
from gnatsweb.config import table

admin.site.register(table)

3. urls.py:

from django.contrib import admin

admin.autodiscover()

# Add admin page url pattern.
= patterns('',
   ('^admin/', include(admin.site.urls)),
)

Additionally I have commentated this line from urls.py:

   # Uncomment this for admin:
(r'^admin/', include('django.contrib.admin.urls')),

Please help me to know, what I am missing here?

My application URL to access the site is
"http://server-name:1020/web/database/

In this case what will be my admin site URL?

Is this correct?
http://server-name:1020/web/admin/

Any help will be highly appreciated.

Thanks,
-- 
View this message in context: 
http://www.nabble.com/How-to-set-up-site-admin-page-for-my-application-tp24290065p24290065.html
Sent from the django-users mailing list archive at Nabble.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
-~--~~~~--~~--~--~---



PostgreSQL 8.4 released

2009-07-01 Thread Joshua D. Drake

Hey folks,

Thought I would let you know this little wonderful tidbit for the day.
PostgreSQL 8.4 has been released. You can check out the release here:

http://www.postgresql.org/about/news.1108

Joshua D. Drake
-- 
PostgreSQL - XMPP: jdr...@jabber.postgresql.org
   Consulting, Development, Support, Training
   503-667-4564 - http://www.commandprompt.com/
   The PostgreSQL Company, serving since 1997


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: PyDev users: how do you manage tabs?

2009-07-01 Thread AmanKow

> I have the same problem in Komodo Edit - although I the whole filename
> does show up in the window title I never think to look there. Anyway,
> I partially solved it by adding a comment at the top of the file for
> what app the file is for, so I'll see what I'm working on right there
> in the editor window.
>
> On Jul 1, 11:41 am, Steve Howell  wrote:
>
> > On Jun 30, 10:42 pm, Rex  wrote:
>
> > > Kind of a petty question:
>
> > > I've been using PyDev to do my Django work and find it to be great.
> > > However, my only gripe is that it's hard to keep track of tabs, since
> > > they display only the (non-qualified) file name, which is a problem
> > > given Django's very regular naming scheme. So for example I'll often
> > > have 4+ tabs that are all named "views.py", and I have to mouse over
> > > each to find which one is the one I'm looking for.
>
> > I definitely feel your pain.
>
> > One thing that you can do is put view code into files that are not
> > called "views.py."  It's always a little risky to break the convention
> > here, but I have done it in on nontrivial projects without major
> > hangups.
>
> > On the other hand I don't think you want to mess with conventions on
> > models.py and certain other files, but I tend to spend less time
> > editing those.

http://traviscline.com/blog/2008/04/30/komodo-tab-macro-to-ease-django-development-in-komodo/

There are ways to get the behavior you want in Komodo!

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



How to write to the history

2009-07-01 Thread mettwoch

Hi group,

What would be a good way to log changes made to models from outside
the admin interface?

Thanks for any hint

Marc
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: PyDev users: how do you manage tabs?

2009-07-01 Thread Chris Lawlor

I have the same problem in Komodo Edit - although I the whole filename
does show up in the window title I never think to look there. Anyway,
I partially solved it by adding a comment at the top of the file for
what app the file is for, so I'll see what I'm working on right there
in the editor window.

On Jul 1, 11:41 am, Steve Howell  wrote:
> On Jun 30, 10:42 pm, Rex  wrote:
>
> > Kind of a petty question:
>
> > I've been using PyDev to do my Django work and find it to be great.
> > However, my only gripe is that it's hard to keep track of tabs, since
> > they display only the (non-qualified) file name, which is a problem
> > given Django's very regular naming scheme. So for example I'll often
> > have 4+ tabs that are all named "views.py", and I have to mouse over
> > each to find which one is the one I'm looking for.
>
> I definitely feel your pain.
>
> One thing that you can do is put view code into files that are not
> called "views.py."  It's always a little risky to break the convention
> here, but I have done it in on nontrivial projects without major
> hangups.
>
> On the other hand I don't think you want to mess with conventions on
> models.py and certain other files, but I tend to spend less time
> editing those.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: dynamic settings through script

2009-07-01 Thread Michel Thadeu Sabchuk

Hi Tino,

> Wouldn't it be easier to create a 'lock-file'? Have your middelware check
> for the lock file, if it's present, block access, if not, do nothing.

You are right, a lock file is easier, thanks for pointing me at that.

Anyway, I want to use the settings file instead of a lock file,
suppose I have too much hits during the lock time, there will be too
much access to hard disk, but with settings, these accesses will be on
the RAM...

Thanks again!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: PyDev users: how do you manage tabs?

2009-07-01 Thread Steve Howell


On Jun 30, 10:42 pm, Rex  wrote:
> Kind of a petty question:
>
> I've been using PyDev to do my Django work and find it to be great.
> However, my only gripe is that it's hard to keep track of tabs, since
> they display only the (non-qualified) file name, which is a problem
> given Django's very regular naming scheme. So for example I'll often
> have 4+ tabs that are all named "views.py", and I have to mouse over
> each to find which one is the one I'm looking for.
>

I definitely feel your pain.

One thing that you can do is put view code into files that are not
called "views.py."  It's always a little risky to break the convention
here, but I have done it in on nontrivial projects without major
hangups.

On the other hand I don't think you want to mess with conventions on
models.py and certain other files, but I tend to spend less time
editing those.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: postgres schemas and django admin

2009-07-01 Thread Miguel Rodriguez

and you have 'django.contrib.admin' under INSTALLED_APPS, right?


On Jul 1, 6:58 am, Unnamed_Hero  wrote:
> > this only fails for admin? are the models being written to the database?
>
> Yes, it is.
> I have a database already filled with data. For fetching data I
> specify a class Meta with a db_name='"db_schema'.'db'" in my models.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Internationalization in django and search engine indexing

2009-07-01 Thread Miguel Rodriguez

cool.
Glad to hear it solved your problem.

On Jun 30, 12:07 pm, Olivier  wrote:
> I've integrated it and it seems to work fine.
> If people are interested in an example of localeurl, you can 
> checkwww.spiderchallenge.com(just switch language at the bottom of the
> sidebar)
> We will see if google like it, it mights take some time but my
> sitemap.xml is ready ;)
> Thanks for the help,
>
> Olivier
>
> On 24 juin, 14:32, Olivier  wrote:
>
> > ThanksMiguel,
>
> > It seems that it does what I want, I will try it !
> > I'm using django on Google App Engine (with app engine patch) which
> > use differents data models, do you think it will still work ?
>
> > Cheers,
> > Olivier
>
> > On 24 juin, 12:30, Kenneth Gonsalves  wrote:
>
> > > On Wednesday 24 June 2009 13:56:49MiguelRodriguez wrote:
>
> > > > You can check an example of how your urls will look once is
> > > > implemented in here: http:\\jaratech.com
>
> > > the '\\' did not get converted to '//' ;-)
> > > --
> > > regards
> > > kghttp://lawgon.livejournal.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
-~--~~~~--~~--~--~---



Display Data From Multiple Tables

2009-07-01 Thread The Danny Bos

Hi there,

Seems easy, but I'm having an ass of a time. I think once I wrap my
head around how to do this, I'll be rolling through Django like it's
building sprites on a Commodore 64.

So, I have four tables. Book, Publisher, Author and Review. A classic
scenario.
I want to display a loop on the home page showing all Reviews, display
the Book.Title, Publisher.Name and Author.Name(s) among other things.
One thing to note is, Publisher, Author, Book live in the 'books' APP
and Review lives in the 'reviews' APP.

Am keen to hear how to create a view and a template to display all of
this linked data in one set.
Here are the models for each:

class Publisher(models.Model):
name = models.CharField(max_length=120)

class Author(models.Model):
name = models.CharField(max_length=120)

class Book(models.Model):
title = models.CharField(max_length=120)
publication_date = models.DateField(blank=True, null=True)
authors = models.ManyToManyField(Author)
publisher = models.ForeignKey(Publisher)

class Review(models.Model):
pream = models.TextField(blank=True)
body = models.TextField()
item = models.ForeignKey('books.Book')

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Will future Django releases support multiple databases?

2009-07-01 Thread Emily Rodgers



On Jul 1, 3:44 pm, Alex Gaynor  wrote:
> On Wed, Jul 1, 2009 at 9:39 AM, Emily Rodgers <
>
>
>
> emily.kate.rodg...@googlemail.com> wrote:
>
> > On Jul 1, 3:22 pm, Alex Gaynor  wrote:
> > > On Wed, Jul 1, 2009 at 9:16 AM, Emily Rodgers <
>
> > > emily.kate.rodg...@googlemail.com> wrote:
>
> > > > On Jun 25, 6:45 pm, Alex Gaynor  wrote:
> > > > > On Thu, Jun 25, 2009 at 10:24 AM, Tim Chase
> > > > > wrote:
> > > > > > > Right now, Django doesn't seem to support the multiple
> > > > > > > databases on the same server or different servers.  Will that
> > > > > > > feature be available out of the box for future releases?
>
> > > > > > You may want to eavesdrop on the Django Developers group (as
> > > > > > opposed to this Django Users group) where Alex Gaynor has been
> > > > > > posting updates on his GSoC project to add multi-DB support to
> > > > > > Django[1].  There are several aspects to multi-DB support[2] but
> > > > > > I believe he's addressing some of the more common use-cases.  You
> > > > > > can even follow along if you like to live dangerously as I
> > > > > > believe he's got a public repository for his code on GitHub.
>
> > > > > > -tim
>
> > > > > > [1]
>
> >http://groups.google.com/group/django-developers/search?group=django-.
> > > > ..
>
> > > > > > [2]
>
> >http://groups.google.com/group/django-users/browse_thread/thread/6630.
> > > > ..
> > > > > > for my posted concerns
>
> > > > > I have both a public code repository on github at
> > > > github.com/alex/django/ as
> > > > > well as a branch in Django's SVN at branches/soc2009/multidb.  The
> > best
> > > > > place to find out about the work is the django-developers list, where
> > I
> > > > have
> > > > > sent any number of emails discussing both the overall design, as well
> > as
> > > > the
> > > > > status.
>
> > > > > Alex
>
> > > > > --
> > > > > "I disapprove of what you say, but I will defend to the death your
> > right
> > > > to
> > > > > say it." --Voltaire
> > > > > "The people's good is the highest law."--Cicero
>
> > > > Hi,
>
> > > > Alex - do you know roughly when this is likely to be incorporated into
> > > > django? I am working on a project that is going to need to connect to
> > > > multiple databases (I am just planning / designing at the moment), and
> > > > I want to know whether I should start investigating how to do this
> > > > using django 1.0.2 or if that would be a waste of my time.
>
> > > > If it is going to be a while, where would you suggest I start looking
> > > > if I need to understand how to do it with django 1.0.2?
>
> > > > Cheers,
> > > > Em
>
> > > It will, at a minimum not occur until the end of the summer.  Beyond that
> > I
> > > can't make any really useful guesses, other than to say that the
> > aggregation
> > > GSOC project from last summer
> > > ultimately made it's way into django trunk in January, about 3-4 months
> > > after the official end of GSOC.  That may or may not ultimately be
> > > representative of how long it will take multi-db to make it's way back
> > into
> > > Django.  A lot of it probably depends on how the 1.2/1.3 releases are
> > > scheduled.  For example is 1.2 ends up being a smaller release that's put
> > > out in Novemberish I wouldn't expect multi-db to be considered for trunk
> > > until 1.3.  Like I said all of that's rather speculative :)
>
> > > Alex
> > > --
> > > "I disapprove of what you say, but I will defend to the death your right
> > to
> > > say it." --Voltaire
> > > "The people's good is the highest law."--Cicero
>
> > Thanks Alex. I don't think I can wait that long so it looks like I am
> > going to have to get my hands dirty!
>
> > Is this [1] a sensible starting point?
>
> > [1]
> >http://www.mechanicalgirl.com/view/multiple-database-connection-a-sim...
>
> That blog post is a good source of information, as 
> is:http://www.eflorenzano.com/blog/post/easy-multi-database-support-djan...
> unfortunately appears to be down right now).
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero

Thanks - it is great that you are working on this because it is one of
the few things that I find a little frustrating about django
(otherwise I am a big fan and often bore my co-workers who prefer to
code in perl - strange people).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Is IP address caching built into the Django Framework?

2009-07-01 Thread links_awakening

Thanks for sharing this knowledge.  It sounds like my best option
would be to cache IP addresses and use some sort of heuristics to
detect odd voting patterns.

On Jun 29, 7:26 am, James  wrote:
> On Jun 29, 8:13 am, Vladimir Shulyak  wrote:
>
> > > You can't rely on just theIP. If you do then you will have problems
> > > where large numbers of people sit behind a singleIP, as will be case
> > > where corporate firewall is used, or where proxies or other gateway or
> > > NAT solution are used by ISPs.
>
> > That's right, try to use cookie check instead ofIPcheck.
>
> Except cookies are very easy to fake  it depends on how serious
> you want your voting to be; whether you could tolerate a little
> hacking or not.
>
> http://stackoverflow.com/questions/1042580/best-way-to-store-views-of...
> Is a discussion on this in mysql/php but the general principles are
> the same.
>
> Basically,IPaddr is the only thing it's really hard to play around
> with - user-agent, cookie, everything else is fakable with ease. But
> if you useIPaddr only then 2 people sharing the sameIPaddress
> (different computers on the same broadband connection, etc) can only
> vote once. It's a problem.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: issue with django.views.generic.date_based.archive_index's date_list

2009-07-01 Thread Seth Buntin

Karen,

That makes total sense.  I really missed the verbiage there.

Thanks.

On Jun 30, 10:34 pm, Karen Tracey  wrote:
> On Tue, Jun 30, 2009 at 1:55 PM, Seth Buntin  wrote:
>
> > I'm having an issue with the date_based generic views archive_index.
> > I am expecting the context to return a date_list with datetime
> > instances of the years specified in my queryset.
>
> > The problem is my queryset doesn't return what I am expecting.  The
> > queryset only has one instance and it has a datefield values of June
> > 6, 2009 the only date object I get in date_list is an object for
> > January 1, 2009. Any ideas on what might be causing this?
>
> This is what I'd expect base on the documentation.
>
> http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-...
>
> says date_list is "A list of datetime.date objects representing all years
> that have objects available according to queryset. These are ordered in
> reverse. This is equivalent to queryset.dates(date_field, 'year')[::-1]."
>
> Looking up queryset.date 
> (http://docs.djangoproject.com/en/dev/ref/models/querysets/#dates-fiel...),
> when you specify kind as "year", it says what will be generated is a list of
> all distinct year values for the field.  The example for kind="year" shows
> datetime.date value of Jan 1 for the single year in the example set (the
> full set in the example has multiple dates in the same year).
>
> Note the only significant value in the datetimes returned is the year, but
> the month and day have to have values set to something (since Python doesn't
> support a datetime.date with only the year part specified), so they are
> arbitrarily set to 1 and 1.  This does not mean there is necessarily any
> instance in the queryset that has that exact date, it simply means there is
> at least one (perhaps more) instance within the queryset with a date in that
> year.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Will future Django releases support multiple databases?

2009-07-01 Thread Alex Gaynor
On Wed, Jul 1, 2009 at 9:39 AM, Emily Rodgers <
emily.kate.rodg...@googlemail.com> wrote:

>
>
>
> On Jul 1, 3:22 pm, Alex Gaynor  wrote:
> > On Wed, Jul 1, 2009 at 9:16 AM, Emily Rodgers <
> >
> >
> >
> > emily.kate.rodg...@googlemail.com> wrote:
> >
> > > On Jun 25, 6:45 pm, Alex Gaynor  wrote:
> > > > On Thu, Jun 25, 2009 at 10:24 AM, Tim Chase
> > > > wrote:
> > > > > > Right now, Django doesn't seem to support the multiple
> > > > > > databases on the same server or different servers.  Will that
> > > > > > feature be available out of the box for future releases?
> >
> > > > > You may want to eavesdrop on the Django Developers group (as
> > > > > opposed to this Django Users group) where Alex Gaynor has been
> > > > > posting updates on his GSoC project to add multi-DB support to
> > > > > Django[1].  There are several aspects to multi-DB support[2] but
> > > > > I believe he's addressing some of the more common use-cases.  You
> > > > > can even follow along if you like to live dangerously as I
> > > > > believe he's got a public repository for his code on GitHub.
> >
> > > > > -tim
> >
> > > > > [1]
> >
> > > > >
> http://groups.google.com/group/django-developers/search?group=django-.
> > > ..
> >
> > > > > [2]
> >
> > > > >
> http://groups.google.com/group/django-users/browse_thread/thread/6630.
> > > ..
> > > > > for my posted concerns
> >
> > > > I have both a public code repository on github at
> > > github.com/alex/django/ as
> > > > well as a branch in Django's SVN at branches/soc2009/multidb.  The
> best
> > > > place to find out about the work is the django-developers list, where
> I
> > > have
> > > > sent any number of emails discussing both the overall design, as well
> as
> > > the
> > > > status.
> >
> > > > Alex
> >
> > > > --
> > > > "I disapprove of what you say, but I will defend to the death your
> right
> > > to
> > > > say it." --Voltaire
> > > > "The people's good is the highest law."--Cicero
> >
> > > Hi,
> >
> > > Alex - do you know roughly when this is likely to be incorporated into
> > > django? I am working on a project that is going to need to connect to
> > > multiple databases (I am just planning / designing at the moment), and
> > > I want to know whether I should start investigating how to do this
> > > using django 1.0.2 or if that would be a waste of my time.
> >
> > > If it is going to be a while, where would you suggest I start looking
> > > if I need to understand how to do it with django 1.0.2?
> >
> > > Cheers,
> > > Em
> >
> > It will, at a minimum not occur until the end of the summer.  Beyond that
> I
> > can't make any really useful guesses, other than to say that the
> aggregation
> > GSOC project from last summer
> > ultimately made it's way into django trunk in January, about 3-4 months
> > after the official end of GSOC.  That may or may not ultimately be
> > representative of how long it will take multi-db to make it's way back
> into
> > Django.  A lot of it probably depends on how the 1.2/1.3 releases are
> > scheduled.  For example is 1.2 ends up being a smaller release that's put
> > out in Novemberish I wouldn't expect multi-db to be considered for trunk
> > until 1.3.  Like I said all of that's rather speculative :)
> >
> > Alex
> > --
> > "I disapprove of what you say, but I will defend to the death your right
> to
> > say it." --Voltaire
> > "The people's good is the highest law."--Cicero
>
> Thanks Alex. I don't think I can wait that long so it looks like I am
> going to have to get my hands dirty!
>
> Is this [1] a sensible starting point?
>
> [1]
> http://www.mechanicalgirl.com/view/multiple-database-connection-a-simple-use-case/
>
> >
>
That blog post is a good source of information, as is:
http://www.eflorenzano.com/blog/post/easy-multi-database-support-django/(which
unfortunately appears to be down right now).

Alex

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

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



Re: dynamic settings through script

2009-07-01 Thread TiNo
Wouldn't it be easier to create a 'lock-file'? Have your middelware check
for the lock file, if it's present, block access, if not, do nothing.

This is at least how some programs do their locks (Adobe Creative suite for
example) and quite easy to implement.

Tino

On Wed, Jul 1, 2009 at 16:34, Michel Thadeu Sabchuk wrote:

>
> Hi guys,
>
> I need to block access to my site during a time period, when a script
> is running and do some calculations. I want to avoid user interaction
> during this calculations, this is why I want to block access to the
> site when the script starts and liberate when the script ends.
>
> First of all, I think on change the apache configuration and restart
> it when start the script, but I want to simple it and just check a
> parameter on the settings.py, direct on django.
>
> I created a middleware that make this thing and it works if the
> settings parameter changes. The problem now is: how to change the
> settings parameter through the script outside of django?
>
> I try to import the settings and change the parameter but the site
> don't see the change. Is this possible or I need to find another way?
>
> Thanks 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: Will future Django releases support multiple databases?

2009-07-01 Thread Emily Rodgers



On Jul 1, 3:22 pm, Alex Gaynor  wrote:
> On Wed, Jul 1, 2009 at 9:16 AM, Emily Rodgers <
>
>
>
> emily.kate.rodg...@googlemail.com> wrote:
>
> > On Jun 25, 6:45 pm, Alex Gaynor  wrote:
> > > On Thu, Jun 25, 2009 at 10:24 AM, Tim Chase
> > > wrote:
> > > > > Right now, Django doesn't seem to support the multiple
> > > > > databases on the same server or different servers.  Will that
> > > > > feature be available out of the box for future releases?
>
> > > > You may want to eavesdrop on the Django Developers group (as
> > > > opposed to this Django Users group) where Alex Gaynor has been
> > > > posting updates on his GSoC project to add multi-DB support to
> > > > Django[1].  There are several aspects to multi-DB support[2] but
> > > > I believe he's addressing some of the more common use-cases.  You
> > > > can even follow along if you like to live dangerously as I
> > > > believe he's got a public repository for his code on GitHub.
>
> > > > -tim
>
> > > > [1]
>
> > > >http://groups.google.com/group/django-developers/search?group=django-.
> > ..
>
> > > > [2]
>
> > > >http://groups.google.com/group/django-users/browse_thread/thread/6630.
> > ..
> > > > for my posted concerns
>
> > > I have both a public code repository on github at
> > github.com/alex/django/ as
> > > well as a branch in Django's SVN at branches/soc2009/multidb.  The best
> > > place to find out about the work is the django-developers list, where I
> > have
> > > sent any number of emails discussing both the overall design, as well as
> > the
> > > status.
>
> > > Alex
>
> > > --
> > > "I disapprove of what you say, but I will defend to the death your right
> > to
> > > say it." --Voltaire
> > > "The people's good is the highest law."--Cicero
>
> > Hi,
>
> > Alex - do you know roughly when this is likely to be incorporated into
> > django? I am working on a project that is going to need to connect to
> > multiple databases (I am just planning / designing at the moment), and
> > I want to know whether I should start investigating how to do this
> > using django 1.0.2 or if that would be a waste of my time.
>
> > If it is going to be a while, where would you suggest I start looking
> > if I need to understand how to do it with django 1.0.2?
>
> > Cheers,
> > Em
>
> It will, at a minimum not occur until the end of the summer.  Beyond that I
> can't make any really useful guesses, other than to say that the aggregation
> GSOC project from last summer
> ultimately made it's way into django trunk in January, about 3-4 months
> after the official end of GSOC.  That may or may not ultimately be
> representative of how long it will take multi-db to make it's way back into
> Django.  A lot of it probably depends on how the 1.2/1.3 releases are
> scheduled.  For example is 1.2 ends up being a smaller release that's put
> out in Novemberish I wouldn't expect multi-db to be considered for trunk
> until 1.3.  Like I said all of that's rather speculative :)
>
> Alex
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero

Thanks Alex. I don't think I can wait that long so it looks like I am
going to have to get my hands dirty!

Is this [1] a sensible starting point?

[1] 
http://www.mechanicalgirl.com/view/multiple-database-connection-a-simple-use-case/

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



dynamic settings through script

2009-07-01 Thread Michel Thadeu Sabchuk

Hi guys,

I need to block access to my site during a time period, when a script
is running and do some calculations. I want to avoid user interaction
during this calculations, this is why I want to block access to the
site when the script starts and liberate when the script ends.

First of all, I think on change the apache configuration and restart
it when start the script, but I want to simple it and just check a
parameter on the settings.py, direct on django.

I created a middleware that make this thing and it works if the
settings parameter changes. The problem now is: how to change the
settings parameter through the script outside of django?

I try to import the settings and change the parameter but the site
don't see the change. Is this possible or I need to find another way?

Thanks 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: Will future Django releases support multiple databases?

2009-07-01 Thread Alex Gaynor
On Wed, Jul 1, 2009 at 9:16 AM, Emily Rodgers <
emily.kate.rodg...@googlemail.com> wrote:

>
>
>
> On Jun 25, 6:45 pm, Alex Gaynor  wrote:
> > On Thu, Jun 25, 2009 at 10:24 AM, Tim Chase
> > wrote:
> > > > Right now, Django doesn't seem to support the multiple
> > > > databases on the same server or different servers.  Will that
> > > > feature be available out of the box for future releases?
> >
> > > You may want to eavesdrop on the Django Developers group (as
> > > opposed to this Django Users group) where Alex Gaynor has been
> > > posting updates on his GSoC project to add multi-DB support to
> > > Django[1].  There are several aspects to multi-DB support[2] but
> > > I believe he's addressing some of the more common use-cases.  You
> > > can even follow along if you like to live dangerously as I
> > > believe he's got a public repository for his code on GitHub.
> >
> > > -tim
> >
> > > [1]
> >
> > >http://groups.google.com/group/django-developers/search?group=django-.
> ..
> >
> > > [2]
> >
> > >http://groups.google.com/group/django-users/browse_thread/thread/6630.
> ..
> > > for my posted concerns
> >
> > I have both a public code repository on github at
> github.com/alex/django/ as
> > well as a branch in Django's SVN at branches/soc2009/multidb.  The best
> > place to find out about the work is the django-developers list, where I
> have
> > sent any number of emails discussing both the overall design, as well as
> the
> > status.
> >
> > Alex
> >
> > --
> > "I disapprove of what you say, but I will defend to the death your right
> to
> > say it." --Voltaire
> > "The people's good is the highest law."--Cicero
>
> Hi,
>
> Alex - do you know roughly when this is likely to be incorporated into
> django? I am working on a project that is going to need to connect to
> multiple databases (I am just planning / designing at the moment), and
> I want to know whether I should start investigating how to do this
> using django 1.0.2 or if that would be a waste of my time.
>
> If it is going to be a while, where would you suggest I start looking
> if I need to understand how to do it with django 1.0.2?
>
> Cheers,
> Em
>
> >
>
It will, at a minimum not occur until the end of the summer.  Beyond that I
can't make any really useful guesses, other than to say that the aggregation
GSOC project from last summer
ultimately made it's way into django trunk in January, about 3-4 months
after the official end of GSOC.  That may or may not ultimately be
representative of how long it will take multi-db to make it's way back into
Django.  A lot of it probably depends on how the 1.2/1.3 releases are
scheduled.  For example is 1.2 ends up being a smaller release that's put
out in Novemberish I wouldn't expect multi-db to be considered for trunk
until 1.3.  Like I said all of that's rather speculative :)

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

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



Re: Will future Django releases support multiple databases?

2009-07-01 Thread Emily Rodgers



On Jun 25, 6:45 pm, Alex Gaynor  wrote:
> On Thu, Jun 25, 2009 at 10:24 AM, Tim Chase
> wrote:
> > > Right now, Django doesn't seem to support the multiple
> > > databases on the same server or different servers.  Will that
> > > feature be available out of the box for future releases?
>
> > You may want to eavesdrop on the Django Developers group (as
> > opposed to this Django Users group) where Alex Gaynor has been
> > posting updates on his GSoC project to add multi-DB support to
> > Django[1].  There are several aspects to multi-DB support[2] but
> > I believe he's addressing some of the more common use-cases.  You
> > can even follow along if you like to live dangerously as I
> > believe he's got a public repository for his code on GitHub.
>
> > -tim
>
> > [1]
>
> >http://groups.google.com/group/django-developers/search?group=django-...
>
> > [2]
>
> >http://groups.google.com/group/django-users/browse_thread/thread/6630...
> > for my posted concerns
>
> I have both a public code repository on github at github.com/alex/django/ as
> well as a branch in Django's SVN at branches/soc2009/multidb.  The best
> place to find out about the work is the django-developers list, where I have
> sent any number of emails discussing both the overall design, as well as the
> status.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero

Hi,

Alex - do you know roughly when this is likely to be incorporated into
django? I am working on a project that is going to need to connect to
multiple databases (I am just planning / designing at the moment), and
I want to know whether I should start investigating how to do this
using django 1.0.2 or if that would be a waste of my time.

If it is going to be a while, where would you suggest I start looking
if I need to understand how to do it with django 1.0.2?

Cheers,
Em

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 Search Form in Admin

2009-07-01 Thread Alessandro Ronchi

Given a simple model, I need to write a search form in admin (not the
text search inside admin model list).

It's the same as a form.as_table() but inside admin.

Is it possible?

Any working example?

I also need to insert a button with a link to export the result
queryset to Excel or PDF. (a simple link pointing to a view sending
the search form filled as POST).

Must I write a new app outside the admin?

-- 
Alessandro Ronchi

SOASI
Sviluppo Software e Sistemi Open Source
http://www.soasi.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: serving a static file via nginx requiring authentication from django

2009-07-01 Thread Annie

See, I knew it was probably something simple that I'd missed because
I'd been looking at this for too long. *g* I changed the PROTECTED_DIR
to '/media/books/' to match what I had in my nginx.conf and changed
the response['X-Accel-Redirect'] to filename in views.py and it works
perfectly now. (I thought I'd tried that variation of the location,
but it must've been earlier before I actually had the rest of it
working. *g*) Thanks, John!

I'll write this all up in full shortly on my blog
(herself.movielady.net), as I had a hard time finding detailed info
that combined this particular combination of software. :)

Thanks for the help, folks -
Annie


On Jun 29, 11:00 pm, John Hensley  wrote:
> On 6/28/09 10:20 PM, Annie wrote:
>
> > I'm trying to this to work: users can download their files from their
> > account page from a url like 
> > this:http://example.com/account/download/a1234565789asedga-2/
> > for which django processes the authentication and then passes along
> > the info to nginx to serve the file.
>
> [...]
>
>
>
> > Here are the relevant bits of code:
>
> > # part of the views.py
>
> > def download_file(request, dlkey=None, ftype=None):
> >  if request.user.is_authenticated():
> >  try:
> >  k = Ebook.objects.select_related().filter
> > (ftype__exact=ftype).filter
> > (book__orderdetail__dlkey__exact=dlkey).filter
> > (book__orderdetail__medium__exact='E')[:1]
> >  for e in k:
> >  ebook = e.ebook
> >  filename = os.path.join(PROTECTED_DIR, os.path.basename
> > (ebook))
> >  response = HttpResponse()
> >  response['X-Accel-Redirect'] = ebook
> >  response['Content-Disposition'] =
> > "attachment;filename=" + ebook
> >  return response
> >  except Exception:
> >  raise Http404
>
> > # part of the nginx configuration for the domain:
>
> >  location ^~ /account/download/ {
> >  include /etc/nginx/
> > fastcgi_params_django;
> >  fastcgi_pass127.0.0.1:1024;
> >  alias   /home/me/web/example.com/
> > public/media/books/;
> >  }
>
> >  location ^~ /media/books/ {
> >  root/home/me/web/example.com/
> > public;
> >  internal;
> >  }
>
> [...]
>
> > [1]http://wiki.nginx.org/NginxXSendfile
>
> I think the answer's in that document, actually. The value of
> X-Accel-Redirect should be your internal location's URL
> ('/media/books/') plus your filename (os.path.basename(ebook), in your
> view). Nginx will deliver
> /home/me/web/example.com/public/media/books/ebook-basename.pdf.
>
> 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: Django 1.0.2 Thread safety

2009-07-01 Thread Karen Tracey
On Wed, Jul 1, 2009 at 9:38 AM, Miles  wrote:

>
> On Jun 30, 8:10 am, Thomas Guettler  wrote:
> > Hi,
> >
> > I hit this bug some time ago, too. If you run SVN 1.0.X you get the
> > bug fixes for free.
> >
> >   Thomas
>
> Yeah, but then you have to test your releases really carefully on each
> svn up - not every commit has gone through a complete test run, as
> 10036 shows, up to 10039, those Django versions won't even start.
>

That's pretty rare, and such problems are usually noted and fixed pretty
quickly.  Here it looks like it took about half an hour.


>
> Slightly off topic: when is 1.0.3 scheduled for? There have been quite
> a few commits in the 1.0.x branch since 1.0.2, bugfixes only, if there
> aren't any problems it would be nice to have a tested release to
> upgrade to.
>

About the same time as 1.1.

Karen

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



Re: How to filter out posts from friends?

2009-07-01 Thread Mathieu Leplatre

On 1 juil, 14:44, coan  wrote:
> I have a friendship model for users and want to retrieve all the posts
> my friends made.
>
> class Friendship(models.Model):
>  from_friend = models.ForeignKey( User, related_name='friend_set' )
>  to_friend = models.ForeignKey( User, related_name='to_friend_set' )
>
> class Post(models.Model):
>  text = models.TextField()
>  user = models.ForeignKey(User)
>
> I retrieve my friends posts with this:
>
> my_friendships = Friendship.objects.filter(from_friend=request.user)
> list_of_my_friends_ids = []
>
> for friendship in my_friendships:
>  list_of_my_friends_ids.append(friendship.to_friend.id)
>
> posts_my_friends_made = Post.objects.filter( user__in =
> list_of_my_friends_ids )
>
> Is there a better, less ugly way to filter the posts?

I don't know what Django can do here, but with Python you can do :
friends_ids = [ f.to_friend.id for f in Friendship.objects.filter
(from_friend=request.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: how to select resultset by foreignkey `s attribute

2009-07-01 Thread Gabriel .

2009/7/1 newlife :
>
> class company(models.Model):
>on=models.BooleanField()
> class work(models.Model):
>company=models.ForeignKey
> (company,related_name='vote_company',)
>
>  
>  
>
> how can I get the works those company.on is true??

work.objects.filter(company__on=True)

The django documentation is a good place to look at
(http://docs.djangoproject.com/en/dev/topics/db/queries/#lookups-that-span-relationships)

-- 
Kind Regards

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



Catch an IntegrityError in views to get back pk value of prexisting model

2009-07-01 Thread Frédéric Hébert

Hello,

 I 'm  working on a prexisting application which goal is to manage
courses and to link them to categories, teachers and so on...

 I have to rewrite a view. In this view, the third of the overall
process, users link their course to at least one teacher. The point
here is that there is no concept of (teacher) account neither a way to
retrieve a prexisting teacher from the DB. For example, lets say that
a teacher A has filled in his information for one course, and two
weeks after he wants to fill in again information about another
course. At this time, there is no way to him to retrieve

 At this time, in order to avoid duplicate rows in teacher table, a
hack has been setted up :

(here : Enseignant means Teacher and ue means course , it's in french)

 --- CODE --

@user_passes_test(lambda u: u.has_perm('Baobab_2009.add_ue'))
def ue_enseignants(request, annee_id, ue_id):
"""
Formulaire de saisie des enseignants d'une UE
"""
# TODO: essayer de ne pas créer de doublons Enseignant (nom,
prénom, qualité, ...)
# avant d'enregistrer (sur un POST), essayer de rechercher les
enseignants ayant le même nom, prénom, qualité
# et de remplacer par l'ID trouvé
anneeuniv = get_object_or_404(AnneeUniversitaire, annee=annee_id)
ue = get_object_or_404(UE, pk=ue_id)

form1 = EnseignantForm()
form2 = EnseignantUEForm()

if request.method == 'POST':
new_data1 = request.POST.copy()
new_data2 = request.POST.copy()
# découper les données reçues avant la validation
# une partie pour enseignant (prenom, nom, qualite,
autre_qualite, hdr, retraite)
# une partie pour enseignantue (principal +ue, +enseignant)
if new_data1.has_key('principal'):
del new_data1['principal']
if new_data2.has_key('prenom'):
del new_data2['prenom']
if new_data2.has_key('nom'):
del new_data2['nom']
if new_data2.has_key('qualite'):
del new_data2['qualite']
if new_data2.has_key('autre_qualite'):
del new_data2['autre_qualite']
if new_data2.has_key('hdr'):
del new_data2['hdr']
if new_data2.has_key('retraite'):
del new_data2['retraite']

form1 = EnseignantForm(new_data1)

if form1.is_valid():
# recherche de doublons sur les enseignants
# rechercher un enseignant ayant même nom, prénom
#doublons = Enseignant.objects.filter(nom=new_data1
['nom']).filter(prenom=new_data1['prenom'])
# autre solution pour éliminer les doublons en conservant
la possibilité d'annualiser les qualités, tester sur tous les champs
Enseignant
doublons = []
try:
if new_data1['qualite']:
doublons = Enseignant.objects.filter(nom=new_data1
['nom'], prenom=new_data1['prenom'], qualite__id=int(new_data1
['qualite']), autre_qualite=new_data1['autre_qualite'], hdr=int
(new_data1['hdr']), retraite=int(new_data1['retraite']))
else:
doublons = Enseignant.objects.filter(nom=new_data1
['nom'], prenom=new_data1['prenom'], autre_qualite=new_data1
['autre_qualite'], hdr=int(new_data1['hdr']), retraite=int(new_data1
['retraite']))
except:
pass
if len(doublons) > 0:
# on a trouvé au moins un enseignant ayant même nom,
prénom
# prendre le premier de la liste des doublons
enseignant = doublons[0]
else:
# pas un doublon
# Pas d'erreurs pour l'enseignant, on peut
l'enregistrer
enseignant = form1.save()

# recherche de doublons
# récupérer ID enseignant créé ou récupéré pour le 2e
manipulateur
new_data2['enseignant'] = str(enseignant.id)
new_data2['ue'] = str(ue.id)
form2 = EnseignantUEForm(new_data2)
if form2.is_valid():
enseignantue =  form2.save()
# rediriger à la page d'édition
return HttpResponseRedirect('/ue/%i/enseignants/' %
ue.id)

form2 = EnseignantUEForm(new_data2)


return render_to_response('Baobab_2009/ue_enseignants_form.html',
{'form1': form1, 'form2': form2, 'ue': ue, 'anneeuniv': anneeuniv})

- CODE ---

 What I tried to do is a no less stupid hack : put an unique_together
constraint on the Enseignant model and catch a hypothetic
IntegrityError in the view.

With a from django.db import IntegrityError

 --- CODE -
  form1 = EnseignantForm()
  form2 = EnseignantUEForm()

if request.method == 'POST':
new_data1 = {}
new_data2 = {}
new_data1 = request.POST.copy()
new_data2.update(principal=new_data1.pop('principal', None))
form1 = EnseignantForm(new_data1)

if 

Re: Django 1.0.2 Thread safety

2009-07-01 Thread Miles

On Jun 30, 8:10 am, Thomas Guettler  wrote:
> Hi,
>
> I hit this bug some time ago, too. If you run SVN 1.0.X you get the
> bug fixes for free.
>
>   Thomas

Yeah, but then you have to test your releases really carefully on each
svn up - not every commit has gone through a complete test run, as
10036 shows, up to 10039, those Django versions won't even start.

Slightly off topic: when is 1.0.3 scheduled for? There have been quite
a few commits in the 1.0.x branch since 1.0.2, bugfixes only, if there
aren't any problems it would be nice to have a tested release to
upgrade to.

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



how to select resultset by foreignkey `s attribute

2009-07-01 Thread newlife

class company(models.Model):
on=models.BooleanField()
class work(models.Model):
company=models.ForeignKey
(company,related_name='vote_company',)

  
  

how can I get the works those company.on is true??


bow

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



How to filter out posts from friends?

2009-07-01 Thread coan


I have a friendship model for users and want to retrieve all the posts
my friends made.

class Friendship(models.Model):
 from_friend = models.ForeignKey( User, related_name='friend_set' )
 to_friend = models.ForeignKey( User, related_name='to_friend_set' )

class Post(models.Model):
 text = models.TextField()
 user = models.ForeignKey(User)

I retrieve my friends posts with this:

my_friendships = Friendship.objects.filter(from_friend=request.user)
list_of_my_friends_ids = []

for friendship in my_friendships:
 list_of_my_friends_ids.append(friendship.to_friend.id)

posts_my_friends_made = Post.objects.filter( user__in =
list_of_my_friends_ids )

Is there a better, less ugly way to filter the posts?

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



file extensions for templates

2009-07-01 Thread David De La Harpe Golden

Hi,

As far as I can see, django shouldn't care in the slightest about
template file name extensions, but being a django newbie, I could have
missed something (e.g. autosetting of a mime type somewhere based on
extension), so just to verify - it doesn't?

(considering moving to an extra file extension like .html.djt .txt.djt
etc. for django-templated files for my project, just to make picking an
appropriate editing mode easy)







--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Making a ManyToManyField to its own model?

2009-07-01 Thread Mathieu Leplatre

On 1 juil, 10:45, littlejim84  wrote:
> I'm new to Django, and I'm developing an project where I have an app
> called 'people' and a model inside called 'person'. The project itself
> is based around the idea of people connecting with each other... So, I
> as a person can connect to 3 other persons in the project, or any of
> those persons can connect with any other number of persons etc. So I
> do presume this should definitely be a ManyToManyField. But would I
> just pass the Person model as the ManyToManyField parameter inside the
> Person model? ... Is this the best way to do this, as it'll be many-to-
> many to itself?
>
> Hope this makes sense...
> Thanks

Indeed, it is a many-to-many to itself, you'll find examples in the
official doc:
http://www.djangoproject.com/documentation/models/m2m_recursive/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 cache framework not work well on mod_python of apache

2009-07-01 Thread Graham Dumpleton



On Jul 1, 7:22 pm, Hongyu Li  wrote:
> #!/usr/bin/env python
> # -*- coding: utf-8     -*-
> import xmlrpclib
> import os
> import sys
> import time
> import math
> import optparse
> import tm.filecheck
> import service
> from django.http import HttpResponse
> from django.core.cache import cache
>
> def getCategoryAndDetail(request):
>         keyword = request.GET.__getitem__('keyword' )
>         result1 = keyword + str(cache.has_key('SC_MAPPER'))
>         if not (cache.has_key('SC_MAPPER')):
>                 cache.set('SC_MAPPER','SC',9)
>         else:
>                 sc = cache.get('SC_MAPPER')
>         result2 = keyword + str(cache.has_key('SC_MAPPER'))
>         return HttpResponse(result1 + result2)
> before is my testing code.
> When I call this mothod by http, it should retrun false when I first visit,
> and return true all the other time, but it is not return true all time after
> I first visit. any one meeting the same problem?  this code is work well in
> local django development server.

Could it be because Apache is a multi process server on UNIX systems?

If this is changing per process state, then it will not affect other
concurrently running processes, so if subsequent requests go to a
different process, you will not see what you expect.

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



EveryBlock source code public

2009-07-01 Thread James Matthews
And we have another Django blog application! :)

http://blog.everyblock.com/2009/jun/30/source/

-- 
http://www.goldwatches.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
-~--~~~~--~~--~--~---



How to model a OneToMany relation to an abstract class ?

2009-07-01 Thread Mathieu Leplatre

Hi all,

I am trying to design the following model :
  - a checklist is a collection of checkpoints
  - a checkpoint can be an action, or a group of actions.
  - the same action can be in several groups

I read the Generic relations documentation :
http://www.djangoproject.com/documentation/models/generic_relations/

And also found this thread (but could not extract the essence of it) :
http://groups.google.com/group/django-users/browse_thread/thread/2ca173c9dd57980c/943765855107d2ac

Now, intuitively, I would do this :

class Checklist(models.Model):
description = models.CharField(max_length=512)
def __unicode__(self):
return self.description

class Checkpoint(models.Model):
list = models.ForeignKey(Checklist, null=True)
content_object = generic.GenericForeignKey()
class Meta:
abstract = True

class Action(Checkpoint):
documentation   = models.CharField(max_length=512)

class ActionGroup(Checkpoint):
actions = models.ManyToManyField(Action)

Is this relevant and djangonic ?
I would like to confirm this before struggling with automatic admin,
inlines, jquery etc.

Thank you for your support !

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 cache framework not work well on mod_python of apache

2009-07-01 Thread Hongyu Li
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import xmlrpclib
import os
import sys
import time
import math
import optparse
import tm.filecheck
import service
from django.http import HttpResponse
from django.core.cache import cache

def getCategoryAndDetail(request):
keyword = request.GET.__getitem__('keyword' )
result1 = keyword + str(cache.has_key('SC_MAPPER'))
if not (cache.has_key('SC_MAPPER')):
cache.set('SC_MAPPER','SC',9)
else:
sc = cache.get('SC_MAPPER')
result2 = keyword + str(cache.has_key('SC_MAPPER'))
return HttpResponse(result1 + result2)
before is my testing code.
When I call this mothod by http, it should retrun false when I first visit,
and return true all the other time, but it is not return true all time after
I first visit. any one meeting the same problem?  this code is work well in
local django development server.

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



Making a ManyToManyField to its own model?

2009-07-01 Thread littlejim84

I'm new to Django, and I'm developing an project where I have an app
called 'people' and a model inside called 'person'. The project itself
is based around the idea of people connecting with each other... So, I
as a person can connect to 3 other persons in the project, or any of
those persons can connect with any other number of persons etc. So I
do presume this should definitely be a ManyToManyField. But would I
just pass the Person model as the ManyToManyField parameter inside the
Person model? ... Is this the best way to do this, as it'll be many-to-
many to itself?

Hope this makes sense...
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
-~--~~~~--~~--~--~---



Can I use databrowse to display a QuerySet ???½

2009-07-01 Thread Jesper

Hello there,

I've just started using django.  I've set up my models, got the admin
pages up and is using databrowse to present the raw data of each
model.

I need to generate some well defined queries and present those too.
Is this somehow possible with databrowse?

Cheers,
Jesper

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 field value before valid of admin

2009-07-01 Thread Kenneth Gonsalves

On Wednesday 01 July 2009 14:58:00 Shuge Lee wrote:
> # cat models.py
>
> class Seed(models.Model):
> name = models.CharField(max_length=128, unique=True)
> category = models.ForeignKey(Category)
> source = models.CharField(max_length=256)
>
> now, I want
> source = category + '/' + name
> if user doesn't fill source field in admin view
>
> How to do that ?

overide save()
-- 
regards
kg
http://lawgon.livejournal.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
-~--~~~~--~~--~--~---



change field value before valid of admin

2009-07-01 Thread Shuge Lee

# cat models.py

class Seed(models.Model):
name = models.CharField(max_length=128, unique=True)
category = models.ForeignKey(Category)
source = models.CharField(max_length=256)

now, I want
source = category + '/' + name
if user doesn't fill source field in admin view

How to do that ?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: serving a static file via nginx requiring authentication from django

2009-07-01 Thread Alvin

I'll be writing a blog post about this soon

when John wrote is right on though it took me a while to wrap my mind
around it

the nginx location + nginx alias + url passed = file to be served

so to get file /home/me/web/example.com/download/file.pdf

 location ^~ /download {
internal;
root/home/me/web/example.com/
}

would be accessed via:

response['X-Accel-Redirect'] = '/download/file.pdf'
return response


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Using a dynamically created ImageField filename prior to save?

2009-07-01 Thread Andrew Turner

2009/6/30 Andrew Turner :
> Hi,
>
> This is an issue which, I believe, is related to Ticket #10788
> (http://code.djangoproject.com/ticket/10788).
>
> The following code snippet used to work with Django 1.0.2, but with
> the latest svn version the slug is not being set to the filename
> produced by get_path because, as I understand it, get_path will not be
> called until the instance is saved to the database.
>
> def get_path(instance, filename):
>    salt = hashlib.sha1(str(random.random())).hexdigest()
>    name = hashlib.sha1(salt+filename).hexdigest()[:16]
>    return '%s.jpg' % (name)
>
> class Photo(models.Model):
>    photo = models.ImageField(upload_to=get_path, blank=False)
>    ...
>    slug = models.CharField(max_length=16, unique=True)
>
>    def save(self):
>        self.slug = self.photo.url.split('/')[-1:][0].split('.')[0]
>        super(Photo, self).save()
>
> I could call instance.save() twice in my view to force it to use the
> correct name, but this feels a bit messy to me. What's the best way to
> get the correct value for the slug field prior to saving it to the
> database, given that the filename is 'randomly' generated?

e.g. Generated filename:-

ebc151e5aad64f4b.jpg

Derived url for Photo view:-

http://mydomain.com/photo/ebc151e5aad64f4b

>From reading the above mentioned ticket and it's referenced discussion
threads, I can't see any way of generating a slug field from the
filename before the instance is saved. At the moment I am saving the
instance to generate the hashed filename, creating the slug based on
the dynamically generated filename, and then saving to the database
again.

Doesn't seem ideal to me, especially as it worked without the extra
save in 1.0.2, and I'm using this dynamic filename/slug method on
several projects.

Cheers,
Andrew

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: PyDev users: how do you manage tabs?

2009-07-01 Thread kRON

One thing you can do is turn on the option 'Link with editor' on your
package\project explorer view. You have the *down arrow* ['View Menu'
tooltip] and an option at the bottom--'Link with Editor'.

That way, any active file in the editor will highlight the file in
your view, and you can keep track of which file you editing by it's
location in your project structure. The only problem with this is
that, if you have a deep/long project structure that you'll notice
that your view will be jumping all over to focus on the entries, but
it's a behavior you can get used to, albeit it can get annoying at
times.

On Jul 1, 7:42 am, Rex  wrote:
> Kind of a petty question:
>
> I've been using PyDev to do my Django work and find it to be great.
> However, my only gripe is that it's hard to keep track of tabs, since
> they display only the (non-qualified) file name, which is a problem
> given Django's very regular naming scheme. So for example I'll often
> have 4+ tabs that are all named "views.py", and I have to mouse over
> each to find which one is the one I'm looking for.
>
> For those of you who use PyDev, have you found this to be an issue as
> well? Are there any solutions, like a plugin that adds the parent
> directory name to the tab?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: marrying django to twitter

2009-07-01 Thread Kenneth Gonsalves

On Wednesday 01 July 2009 09:01:58 David Zhou wrote:
> On Tue, Jun 30, 2009 at 11:21 PM, Kenneth Gonsalves
>
>  wrote:
> > has anyone succeeded in marrying django to twitter - that is broadcasting
> > updates in the django db to twitter? I did see one post on the subject in
> > the archives, but there was no information as to whether the operation
> > was successful.
>
> I haven't tried it, but it shouldn't be hard.  Subscribe to the
> relevant signals for whatever you want to track, and use a Python
> Twitter library to post to the Twitter account.
>
> I've used Mike's module at: http://mike.verdone.ca/twitter/ previously
> to great success.   To post something an account with that module:
>
> import twitter
> t = twitter.api.Twitter('username', 'password')
> t.statuses.update(status="This is the tweet.")

works - here is the code:

def tweetit(sender,**kwargs):
"""
extract relevant info and tweet it
"""
if kwargs['created']:
t = twitter.Api(settings.TWITTER_USER, settings.TWITTER_PASSWORD)
t.PostUpdate("%s has registered as a delegate" 
%(kwargs['instance'].username))

post_save.connect(tweetit, sender=Delegate)

-- 
regards
kg
http://lawgon.livejournal.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: serving a static file via nginx requiring authentication from django

2009-07-01 Thread Skylar Saveland

You could document this experience once you get it running; sounds
useful.

On Jun 30, 1:00 am, John Hensley  wrote:
> On 6/28/09 10:20 PM, Annie wrote:
>
> > I'm trying to this to work: users can download their files from their
> > account page from a url like 
> > this:http://example.com/account/download/a1234565789asedga-2/
> > for which django processes the authentication and then passes along
> > the info to nginx to serve the file.
>
> [...]
>
>
>
> > Here are the relevant bits of code:
>
> > # part of the views.py
>
> > def download_file(request, dlkey=None, ftype=None):
> >      if request.user.is_authenticated():
> >          try:
> >              k = Ebook.objects.select_related().filter
> > (ftype__exact=ftype).filter
> > (book__orderdetail__dlkey__exact=dlkey).filter
> > (book__orderdetail__medium__exact='E')[:1]
> >              for e in k:
> >                  ebook = e.ebook
> >                  filename = os.path.join(PROTECTED_DIR, os.path.basename
> > (ebook))
> >                  response = HttpResponse()
> >                  response['X-Accel-Redirect'] = ebook
> >                  response['Content-Disposition'] =
> > "attachment;filename=" + ebook
> >                  return response
> >          except Exception:
> >              raise Http404
>
> > # part of the nginx configuration for the domain:
>
> >                  location ^~ /account/download/ {
> >                          include         /etc/nginx/
> > fastcgi_params_django;
> >                          fastcgi_pass    127.0.0.1:1024;
> >                          alias           /home/me/web/example.com/
> > public/media/books/;
> >                  }
>
> >                  location ^~ /media/books/ {
> >                          root            /home/me/web/example.com/
> > public;
> >                          internal;
> >                  }
>
> [...]
>
> > [1]http://wiki.nginx.org/NginxXSendfile
>
> I think the answer's in that document, actually. The value of
> X-Accel-Redirect should be your internal location's URL
> ('/media/books/') plus your filename (os.path.basename(ebook), in your
> view). Nginx will deliver
> /home/me/web/example.com/public/media/books/ebook-basename.pdf.
>
> 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: Searching IntegerField

2009-07-01 Thread Harish

Sorry By mistake I typed as "search_field" , it was
"search_fields" actually in the code

On Jul 1, 11:24 am, Marcelo Ramos  wrote:
> On Wed, Jul 1, 2009 at 2:29 AM, Harish wrote:
>
> > hi friends,
> >    I designed a model in django, which has a Integer field. When I
> > include the integer field in the search_list, the searching is not
> > working. I am using django 0.97 (when I gave 'django.VERSION' in
> > python interpreter it gave me (0, 97, 'pre') ).
>
> > the code is as follows
>
> > class Person(models.Model):
> >     name=models.CharField('Name',max_length=20)
> >     rollNo=models.IntegerField('Roll No', maxloength=12)
>
> >     def __unicode__(self):
> >            return self.name
>
> >     class Admin:
> >         list_display=('name','rollNo')
> >         search_field=['name','rollNo']
>
> The keyword name is "search_fields" and you are using "search_field".
>
> --
> Marcelo Ramos
> Django/Python developer
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Searching IntegerField

2009-07-01 Thread Marcelo Ramos

On Wed, Jul 1, 2009 at 2:29 AM, Harish wrote:
>
> hi friends,
>    I designed a model in django, which has a Integer field. When I
> include the integer field in the search_list, the searching is not
> working. I am using django 0.97 (when I gave 'django.VERSION' in
> python interpreter it gave me (0, 97, 'pre') ).
>
> the code is as follows
>
> class Person(models.Model):
>     name=models.CharField('Name',max_length=20)
>     rollNo=models.IntegerField('Roll No', maxloength=12)
>
>     def __unicode__(self):
>            return self.name
>
>     class Admin:
>         list_display=('name','rollNo')
>         search_field=['name','rollNo']

The keyword name is "search_fields" and you are using "search_field".

-- 
Marcelo Ramos
Django/Python developer

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: PyDev users: how do you manage tabs?

2009-07-01 Thread Xavier Ordoquy


> For those of you who use PyDev, have you found this to be an issue as
> well? Are there any solutions, like a plugin that adds the parent
> directory name to the tab?

Hello,

You get the full name within the eclipse window's name - the one from
the window manager.
I usually have only one application active and close as much as possible
the other tabs.

Hope this'll 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
-~--~~~~--~~--~--~---