Re: forms question in django 1.1

2010-04-28 Thread knight
Thanks a lot. That's the problem.
As always, my stupid mistake.

On Apr 28, 6:12 pm, Bill Freeman  wrote:
> I do notice that you have 'player_option' in the fields tuple, while
> there is no such model field, but instead a field named 'player_options'
> (plural).  If that's actually in the source, I'd fix it before looking any
> harder.
>
>
>
>
>
> On Wed, Apr 28, 2010 at 10:32 AM, knight  wrote:
> > I have the following form:
>
> > class ModuleItemForm2(forms.ModelForm):
> >    class Meta:
> >        model = Module_item
> >        fields = ('title', 'media', 'thumb', 'desc', 'default',
> > 'player_option')
>
> > The model is:
>
> > class Module_item(models.Model):
> >    title = models.CharField(max_length=100)
> >    layout = models.CharField(max_length=5, choices=LAYOUTS_CHOICE)
> >    media = models.CharField(help_text='Media url', max_length=500,
> > blank=True, null=True)
> >    conserv = models.ForeignKey(Conserv, help_text= 'Redirect to
> > Conserv', blank=True, null=True)
> >    conserve_section = models.CharField(max_length=100, help_text=
> > 'Section within the redirected Conserv', blank=True, null=True)
> >    parent = models.ForeignKey('self', help_text='Upper menu.',
> > blank=True, null=True)
> >    module = models.ForeignKey(Module, blank=True, null=True)
> >    thumb = models.FileField(upload_to='sms/module_items/thumbs',
> > blank=True, null=True)
> >    desc = models.CharField(max_length=500, blank=True, null=True)
> >    auto_play = models.IntegerField(help_text='Auto start play
> > (miliseconds)', blank=True, null=True)
> >    order = models.IntegerField(help_text='Display order', blank=True,
> > null=True)
> >    depth = models.IntegerField(help_text='The layout depth',
> > blank=True, null=True)
> >    flow_replace = models.IntegerField(blank=True, null=True)
> >    default = models.IntegerField(help_text='The selected sub item
> > (Note: Starting from 0)', blank=True, null=True)
> >    player_options = models.CharField(max_length=1000, null=True,
> > blank=True)
>
> > In my view I build form:
>
> > module_item_form2 = ModuleItemForm2()
> > print module_item_form2
>
> > And I get the following error on the print line:
>
> > 'NoneType' object has no attribute 'label'
>
> > It works fine with django 1.0.2. I see the error only in django 1.1.
>
> > Do you have an idea what am I doing wrong?
>
> > Regards, Arshavski Alexander.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



"dynamically" setting ModelAdmin properties?

2010-04-28 Thread akonsu
hello,

in my custom admin class that inherits ModelAdmin i need to set
ModelAdmin.exclude, ModelAdmin.list_display, etc based on whether the
logged in user is a superuser or not.

is this possible?

thanks
konstantin

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



using django-registration

2010-04-28 Thread andy saksena
Hi all,
I m using django-registration app from bitbucket for a form in my
project and stuck in understanding where is the model of the form.
my database for he project has a table named registration profile woth
the uniqhe id..but whatever fields i have in the database are getting
populated in some table which I dont understand.
the app can be seen from
http://bitbucket.org/ubernostrum/django-registration/src
I'll really appreciate some sort of help here
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



manyToManyField custom column names

2010-04-28 Thread DimebagBorgir
Hi,
I'm porting an old database from an inhouse system to django and I'm
just wondering if there is anything like what is defined at this URL
in django 1.1.1 or upcoming versions:
http://undefined.org.ua/blog/2008/02/29/manytomanywithcustomfield/?lang=en

I could easily rename the fields to conform to django standards but
I'm just curious to see if there is another way in code by which I can
manage this.

Cheers!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Transaction commit with cursor.execute

2010-04-28 Thread idle sign
I'm using the latest trunk from http://github.com/django/django.
A complete test project you can grab at 
http://idlesign.narod.ru/django/django-tests.tar.gz
There is a little bootstrap.sh to run to create DBs.

Thank you, Russ.


On 29 апр, 10:16, Russell Keith-Magee  wrote:
> On Thu, Apr 29, 2010 at 11:04 AM, idle sign  wrote:
> > I thought so, have tried so, but got "This code isn't under
> > transaction management", and opened this thread :)
>
> I get that error if I *omit* the using= argument to commit (which is
> what I'd expect to see).
>
> What version of trunk are you using? There have been a couple of
> bugfixes to the commit decorators since the beta, and it's possibly
> you might be tripping over one of them.
>
> Failing that - I can only assume there is something unusual with your
> database or router setup that is causing a complication. I'd need to
> see specifics (for example, a complete test project) to verify if
> there is something else going on.
>
> Yours,
> Russ Magee %-)
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Inconsistency between DB Query Results Between Threads

2010-04-28 Thread Jared Smith
Thanks for the advice it appears that the issue was related to the old
transaction sticking around.

I put:
@transaction.commit_on_success

On top of the method and it looks like I'm no longer getting stale data;
guess I'll have to go do this around all data retrieval methods.  I was
assuming I needed this on the methods that changed data but didn't realize
it would make a difference on methods that do reads in other threads.

Thanks,

Jared


2010/4/28 Tomasz Zieliński 

>
>
> On 28 Kwi, 22:04, Jared Smith  wrote:
> > Using Django DB API I have two threads one that increments a counter
> getting
> > stored to the database and then another thread that is reading this
> counter.
> >
> > T1(Thread 1) increments
> > T2(Thread 2) reads
> >
> > I have found that if I increment and store the counter value in T1 and
> then
> > if I fetch it in the same thread I get the correct answer for the
> counter.
> > The fetched number matches what I store.
> >
> > However I notice that if T2 reads after T1 stores the value there is some
> > lag where it gives the wrong answer even though T1 is able to
> successfully
> > read the value with the same exact method.  I put a loop spinning reading
> > this value and within a second or two it seems to get the right answer.
> >
> > Is there some lag for different threads to get the same results due to
> some
> > per thread caching happening under the covers?  Anyone know of a work
> around
> > to make sure this cache is flushed?  I'm worried I could get this problem
> > more generally since there are multiple threads accessing the DB and I
> need
> > to make all of them get the most recently committed value.
> >
> > Thank you for any advice,
> >
>
> I'm guessing that this is happening to you:
>
>
> http://stackoverflow.com/questions/2235318/how-do-i-deal-with-this-race-condition-in-django/2235624#2235624
>
> Note that you can also lower the isolation level to READ COMMITED (in
> case of MySQL)
> to get similar result, but READ COMMITED is allegedly (I read it
> somewhere) less used
> and therefore less tested that default REPEATABLE READ.
>
> --
> Tomasz Zielinski
> http://pyconsultant.eu
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Transaction commit with cursor.execute

2010-04-28 Thread Russell Keith-Magee
On Thu, Apr 29, 2010 at 11:04 AM, idle sign  wrote:
> I thought so, have tried so, but got "This code isn't under
> transaction management", and opened this thread :)

I get that error if I *omit* the using= argument to commit (which is
what I'd expect to see).

What version of trunk are you using? There have been a couple of
bugfixes to the commit decorators since the beta, and it's possibly
you might be tripping over one of them.

Failing that - I can only assume there is something unusual with your
database or router setup that is causing a complication. I'd need to
see specifics (for example, a complete test project) to verify if
there is something else going on.

Yours,
Russ Magee %-)

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



Is it safe to alter Django generated tables in MySQL to have composite PK?

2010-04-28 Thread Continuation
I'm using MySQL with Django.

MySQL uses clustered index. I have a class AuctionBid for which the
"natural" PK is (user_id, auction_id).

I'd like to set (user_id, aucton_id) as the PK so that it'll be the
clustered index. I understand that Django doesn't support composite
PK. But what if after syncdb I just ALTER TABLE to make (user_id,
aucton_id) the PK. Would that work with Django or would that introduce
some unwanted behavior under the hood?

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-us...@googlegroups.com.
To unsubscribe from this group, 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: Transaction commit with cursor.execute

2010-04-28 Thread idle sign
I thought so, have tried so, but got "This code isn't under
transaction management", and opened this thread :)

Environment:

Request Method: GET
Request URL: http://localhost:8000/
Django Version: 1.2 beta 1
Python Version: 2.6.4
Installed Applications:
['testapp']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/usr/lib/python2.6/dist-packages/django/core/handlers/base.py"
in get_response
  100. response = callback(request,
*callback_args, **callback_kwargs)
File "/home/idle/projects/gitdev/django-tests/testapp/views.py" in
test
  22. transaction.commit(using='test')
File "/usr/lib/python2.6/dist-packages/django/db/transaction.py" in
commit
  200. set_clean(using=using)
File "/usr/lib/python2.6/dist-packages/django/db/transaction.py" in
set_clean
  125. raise TransactionManagementError("This code isn't under
transaction management")

Exception Type: TransactionManagementError at /
Exception Value: This code isn't under transaction management


On 29 апр, 09:07, Russell Keith-Magee  wrote:
> On Thu, Apr 29, 2010 at 12:59 AM, idle sign  wrote:
> > I think I spotted something weird. May be someone could explain that?
>
> > 1. In Django 1.2 define two DBs (let it be sqlite), one of which name
> > 'test'.
> > 2. Define DB router for 'testapp' so that it always uses 'test' DB.
> > 3. Use 'commit_manually' decorator for 'test' view.
> > 4. In 'test' view define 'cursor' pointing to 'test' DB.
> > 5. Execute some INSERTs and commit
> > *. 'Samples' object (exported from model) would show all inserted
> > object, but nothing would be written into DB.
>
> The problem is on this line:
>
> >    transaction.commit()
>
> By default (for backwards compatibility), commit() operates on the
> default database. If you want to commit results on the 'test'
> connection, you need to provide a 'using' argument:
>
> transaction.commit(using='test')
>
> Yours,
> Russ Magee %-)
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Transaction commit with cursor.execute

2010-04-28 Thread Russell Keith-Magee
On Thu, Apr 29, 2010 at 12:59 AM, idle sign  wrote:
> I think I spotted something weird. May be someone could explain that?
>
> 1. In Django 1.2 define two DBs (let it be sqlite), one of which name
> 'test'.
> 2. Define DB router for 'testapp' so that it always uses 'test' DB.
> 3. Use 'commit_manually' decorator for 'test' view.
> 4. In 'test' view define 'cursor' pointing to 'test' DB.
> 5. Execute some INSERTs and commit
> *. 'Samples' object (exported from model) would show all inserted
> object, but nothing would be written into DB.

The problem is on this line:

>    transaction.commit()

By default (for backwards compatibility), commit() operates on the
default database. If you want to commit results on the 'test'
connection, you need to provide a 'using' argument:

transaction.commit(using='test')

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Moving django.contrib.auth to its own database

2010-04-28 Thread Russell Keith-Magee
On Thu, Apr 29, 2010 at 8:32 AM, Brandon Belew  wrote:
> Hello,
>
> I am attempting to use a database router to move django.contrib.auth
> off to its own database.   Reasoning behind this - I want to share
> just a few tables ( Auth and a custom app called AdminAccess )  across
> multiple sites which might be on multiple servers not sharing a single
> codebase.    Basically allowing me to have separate sites with a
> single sign on.    The AdminAccess app basically makes it where a user
> who is_staff on one domain can't access the staff panel on another
> site without permission.
>
> I put in the router and wrote a custom admin backend and managed to
> get the changes in the admin interface to change the users in the new
> database.   The problem I had was it complained about
> django_content_type not being in the same table.    I copied it over -
> but I fear it might be needed by a few other things in the admin
> backend.    Is it?   Will it hurt to move it?    Is there an easier
> way to do this?    I don't want to hack django to the point where it's
> an epic pain to update.    I'd like to do this as easy as
> possible.

See #12767. In short, this isn't possible (at least, not easily)
because foreign keys can't cross databases. It might be possible to
get it to work, but it's not an officially sanctioned practice at the
moment.

Yours,
Russ Magee %-)

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



Moving django.contrib.auth to its own database

2010-04-28 Thread Brandon Belew
Hello,

I am attempting to use a database router to move django.contrib.auth
off to its own database.   Reasoning behind this - I want to share
just a few tables ( Auth and a custom app called AdminAccess )  across
multiple sites which might be on multiple servers not sharing a single
codebase.Basically allowing me to have separate sites with a
single sign on.The AdminAccess app basically makes it where a user
who is_staff on one domain can't access the staff panel on another
site without permission.

I put in the router and wrote a custom admin backend and managed to
get the changes in the admin interface to change the users in the new
database.   The problem I had was it complained about
django_content_type not being in the same table.I copied it over -
but I fear it might be needed by a few other things in the admin
backend.Is it?   Will it hurt to move it?Is there an easier
way to do this?I don't want to hack django to the point where it's
an epic pain to update.I'd like to do this as easy as
possible.


Here is the router i'm using.

class AuthRouter(object):

def db_for_read(self, model, **hints):
"Point all operations on auth models to 'users'"
if model._meta.app_label == 'auth.User':
return 'users'
return None

def db_for_write(self, model, **hints):
"Point all operations on auth models to 'users'"
if model._meta.app_label == 'auth.User':
return 'users'
return None

def allow_relation(self, obj1, obj2, **hints):
"Allow any relation if a model in auth is involved"
if obj1._meta.app_label == 'auth.User' or obj2._meta.app_label
== 'auth.User':
return True
return None

def allow_syncdb(self, db, model):
"Make sure the auth app only appears on the 'users' db"
if db == 'users':
return model._meta.app_label == 'auth.User'
elif model._meta.app_label == 'auth.User':
return False
return None



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-us...@googlegroups.com.
To unsubscribe from this group, 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: Template lookup order not behaving as expected

2010-04-28 Thread Thomas Allen
On Apr 28, 6:41 pm, creecode  wrote:
> You could add a "pages" directory to your templates directory.
> Something like...
>
> ./pages
> ./pages/templates
> ./pages/templates/pages
>
> And then you would do...
>
> return render_to_response( 'pages/index.html'...

Thanks! It looks like that is also how the popular open-source Django
apps structure their templates.

Thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Deleting parent object when many related objects exist is to slow

2010-04-28 Thread Christophe Pettus


On Apr 28, 2010, at 4:36 PM, dzida wrote:

"When Django deletes an object, it emulates the behavior of the SQL
constraint ON DELETE CASCADE --
in other words, any objects which had foreign keys pointing at the
object to be deleted will be deleted along with it. ",
which is something I really want - but performed in shorter time.


I'm a bit surprised Django does this.  Is there a reason that Django  
re-implements ON DELETE CASCADE for databases that support it?


--
-- Christophe Pettus
   x...@thebuild.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Error with django-registration

2010-04-28 Thread andy saksena
Thanks Its been resolved

On Apr 28, 5:10 pm, James Bennett  wrote:
> On Wed, Apr 28, 2010 at 2:46 AM, andy saksena  wrote:
> > (111, 'Connection refused')
>
> As a Google search would have told you, this is the error Python's
> smtplib module will raise when you tell it to connect to a mail server
> and it can't. Which means you need to go double-check the settings
> you've given to Django for sending email (as covered in the Django
> documentation:http://docs.djangoproject.com/en/1.1/topics/email/) to
> make sure you've provided the correct information for the server
> you're sending mail through.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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 deployment structure configuration

2010-04-28 Thread Joshua Partogi
Hi All,

This might be a little bit off-topic. I would like to learn about
django deployment structure in Everyblock.

Would anyone by chance know how does Everyblock deploy it's django
app? I can see that every city maps into a subdomain. Does Everyblock
deploy one app per subdomain, or is it only one app for all cities and
then django would pick up the subdomain? If it is the latter, how can
we pick up the subdomain name from django?

Thank you very much in advance for the insights.


Kind regards,
Joshua

-- 
http://twitter.com/scrum8

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



Deleting parent object when many related objects exist is to slow

2010-04-28 Thread dzida
Hi all,

I came here with following problem:

I was pretty happy user of Django ORM delete method until I found that
it takes a lot of time when you want to delete object that has A LOT
of objects connected to it via FK.

Assume we have 3 models defined:

class A(models.Model):
pass

class B(models.Model):
a = models.ForeignKey(A)

class C(models.Model):
b = models.ForeignKey(B)

for this models definitions we create following objects:
a - 1 instance of A
b - 10 000 instances of B, each pointed on a
c - no instances (or some - no matter)

My use case is to delete (as fast as possible) a and all related b and
c objects, but a.delete() takes way to much time than accepted.
What I found is that Django behind the scenes tries to SELECT
potential c objects existing for each b, which obviously leads to
enormous number of SQL statements (10 000 selects + other statements).

This must be effect of DJango's deleting policy described in docs as:
"When Django deletes an object, it emulates the behavior of the SQL
constraint ON DELETE CASCADE --
in other words, any objects which had foreign keys pointing at the
object to be deleted will be deleted along with it. ",
which is something I really want - but performed in shorter time.

Do you know how to improve speed of operation I have described
(assuming large ammount of related objects)?

Any help is much appreciated.
Kind Regards,
Lukasz

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: fixtures for test fail to load

2010-04-28 Thread eka (Esteban)
Found that loaddata also doesn't work when the DB has no records.

Same error.

On Apr 28, 7:47 pm, "eka (Esteban)"  wrote:
> Hi all,
>
> Did a dumpdata of my project, then added that to my test and I get:
> DoesNotExist: XXX matching query does not exist.
> The strange thing is that manually loading it using loaddata works
> perfectly.
> Any clue?
>
> Note: Using django.test.TestCase
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



fixtures for test fail to load

2010-04-28 Thread eka (Esteban)
Hi all,

Did a dumpdata of my project, then added that to my test and I get:
DoesNotExist: XXX matching query does not exist.
The strange thing is that manually loading it using loaddata works
perfectly.
Any clue?

Note: Using django.test.TestCase

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Template lookup order not behaving as expected

2010-04-28 Thread creecode
Hello Thomas,

On Apr 28, 2:33 pm, Thomas Allen  wrote:
> I have noticed that the first app in my INSTALLED_APPS tuple overrides
> all of the others for an ambiguous template name. "accounts" does not
> have one, but "dashboard" does, which is why I am seeing what I am
> seeing (if I place "ads" above "dashboard", the "ads" template
> precedes all others). I thought that an app's view would check its own
> templates directory before any others but I guess I was wrong...

The behavior you are seeing is described in <
http://docs.djangoproject.com/en/dev/ref/templates/api/#loader-types
>, in the "django.template.loaders.app_directories.Loader" section.

> is
> there a way to override this default top-down lookup behavior? Or some
> way to specify my template with greater precision while keeping the
> "index.html" filename?

You could add a "pages" directory to your templates directory.
Something like...

./pages
./pages/templates
./pages/templates/pages

And then you would do...

return render_to_response( 'pages/index.html'...

Toodle-loo.
creecode

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



QuerySet.distinct and aggregates

2010-04-28 Thread Wedg
I guess I'm writing this to confirm a behaviour and see if there might
be a work around.

It appears that qs.aggregate(Sum('field')) ignores qs.distinct().

If I have something like this:

qs = Model.objects.filter(reverserelation__field=id).distinct()

... then len(qs) will return the correct number of unique items,
however ...

total = qs.aggregate(total=Sum('field')).get('total')

... appears to ignore the qs.distinct() and will sum all the items,
which may not be distinct if the reverse relation isn't one to one.

Is this something that's a bug? Or does it have to do with the SQL
produced by the qs? Is there a workaround for this?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Inconsistency between DB Query Results Between Threads

2010-04-28 Thread Tomasz Zieliński


On 28 Kwi, 22:04, Jared Smith  wrote:
> Using Django DB API I have two threads one that increments a counter getting
> stored to the database and then another thread that is reading this counter.
>
> T1(Thread 1) increments
> T2(Thread 2) reads
>
> I have found that if I increment and store the counter value in T1 and then
> if I fetch it in the same thread I get the correct answer for the counter.
> The fetched number matches what I store.
>
> However I notice that if T2 reads after T1 stores the value there is some
> lag where it gives the wrong answer even though T1 is able to successfully
> read the value with the same exact method.  I put a loop spinning reading
> this value and within a second or two it seems to get the right answer.
>
> Is there some lag for different threads to get the same results due to some
> per thread caching happening under the covers?  Anyone know of a work around
> to make sure this cache is flushed?  I'm worried I could get this problem
> more generally since there are multiple threads accessing the DB and I need
> to make all of them get the most recently committed value.
>
> Thank you for any advice,
>

I'm guessing that this is happening to you:

http://stackoverflow.com/questions/2235318/how-do-i-deal-with-this-race-condition-in-django/2235624#2235624

Note that you can also lower the isolation level to READ COMMITED (in
case of MySQL)
to get similar result, but READ COMMITED is allegedly (I read it
somewhere) less used
and therefore less tested that default REPEATABLE READ.

--
Tomasz Zielinski
http://pyconsultant.eu

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Template composition: Rendering based on permissions

2010-04-28 Thread Nick
The bible for user authentication is found here
http://docs.djangoproject.com/en/1.1/topics/auth/

The quick answer to number 2 is to check for authentication in a
template tag:

{% if user.is_authenticated %}
Welcome back you rotten jerk
{% else %}
Log in, you rotten jerk
{% endif %}

On Apr 28, 2:46 pm, Thomas Allen  wrote:
> I think that template context processors are the answer to my first
> question. As for my second question, I could certainly check for
> permission membership in the provided PermWrapper, but I'm very
> interested in a way to check this based on the view permission
> requirement (implicitly).
>
> Thomas
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Models as remote API: High-level questions

2010-04-28 Thread Thomas Allen
I'm sorry, I should've specified that I am using Django 1.1 (Django-
ROA is compatible with 1.2 only according to its documentation).

Thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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 module named admin.site.root" on r13043

2010-04-28 Thread Ramiro Morales
On Wed, Apr 28, 2010 at 6:02 PM, sli  wrote:
> I've been trying to fix this issue for about half an hour, now.
> Current code:
>
> from django.contrib import admin
> admin.autodiscover()
> ...
> # Uncomment the next line to enable the admin:
> (r'^admin/(.*)', include('admin.site.root')),
>
> I've also tried the version that is used in a newly created project
> and ended up with the same issue.

You are mixing the syntax used to map the admin
URLs up to and including 1.0:

  (r'^admin/(.*)', admin.site.root),

and the syntax used since 1.1:

  (r'^admin/', include(admin.site.urls)),

Read the respective part #2 of the Django tutorials
to compare them.

Where did you get the

  # Uncomment the next line to enable the admin:
  (r'^admin/(.*)', include('admin.site.root')),

fragment from?

-- 
Ramiro Morales  |  http://rmorales.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-us...@googlegroups.com.
To unsubscribe from this group, 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-admin tab completion not working

2010-04-28 Thread Martin Lundberg
Hello,

I've source the django_bash_completion script but when I try to use it
by hitting TAB I get this:

$ django-admin.py heType 'django-admin.py help' for usage.

I hit tab after 'he' but it is not working and I get the above message
instead.

Any idea what I'm doing wrong?

Thanks,

-Martin

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



manage.py runserver --adminmedia

2010-04-28 Thread Thomas Neumeier
Hi,
im trying to setup django grappelli.
i'm using django 1.1.1, and grappelli 3
the setup works fine, as long as I specify the --adminmedia flag.
but when i run the manage.py test command i get exactly the same tests
failing as if i would run the test command on a clean django install.
i thougt, it might help to specify the value of the --adminmedia flag
in settings.py or similar. but i could not find a solution, how to do
this.
well this somekind related to grappelli, but i think the main reason
is the --adminmedi flag, so im posting this here.
does anybody know how to solve this issue?
Thanks
Thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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 module named admin.site.root" on r13043

2010-04-28 Thread sli
I've been trying to fix this issue for about half an hour, now.
Current code:

from django.contrib import admin
admin.autodiscover()
...
# Uncomment the next line to enable the admin:
(r'^admin/(.*)', include('admin.site.root')),

I've also tried the version that is used in a newly created project
and ended up with the same issue.

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



manage.py runserver --adminmedia

2010-04-28 Thread Thomas Neumeier

Hi,

I'm trying to install django-grappelli.
the admin media is perfectly found, if I run the development server: 
"python manage.py runserver --adminmedia=/path/to/grappelli/media".
i would like to make a change to settings.py so i can leave out the 
--adminmedia flag, when calling manage.py runserver.

how can i do this?

Thanks in advance
Thoms

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



QuerySet.Create Driving Me Mad

2010-04-28 Thread MauroCam
Enough!

I have battled with this for the past few hours, but to no avail.

I basically cannot get a QuerySet.Create or a model Save() to save
some non mandatory URLField values.

Below is the code cleaned up and commented, hoping I haven't cleaned
up too much.

Any help / explanation of what is wrong and how to solve it would be
HUGELY appreciated.

Thanks

# JOB MODEL
# Settting URLField to blank=True has worked elsewhere for me
class Job(models.Model):
company = models.ForeignKey(Company, related_name='companyjobs')
jobtitle = models.CharField(max_length=100)
jobdesc = models.TextField()
joblink = models.URLField()
jobweblink = models.URLField(verify_exists=False, blank=True),
jobemaillink = models.URLField(verify_exists=False, blank=True),

# COMPANY MODEL
class Company(models.Model):
companyadmin = models.ForeignKey(User)
companyname = models.CharField(max_length=256)
companywebsite = models.URLField(verify_exists=True)

#CODE THAT TRIES TO SAVE JOB ASSOCIATED TO A COMPANY
company_db = Company.objects.get(name='CompanyName')

try:
#NOTE - JOBS ARE SAVED IN INTERMEDIATE tempjob CLASS

#APPROACH 1 FAILS - TRY TO SAVE JOB USING companyjobs JobSet
#Following errors raised
#Error adding job: 'emaillink' is an invalid keyword argument for
this function
# OR
#Error adding job: 'weblink' is an invalid keyword argument for
this function
company_db.companyjobs.create(
jobtitle = tempjob.title,
joblink = tempjob.url,
jobdesc = tempjob.desc,
jobweblink = (tempjob.weblink if tempjob.weblink != None else
None),
jobemaillink = (tempjob.emaillink if tempjob.emaillink != None
else None)
) #No save as per Django docs

#APPROACH 2 SUCCEEDS USING QUERYSET.CREATE BUT WITHOUT SAVING
jobweblink & jobemaillink
#Jobs are created and the two fields are correctly set to NULL in
DB
company_db.companyjobs.create(
jobtitle = tempjob.title,
joblink = tempjob.url,
jobdesc = tempjob.desc).save()

#APPROACH 3 FAILS - TRY TO SAVE JOB USING CLASSIC APPROACH, and
without conditional IF
#No errors raised, but jobweblink and jobemail link are both NULL
in DB
job_db = Job(
company=company_db,
jobtitle = tempjob.title,
joblink = tempjob.url,
jobdesc = tempjob.desc,
).save(force_insert=True)
job_db.jobweblink = tempjob.weblink
job_db.jobemaillink = tempjob.weblink
job_db.save()

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Template lookup order not behaving as expected

2010-04-28 Thread Thomas Allen
I have noticed that the first app in my INSTALLED_APPS tuple overrides
all of the others for an ambiguous template name. "accounts" does not
have one, but "dashboard" does, which is why I am seeing what I am
seeing (if I place "ads" above "dashboard", the "ads" template
precedes all others). I thought that an app's view would check its own
templates directory before any others but I guess I was wrong...is
there a way to override this default top-down lookup behavior? Or some
way to specify my template with greater precision while keeping the
"index.html" filename?

Thanks,
Thomas

On Apr 28, 5:19 pm, Thomas Allen  wrote:
> Hi everyone,
>
> In my "pages" app, I have the following view function which renders
> index.html:
>
> @login_required
> def index(req):
>     return render_to_response(
>       'index.html',
>       context_instance=RequestContext(req)
>     )
>
> What really has me stuck here is that it doesn't render pages/
> templates/index.html, instead it renders dashboard/templates/
> index.html. This is not consistent with the lookup order I have seen
> in backtraces for missing templates, where the calling app's directory
> is the first one checked. I have verified that the correct view
> function is being called, so this doesn't seem like a URL issue to me.
>
> Up to this point, all of my templates have been located as I would
> expect them to be, so hopefully this is a minor rather than a major
> issue with my application.
>
> Here is my directory structure:
>
> % find . -type d
> .
> ./accounts
> ./accounts/templates
> ./ads
> ./ads/templates
> ./dashboard
> ./dashboard/templates
> ./db
> ./media
> ./media/templates
> ./pages
> ./pages/templates
> ./static
> ./static/css
> ./templates
> ./templates/layouts
> ./templates/registration
>
> And here are some settings which I think might be relevant:
>
> INSTALLED_APPS = (
>   'pnc.accounts',
>   'pnc.dashboard',
>   'pnc.ads',
>   'pnc.media',
>   'pnc.pages',
>
>   'django.contrib.admin',
>   'django.contrib.admindocs',
>   'django.contrib.auth',
>   'django.contrib.contenttypes',
>   'django.contrib.sessions',
>   'django.contrib.sites'
> )
>
> TEMPLATE_LOADERS = (
>   'django.template.loaders.filesystem.load_template_source',
>   'django.template.loaders.app_directories.load_template_source'
> )
>
> MIDDLEWARE_CLASSES = (
>   'django.middleware.common.CommonMiddleware',
>   'django.contrib.sessions.middleware.SessionMiddleware',
>   'django.contrib.auth.middleware.AuthenticationMiddleware'
> )
>
> TEMPLATE_DIRS = (
>   os.path.join(BASEDIR, 'templates')
> )
>
> Thanks,
> Thomas
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Template lookup order not behaving as expected

2010-04-28 Thread Thomas Allen
Hi everyone,

In my "pages" app, I have the following view function which renders
index.html:

@login_required
def index(req):
return render_to_response(
  'index.html',
  context_instance=RequestContext(req)
)

What really has me stuck here is that it doesn't render pages/
templates/index.html, instead it renders dashboard/templates/
index.html. This is not consistent with the lookup order I have seen
in backtraces for missing templates, where the calling app's directory
is the first one checked. I have verified that the correct view
function is being called, so this doesn't seem like a URL issue to me.

Up to this point, all of my templates have been located as I would
expect them to be, so hopefully this is a minor rather than a major
issue with my application.

Here is my directory structure:

% find . -type d
.
./accounts
./accounts/templates
./ads
./ads/templates
./dashboard
./dashboard/templates
./db
./media
./media/templates
./pages
./pages/templates
./static
./static/css
./templates
./templates/layouts
./templates/registration

And here are some settings which I think might be relevant:

INSTALLED_APPS = (
  'pnc.accounts',
  'pnc.dashboard',
  'pnc.ads',
  'pnc.media',
  'pnc.pages',

  'django.contrib.admin',
  'django.contrib.admindocs',
  'django.contrib.auth',
  'django.contrib.contenttypes',
  'django.contrib.sessions',
  'django.contrib.sites'
)

TEMPLATE_LOADERS = (
  'django.template.loaders.filesystem.load_template_source',
  'django.template.loaders.app_directories.load_template_source'
)

MIDDLEWARE_CLASSES = (
  'django.middleware.common.CommonMiddleware',
  'django.contrib.sessions.middleware.SessionMiddleware',
  'django.contrib.auth.middleware.AuthenticationMiddleware'
)

TEMPLATE_DIRS = (
  os.path.join(BASEDIR, 'templates')
)

Thanks,
Thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: odering User in a form

2010-04-28 Thread zinckiwi
> class Pubblicazioni(models.Model):
>     anno = models.DateField(blank=True, null=True,default=datetime.date.today)
>     autori = models.CharField(max_length=500)
>     titolo = models.CharField(max_length=500)
>     autori_daf = models.ManyToManyField(User)
>
> I need to ordering  (by the User.last_name) the field 'autori_daf'
> when it is displayed at the form generated by
>
> class PubblicazioniForm(ModelForm):
>     class Meta:
>         model = Pubblicazioni


You can explicitly provide a queryset to the appropriate field in your
PubblicazioniForm:

class PubblicazioniForm(ModelForm):
autori_daf =
forms.ModelMultipleChoiceField(queryset=User.objects.all().order_by('last_name'))

class Meta:
    model = Pubblicazioni


Regards
Scott

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: following reverse relationship of an extended model

2010-04-28 Thread Nick Serra
Yeah, that is going to be my fallback, I was just curious on an actual
reverse relationship solution to the situation. Thanks for the input!

On Apr 28, 4:12 pm, zinckiwi  wrote:
> > class Account(models.Model):
> >     name = CharField
>
> > class Entry(models.Model):
> >     account = ForeignKey(Account)
>
> > class Page(Entry):
> >     name = CharField
>
> > There's my simple example. I want to get all pages that belong to
> > Account. account.page_set.all() does not relate, and I can do
> > account.entry_set.all(), but i obviously get all entries, which is a
> > problem because there will be many extended entry classes. Thanks in
> > advance!
>
> Perhaps not the most sophisticated solution, but I would expect
> Page.objects.filter(account=account) to work.
>
> Regards
> Scott
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: following reverse relationship of an extended model

2010-04-28 Thread zinckiwi
> class Account(models.Model):
>     name = CharField
>
> class Entry(models.Model):
>     account = ForeignKey(Account)
>
> class Page(Entry):
>     name = CharField
>
> There's my simple example. I want to get all pages that belong to
> Account. account.page_set.all() does not relate, and I can do
> account.entry_set.all(), but i obviously get all entries, which is a
> problem because there will be many extended entry classes. Thanks in
> advance!

Perhaps not the most sophisticated solution, but I would expect
Page.objects.filter(account=account) to work.

Regards
Scott

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



following reverse relationship of an extended model

2010-04-28 Thread Nick Serra
Hey, quick query question. I know there has to be an answer for this
one, just don't know the syntax. I need to follow the reverse
relationship for an extended model.

class Account(models.Model):
name = CharField

class Entry(models.Model):
account = ForeignKey(Account)

class Page(Entry):
name = CharField


There's my simple example. I want to get all pages that belong to
Account. account.page_set.all() does not relate, and I can do
account.entry_set.all(), but i obviously get all entries, which is a
problem because there will be many extended entry classes. 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Inconsistency between DB Query Results Between Threads

2010-04-28 Thread Jared Smith
Using Django DB API I have two threads one that increments a counter getting
stored to the database and then another thread that is reading this counter.

T1(Thread 1) increments
T2(Thread 2) reads


I have found that if I increment and store the counter value in T1 and then
if I fetch it in the same thread I get the correct answer for the counter.
The fetched number matches what I store.

However I notice that if T2 reads after T1 stores the value there is some
lag where it gives the wrong answer even though T1 is able to successfully
read the value with the same exact method.  I put a loop spinning reading
this value and within a second or two it seems to get the right answer.


Is there some lag for different threads to get the same results due to some
per thread caching happening under the covers?  Anyone know of a work around
to make sure this cache is flushed?  I'm worried I could get this problem
more generally since there are multiple threads accessing the DB and I need
to make all of them get the most recently committed value.


Thank you for any advice,

Jared

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Template composition: Rendering based on permissions

2010-04-28 Thread Thomas Allen
I think that template context processors are the answer to my first
question. As for my second question, I could certainly check for
permission membership in the provided PermWrapper, but I'm very
interested in a way to check this based on the view permission
requirement (implicitly).

Thomas

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



Template composition: Rendering based on permissions

2010-04-28 Thread Thomas Allen
Hi everyone,

I have two questions about rendering specific design elements, and the
second ties in somewhat with the first.

How do you make a variable available in multiple views (multiple
templates)? For instance, maybe I want the active user object to be
available on each page so that I can render a link as "Sign Out
(the_username)".

How do you specify the display of a design element based on user
permissions? For instance, a link like that one would display as "Sign
In" and point to the auth login view rather than the logout view if a
user were not logged in. Similarly, I would like to display links only
if the user passes the view in question's @has_permission test.

Thanks,
Thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Models as remote API: High-level questions

2010-04-28 Thread Thomas Allen
That looks excellent, thank you. I like that it integrates with the
admin, which means I can test the interaction with the remote app very
easily.

Of course I'm still interested in any other opinions :^)

Thomas

On Apr 28, 2:08 pm, Tom Evans  wrote:
> On Wed, Apr 28, 2010 at 6:37 PM, Thomas Allen  wrote:
> > Hi everyone,
>
> > I am building an application where many of the models reside on
> > another server, being served by a PHP application (we needed to do
> > that because many clients can only host PHP).
>
> > What facilities does Django provide for this sort of interaction, and
> > how might you consider implementing it? I have taken a brief look at
> > django-pipes which seems promising and I'd be curious as to the
> > experience users here have had with that library.
>
> > The remote application is flexible enough that it will not be
> > difficult to refactor its URL scheme to match whichever approach I
> > take. Right now it is configured to handle requests based on HTTP
> > methods, with the idea of integrating with Rails' ActiveResource which
> > sadly proved to be very buggy for me (so I'm happily back with good
> > old Django).
>
> > Thanks,
> > Thomas
>
> I'm not aware of anything built-in - 
> tryhttp://code.welldev.org/django-roa/wiki/Home
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Models as remote API: High-level questions

2010-04-28 Thread Tom Evans
On Wed, Apr 28, 2010 at 6:37 PM, Thomas Allen  wrote:
> Hi everyone,
>
> I am building an application where many of the models reside on
> another server, being served by a PHP application (we needed to do
> that because many clients can only host PHP).
>
> What facilities does Django provide for this sort of interaction, and
> how might you consider implementing it? I have taken a brief look at
> django-pipes which seems promising and I'd be curious as to the
> experience users here have had with that library.
>
> The remote application is flexible enough that it will not be
> difficult to refactor its URL scheme to match whichever approach I
> take. Right now it is configured to handle requests based on HTTP
> methods, with the idea of integrating with Rails' ActiveResource which
> sadly proved to be very buggy for me (so I'm happily back with good
> old Django).
>
> Thanks,
> Thomas
>

I'm not aware of anything built-in - try
http://code.welldev.org/django-roa/wiki/Home

Cheers

Tom

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



Re: Saving the query object for later

2010-04-28 Thread Peter Landry
+1 to this. I had similar requirements, and initially went down the road of
pickling a queryset. It became clear quickly that (at least in my case) a
better solution was to have a function that translates a Form instance into
a Queryset. Then serialize the form (or form data) and regenerate the
Queryset that way.

Peter


On 4/28/10 12:28 PM, "Bill Freeman"  wrote:

> The request may have references to objects that will no longer
> exist, or may be inappropriate when rerun later.  I can't promise
> that it won't work, but I believe that pickling the request is at
> best a fragile solution.
> 
> To save just the required parameters won't take much code,
> especially if you refactor the code that turns the parameters into
> a the search operation into a function (or method) that you can
> use both initially and when you rerun the search.
> 
> Having to do some preparation again probably isn't going to be
> as big a performance drain as unpickling enough context to
> make it work without extra code.
> 
> On Wed, Apr 28, 2010 at 11:56 AM, Mark Jones  wrote:
>> I was thinking I could pickle/unpickle the request then run it thru
>> with an extra flag of (send email) thru the same code that wsgi uses.
>> If I jsonify the data, how would I get that back into a python object?
>> 
>> Is it really as simple as str=json.dumps(request) and request =
>> json.loads(str)
>> 
>> I don't see how json keeps track of the object it is dumping, and not
>> sure how to construct a request object from the json return value.
>> 
>> I can see how easy that part would be in C++, but my python skills are
>> a good deal weaker  I guess I'm hunting for "how to do this in
>> python"
>> 
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>> 
>> 

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



Models as remote API: High-level questions

2010-04-28 Thread Thomas Allen
Hi everyone,

I am building an application where many of the models reside on
another server, being served by a PHP application (we needed to do
that because many clients can only host PHP).

What facilities does Django provide for this sort of interaction, and
how might you consider implementing it? I have taken a brief look at
django-pipes which seems promising and I'd be curious as to the
experience users here have had with that library.

The remote application is flexible enough that it will not be
difficult to refactor its URL scheme to match whichever approach I
take. Right now it is configured to handle requests based on HTTP
methods, with the idea of integrating with Rails' ActiveResource which
sadly proved to be very buggy for me (so I'm happily back with good
old Django).

Thanks,
Thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Oracle cursor.execute problem

2010-04-28 Thread Ian
On Apr 27, 2:36 pm, Tim Sawyer  wrote:
> Hmm, nearly.  That gets around the error, but the return value isn't
> populated.
>
>  >>> import cx_Oracle
>  >>> from django.db import connection
>  >>> cursor = connection.cursor()
>  >>> lOutput = cursor.var(cx_Oracle.STRING)
>  >>> cursor.execute("BEGIN %s := 'N'; END; ", [lOutput])
>  >>> print lOutput
> 
>  >>> print lOutput.getvalue()
> None
>  >>>
>
> Any more clues, or am I just going to have to stick with creating a
> specific Oracle connection to do this?

That would be a bug.  I've just checked in a fix, which will be
included in Django 1.2 and the next 1.1.X release.  If you're not
willing to use trunk or wait for the release, my recommendation would
be to use cursor.callfunc if possible.  Otherwise, you can get the
cx_Oracle cursor from cursor.cursor and use that directly.

Ian

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



Question regarding formset initial number of forms

2010-04-28 Thread Sonal Breed
Hi all,

I have a model formset as

RowFormSet = modelformset_factory(Row, extra=7)

I want to initially display 7 rows. And give user a link to add
another row
one at a time. Hence I used extra = 7 and omitted max_num parameter.

So while saving what happens is that, it adds another 7 rows to the
existing number of rows
and then it gets saved. I just want the existing number of rows to get
saved and also, want to
display initially 7 rows and put no restriction on max number of rows
so that user can keep adding rows. I do not see a parameter like
initial_number_rows that we can pass while initializing
modelformset_factory.

Can anyone help me out here.


Thanks,
Sincerely,
Sonal.

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



Transaction commit with cursor.execute

2010-04-28 Thread idle sign
I think I spotted something weird. May be someone could explain that?

1. In Django 1.2 define two DBs (let it be sqlite), one of which name
'test'.
2. Define DB router for 'testapp' so that it always uses 'test' DB.
3. Use 'commit_manually' decorator for 'test' view.
4. In 'test' view define 'cursor' pointing to 'test' DB.
5. Execute some INSERTs and commit
*. 'Samples' object (exported from model) would show all inserted
object, but nothing would be written into DB.

@transaction.commit_manually(using='test')

def test(request):



print Samples.objects.all()



cursor = connections['test'].cursor()



cursor.execute("PRAGMA temp_store=MEMORY")

cursor.execute("PRAGMA synchronous=OFF")



for i in range(1, 25):

cursor.execute("INSERT INTO testapp_samples (simplefield)
VALUES (%s);", [i])



transaction.commit()



print Samples.objects.all()



raise Http404

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



Master Slave django applications

2010-04-28 Thread Kashif Ali
Hi,

I am working on an applications that is divided into two parts i.e. master,
slave. Master application will be used for handling the slave applications
and will be installed on a single server while slave will be installed on
more than one servers.

Actually i have a django based application (slave) that has roundabout 35
pages and it gets different types of information about that server's
hardware on which it is installed. This same application is installed on
more than one servers and I have to login to this application on each server
to see the info i required. e.g. if I have 10 servers then I have to login
to each of these 10 servers to get the states/info etc.

Now I am going to develop a master application from which i can manage slave
application installed on all servers. Here i need some guideline how to work
on it. The idea in my mind:
- create API calls for slave application that can be called in master
application to get the required info. This requires a bit of work todo.

Is there any way master application can connect to slave application's db
remotely? If yes how to plz. brief discription I need.

The idea in my mind is that if the db can be changed on the fly then why to
use API calls, just connect to dbms on other servers and get the stored
information in master application. Is it right way I am thinking about?

If someone can guide me on these lines or can tell me other ways to do that
type of work please.

Regards,
Kashif

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



Re: Admin Inline empty extra - how to access parent form model ID?

2010-04-28 Thread mixit
Ah, ok, this isgetting interesting; the formset, eh?
I'm guessing I get to the formset from the parentForm somehow...
Right, I shall start poking around and see if I can find the link.
Many thanksfor the pointer!
Regards,
si

On Apr 28, 1:55 pm, Daniel Roseman  wrote:
> On Apr 28, 10:48 am, mixit  wrote:
>
>
>
>
>
> > Using an Inline in an Admin form:
> > The main Form model has various text fields, and one Inline, using a
> > custom little form of its own.
> > The Inline model has an parentFK pointing to the parent Form model and
> > has an different FK to a large table, which is displayed as a popup
> > (or dropdown) menu with ALL its entries - all works perfectly :o)
>
> > I want to filter the Inline's FK popup menu (because its too large) by
> > the ID of the parent model instance (plus various other factors).
>
> > Working part of the Implementation:
> > A "populated" (i.e. already 'saved') inline has an instance, thus I
> > can access the parentFK from the Inline via 'self.instance.parentFK"
> > and filter the popup menu by filtering its queryset... again works
> > perfectly :o)
>
> > Problem:
> > The Inline has 'extra: 1' set, to give me one empty extra Inline.
> > This empty extra however has NO instance before saving (i.e.
> > self.instance is None), therefore I cannot use the above technique to
> > get to its parent model, so I cannot filter its popup menu as before :
> > (
>
> > Horrible hack workaround:
> > use formfield_for_foreignkey(),
> > hunt for the popup field name,
> > grab the request.META['PATH_INFO']
> > regexp it and pull out the parent model ID.
> > finally, use the parent model ID thus acquired to filter the popup
> > menu queryset.
>
> > Question:
> > Is there no other way to access the parent Form model ID from an
> > unsaved, "empty" Inline?
>
> > I've spent a couple of days wading through the Admin code but can't
> > find anyway for an empty, "extra" Inline to know anything about the
> > form model it is embedded in...
>
> > Can anyone advise if there is some nifty field, attribute or function
> > that I am missing?
> > regards
> > si
>
> The inline formset itself (rather than its forms) has an "instance"
> attribute which refers to the instance of the parent form.
> --
> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



grabbing request while overriding save or in a signal

2010-04-28 Thread Nick Serra
Hey everyone. I'm trying to access the request object while overriding
the save or tapping into the post_save on a model. I need request info
when someone posts a comment. But I don't just want to handle this in
my view, I would like it to be cleaner than that, so that
functionality would remain even when i'm testing in the django admin.
Kinda stumped here. Thanks in advace!

class Comment(models.Model):
post = models.ForeignKey(Post)
author = models.ForeignKey(User, blank=True, null=True)
name = models.CharField(max_length=255)
email = models.EmailField(blank=True)
body = models.TextField()
timestamp = models.DateTimeField(auto_now_add=True)

def __unicode__(self):
return self.name

def save(self, *args, **kwargs):
#NEED REQUEST IN HERE
super(Comment, self).save(*args, **kwargs)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Many2Many / Generic Relation filter, doesn't behave like expected, how is the right way to do it?

2010-04-28 Thread Tom Evans
On Wed, Apr 28, 2010 at 5:12 PM, HWM-Rocker  wrote:
>
>
> On Apr 28, 4:21 am, Tom Evans  wrote:
>> On Wed, Apr 28, 2010 at 1:00 AM, HWM-Rocker  wrote:
>> > I have a TaggedObject that has a GenericRelation to Foo with the name
>> > tags. When I am searching something like that
>>
>> > TaggedObject.objects.filter(Q(tags__tag=1)(tags__tag=4))
>>
>> > I get no Objects in return. But when I filter with (or) '|' then I get
>> > 4 Objects. But I have only 3 objects tagged. So the object, that was
>> > tagged with 1 and with 4 will be returned twice?
>>
>> > Thats strange. Any idea how to create this queries correctly?
>>
>> > thanks in advance!!!
>>
>> That query looks for tags which are both 1 and 4 at the same time.
>> What you want to do is look for tags which are 1, look for tags which
>> are 4, and intersect them.
>>
>> In other words:
>>
>> TaggedObject.objects.filter(tags__tag=1).filter(tags__tag=4)
>
> yeah I changed my code, but is there any possibility to do this with
> Q, so that I can just execute one query in the end? I want to build a
> complex nested search/filter and Q gives me the possibility to negate
> queries. Is there a possibility to split those two Q's to behave in a
> way that would be useful for my case.
>
>>
>> Cheers
>>
>> Tom
>>
> thx for your tip !!

What you ask the ORM for has more effect on how many queries are done
than how many times you call filter() - querysets are only evaluated
(go to the DB) when they are displayed/iterated through.

This ORM statement:
  TaggedObject.objects.filter(tags__tag=1).filter(tags__tag=4)

would boil down to one SQL statement, joining to the tags table twice.

Use the django debug toolbar, or manually examine
django.db.connection.queries ("from django.db import connection; print
connection.queries") to see more clearly what the ORM is doing.

In this case you are asking for how you can dynamically filter by tags
(in an AND search):

qs = TaggedObjects.objects.filter( .. )
for tag in tag:
  qs = qs.filter(tags__tag=tag)

If you wanted to filter on (tag a or tag b) and tag c:
qs = qs.filter(Q(tags__tag=taga) | Q(tags__tag=tagb)).filter(tags__tag=tagc)

I'll leave it up to you to turn that into something dynamic :P

Be aware, each tag you 'AND' filter on adds another join - the joys of RDBMS


Cheers

Tom

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



Re: Saving the query object for later

2010-04-28 Thread Bill Freeman
The request may have references to objects that will no longer
exist, or may be inappropriate when rerun later.  I can't promise
that it won't work, but I believe that pickling the request is at
best a fragile solution.

To save just the required parameters won't take much code,
especially if you refactor the code that turns the parameters into
a the search operation into a function (or method) that you can
use both initially and when you rerun the search.

Having to do some preparation again probably isn't going to be
as big a performance drain as unpickling enough context to
make it work without extra code.

On Wed, Apr 28, 2010 at 11:56 AM, Mark Jones  wrote:
> I was thinking I could pickle/unpickle the request then run it thru
> with an extra flag of (send email) thru the same code that wsgi uses.
> If I jsonify the data, how would I get that back into a python object?
>
> Is it really as simple as str=json.dumps(request) and request =
> json.loads(str)
>
> I don't see how json keeps track of the object it is dumping, and not
> sure how to construct a request object from the json return value.
>
> I can see how easy that part would be in C++, but my python skills are
> a good deal weaker  I guess I'm hunting for "how to do this in
> python"
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: background-image

2010-04-28 Thread Bill Freeman
Are you using the development server, or are you running behind
apache or similar?

If the former, have you configured the development server to serve
static media?  See:

   http://docs.djangoproject.com/en/1.1/howto/static-files/

If the latter, have you configured the front end server to serve those
those directories at those urls.  This depends on the server, but
with apache you probably use an "Alias" command within your
 tag (if used).  E.g.;

  Alias /media_sito/
"/home/lucak904/Scrivanai/Luca/Webframework/Jacopo/sito/sito_jacopo/media_sito/"

There may be other front end configuration to do, but if you have it
successfully
serving your admin media, it has probably been done.

Then your css should use "url(/media_sito/images/genova_3.JPG)".
You did copy, move, or link the file to your new images directory, didn't you?

You should be able to test this, in either case, by typing it's address in
your browser's location bar:

   http://dns_name_or_localhost_or_ip_address/media_sito/images/genova_3.JPG

This takes most of the custom app stuff you may be doing out of things,
and if you are using apache, Django and Python aren't involved at all.

(When this is working, you should consider putting the css in a css file,
using, for example, a class on the body tag, to select this styling.)

On Wed, Apr 28, 2010 at 11:53 AM, luca72  wrote:
> Hello and thanks for your reply i have this:
>
> MEDIA_ROOT = '/home/lucak904/Scrivania/Luca/Webframework/Jacopo/sito/
> sito_jacopo/media_sito/'
>
> MEDIA_URL = '/media_sito/'
>
> i have make u subfolder called images under media_sito, but the page
> is loaded but the image is not show, in the shell of the server i get:
>
> [28/Apr/2010 17:49:54] "GET /media_sito/images/sf300.jpg HTTP/1.1" 404
> 2032
>
> Any sugg.
>
> Thanks
> Luca
>
> On 28 Apr, 17:07, Bill Freeman  wrote:
>> url() must be given a url, not a file path.  You need to put the image
>> somewhere that is being served by apache, or by the development
>> server (usually a subdirectory of 'media/' or similar) and then use
>> the corresponding url.  For example, when running the devolopment
>> server in /home/me/djprojects/proj1 where I have my MEDIA_ROOT
>> set to '/home/me/djprojects/proj1/site_media/' and my MEDIA_URL
>> set to '/site_media/', and the image has be moved or copied to be
>> /home/me/djprojects/proj1/site_media/images/foo.jpg then the right
>> thing to put in the css is url(/site_media/images/foo.jpg) - note that
>> no quotes are used either.
>>
>>
>>
>> On Wed, Apr 28, 2010 at 10:51 AM, luca72  wrote:
>> > Hello i have a problem when i render with django a background image
>> > with css:
>> > simple css:
>>
>> > div#main {position: absolute; top: 20%; left: 20%; bottom: 0; right:
>> > 0; overflow:scroll; background-color: black; color:red; font-
>> > size:medium; font-family: TimesNR, serif; font-weight: bold;background-
>> > image: url('/home/lucak904/Scrivania/Luca/Webframework/Jacopo/
>> > genova_3.JPG');}
>>
>> > this css is in html file all the other instruction are executed, but
>> > not the backgound-image can you geve me the correct way to do it.
>>
>> > Thanks
>>
>> > Luca
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "Django users" group.
>> > To post to this group, send email to django-us...@googlegroups.com.
>> > To unsubscribe from this group, send email to 
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group 
>> > athttp://groups.google.com/group/django-users?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group 
>> athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Many2Many / Generic Relation filter, doesn't behave like expected, how is the right way to do it?

2010-04-28 Thread HWM-Rocker


On Apr 28, 4:21 am, Tom Evans  wrote:
> On Wed, Apr 28, 2010 at 1:00 AM, HWM-Rocker  wrote:
> > I have a TaggedObject that has a GenericRelation to Foo with the name
> > tags. When I am searching something like that
>
> > TaggedObject.objects.filter(Q(tags__tag=1)(tags__tag=4))
>
> > I get no Objects in return. But when I filter with (or) '|' then I get
> > 4 Objects. But I have only 3 objects tagged. So the object, that was
> > tagged with 1 and with 4 will be returned twice?
>
> > Thats strange. Any idea how to create this queries correctly?
>
> > thanks in advance!!!
>
> That query looks for tags which are both 1 and 4 at the same time.
> What you want to do is look for tags which are 1, look for tags which
> are 4, and intersect them.
>
> In other words:
>
> TaggedObject.objects.filter(tags__tag=1).filter(tags__tag=4)

yeah I changed my code, but is there any possibility to do this with
Q, so that I can just execute one query in the end? I want to build a
complex nested search/filter and Q gives me the possibility to negate
queries. Is there a possibility to split those two Q's to behave in a
way that would be useful for my case.

>
> Cheers
>
> Tom
>
thx for your tip !!

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

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



Re: Saving the query object for later

2010-04-28 Thread Mark Jones
I was thinking I could pickle/unpickle the request then run it thru
with an extra flag of (send email) thru the same code that wsgi uses.
If I jsonify the data, how would I get that back into a python object?

Is it really as simple as str=json.dumps(request) and request =
json.loads(str)

I don't see how json keeps track of the object it is dumping, and not
sure how to construct a request object from the json return value.

I can see how easy that part would be in C++, but my python skills are
a good deal weaker  I guess I'm hunting for "how to do this in
python"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: background-image

2010-04-28 Thread luca72
Hello and thanks for your reply i have this:

MEDIA_ROOT = '/home/lucak904/Scrivania/Luca/Webframework/Jacopo/sito/
sito_jacopo/media_sito/'

MEDIA_URL = '/media_sito/'

i have make u subfolder called images under media_sito, but the page
is loaded but the image is not show, in the shell of the server i get:

[28/Apr/2010 17:49:54] "GET /media_sito/images/sf300.jpg HTTP/1.1" 404
2032

Any sugg.

Thanks
Luca

On 28 Apr, 17:07, Bill Freeman  wrote:
> url() must be given a url, not a file path.  You need to put the image
> somewhere that is being served by apache, or by the development
> server (usually a subdirectory of 'media/' or similar) and then use
> the corresponding url.  For example, when running the devolopment
> server in /home/me/djprojects/proj1 where I have my MEDIA_ROOT
> set to '/home/me/djprojects/proj1/site_media/' and my MEDIA_URL
> set to '/site_media/', and the image has be moved or copied to be
> /home/me/djprojects/proj1/site_media/images/foo.jpg then the right
> thing to put in the css is url(/site_media/images/foo.jpg) - note that
> no quotes are used either.
>
>
>
> On Wed, Apr 28, 2010 at 10:51 AM, luca72  wrote:
> > Hello i have a problem when i render with django a background image
> > with css:
> > simple css:
>
> > div#main {position: absolute; top: 20%; left: 20%; bottom: 0; right:
> > 0; overflow:scroll; background-color: black; color:red; font-
> > size:medium; font-family: TimesNR, serif; font-weight: bold;background-
> > image: url('/home/lucak904/Scrivania/Luca/Webframework/Jacopo/
> > genova_3.JPG');}
>
> > this css is in html file all the other instruction are executed, but
> > not the backgound-image can you geve me the correct way to do it.
>
> > Thanks
>
> > Luca
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



unit test for form with recaptcha field

2010-04-28 Thread cerberos
I want to write a form submission unit test for a form that has a
recaptcha field, how do I fake a pass? Is there any way to tell in the
form code that execution is being done by a test?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Static media in development server

2010-04-28 Thread Jonathan Hayward
I found the problem; I was trying to serve static (non-admin) media from a
'media/', and that was apparently being overridden by admin media use of the
same URL.

On Tue, Apr 27, 2010 at 7:53 PM, Jonathan Hayward <
christos.jonathan.hayw...@gmail.com> wrote:

> Thank you; right now I am using the development server (i.e. not deployed
> to Apache for real use).
>
> I added the FILE_UPLOAD_PERMISSIONS assignment to settings.py and can't
> observe a difference in behavior.
>
>
> On Tue, Apr 27, 2010 at 7:37 PM, Nadae Ivar Badio wrote:
>
>> Hi,
>>
>> Use this FILE_UPLOAD_PERMISSIONS = 0600
>> and you have to give permissions to apache to read the file upload
>> directory.
>>
>>
>>
>>
>> Jonathan Hayward wrote:
>>
>>> The file permissions are right AFAIK; the directory is mode 755 and the
>>> file 644, owned by the user running the server, so accessing and reading
>>> shouldn't be a problem.
>>>
>>> Are you using Django installed through the package manager or the latest
>>> release from djangoproject.com ?
>>>
>>>
>>> On Tue, Apr 27, 2010 at 6:37 PM, Xavier Ordoquy 
>>> > xordo...@linovia.com>> wrote:
>>>
>>>It is pretty much what I also have and works both on ubuntu 9.10
>>>32 bits and osx.
>>>
>>>Did you checked that your media directory exists and lives in the
>>>same directory as the settings.py ?
>>>Also check that you have the right permissions for accessing it
>>>with the user that runs the dev server.
>>>
>>>Regards,
>>>Xavier.
>>>
>>>Le 28 avr. 2010 à 01:00, Jonathan Hayward a écrit :
>>>
>>> Thank you!

Right now, I have, in settings.py:

MEDIA_ROOT =
os.path.join(os.path.abspath(os.path.dirname(__file__)), 'media')

MEDIA_URL = '/media/'

And at the end of urls.py:

if settings.DEBUG:
urlpatterns += patterns('django.views.static',
  (r'^%s(?P.*)$' % (settings.MEDIA_URL[1:],),  'serve', {
'document_root': settings.MEDIA_ROOT,
'show_indexes': True }),)

But I'm still getting a "not found" error when I try to load a
picture from the media directory. I am also getting "Permission
denied: /media/" when I load the root media URL.

I'm on an Ubuntu32 9.10 system, so even if I should be specifying
a virgule instead of os.path.join(), the path should be forward
slash separated. Is there anything that looks askew about the
code above?

On Tue, Apr 27, 2010 at 5:28 PM, Xavier Ordoquy
> wrote:

Hi,

Here's something better for your dev server:

from django.conf import settings

if settings.DEBUG:
urlpatterns += patterns('django.views.static',
(r'^%s(?P.*)$' % (settings.MEDIA_URL[1:],),  'serve', {

 'document_root': settings.MEDIA_ROOT,

 'show_indexes': True }),)


To answer your question, you should
use os.path.abspath(os.path.dirname(__file__)) instead of
os.path.dirname(__file__).

Regards,
Xavier.


Le 28 avr. 2010 à 00:00, Jonathan Hayward a écrit :

 I'm trying to serve up media from a document_root of
>/media via, in urls.py:
>
>urlpatterns = patterns('',
>...
>(r'^media/(?P.*)$', 'django.views.static.serve',
>  {'document_root':
>os.path.join(os.path.dirname(__file__), 'media')}),
>...
>
>It gives a "file not found" error, either this way or if I
>add a trailing slash.
>
>How can I serve up static content from name>/media/* to a URL of /media/* from the development server?
>
>-- → Jonathan Hayward,
> christos.jonathan.hayw...@gmail.com
>
>
>→ An Orthodox Christian author: theology, literature, et cetera.
>→ My award-winning collection is available for free reading
>online:
>☩ I invite you to visit my main site at
>http://JonathansCorner.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
>
> 
> >.
>
>   

Re: forms question in django 1.1

2010-04-28 Thread Bill Freeman
I do notice that you have 'player_option' in the fields tuple, while
there is no such model field, but instead a field named 'player_options'
(plural).  If that's actually in the source, I'd fix it before looking any
harder.

On Wed, Apr 28, 2010 at 10:32 AM, knight  wrote:
> I have the following form:
>
> class ModuleItemForm2(forms.ModelForm):
>    class Meta:
>        model = Module_item
>        fields = ('title', 'media', 'thumb', 'desc', 'default',
> 'player_option')
>
> The model is:
>
> class Module_item(models.Model):
>    title = models.CharField(max_length=100)
>    layout = models.CharField(max_length=5, choices=LAYOUTS_CHOICE)
>    media = models.CharField(help_text='Media url', max_length=500,
> blank=True, null=True)
>    conserv = models.ForeignKey(Conserv, help_text= 'Redirect to
> Conserv', blank=True, null=True)
>    conserve_section = models.CharField(max_length=100, help_text=
> 'Section within the redirected Conserv', blank=True, null=True)
>    parent = models.ForeignKey('self', help_text='Upper menu.',
> blank=True, null=True)
>    module = models.ForeignKey(Module, blank=True, null=True)
>    thumb = models.FileField(upload_to='sms/module_items/thumbs',
> blank=True, null=True)
>    desc = models.CharField(max_length=500, blank=True, null=True)
>    auto_play = models.IntegerField(help_text='Auto start play
> (miliseconds)', blank=True, null=True)
>    order = models.IntegerField(help_text='Display order', blank=True,
> null=True)
>    depth = models.IntegerField(help_text='The layout depth',
> blank=True, null=True)
>    flow_replace = models.IntegerField(blank=True, null=True)
>    default = models.IntegerField(help_text='The selected sub item
> (Note: Starting from 0)', blank=True, null=True)
>    player_options = models.CharField(max_length=1000, null=True,
> blank=True)
>
> In my view I build form:
>
> module_item_form2 = ModuleItemForm2()
> print module_item_form2
>
> And I get the following error on the print line:
>
> 'NoneType' object has no attribute 'label'
>
> It works fine with django 1.0.2. I see the error only in django 1.1.
>
> Do you have an idea what am I doing wrong?
>
> Regards, Arshavski Alexander.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: background-image

2010-04-28 Thread Bill Freeman
url() must be given a url, not a file path.  You need to put the image
somewhere that is being served by apache, or by the development
server (usually a subdirectory of 'media/' or similar) and then use
the corresponding url.  For example, when running the devolopment
server in /home/me/djprojects/proj1 where I have my MEDIA_ROOT
set to '/home/me/djprojects/proj1/site_media/' and my MEDIA_URL
set to '/site_media/', and the image has be moved or copied to be
/home/me/djprojects/proj1/site_media/images/foo.jpg then the right
thing to put in the css is url(/site_media/images/foo.jpg) - note that
no quotes are used either.

On Wed, Apr 28, 2010 at 10:51 AM, luca72  wrote:
> Hello i have a problem when i render with django a background image
> with css:
> simple css:
>
> div#main {position: absolute; top: 20%; left: 20%; bottom: 0; right:
> 0; overflow:scroll; background-color: black; color:red; font-
> size:medium; font-family: TimesNR, serif; font-weight: bold;background-
> image: url('/home/lucak904/Scrivania/Luca/Webframework/Jacopo/
> genova_3.JPG');}
>
> this css is in html file all the other instruction are executed, but
> not the backgound-image can you geve me the correct way to do it.
>
> Thanks
>
> Luca
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: background-image

2010-04-28 Thread Brett Parker
On 28 Apr 07:51, luca72 wrote:
> Hello i have a problem when i render with django a background image
> with css:
> simple css:
> 
> div#main {position: absolute; top: 20%; left: 20%; bottom: 0; right:
> 0; overflow:scroll; background-color: black; color:red; font-
> size:medium; font-family: TimesNR, serif; font-weight: bold;background-
> image: url('/home/lucak904/Scrivania/Luca/Webframework/Jacopo/
> genova_3.JPG');}
> 
> this css is in html file all the other instruction are executed, but
> not the backgound-image can you geve me the correct way to do it.

You can't point to a local file, the css is parsed by the browser *not*
the server, so the url should point to the correct url that that image
will be served from. *If* you're only running it and viewing it from
your local machine, then adding file:// to the beginning of the url
should work, i.e.
   background-image: 
url(file:///home/lucak904/Scrivania/Luca/Webframework/Jacopo/genova_3.JPG);

Thanks,
-- 
Brett Parker

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: statistics, reporting, charts for django

2010-04-28 Thread Georg Holzmann
Hallo !

Yes, thanks, I already looked into google-chartwrapper and they work
quite nice !
However, I think I will integrate the interactive charts (google
visualization) - there are no template tags for it so far, but a
python interface exists: http://code.google.com/p/google-visualization-python/
.

LG
Georg

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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 tinymce/filebrowser issue

2010-04-28 Thread Bill Freeman
It means that something is calling reverse, or a template is using
the url tag, with a bad argument.  The argument could be bad
in it's own right (if it's your own code doing it, or if something like
filebrowser or tinymce is using an improperly set configuration
variable from settings.py), or that the object sought isn't in the
chain of url patterns.  I'm suspicious of "/tinymce/filebrowser/"
because it doesn't look like an argument to reverse, but rather
the sort of thing that reverse is expected to return.

Have you read all the stuff about configuring tinymce?  Have
you spliced it into your url structure?

There's a lot more stuff in that traceback which should let you
figure out where the info being passed to reverse is coming from.
There is also the triangle that lets you see variables, so you
can see what it's trying to reverse.  There's one of these at
every stack level.

On Wed, Apr 28, 2010 at 10:38 AM, Bobby Roberts  wrote:
> hey bill i'm getting this traceback:
>
>
> NoReverseMatch at /tinymce/filebrowser/
>
> Reverse for 'filebrowser-index' with arguments '()' and keyword
> arguments '{}' not found.
>
> Request Method:         GET
> Request URL:    http://www.rakeshark.com/tinymce/filebrowser/
> Exception Type:         NoReverseMatch
> Exception Value:
>
> Reverse for 'filebrowser-index' with arguments '()' and keyword
> arguments '{}' not found.
>
> Exception Location:     /home/absentx/webapps/django_apps/lib/python2.5/
> django/core/urlresolvers.py in reverse, line 300
> Python Executable:      /usr/local/bin/python
> Python Version:         2.5.4
> Python Path:    ['/home/absentx/lib/python2.5', '/home/absentx/webapps/
> django_apps', '/home/absentx/webapps/django_apps/live', '/home/absentx/
> lib/python2.5', '/home/absentx/webapps/django_apps/lib/python2.5', '/
> usr/local/lib/python25.zip', '/usr/local/lib/python2.5', '/usr/local/
> lib/python2.5/plat-linux2', '/usr/local/lib/python2.5/lib-tk', '/usr/
> local/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-
> packages', '/usr/local/lib/python2.5/site-packages/PIL']
> Server time:    Wed, 28 Apr 2010 09:37:46 -0500
>
>
> any idea what this means?
>
> On Apr 28, 10:30 am, Bill Freeman  wrote:
>> In firebug (in firefox) there is a "NET" tab that shows you all the stuff
>> that got loaded, including which ones 404.
>>
>> When I was installing this stuff I made the mistake of installing as an
>> egg, and the media subdirectories didn't get pulled in.  Both tinymce
>> and filebrowser had problems like this.  At the very least, go to the
>> tar file to see what javascript/css/image stuff there is and be sure
>> that it is installed where your server can serve it, at the urls that the
>> packages are configured to use.  I don't remember that being the
>> last problem, but it's a start.
>>
>> If all the media is working, make sure that the context pulls in an
>> appropriate top level js to configure tinymce.  We had this working
>> in one part of a site but not another, and the firebug NET tool was
>> very helpful in showing what was loaded in one context but not or
>> differently in the other.  I spent a long time setting breakpoints in
>> firebug, but it was an initialization issue (the plugin stuff was hard
>> to debug).
>>
>> Bill
>>
>>
>>
>> On Wed, Apr 28, 2010 at 9:01 AM, Bobby Roberts  wrote:
>> > not sure how to do that...  i'm not really getting any javascript
>> > errors or anything.
>>
>> > On Apr 28, 3:26 am, Xavier Ordoquy  wrote:
>> >> Hi,
>>
>> >> Filebrowser is a bit tricky to setup.
>> >> Did you had a look at 404 requests made by your browser ? There should be 
>> >> something that isn't available at some point.
>> >> Took me some time to setup it up correctly the first time.
>>
>> >> Regards,
>> >> Xavier.
>>
>> >> Le 28 avr. 2010 à 04:57, Bobby Roberts a écrit :
>>
>> >> > hey group -
>>
>> >> > I've installed djangotinymce and filebrowser per the instructions.
>> >> > I've run across a strange issue.  When I go to insert an image, the
>> >> > image dialog pops up just fine with the button for filebrowser.
>> >> > However, when I click the filebrowser button, nothing happens.  Any
>> >> > idea what could be causing 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-us...@googlegroups.com.
>> >> > To unsubscribe from this group, send email to 
>> >> > django-users+unsubscr...@googlegroups.com.
>> >> > For more options, visit this group 
>> >> > athttp://groups.google.com/group/django-users?hl=en.
>>
>> >> --
>> >> You received this message because you are subscribed to the Google Groups 
>> >> "Django users" group.
>> >> To post to this group, send email to django-us...@googlegroups.com.
>> >> To unsubscribe from this group, send email to 
>> >> django-users+unsubscr...@googlegroups.com.
>> >> For more 

background-image

2010-04-28 Thread luca72
Hello i have a problem when i render with django a background image
with css:
simple css:

div#main {position: absolute; top: 20%; left: 20%; bottom: 0; right:
0; overflow:scroll; background-color: black; color:red; font-
size:medium; font-family: TimesNR, serif; font-weight: bold;background-
image: url('/home/lucak904/Scrivania/Luca/Webframework/Jacopo/
genova_3.JPG');}

this css is in html file all the other instruction are executed, but
not the backgound-image can you geve me the correct way to do it.

Thanks

Luca

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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 tinymce/filebrowser issue

2010-04-28 Thread fuxter
> Any
> idea what could be causing that?
>

last time i had exact same problem. existing button but filebrowser
not appearing. it was thist one:



if you check the url you'd get an clear error about reverse url fault.
actually i had to fix tinymce python source:

fb_url = "%s://%s%s" % (request.is_secure() and 'https' or 'http',
#request.get_host(), urlresolvers.reverse('filebrowser-index'))
request.get_host(), urlresolvers.reverse('fb_browse'))

since filebrouser url.py has no "filebrowser" now, it's 'fb_browse'.

well that's what i had to do last time.

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



Re: Saving the query object for later

2010-04-28 Thread Bill Freeman
Presumably the user entered data into a form to perform the search.
I'd save the form field values, possibly slightly pre-processed.
Remember to include stuff that you're pulling out of, for example,
request.user.  Then you can change the details of your search
function, your database schema, and a bunch of other things, and
still have the search work.

Pickling such stuff is probably safe if there are no classes involved,
but changing the definition of pickled classes can lead to trouble.
If you jsonify it instead, you can even change python versions and
have it still work.

On Wed, Apr 28, 2010 at 10:34 AM, Mark Jones  wrote:
> When someone searches for something on the site and finds nothing, I
> want to save that query for later reuse (so I can run it each night to
> see if anything new matches their request, and email what is found to
> the user).
>
> What is the best way to go about this?
>  1. Save the SQL that is generated and just run it later?  If so,
> how? I'm going to want the ORM to be involved in this since I will be
> templating the emails.
>  2. Pickle the lookup?
>
> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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 and defaults

2010-04-28 Thread Tom Evans
On Wed, Apr 28, 2010 at 3:30 PM, Tom Evans  wrote:
> Hi
>
> I'm trying to make my website fully i18n/l10n compliant, but I'm
> hitting a few issues with default values for translations.
>
> To test my website, I've set my Accept-Language to French, and
> compiled a complete french po file for all the currently marked up
> content on my website. This works for the most part, however certain
> words/phrases are translated to strings that are not in my po file.
> For example, I have translated the word 'Home' to 'Accueil'
> ('Welcome'), however it displays on the website as 'Racine' ('Root')*.
>
> Can anyone explain this behaviour? I presume this is one of django's
> translations leaking through (although I can't actually find it in any
> catalogue) - is there any way to disable django's catalogues?
>
>
> Cheers
>
> Tom
>
> * Before anyone says anything; this is an example that exhibits an
> issue - I've already changed this to 'Home (webpage)' and added an
> english translation as 'Home'.
>

Meh, I've just found the translation - its part of the app I'm using
to enter translations (django-rosetta). I'll guess I just have to make
sure that there are no overlaps between the two.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Getting a Blog included in the Django community aggregator

2010-04-28 Thread Russell Keith-Magee
On Wed, Apr 28, 2010 at 9:50 PM, Gustavo Narea
 wrote:
> Hello, Russell et al.
>
> We also have a relatively new blog where we talk about Django and the
> extensions we write for Django, and one of my fellow developers
> contacted Jacob a few months ago but he never replied.
>
> Here's the feed for Django-related posts:
> http://dev.2degreesnetwork.com/feeds/posts/default/-/django
> And here's the homepage: http://dev.2degreesnetwork.com/

Done.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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 tinymce/filebrowser issue

2010-04-28 Thread Bobby Roberts
hey bill i'm getting this traceback:


NoReverseMatch at /tinymce/filebrowser/

Reverse for 'filebrowser-index' with arguments '()' and keyword
arguments '{}' not found.

Request Method: GET
Request URL:http://www.rakeshark.com/tinymce/filebrowser/
Exception Type: NoReverseMatch
Exception Value:

Reverse for 'filebrowser-index' with arguments '()' and keyword
arguments '{}' not found.

Exception Location: /home/absentx/webapps/django_apps/lib/python2.5/
django/core/urlresolvers.py in reverse, line 300
Python Executable:  /usr/local/bin/python
Python Version: 2.5.4
Python Path:['/home/absentx/lib/python2.5', '/home/absentx/webapps/
django_apps', '/home/absentx/webapps/django_apps/live', '/home/absentx/
lib/python2.5', '/home/absentx/webapps/django_apps/lib/python2.5', '/
usr/local/lib/python25.zip', '/usr/local/lib/python2.5', '/usr/local/
lib/python2.5/plat-linux2', '/usr/local/lib/python2.5/lib-tk', '/usr/
local/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-
packages', '/usr/local/lib/python2.5/site-packages/PIL']
Server time:Wed, 28 Apr 2010 09:37:46 -0500


any idea what this means?

On Apr 28, 10:30 am, Bill Freeman  wrote:
> In firebug (in firefox) there is a "NET" tab that shows you all the stuff
> that got loaded, including which ones 404.
>
> When I was installing this stuff I made the mistake of installing as an
> egg, and the media subdirectories didn't get pulled in.  Both tinymce
> and filebrowser had problems like this.  At the very least, go to the
> tar file to see what javascript/css/image stuff there is and be sure
> that it is installed where your server can serve it, at the urls that the
> packages are configured to use.  I don't remember that being the
> last problem, but it's a start.
>
> If all the media is working, make sure that the context pulls in an
> appropriate top level js to configure tinymce.  We had this working
> in one part of a site but not another, and the firebug NET tool was
> very helpful in showing what was loaded in one context but not or
> differently in the other.  I spent a long time setting breakpoints in
> firebug, but it was an initialization issue (the plugin stuff was hard
> to debug).
>
> Bill
>
>
>
> On Wed, Apr 28, 2010 at 9:01 AM, Bobby Roberts  wrote:
> > not sure how to do that...  i'm not really getting any javascript
> > errors or anything.
>
> > On Apr 28, 3:26 am, Xavier Ordoquy  wrote:
> >> Hi,
>
> >> Filebrowser is a bit tricky to setup.
> >> Did you had a look at 404 requests made by your browser ? There should be 
> >> something that isn't available at some point.
> >> Took me some time to setup it up correctly the first time.
>
> >> Regards,
> >> Xavier.
>
> >> Le 28 avr. 2010 à 04:57, Bobby Roberts a écrit :
>
> >> > hey group -
>
> >> > I've installed djangotinymce and filebrowser per the instructions.
> >> > I've run across a strange issue.  When I go to insert an image, the
> >> > image dialog pops up just fine with the button for filebrowser.
> >> > However, when I click the filebrowser button, nothing happens.  Any
> >> > idea what could be causing 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-us...@googlegroups.com.
> >> > To unsubscribe from this group, send email to 
> >> > django-users+unsubscr...@googlegroups.com.
> >> > For more options, visit this group 
> >> > athttp://groups.google.com/group/django-users?hl=en.
>
> >> --
> >> You received this message because you are subscribed to the Google Groups 
> >> "Django users" group.
> >> To post to this group, send email to django-us...@googlegroups.com.
> >> To unsubscribe from this group, send email to 
> >> django-users+unsubscr...@googlegroups.com.
> >> For more options, visit this group 
> >> athttp://groups.google.com/group/django-users?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.

Saving the query object for later

2010-04-28 Thread Mark Jones
When someone searches for something on the site and finds nothing, I
want to save that query for later reuse (so I can run it each night to
see if anything new matches their request, and email what is found to
the user).

What is the best way to go about this?
  1. Save the SQL that is generated and just run it later?  If so,
how? I'm going to want the ORM to be involved in this since I will be
templating the emails.
  2. Pickle the lookup?

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



forms question in django 1.1

2010-04-28 Thread knight
I have the following form:

class ModuleItemForm2(forms.ModelForm):
class Meta:
model = Module_item
fields = ('title', 'media', 'thumb', 'desc', 'default',
'player_option')

The model is:

class Module_item(models.Model):
title = models.CharField(max_length=100)
layout = models.CharField(max_length=5, choices=LAYOUTS_CHOICE)
media = models.CharField(help_text='Media url', max_length=500,
blank=True, null=True)
conserv = models.ForeignKey(Conserv, help_text= 'Redirect to
Conserv', blank=True, null=True)
conserve_section = models.CharField(max_length=100, help_text=
'Section within the redirected Conserv', blank=True, null=True)
parent = models.ForeignKey('self', help_text='Upper menu.',
blank=True, null=True)
module = models.ForeignKey(Module, blank=True, null=True)
thumb = models.FileField(upload_to='sms/module_items/thumbs',
blank=True, null=True)
desc = models.CharField(max_length=500, blank=True, null=True)
auto_play = models.IntegerField(help_text='Auto start play
(miliseconds)', blank=True, null=True)
order = models.IntegerField(help_text='Display order', blank=True,
null=True)
depth = models.IntegerField(help_text='The layout depth',
blank=True, null=True)
flow_replace = models.IntegerField(blank=True, null=True)
default = models.IntegerField(help_text='The selected sub item
(Note: Starting from 0)', blank=True, null=True)
player_options = models.CharField(max_length=1000, null=True,
blank=True)

In my view I build form:

module_item_form2 = ModuleItemForm2()
print module_item_form2

And I get the following error on the print line:

'NoneType' object has no attribute 'label'

It works fine with django 1.0.2. I see the error only in django 1.1.

Do you have an idea what am I doing wrong?

Regards, Arshavski Alexander.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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 tinymce/filebrowser issue

2010-04-28 Thread Bill Freeman
In firebug (in firefox) there is a "NET" tab that shows you all the stuff
that got loaded, including which ones 404.

When I was installing this stuff I made the mistake of installing as an
egg, and the media subdirectories didn't get pulled in.  Both tinymce
and filebrowser had problems like this.  At the very least, go to the
tar file to see what javascript/css/image stuff there is and be sure
that it is installed where your server can serve it, at the urls that the
packages are configured to use.  I don't remember that being the
last problem, but it's a start.

If all the media is working, make sure that the context pulls in an
appropriate top level js to configure tinymce.  We had this working
in one part of a site but not another, and the firebug NET tool was
very helpful in showing what was loaded in one context but not or
differently in the other.  I spent a long time setting breakpoints in
firebug, but it was an initialization issue (the plugin stuff was hard
to debug).

Bill

On Wed, Apr 28, 2010 at 9:01 AM, Bobby Roberts  wrote:
> not sure how to do that...  i'm not really getting any javascript
> errors or anything.
>
> On Apr 28, 3:26 am, Xavier Ordoquy  wrote:
>> Hi,
>>
>> Filebrowser is a bit tricky to setup.
>> Did you had a look at 404 requests made by your browser ? There should be 
>> something that isn't available at some point.
>> Took me some time to setup it up correctly the first time.
>>
>> Regards,
>> Xavier.
>>
>> Le 28 avr. 2010 à 04:57, Bobby Roberts a écrit :
>>
>> > hey group -
>>
>> > I've installed djangotinymce and filebrowser per the instructions.
>> > I've run across a strange issue.  When I go to insert an image, the
>> > image dialog pops up just fine with the button for filebrowser.
>> > However, when I click the filebrowser button, nothing happens.  Any
>> > idea what could be causing 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-us...@googlegroups.com.
>> > To unsubscribe from this group, send email to 
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group 
>> > athttp://groups.google.com/group/django-users?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group 
>> athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Internationalization and defaults

2010-04-28 Thread Tom Evans
Hi

I'm trying to make my website fully i18n/l10n compliant, but I'm
hitting a few issues with default values for translations.

To test my website, I've set my Accept-Language to French, and
compiled a complete french po file for all the currently marked up
content on my website. This works for the most part, however certain
words/phrases are translated to strings that are not in my po file.
For example, I have translated the word 'Home' to 'Accueil'
('Welcome'), however it displays on the website as 'Racine' ('Root')*.

Can anyone explain this behaviour? I presume this is one of django's
translations leaking through (although I can't actually find it in any
catalogue) - is there any way to disable django's catalogues?


Cheers

Tom

* Before anyone says anything; this is an example that exhibits an
issue - I've already changed this to 'Home (webpage)' and added an
english translation as 'Home'.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Track "before" and "after" state of an object when editing in the Admin?

2010-04-28 Thread Euan Goddard
Hi Derek,

> How and where can this be done?

I've recently been developing a project that uses MongoDB to audit
Django models. I've just published an early version of this work on
launchpad: https://launchpad.net/django-audit/ I haven't got around to
writing any documentation yet, but if you're keen to get hold of
something that can do audit your models, take a look at the tests and
the source and see what you can do.

Good luck, Euan

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Getting a Blog included in the Django community aggregator

2010-04-28 Thread Gustavo Narea
Hello, Russell et al.

We also have a relatively new blog where we talk about Django and the
extensions we write for Django, and one of my fellow developers
contacted Jacob a few months ago but he never replied.

Here's the feed for Django-related posts:
http://dev.2degreesnetwork.com/feeds/posts/default/-/django
And here's the homepage: http://dev.2degreesnetwork.com/

Cheers,

 - Gustavo.

On Apr 28, 2:39 am, Russell Keith-Magee 
wrote:
> On Wed, Apr 28, 2010 at 3:49 AM, Rob  wrote:
> > By strange coincidence, I sent an email to Jacob earlier today
> > requesting that my blog be included in the Django community
> > aggregator.
>
> > I had a suspicion that this type of situation might arise, as I expect
> > many are doing the same.
>
> > My blog address ishttp://www.robgolding.com/blogand the RSS feed for
> > Django ishttp://www.robgolding.com/blog/feed/?tag=django. It would be
> > really great if my content could be included :).
>
> Done.
>
> To answer the broader question: We've got some changes in the works
> for the community pages which will mean you'll be able to manage your
> own blog registrations on the Django website. Hopefully this will be
> just the first of a bunch of updates coming in the near future.
>
> Yours,
> Russ Magee %-)
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Interesting Django or Python Issue

2010-04-28 Thread Brian Morton
Can we see some code?  The description of what you're doing sounds
just fine, so that leaves open the possibility of a technical error.

On Apr 28, 7:42 am, Sam Lai  wrote:
> Maybe database connections aren't closing properly? Don't know where
> to start looking though.
>
> A few weeks ago, I saw something similar (more Django and postgresql
> processes than usual, not doing anything special), but it hasn't
> happened since. Thinking about it, it happened when I was
> reindexing/updating my Whoosh database.
>
> Maybe check open pipes or sockets for the Django processes? Or any
> other open resources for those processes? I didn't really bother to
> investigate when it happened for me as it hasn't happened since, but
> seeing as it is reproducible for you, those are the things I'd take a
> look at first.
>
> On 28 April 2010 06:04, Kenneth Loafman  wrote:
>
>
>
> > Ping.  Anyone?
>
> > Kenneth Loafman wrote:
> >> Folks,
>
> >> I have a user command that runs, via cron, twice hourly with multiple
> >> threads and queues.  At the end of the run, I wait for all of the queues
> >> to empty and join all of the threads.  I close Xapian, print some log
> >> info, and delete the pid file so another instance can run.  All of this
> >> is completed (log file entries and pid file deleted), yet about 3 times
> >> a day, Django does not exit, leaving the task in memory, but idle.
>
> >> I've scratched my head over this but am getting nowhere fast.  Other
> >> than eating up memory, it does no harm as long as I go in and clean out
> >> the old tasks, but this is getting old.
>
> >> Has anyone else seen this behavior?  Any idea how to debug it?
>
> >> Environment is:
> >> Ubuntu Karmic
> >> Django 1.1.1-1ubuntu1
> >> Python 2.6
> >> MySQL 5.1
>
> >> ...Thanks,
> >> ...Ken
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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 tinymce/filebrowser issue

2010-04-28 Thread Bobby Roberts
not sure how to do that...  i'm not really getting any javascript
errors or anything.

On Apr 28, 3:26 am, Xavier Ordoquy  wrote:
> Hi,
>
> Filebrowser is a bit tricky to setup.
> Did you had a look at 404 requests made by your browser ? There should be 
> something that isn't available at some point.
> Took me some time to setup it up correctly the first time.
>
> Regards,
> Xavier.
>
> Le 28 avr. 2010 à 04:57, Bobby Roberts a écrit :
>
> > hey group -
>
> > I've installed djangotinymce and filebrowser per the instructions.
> > I've run across a strange issue.  When I go to insert an image, the
> > image dialog pops up just fine with the button for filebrowser.
> > However, when I click the filebrowser button, nothing happens.  Any
> > idea what could be causing 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-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: Admin Inline empty extra - how to access parent form model ID?

2010-04-28 Thread Daniel Roseman
On Apr 28, 10:48 am, mixit  wrote:
> Using an Inline in an Admin form:
> The main Form model has various text fields, and one Inline, using a
> custom little form of its own.
> The Inline model has an parentFK pointing to the parent Form model and
> has an different FK to a large table, which is displayed as a popup
> (or dropdown) menu with ALL its entries - all works perfectly :o)
>
> I want to filter the Inline's FK popup menu (because its too large) by
> the ID of the parent model instance (plus various other factors).
>
> Working part of the Implementation:
> A "populated" (i.e. already 'saved') inline has an instance, thus I
> can access the parentFK from the Inline via 'self.instance.parentFK"
> and filter the popup menu by filtering its queryset... again works
> perfectly :o)
>
> Problem:
> The Inline has 'extra: 1' set, to give me one empty extra Inline.
> This empty extra however has NO instance before saving (i.e.
> self.instance is None), therefore I cannot use the above technique to
> get to its parent model, so I cannot filter its popup menu as before :
> (
>
> Horrible hack workaround:
> use formfield_for_foreignkey(),
> hunt for the popup field name,
> grab the request.META['PATH_INFO']
> regexp it and pull out the parent model ID.
> finally, use the parent model ID thus acquired to filter the popup
> menu queryset.
>
> Question:
> Is there no other way to access the parent Form model ID from an
> unsaved, "empty" Inline?
>
> I've spent a couple of days wading through the Admin code but can't
> find anyway for an empty, "extra" Inline to know anything about the
> form model it is embedded in...
>
> Can anyone advise if there is some nifty field, attribute or function
> that I am missing?
> regards
> si
>

The inline formset itself (rather than its forms) has an "instance"
attribute which refers to the instance of the parent form.
--
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Admin Inline empty extra - how to access parent form model ID?

2010-04-28 Thread mixit
Using an Inline in an Admin form:
The main Form model has various text fields, and one Inline, using a
custom little form of its own.
The Inline model has an parentFK pointing to the parent Form model and
has an different FK to a large table, which is displayed as a popup
(or dropdown) menu with ALL its entries - all works perfectly :o)

I want to filter the Inline's FK popup menu (because its too large) by
the ID of the parent model instance (plus various other factors).

Working part of the Implementation:
A "populated" (i.e. already 'saved') inline has an instance, thus I
can access the parentFK from the Inline via 'self.instance.parentFK"
and filter the popup menu by filtering its queryset... again works
perfectly :o)

Problem:
The Inline has 'extra: 1' set, to give me one empty extra Inline.
This empty extra however has NO instance before saving (i.e.
self.instance is None), therefore I cannot use the above technique to
get to its parent model, so I cannot filter its popup menu as before :
(

Horrible hack workaround:
use formfield_for_foreignkey(),
hunt for the popup field name,
grab the request.META['PATH_INFO']
regexp it and pull out the parent model ID.
finally, use the parent model ID thus acquired to filter the popup
menu queryset.

Question:
Is there no other way to access the parent Form model ID from an
unsaved, "empty" Inline?

I've spent a couple of days wading through the Admin code but can't
find anyway for an empty, "extra" Inline to know anything about the
form model it is embedded in...

Can anyone advise if there is some nifty field, attribute or function
that I am missing?
regards
si

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Recommendations for a twitter oauth library?

2010-04-28 Thread Aliaksandr Abushkevich
Hi Adam,

OAuth2 works for me. You can use it in any of your python projects.

Best regards,
Alex



On Wed, Apr 28, 2010 at 5:33 AM, adamjamesdrew  wrote:
> Hi has anyone found a good twitter oauth library for django?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Interesting Django or Python Issue

2010-04-28 Thread Sam Lai
Maybe database connections aren't closing properly? Don't know where
to start looking though.

A few weeks ago, I saw something similar (more Django and postgresql
processes than usual, not doing anything special), but it hasn't
happened since. Thinking about it, it happened when I was
reindexing/updating my Whoosh database.

Maybe check open pipes or sockets for the Django processes? Or any
other open resources for those processes? I didn't really bother to
investigate when it happened for me as it hasn't happened since, but
seeing as it is reproducible for you, those are the things I'd take a
look at first.

On 28 April 2010 06:04, Kenneth Loafman  wrote:
> Ping.  Anyone?
>
> Kenneth Loafman wrote:
>> Folks,
>>
>> I have a user command that runs, via cron, twice hourly with multiple
>> threads and queues.  At the end of the run, I wait for all of the queues
>> to empty and join all of the threads.  I close Xapian, print some log
>> info, and delete the pid file so another instance can run.  All of this
>> is completed (log file entries and pid file deleted), yet about 3 times
>> a day, Django does not exit, leaving the task in memory, but idle.
>>
>> I've scratched my head over this but am getting nowhere fast.  Other
>> than eating up memory, it does no harm as long as I go in and clean out
>> the old tasks, but this is getting old.
>>
>> Has anyone else seen this behavior?  Any idea how to debug it?
>>
>> Environment is:
>> Ubuntu Karmic
>> Django 1.1.1-1ubuntu1
>> Python 2.6
>> MySQL 5.1
>>
>> ...Thanks,
>> ...Ken
>>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: usage of TIME_ZONE and zone-to-zone conversion

2010-04-28 Thread David De La Harpe Golden



Thanks for the tip on pytz. It might be what I need.



See django-timezones, django-related helpers around pytz:

http://github.com/brosner/django-timezones

its LocalizedDateTimeField model/form fields construct non-naive python 
datetimes with pytz tzinfo.


(see its tests.py for some additional simple examples)

It's basically indispensable for us, even though we really only use one 
(non-UTC) timezone, just to deal with the idiocy that is DST.



As for the other part of your note, I completely agree with the sentiment.


> The problem is that, in a standard Django installation, there's
> an inherent timezone defined in settings.py.

Set django's settings.TIME_ZONE = 'UTC' and work in utc internally*. 
Seriously.


Django will then (try to - watch out for shared apache [1]) set TZ - and 
will also tell postgresql to expect and return times in utc over the 
wire (explicitly executes a "SET TIME ZONE" command in the connection). 
django models.DateTimeFields become "timestamp with time zone" 
postgresql fields, so your database now uses UTC timestamps that say 
they are UTC and everything just works.  Only now everything's in UTC... 
so...  use django-timezones (django helpers around pytz) to localize 
user-facing time and accept local time inputs.


* Don't use windows on the server, if you are, set the os/system clock 
to utc too and live with it.


[1] http://groups.google.com/group/django-users/msg/6c5e88adfcd2b65f

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Template tag to display boolean values?

2010-04-28 Thread Daniel Roseman
On Apr 28, 10:25 am, derek  wrote:
> On Apr 28, 11:12 am, Daniel Roseman  wrote:
>
> > On Apr 28, 9:08 am, derek  wrote:
>
> > > On Apr 25, 6:55 pm, Dmitry Dzhus  wrote:> Derek wrote:
> > > > > I am looking for a way to display a boolean value, with the "on" / 
> > > > > "off"
>
> > > >http://docs.djangoproject.com/en/1.1/ref/templates/builtins/#yesno
> > > > --
>
> > > Thanks - but that outputs strings, not URL links to images...
>
> > Except if you define the strings as URL links to images...
> > --
>
> So a  '' string will automatically show as an image
> - that's neat!

You may need to pass it through the "safe" filter.
--
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-us...@googlegroups.com.
To unsubscribe from this group, 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: Template tag to display boolean values?

2010-04-28 Thread derek
On Apr 28, 11:12 am, Daniel Roseman  wrote:
> On Apr 28, 9:08 am, derek  wrote:
>
> > On Apr 25, 6:55 pm, Dmitry Dzhus  wrote:> Derek wrote:
> > > > I am looking for a way to display a boolean value, with the "on" / "off"
>
> > >http://docs.djangoproject.com/en/1.1/ref/templates/builtins/#yesno
> > > --
>
> > Thanks - but that outputs strings, not URL links to images...
>
> Except if you define the strings as URL links to images...
> --

So a  '' string will automatically show as an image
- that's neat!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Many2Many / Generic Relation filter, doesn't behave like expected, how is the right way to do it?

2010-04-28 Thread Tom Evans
On Wed, Apr 28, 2010 at 1:00 AM, HWM-Rocker  wrote:
> I have a TaggedObject that has a GenericRelation to Foo with the name
> tags. When I am searching something like that
>
> TaggedObject.objects.filter(Q(tags__tag=1)(tags__tag=4))
>
> I get no Objects in return. But when I filter with (or) '|' then I get
> 4 Objects. But I have only 3 objects tagged. So the object, that was
> tagged with 1 and with 4 will be returned twice?
>
> Thats strange. Any idea how to create this queries correctly?
>
> thanks in advance!!!
>

That query looks for tags which are both 1 and 4 at the same time.
What you want to do is look for tags which are 1, look for tags which
are 4, and intersect them.

In other words:

TaggedObject.objects.filter(tags__tag=1).filter(tags__tag=4)


Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Template tag to display boolean values?

2010-04-28 Thread Daniel Roseman
On Apr 28, 9:08 am, derek  wrote:
> On Apr 25, 6:55 pm, Dmitry Dzhus  wrote:> Derek wrote:
> > > I am looking for a way to display a boolean value, with the "on" / "off"
>
> >http://docs.djangoproject.com/en/1.1/ref/templates/builtins/#yesno
> > --
>
> Thanks - but that outputs strings, not URL links to images...
>

Except if you define the strings as URL links to images...
--
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-us...@googlegroups.com.
To unsubscribe from this group, 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: OS X install, not in home directory?

2010-04-28 Thread Rob
Doh!  Problem solved...  I had created a ~/.pydistutils.cfg file a
couple weeks ago, for some stupid reason I can't remember.  I forgot
to delete that file.  It's contents were:

[install]
install_lib = ~/Library/Python/$py_version_short/site-packages
install_scripts = ~/bin

So it was overriding the normal setup.py behavior.

Rob

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Track "before" and "after" state of an object when editing in the Admin?

2010-04-28 Thread derek
Nick & Tony - many thanks!

Derek

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



Re: Error with django-registration

2010-04-28 Thread James Bennett
On Wed, Apr 28, 2010 at 2:46 AM, andy saksena  wrote:
> (111, 'Connection refused')

As a Google search would have told you, this is the error Python's
smtplib module will raise when you tell it to connect to a mail server
and it can't. Which means you need to go double-check the settings
you've given to Django for sending email (as covered in the Django
documentation: http://docs.djangoproject.com/en/1.1/topics/email/) to
make sure you've provided the correct information for the server
you're sending mail through.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, 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: Template tag to display boolean values?

2010-04-28 Thread derek
On Apr 25, 6:55 pm, Dmitry Dzhus  wrote:
> Derek wrote:
> > I am looking for a way to display a boolean value, with the "on" / "off"
>
> http://docs.djangoproject.com/en/1.1/ref/templates/builtins/#yesno
> --
Thanks - but that outputs strings, not URL links to images...

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



Error with django-registration

2010-04-28 Thread andy saksena
Hi all,
I'm having some troubles while using django-registration used from
bitbucket
http://bitbucket.org/ubernostrum/django-registration/src
After getting evrtythng done Im stuck and having this error.

error at /accounts/register/

(111, 'Connection refused')

Request Method: POST
Request URL:http://localhost:8000/accounts/register/
Exception Type: error
Exception Value:

(111, 'Connection refused')
Can anyone 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-us...@googlegroups.com.
To unsubscribe from this group, 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 tinymce/filebrowser issue

2010-04-28 Thread Xavier Ordoquy
Hi,

Filebrowser is a bit tricky to setup.
Did you had a look at 404 requests made by your browser ? There should be 
something that isn't available at some point.
Took me some time to setup it up correctly the first time.

Regards,
Xavier.

Le 28 avr. 2010 à 04:57, Bobby Roberts a écrit :

> hey group -
> 
> I've installed djangotinymce and filebrowser per the instructions.
> I've run across a strange issue.  When I go to insert an image, the
> image dialog pops up just fine with the button for filebrowser.
> However, when I click the filebrowser button, nothing happens.  Any
> idea what could be causing 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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