Re: Models not being updated when accessed by multiple processes

2010-11-23 Thread Iqbal Abdullah
Since we only run the application on a single server we're using file
based locking; fail_to_get_lock() and release_lock() tries to create a
file in the tmp directory with the user's unique identification data,
and release_lock() deletes it.

What I don't understand is, even if the save() method is not thread
safe, am I correct to assume that everytime I call something like
object = MyModel.object.get(id=1) I will get the latest data for
object?

On 11月20日, 午後2:18, JeeyoungKim  wrote:
> I'm wondering, how are fail_to_get_lock and release_lock implemented?
> It would be some kind of multiprocess lock, which seems overly
> complicated..
>
> using save() in this case is cumbersome, because save() isnot
> threadsafe... you'll have to try to maintain your own lock.
>
> If you only want to implement increments and decrements, you can use
> F() object and update() methods to update the database.
>
> I have an example, here
>
> http://pastebin.com/qp4ExWC2
>
> On Nov 19, 4:30 pm, Iqbal Abdullah  wrote:
>
> > Hi Steve,
>
> > Ops, yes, I forgot to include the object.save() in the pseudo code
> > above. Yes, we're actually saving it:
>
> > 1 object = MyModel.object.get(id=1)
> > 2 print object.value    # starting value is 5
> > 3 while object.fail_to_get_lock():
> > 4    sleep(5)
> > 5 object = MyModel.object.get(id=1)  # Re-get the object so we can
> > have the latest state
> > 6 object.value = object.value - 1
> > 7 object.save()
> > 8 print object.value    # returns 4
> > 9 object.release_lock()
>
> > On 11月20日, 午前7:39, Steve Holden  wrote:
>
> > > On 11/19/2010 5:35 PM, Iqbal Abdullah wrote:
>
> > > > Hi,
>
> > > > This might be a gotcha on themodelsside, but I would like
> > > > clarification and guidance on how to write the code better concerning
> > > >multipleprocess accessing the same data viamodels.
>
> > > > I have a backend script that runs the following code inmultiple
> > > >processes:
>
> > > > 1 object = MyModel.object.get(id=1)
> > > > 2 print object.value    # starting value is 5
> > > > 3 while object.fail_to_get_lock():
> > > > 4    sleep(5)
> > > > 5 object = MyModel.object.get(id=1)  # Re-get the object so we can
> > > > have the latest state
> > > > 6 object.value = object.value - 1
> > > > 7 print object.value    # returns 4
> > > > 8 object.release_lock()
>
> > > > If the above code fails to get the lock because another process is
> > > > running the code, it goes to sleep until the other process finishes.
> > > > The other process will also be decrementing object.value, so if we
> > > > have 2processesrunning the above script at the same time, I would
> > > > expect the later process to return line 7 as 3 andnot4.
>
> > > Shouldn't some saving occur for that to be true?
>
> > > regards
> > >  Steve
> > > --
> > > DjangoCon US 2010 September 7-9http://djangocon.us/

-- 
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: Hosting multiple projects

2010-11-23 Thread Reinout van Rees

On 11/22/2010 10:42 PM, Todd Wilson wrote:

I teach a course in which I have students developing unrelated Django
projects on servers of their own choice.  As we near the end of the
semester, I would like to set up a single server where I can host all
of these student projects together.  I will obviously create a new
user, as well as a new mysql account and database, on this server for
each project, and ask the student teams to upload their project files
into the home directories of these accounts.  But what else will I
have to do to make this work?

I suppose I'll have to install the union of all the python libraries
used by the individual projects, but each project will have its own
settings and "local" URL structure, and I'm not sure how all of this
should be coordinated, or what changes I'll have to ask the teams to
make to their own projects to allow this coordination.  (The server is
Apache/mod_wsgi.)

Any recommendations?


Probably handiest: provide isolation between the various projects.  So 
virtualenv or buildout.


What I'd do is to give every student a project skeleton with a pre-made 
buildout config including an apache config.  Theoretically you should 
then only have to run the buildouts and symlink the various apache 
configs into your /etc/apache2/sites-available/.


Anyhow, make sure their projects look a bit similar.  A setup.py and an 
apache config, for instance.  Hook it up with virtualenv or buildout.



Reinout


--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Collega's gezocht!
Django/python vacature in Utrecht: http://tinyurl.com/35v34f9

--
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 1.3 - JQuery features?

2010-11-23 Thread Derek
In the last Django advent,  Zain Memon said:

"A lot of implemented features missed the cut for Django 1.2, like
drag-and-drop reordering of inlines for models with an ordering field, and
an autocomplete widget for Foreign Key and M2M relations to be used instead
of the select drop-down (or raw_id_fields). Those features (and others) will
most likely land in Django 1.3."

Is this still the plan?  I think autocomplete is one of the features that is
sorely missing from Django (working with lookups numbering in the tens of
thousands is virtually impossible). All of the third party apps have various
quirks and shortcomings - great in some areas and poor in others.  An
official, full-featured solution would be ideal.

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: Hosting multiple projects

2010-11-23 Thread Daniel Roseman
On Nov 22, 9:42 pm, Todd Wilson  wrote:
> I teach a course in which I have students developing unrelated Django
> projects on servers of their own choice.  As we near the end of the
> semester, I would like to set up a single server where I can host all
> of these student projects together.  I will obviously create a new
> user, as well as a new mysql account and database, on this server for
> each project, and ask the student teams to upload their project files
> into the home directories of these accounts.  But what else will I
> have to do to make this work?
>
> I suppose I'll have to install the union of all the python libraries
> used by the individual projects, but each project will have its own
> settings and "local" URL structure, and I'm not sure how all of this
> should be coordinated, or what changes I'll have to ask the teams to
> make to their own projects to allow this coordination.  (The server is
> Apache/mod_wsgi.)
>
> Any recommendations?

You might want to take inspiration from the way Webfaction, one of the
main Django hosters, do it. They have a central Apache for each
server, but they then also have separate Apache instances for each
Django user. The main Apache proxies to the individual user instances.
Then the users can configure and restart their own Apaches as
necessary, without disturbing everyone else on the server.
Additionally, the central instance takes care of serving static
assets.

As regards libraries, I would encourage you to get your students to
use virtualenv. They can then create a requirements.txt file, which
encapsulates all the external libraries they need, and you can install
everything for each user with a single command.
--
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.



Adding manager class to model during runtime

2010-11-23 Thread Vidja
I'm not sure if this is the right way of describing it, but I would
like to add a model manager on a model during project loading.

This is what I am doing to add new functions to a class:

## in models.py ##
class customer(models.Model):
customer_id = models.AutoField(primary_key=True)
name = models.TextField(unique=True)
name = models.TextField(unique=True)


## in modelsdefs.py##

def unicode_name(self):
return self.name

## in __init__.py ##

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



Adding manager class to model during runtime

2010-11-23 Thread Vidja
I'm not sure if it is possible, but I'm trying to add a model manager
defined outside of the model.py to a modelclass, in a similar way as I
add functions to a model class.

this is how I add a new function to a model class (leaving out

## in models.py
class Customer(models.Model):
customer_id = models.AutoField(primary_key=True)
name = models.CharField(max_length=255)
companyname = models.CharField(max_length=255)
active = models.BooleanField()


## in modeldefs.py
def unicode_name(self):
return ("%s [%s]" %(self.name, self.companyname)

## in __init__.py
from cust.modeldefs import unicode_name
setattr(Customer, '__unicode__', unicode_name)

So far so good.
Now I want to add a customanager.
I can define the manager as follows (directly adapted from the
manual) inside models.py:

class CustomerManager(models.Manager):
def get_query_set(self):
return super(CustomerManager,
self).get_query_set().filter(active=True)

class Customer(models.Model):
customer_id = models.AutoField(primary_key=True)
name = models.CharField(max_length=255)
companyname = models.CharField(max_length=255)
active = models.BooleanField()


-- 
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: In-memory sorting of a QuerySet, yielding a QuerySet

2010-11-23 Thread bruno desthuilliers
On 23 nov, 01:27, Christophe Pettus  wrote:
> Apologies if this is a FAQ...

Not AFAIK

> I'd like to take a QuerySet and order it in memory, rather than using 
> 'order_by'.  However, I need it to stay a QuerySet, since I'll be feeding it 
> to the .queryset attribute of a ModelChoiceField.  Is there any way of 
> accomplishing this?


Strictly speaking, you don't need the queryset attribute of a
ModelChoiceField to be a QuerySet instance - as long as the object you
pass in has a '.all()' method that returns an iterable, you should be
fine (cf django/forms/models.py for the definition of the
ModelChoiceField class and the companion ModelChoiceIterator class).

Also, note that if you manually set the .choices property of your
ModelChoiceField, it will totally bypass access to the .queryset
attribute.

HTH

-- 
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.



Adding manager class to model during runtime

2010-11-23 Thread Vidja
I'm not sure if it is possible, but I'm trying to add a model manager
defined outside of the model.py to a modelclass, in a similar way as I
add functions to a model class. (my model classes (> 100) are
automatically generated from the database and I don't want to edit
that file every time)

this is how I add a new function to a model class

## in models.py
class Customer(models.Model):
customer_id = models.AutoField(primary_key=True)
name = models.CharField(max_length=255)
companyname = models.CharField(max_length=255)
active = models.BooleanField()

## in modeldefs.py
def unicode_name(self):
return ("%s [%s]" %(self.name, self.companyname)

## in __init__.py
from cust.modeldefs import unicode_name
setattr(Customer, '__unicode__', unicode_name)

So far so good, the function unicode_name is added to the customer
class as __unicode__ function. This way I am writing the function only
once and I can add it to as many models as I want (as far as the model
fields match of course)

Now I want to add a custom manager..

I can define the manager as follows (directly adapted from the
manual) inside models.py :

class CustomerManager(models.Manager):
def get_query_set(self):
return super(CustomerManager,
self).get_query_set().filter(active=True)

class Customer(models.Model):
customer_id = models.AutoField(primary_key=True)
name = models.CharField(max_length=255)
companyname = models.CharField(max_length=255)
active = models.BooleanField()

activecustomers = CustomerManager()

Querying Customer.activecustomers.all() gives me all active customers.
However, what I WOULD like to do, is not to define the manager in
models.py and add the manager in the Customer class definition, but I
would like to use a similar method as with the class functions:

Thus:
Define the CustomerManager in modeldefs.py and then;

## in __init__.py
from cust.modeldefs import unicode_name, CustomerManager
setattr(Customer, '__unicode__', unicode_name)
setattr(Customer, 'activecustomers', CustomerManager)

However, when I do this I get a 'NoneType' object has no attribute
'_meta'

Is it possible at all to add a manager to a model class afterwards?

Vidja


-- 
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.



tree hierarchy

2010-11-23 Thread rattanpriya bhasin
Hi
I want to implement a tree hierarchy of customers in my django application.
If i want to add customers then manager at root can add cistomers of gold
class(say Level 1) and further customer 1 can add people at (level 2 ) in
tree.This is howi want my customer tree hierarchy .Can any body give me
suggestions on how to code for Tree hierarchies .
Also ,i have user account of all the customers in an application of same
project.So Whenever a new customer is added to the tree hierarchy,it gets
updated in his profile also..that customer joined so and so product
followups.
I cant make an approach to apply this.
Can anybody help me?

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

2010-11-23 Thread Graham Dumpleton


On Nov 23, 8:18 pm, Daniel Roseman  wrote:
> On Nov 22, 9:42 pm, Todd Wilson  wrote:
>
>
>
>
>
> > I teach a course in which I have students developing unrelated Django
> > projects on servers of their own choice.  As we near the end of the
> > semester, I would like to set up a single server where I can host all
> > of these student projects together.  I will obviously create a new
> > user, as well as a new mysql account and database, on this server for
> > each project, and ask the student teams to upload their project files
> > into the home directories of these accounts.  But what else will I
> > have to do to make this work?
>
> > I suppose I'll have to install the union of all the python libraries
> > used by the individual projects, but each project will have its own
> > settings and "local" URL structure, and I'm not sure how all of this
> > should be coordinated, or what changes I'll have to ask the teams to
> > make to their own projects to allow this coordination.  (The server is
> > Apache/mod_wsgi.)
>
> > Any recommendations?
>
> You might want to take inspiration from the way Webfaction, one of the
> main Django hosters, do it. They have a central Apache for each
> server, but they then also have separate Apache instances for each
> Django user. The main Apache proxies to the individual user instances.
> Then the users can configure and restart their own Apaches as
> necessary, without disturbing everyone else on the server.
> Additionally, the central instance takes care of serving static
> assets.

They actually use nginx as front end these days and not Apache.

Graham

> As regards libraries, I would encourage you to get your students to
> use virtualenv. They can then create a requirements.txt file, which
> encapsulates all the external libraries they need, and you can install
> everything for each user with a single command.
> --
> 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.



Modifying client.session from a testcase

2010-11-23 Thread leandrodemarco
Hi, I'm testing, and I need to set/modify the session dictionary
before doing the client.get(), as that get, calls a view that expects
that the session dictionary has certain keys.

According to the documentation, I should store de self.client.session
in a variable, modify the variable and, finally, do a save on that
variable. However, if I do this and then run python manage.py test, I
get an AtrributeError, saying that dict has no save() method.

If I just modify the self.client.session then it seems it has no
effect at the time of making client.get(), as I get an error from the
view, saying that there's no Key in the session with the name
specified.

My code, according to the documentation is like this:

class TestAttack(TestCase):
def test_attack_no_troops(self):
player = Player.objects.get(colour==RED)
session = self.client.session
session["player_id"] = player.id
session.save() # Here I get the AttributeError
self.client.get()
... "more stuff I can't reach as the error is raised
before" ...

Is there anyway to do this?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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 there a way to create a new database table other than model?

2010-11-23 Thread vbs
Hi all,

This is my situation, I want to make a web based game-hall.
I have a model named Game. When I add a new game from the admin panel,
a new record will be added to the database table assigned to model
Game. This is what django does.
And at the same time, I also want a new database table to be created,
named as the name of the new game, or with some prefix. It's best to
have a model assigned to this table.

Is there any way to do this?

Thank you.

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

2010-11-23 Thread Manoj Kumar
hi

How about the people in level 2 whether they can add more peoples??

On Tue, Nov 23, 2010 at 4:12 PM, rattanpriya bhasin <
bhasin.rattanpr...@gmail.com> wrote:

> Hi
> I want to implement a tree hierarchy of customers in my django application.
> If i want to add customers then manager at root can add cistomers of gold
> class(say Level 1) and further customer 1 can add people at (level 2 ) in
> tree.This is howi want my customer tree hierarchy .Can any body give me
> suggestions on how to code for Tree hierarchies .
> Also ,i have user account of all the customers in an application of same
> project.So Whenever a new customer is added to the tree hierarchy,it gets
> updated in his profile also..that customer joined so and so product
> followups.
> I cant make an approach to apply this.
> Can anybody help me?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-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.
>



-- 
Thanks
Manoj Kumar

-- 
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: Debugging Unit Tests

2010-11-23 Thread Murray
Aah no,
I'm using xmlrunner.
Looks like switching back to the default works for me too.

On Nov 22, 4:18 pm, Shawn Milochik  wrote:
> This works for me. Are you certain the code you think is being executed is 
> where it's "freezing"?
>
> Try some logging statements. How are you running your tests -- are you just 
> using the standard test runner?
>
> On Nov 22, 2010, at 9:04, Murray  wrote:
>
>
>
>
>
>
>
> > pdb dosn't seem to work inside my unit tests,  whenever I run
> > set_trace the unit test running freezes with no output.  I presume
> > this is because the output from the tests is suppressed somehow when
> > they are being run.
>
> > Is there someway to disable this so that I can use pdb to debug my
> > failing tests?
>
> > Thanks,
> > Murray
>
> > --
> > 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: how to configure database?

2010-11-23 Thread Michael Sprayberry
have you done python manage.py syncdb?

--- On Mon, 11/22/10, pa_ree  wrote:


From: pa_ree 
Subject: how to configure database?
To: "Django users" 
Date: Monday, November 22, 2010, 3:32 PM


hello, i'm new to django framework.

i want to know how can i configure a single database to two
applications.

the problem is essentially, that i first created a database and an
application in two subparts, and configured the database to the first
part of application. Now i want to link the second part of my app into
the same database.
In settings.py in INSTALLED_APPS i have included both, still it doesnt
seem to wrk.

any solution?

-- 
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.



Conflict trying to save models when roles metaclass is applied.

2010-11-23 Thread Ben Scherrey
We are attempting to apply the concepts of Domain-Context
Interaction (DCI) to our python/django development. Unfortunately, the
metaclass mechanism which the main python library supporting this uses
conflicts with that of Django's metaclass for db.models. What happens
is that a metaclass and new methods are temporarily injected into the
model object while it acts as a role within a context. While it is an
instance of that role, we cannot use the save method on it. When the
role is removed the object may then be saved. Unfortunately that's
quite unsatisfactory and I'm wondering if Django's models can be a
little smarter when figuring out whether an object is a Django
db.model instance or not (we use multiple inheritance to retain the
db.model metaclass). Alternatively, can someone who gets more about
how the metaclass stuff is working with Django suggest a fix in the
roles module that would make it get along better with Django's ORM?

roles can be found: http://pypi.python.org/pypi/roles/0.8
the dci group (object composition) is: 
http://groups.google.com/group/object-composition

some example code showing how to make it all "work" with django
is: 
http://groups.google.com/group/object-composition/browse_thread/thread/fbb11a1e02b68de9

DCI is a very exciting architecture to me that extends the object
model &MVC/T to a more logical end and addresses a lot of complex
issues in design. The concepts have significantly altered my approach
to designing new systems. I really want to be able to make this work
cleanly with Django if at all possible. Appreciate any insights.

  -- Ben Scherrey


-- 
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: Hosting multiple projects

2010-11-23 Thread Brian Bouterse
We use Opus  to do our django deployments.
 It creates a secure version of the setup described in this thread (with
apache not nginx), and even takes care of deploying the databases also (if
you don't mind postgres).

my 2 cents,
Brian

On Tue, Nov 23, 2010 at 6:14 AM, Graham Dumpleton <
graham.dumple...@gmail.com> wrote:

>
>
> On Nov 23, 8:18 pm, Daniel Roseman  wrote:
> > On Nov 22, 9:42 pm, Todd Wilson  wrote:
> >
> >
> >
> >
> >
> > > I teach a course in which I have students developing unrelated Django
> > > projects on servers of their own choice.  As we near the end of the
> > > semester, I would like to set up a single server where I can host all
> > > of these student projects together.  I will obviously create a new
> > > user, as well as a new mysql account and database, on this server for
> > > each project, and ask the student teams to upload their project files
> > > into the home directories of these accounts.  But what else will I
> > > have to do to make this work?
> >
> > > I suppose I'll have to install the union of all the python libraries
> > > used by the individual projects, but each project will have its own
> > > settings and "local" URL structure, and I'm not sure how all of this
> > > should be coordinated, or what changes I'll have to ask the teams to
> > > make to their own projects to allow this coordination.  (The server is
> > > Apache/mod_wsgi.)
> >
> > > Any recommendations?
> >
> > You might want to take inspiration from the way Webfaction, one of the
> > main Django hosters, do it. They have a central Apache for each
> > server, but they then also have separate Apache instances for each
> > Django user. The main Apache proxies to the individual user instances.
> > Then the users can configure and restart their own Apaches as
> > necessary, without disturbing everyone else on the server.
> > Additionally, the central instance takes care of serving static
> > assets.
>
> They actually use nginx as front end these days and not Apache.
>
> Graham
>
> > As regards libraries, I would encourage you to get your students to
> > use virtualenv. They can then create a requirements.txt file, which
> > encapsulates all the external libraries they need, and you can install
> > everything for each user with a single command.
> > --
> > 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.
>
>


-- 
Brian Bouterse
ITng Services

-- 
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: Set Language in the Admin

2010-11-23 Thread Federico Capoano
I got rid of the LocaleMiddleware.

To translate the frontend of the application I'm using
http://bitbucket.org/carljm/django-localeurl/overview

It seems the best solution for me.




On Nov 18, 1:29 pm, Federico Capoano  wrote:
> Thanks
>
> On Nov 16, 11:19 am, Tom Evans  wrote:
>
>
>
>
>
>
>
> > On Tue, Nov 16, 2010 at 9:58 AM, Federico Capoano
>
> >  wrote:
> > > This will affect the frontend too?
>
> > Yes, I'd replace it with a customized version of the LocaleMiddleware,
> > something like this ought to do the trick:
>
> > from django.middleware.locale import LocaleMiddleware
> > from django.utils import translation
>
> > class LocaleButNotInAdminMiddleware(LocaleMiddleware):
> >   KWARG = 'DisableLocalisation'
> >   def process_view(self, request, view_func, view_args, view_kwargs):
> >     disable_localisation = self.KWARG in view_kwargs and
> > view_kwargs.pop(self.KWARG)
> >     if disable_localisation:
> >       translation.deactivate()
> >       if hasattr(request, 'LANGUAGE_CODE')
> >         del request.LANGUAGE_CODE
> >   def process_response(self, request, response):
> >     if hasattr(request, 'LANGUAGE_CODE'):
> >       super(LocaleButNotInAdminMiddleware,
> > self).process_response(request, response)
> >     return response
>
> > and then change how you include the admin into your urlconf from
> > something like this:
>
> >   urlpatterns = patterns('',
> >     (r'^admin/(.*)', include(admin.site.urls)),
> >   )
>
> > to something like this:
>
> >   urlpatterns = patterns('',
> >     (r'^admin/(.*)', include(admin.site.urls), {'DisableLocalisation': 
> > True}),
> >   )
>
> > So that it disables the effects of the LocaleMiddleware when the view
> > to be served will be passed the appropriate kwarg, and the kwarg is
> > passed to the view by configuring it so in the urlconf. The kwarg
> > should never make it to the admin views.
>
> > 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: django charts

2010-11-23 Thread Pablo Ilardi
My 2 cents, I'm using http://code.google.com/p/flot/ does the job on
the browser side, you just have to pass it the data from django, it
works very good and is cross browser.

- Pablo

On Nov 19, 3:56 am, Priya  wrote:
> Hi,
> I am a new user to django ,can anybody please help me resolve this
> issue.I am trying to construct a Gant chart based on the certain
> constraints.Now i am unable to make a line of approach for this.I have
> defined a class for chart and defined function for it in views.Now how
> do i pass my values to the gant chart .
> So the idea is..i have n number of task who have deadlines.So i want
> to show thiese tasks thru a gant chart and then want to show a pie
> chart giving the perfomance eg. 4% work done til so and so date.
> Can anybody help me with the coding of all these.

-- 
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: Do Fixtures have a limit?

2010-11-23 Thread Ryno in Stereo
Hey Reinot,

Thanks so much for replying! It wasn't quite as simple as those rows
were duplicates but that got me on the right track and now it works
perfectly.

Cheers,
Ryan

On Nov 23, 12:22 am, Reinout van Rees  wrote:
> On 11/22/2010 03:16 PM, Ryno in Stereo wrote:
>
> > I'm trying to create around 32,000 rows in a table via a json fixture
> > and although Django confirms via the commandline that it's worked
> > (Installed 32423 object(s) from 1 fixture(s)
> > ), I can only ever see 20,149 records in my MySQl database.
>
> > I can't any mention of an upperlimitforfixturesand this really has
> > me stumped.
>
> > Any ideas?
>
> Duplicate primary keys is the only thing I can think off right now.  So:
> it added 32k objects, but 12k of them were duplicates.  Worth a quick check.
>
> Reinout
>
> --
> Reinout van Rees - rein...@vanrees.org -http://reinout.vanrees.org
> Collega's gezocht!
> Django/python vacature in Utrecht:http://tinyurl.com/35v34f9

-- 
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.



Announces django-guardian 1.0.0.pre

2010-11-23 Thread lukaszb
Recently I've finally write down first part of integration with admin.
Positive side effect are reusable forms for object permissions
management.

There are still some caveats (i.e. queries number, not needed generic
fk with content_type, test runner and other small things) but they
should be removed before final release.

There is one "little" thing still left to be implemented - correlation
between normal and object permissions level. Russ cleared things up at
the last message at 
http://groups.google.com/group/django-users/browse_thread/thread/b54923791ed8d0d4.
This is also going to be written down before final release.

As always, any help pushing things forward is welcomed.

Try it, smash it and send feedback :)

PYPI: http://pypi.python.org/pypi/django-guardian/1.0.0.pre
Documentation: http://packages.python.org/django-guardian/
Github source page: https://github.com/lukaszb/django-guardian

-- 
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: Is there a way to create a new database table other than model?

2010-11-23 Thread ringemup
Perhaps there's another way to accomplish your goal.  Why do you want
a table for each game?

On Nov 23, 5:14 am, vbs  wrote:
> Hi all,
>
> This is my situation, I want to make a web based game-hall.
> I have a model named Game. When I add a new game from the admin panel,
> a new record will be added to the database table assigned to model
> Game. This is what django does.
> And at the same time, I also want a new database table to be created,
> named as the name of the new game, or with some prefix. It's best to
> have a model assigned to this table.
>
> Is there any way to do this?
>
> Thank you.

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

2010-11-23 Thread Carlos Daniel Ruvalcaba Valenzuela
What you want is to add more field to the User model, the common way
to do this is to create an UserProfile model which will be linked to a
given user, check the documentation on the django book on this:

http://www.djangobook.com/en/1.0/chapter12/#cn222

Regards,
Carlos Ruvalcaba

On Mon, Nov 22, 2010 at 12:19 PM, robos85  wrote:
> As Django noob I successfully created user validation and managed to
> add user. But I also created additional table for user profile,
> registered it in settings. But when I save() user to create it, my
> additional table is still empty.
> How can I create that user row when adding user to users table? I want
> to put there registration hash (in future a lot more columns). I
> created that hash but have no idea how to add this to new additional
> table:/
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-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: Is there a way to create a new database table other than model?

2010-11-23 Thread S Basl
If you absolutely need to do so, you can execute raw sql queries to do
whatever you need using Django. The docs are here:
http://docs.djangoproject.com/en/1.2/topics/db/sql/

However, it's probably
a 'bad' idea to go mucking about with sql if you can at all avoid it.

On Tue, Nov 23, 2010 at 8:26 AM, ringemup  wrote:

> Perhaps there's another way to accomplish your goal.  Why do you want
> a table for each game?
>
> On Nov 23, 5:14 am, vbs  wrote:
> > Hi all,
> >
> > This is my situation, I want to make a web based game-hall.
> > I have a model named Game. When I add a new game from the admin panel,
> > a new record will be added to the database table assigned to model
> > Game. This is what django does.
> > And at the same time, I also want a new database table to be created,
> > named as the name of the new game, or with some prefix. It's best to
> > have a model assigned to this table.
> >
> > Is there any way to do this?
> >
> > Thank you.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-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.



how do i get access to json data?

2010-11-23 Thread alecx
Hello django users,

after several try outs, i am not able to figure out how to access data
in a serialized object.
E. g. how do I get the name "Douglas", "Adams" in the example:
http://docs.djangoproject.com/en/dev/topics/serialization/#deserialization-of-natural-keys

In javascript i can get e. g. the "name": "Mostly Harmless" with:
this.fields.name.
But how do i get the "author": ["Douglas", "Adams"]?
I tried serveral options, but had no luck.


-- 
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: Is there a way to create a new database table other than model?

2010-11-23 Thread Li You
Is there a prettier way to do it?

Maybe a dynamic model, or nested model, or something like?

On Tue, Nov 23, 2010 at 9:42 PM, S Basl  wrote:
> If you absolutely need to do so, you can execute raw sql queries to do
> whatever you need using Django. The docs are
> here: http://docs.djangoproject.com/en/1.2/topics/db/sql/
> However, it's probably a 'bad' idea to go mucking about with sql if you can
> at all avoid it.
>
> On Tue, Nov 23, 2010 at 8:26 AM, ringemup  wrote:
>>
>> Perhaps there's another way to accomplish your goal.  Why do you want
>> a table for each game?
>>
>> On Nov 23, 5:14 am, vbs  wrote:
>> > Hi all,
>> >
>> > This is my situation, I want to make a web based game-hall.
>> > I have a model named Game. When I add a new game from the admin panel,
>> > a new record will be added to the database table assigned to model
>> > Game. This is what django does.
>> > And at the same time, I also want a new database table to be created,
>> > named as the name of the new game, or with some prefix. It's best to
>> > have a model assigned to this table.
>> >
>> > Is there any way to do this?
>> >
>> > Thank you.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-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.
>



-- 
Best Regards!

Li You
University of Science and Technology of China

-- 
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: Is there a way to create a new database table other than model?

2010-11-23 Thread Li You
Because I want to save user's info about each game. And the best way
is to save the info by each game.

On Tue, Nov 23, 2010 at 9:26 PM, ringemup  wrote:
> Perhaps there's another way to accomplish your goal.  Why do you want
> a table for each game?
>
> On Nov 23, 5:14 am, vbs  wrote:
>> Hi all,
>>
>> This is my situation, I want to make a web based game-hall.
>> I have a model named Game. When I add a new game from the admin panel,
>> a new record will be added to the database table assigned to model
>> Game. This is what django does.
>> And at the same time, I also want a new database table to be created,
>> named as the name of the new game, or with some prefix. It's best to
>> have a model assigned to this table.
>>
>> Is there any way to do this?
>>
>> Thank you.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-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.
>
>



-- 
Best Regards!

Li You
University of Science and Technology of China

-- 
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: how do i get access to json data?

2010-11-23 Thread Li You
Maybe this is what you want:

from json import JSONDecoder
s = '''{
"pk": 1,
"model": "store.book",
"fields": {
"name": "Mostly Harmless",
"author": ["Douglas", "Adams"]
}
}
'''
d = JSONDecoder().decode(s)

print a['fields']['author']

On Tue, Nov 23, 2010 at 9:45 PM, alecx
 wrote:
> Hello django users,
>
> after several try outs, i am not able to figure out how to access data
> in a serialized object.
> E. g. how do I get the name "Douglas", "Adams" in the example:
> http://docs.djangoproject.com/en/dev/topics/serialization/#deserialization-of-natural-keys
>
> In javascript i can get e. g. the "name": "Mostly Harmless" with:
> this.fields.name.
> But how do i get the "author": ["Douglas", "Adams"]?
> I tried serveral options, but had no luck.
>
>
> --
> 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.
>
>



-- 
Best Regards!

Li You
University of Science and Technology of China

-- 
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: how do i get access to json data?

2010-11-23 Thread Li You
sorry but a mistake.

On Tue, Nov 23, 2010 at 10:01 PM, Li You  wrote:
> Maybe this is what you want:
>
> from json import JSONDecoder
> s = '''{
>    "pk": 1,
>    "model": "store.book",
>    "fields": {
>        "name": "Mostly Harmless",
>        "author": ["Douglas", "Adams"]
>    }
> }
> '''
> d = JSONDecoder().decode(s)
>
> print a['fields']['author']
~~~ should be
print d['fields']['author']
>
> On Tue, Nov 23, 2010 at 9:45 PM, alecx
>  wrote:
>> Hello django users,
>>
>> after several try outs, i am not able to figure out how to access data
>> in a serialized object.
>> E. g. how do I get the name "Douglas", "Adams" in the example:
>> http://docs.djangoproject.com/en/dev/topics/serialization/#deserialization-of-natural-keys
>>
>> In javascript i can get e. g. the "name": "Mostly Harmless" with:
>> this.fields.name.
>> But how do i get the "author": ["Douglas", "Adams"]?
>> I tried serveral options, but had no luck.
>>
>>
>> --
>> 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.
>>
>>
>
>
>
> --
> Best Regards!
>
> Li You
> University of Science and Technology of China
>



-- 
Best Regards!

Li You
University of Science and Technology of China

-- 
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: Is there a way to create a new database table other than model?

2010-11-23 Thread S Basl
None that I know of, but I am no Django guru. I get the feeling I'm missing
something about your situation however. It seems like you should be able to
accomplish what you want, saving unique info about each game, without
per-game tables. You have a many to many relationship between games and
users (ie each user can have multiple games & each game can have multiple
users), yes?  If so, you can store additional information in the bridge
table that Django creates. Check the docs for ManyToMany fields:
http://docs.djangoproject.com/en/1.2/ref/models/fields/#django.db.models.ManyToManyField
 &
http://docs.djangoproject.com/en/1.2/topics/db/models/#intermediary-manytomany



On Tue, Nov 23, 2010 at 8:55 AM, Li You  wrote:

> Because I want to save user's info about each game. And the best way
> is to save the info by each game.
>
> On Tue, Nov 23, 2010 at 9:26 PM, ringemup  wrote:
> > Perhaps there's another way to accomplish your goal.  Why do you want
> > a table for each game?
> >
> > On Nov 23, 5:14 am, vbs  wrote:
> >> Hi all,
> >>
> >> This is my situation, I want to make a web based game-hall.
> >> I have a model named Game. When I add a new game from the admin panel,
> >> a new record will be added to the database table assigned to model
> >> Game. This is what django does.
> >> And at the same time, I also want a new database table to be created,
> >> named as the name of the new game, or with some prefix. It's best to
> >> have a model assigned to this table.
> >>
> >> Is there any way to do this?
> >>
> >> Thank you.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Django users" group.
> > To post to this group, send email to django-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.
> >
> >
>
>
>
> --
> Best Regards!
>
> Li You
> University of Science and Technology of China
>
> --
> 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: Django 1.3 - JQuery features?

2010-11-23 Thread Russell Keith-Magee
On Tue, Nov 23, 2010 at 5:18 PM, Derek  wrote:
> In the last Django advent,  Zain Memon said:
>
> "A lot of implemented features missed the cut for Django 1.2, like
> drag-and-drop reordering of inlines for models with an ordering field, and
> an autocomplete widget for Foreign Key and M2M relations to be used instead
> of the select drop-down (or raw_id_fields). Those features (and others) will
> most likely land in Django 1.3."
>
> Is this still the plan?  I think autocomplete is one of the features that is
> sorely missing from Django (working with lookups numbering in the tens of
> thousands is virtually impossible). All of the third party apps have various
> quirks and shortcomings - great in some areas and poor in others.  An
> official, full-featured solution would be ideal.

Plans in an open source project are only as good as somebody willing
to implement them.

Zain's branch hasn't seen any activity since the 1.2 features landed.
There have been some recent discussion about an autocomplete widget
(#14370), but looking at the discussion on the ticket, it's still a
work in progress.

The problem is that we're about a week or so away from the 1.3 feature
freeze, so if any of these UI improvements were to be included in 1.3,
they would need to be ready pretty soon -- and you need to find a core
developer who isn't already booked with other work they want to get
into trunk. I can't speak for anyone else on the core team, but as
much as I would love to see autocomplete in admin, my plate is fairly
full 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.



Re: Is there a way to create a new database table other than model?

2010-11-23 Thread bruno desthuilliers
On 23 nov, 14:55, Li You  wrote:
> Because I want to save user's info about each game. And the best way
> is to save the info by each game.

This doesn't mean having a distinct table per game - unless of course
the database table schema is specific for each game but then you want
something a bit more elaborate than raw sql since you'll have to write
per-game specific code.

Else - I mean, if you have the same table schema for each game
"infos", you just need a foreign key on the game - no table creation
involved at all.

-- 
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: User additional profile

2010-11-23 Thread bruno desthuilliers


On 22 nov, 20:19, robos85  wrote:
> As Django noob I successfully created user validation and managed to
> add user. But I also created additional table for user profile,
> registered it in settings. But when I save() user to create it, my
> additional table is still empty.

You need to create a profile object for your user and save it too.

-- 
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: Is there a way to create a new database table other than model?

2010-11-23 Thread David De La Harpe Golden
On 23/11/10 13:55, Li You wrote:
> Because I want to save user's info about each game. And the best way
> is to save the info by each game.
> 

It sounds like you have some db modelling confusion here.

Are you sure you don't just want a many-to-many between Game and User
with some data on an explicit through model "UserGameInfo" with some
per-user per-game data?

http://docs.djangoproject.com/en/1.2/topics/db/models/#extra-fields-on-many-to-many-relationships

Now, maybe you mean that each game instance is a different /kind of
game/, and the per-game per-user data would be wildly different
for each game instance, but then you probably would use different
models for the different kinds of game.




-- 
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: How can I set a flatpage to be my homepage?

2010-11-23 Thread mongoose
Hi There,

I've specified the URL as / in the admin.
Now I get an error from firefox telling me "The page isn't redirecting
properly".

This is what I'm using for the URLs.py
urlpatterns += patterns('',
(r'^$', include('django.contrib.flatpages.urls')),
)



On Nov 21, 8:43 pm, "Joseph (Driftwood Cove Designs)"
 wrote:
> mongoose -
>   all you need to do is specify the url:  /
>   for theflatpageyou want to be homepage.
>
>   aflatpagecan only have one URL - if you want it to show up on 2
> urls (e.g. / and /home/), you'll need a re-direct, a view, a re-write
> rule, or some other trick.
>
> good luck.
>
> On Nov 21, 2:48 am, mongoose  wrote:
>
> > Hi there,
>
> > I've created some flatpages and they work great. For 
> > examplehttp://127.0.0.1:8000/home/andhttp://127.0.0.1:8000/blog/
>
> > I'm catching my flatpages with
> > urlpatterns += patterns('',
> >     (r'', include('darren_web.flatpages.urls')),
> > )
>
> > What I want though is forhttp://127.0.0.1:8000/home/tocome up 
> > ashttp://127.0.0.1:8000/
> > How can I do this?
>
> > 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: Conflict trying to save models when roles metaclass is applied.

2010-11-23 Thread bruno desthuilliers
On 23 nov, 13:08, Ben Scherrey  wrote:
>     We are attempting to apply the concepts of Domain-Context
> Interaction (DCI) to our python/django development. Unfortunately, the
> metaclass mechanism which the main python library supporting this uses
> conflicts with that of Django's metaclass for db.models. What happens
> is that a metaclass and new methods are temporarily injected into the
> model object while it acts as a role within a context. While it is an
> instance of that role, we cannot use the save method on it. When the
> role is removed the object may then be saved. Unfortunately that's
> quite unsatisfactory and I'm wondering if Django's models can be a
> little smarter when figuring out whether an object is a Django
> db.model instance or not (we use multiple inheritance to retain the
> db.model metaclass). Alternatively, can someone who gets more about
> how the metaclass stuff is working with Django suggest a fix in the
> roles module that would make it get along better with Django's ORM?
>
>     roles can be found:http://pypi.python.org/pypi/roles/0.8
>     the dci group (object composition) 
> is:http://groups.google.com/group/object-composition
>
>     some example code showing how to make it all "work" with django
> is:http://groups.google.com/group/object-composition/browse_thread/threa...
>
>     DCI is a very exciting architecture to me that extends the object
> model &MVC/T to a more logical end and addresses a lot of complex
> issues in design. The concepts have significantly altered my approach
> to designing new systems. I really want to be able to make this work
> cleanly with Django if at all possible. Appreciate any insights.
>


Hi Ben.

Could you post the full error message AND traceback you get when
trying to save your "roled" model instance please ? Django models have
a '._meta' attribute which stores, well, metadata about the model,
like fields, tablename etc, so the author's assumption (exposed in the
thread on the 'object-composition' group) that the problem is caused
by a class name change doesn't stand. I currently lack time to dig
into this DCI thing and python-roles implementation but given enough
context (=>traceback...) I might provide some hints.

HTH

-- 
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 locale/mn doesn't work.

2010-11-23 Thread Tsolmon Narantsogt
Hi fellows.

I'm using Django 1.1 version.

I make some languages in my settings.py
LANGUAGE_CODE = 'en'
LANGUAGES = (
('en','English'),
('mn','Mongolia'),
('ru','Russia'),
)
LANGUAGE_COOKIE_NAME = 'lang'

Then create po and mo files .  ( using django-admin.py makemessages -l ru ,
mn , en  , django-admin.py compilemessages)

So Mongolian translation is doesn't work ? (i'm wondering :D)

I'm debugging some views

in my url.py  i put that code.

(r'^i18n/setlang/$', 'public.views.set_language'),
that's calling below view.


public.views:
so  def set_language(request):
print 'CHANGING LANGUAGE'
next = request.REQUEST.get('next', None)
print 'next:' , next
if not next:
next = request.META.get('HTTP_REFERER', None)
print 'next 1:' , next
if not next:
next = '/'
print 'next 2:' , next
response = http.HttpResponseRedirect(next)
if request.method == 'POST':
lang_code = request.POST.get('language', None)
print 'lang_code',lang_code
  *print 'istrue' , check_for_language(lang_code)*
if lang_code and check_for_language(lang_code):
if hasattr(request, 'session'):
request.session['django_language'] = lang_code
  print 'hasattr'
else:
print 'no attr'
response.set_cookie(settings.LANGUAGE_COOKIE_NAME,
lang_code)
return response


When i choose Russia or English
* print 'istrue' , check_for_language(lang_code)*
on console : ss True
*
*
But when i choose Mongolia that's print
on console : ss False

What happend ? help me

Regards
Tsolmon.

*
*

-- 
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: how to configure database?

2010-11-23 Thread Reeti Pal
i saw the tables getting created in the terminal by using python manage.py
sql appname
but when on entering the url http://127.0.0.1:8000/admin/
m getting dis error on the admin page
AttributeError at /admin/

'str' object has no attribute '_meta'

 Request Method: GET  Request URL: http://127.0.0.1:8000/admin/  Django
Version: 1.3 pre-alpha SVN-14317  Exception Type: AttributeError  Exception
Value:

'str' object has no attribute '_meta'

 Exception Location:
/usr/lib/python2.6/dist-packages/django/contrib/admin/validation.py
in validate, line 21
i have registered both the apps on admin.py
i m not able to understand the error

-- 
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: Issue uploading photos through the admin. PIL issue.

2010-11-23 Thread Reeti Pal
could you plz elaborate on wot u did to solve the problem,
even i want to add images on my admin page.

>
>


-- 
reeti

-- 
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.



Reusing actions "Save and continue editing" and "Save"

2010-11-23 Thread lom276
Hi all.

I want to ask you if there is a best way to implement the actions
"Save and add another", "Save and continue editing" and "Save" for my
own forms. Is it possible to reuse the functionality from the Admin-
Interface or do I have to invent the wheel again and implement it
without reusing any existing code?

Thank you.

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

2010-11-23 Thread jonno
Slight update:  I ran the command:

python manage.py findstatic /imgs/cellohome.jpg

and received a message that ended with:

django.core.exceptions.SuspiciousOperation: Attempted access to '/imgs/
cellohome.jpg' denied.

I think that command applies only to a production environment, though,
so I don't know if it is relevant -- Jon.

-- 
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: how do i get access to json data?

2010-11-23 Thread alecx
Thanks for your answer Li.
This solution works for python, I figured this out too.

But how does this work inside a template with javascript?
I use $.getJSON() inside the template to get the data.
Inside the javascript I can access the data with:
   this.fields.name
but
   this.fields.author
does not work.

Any idea?




On 23 Nov., 15:05, Li You  wrote:
> sorry but a mistake.
>
>
>
> On Tue, Nov 23, 2010 at 10:01 PM, Li You  wrote:
> > Maybe this is what you want:
>
> > from json import JSONDecoder
> > s = '''{
> >    "pk": 1,
> >    "model": "store.book",
> >    "fields": {
> >        "name": "Mostly Harmless",
> >        "author": ["Douglas", "Adams"]
> >    }
> > }
> > '''
> > d = JSONDecoder().decode(s)
>
> > print a['fields']['author']
>
> ~~~ should be
> print d['fields']['author']
>
>
>
>
>
> > On Tue, Nov 23, 2010 at 9:45 PM, alecx
> >  wrote:
> >> Hello django users,
>
> >> after several try outs, i am not able to figure out how to access data
> >> in a serialized object.
> >> E. g. how do I get the name "Douglas", "Adams" in the example:
> >>http://docs.djangoproject.com/en/dev/topics/serialization/#deserializ...
>
> >> In javascript i can get e. g. the "name": "Mostly Harmless" with:
> >> this.fields.name.
> >> But how do i get the "author": ["Douglas", "Adams"]?
> >> I tried serveral options, but had no luck.
>
> >> --
> >> 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.
>
> > --
> > Best Regards!
>
> > Li You
> > University of Science and Technology of China
>
> --
> Best Regards!
>
> Li You
> University of Science and Technology of China

-- 
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 locale/mn doesn't work.

2010-11-23 Thread Tom Evans
On Tue, Nov 23, 2010 at 2:41 PM, Tsolmon Narantsogt  wrote:
> Hi fellows.
> I'm using Django 1.1 version.
> I make some languages in my settings.py
> LANGUAGE_CODE = 'en'
> LANGUAGES = (
>     ('en','English'),
>     ('mn','Mongolia'),
>     ('ru','Russia'),
>     )
> LANGUAGE_COOKIE_NAME = 'lang'
> Then create po and mo files .  ( using django-admin.py makemessages -l ru ,
> mn , en  , django-admin.py compilemessages)
> So Mongolian translation is doesn't work ? (i'm wondering :D)

This is expected - django doesn't ship with a base Mongolian
localization, so you must add one first.

http://docs.djangoproject.com/en/1.2/topics/i18n/localization/#locale-restrictions

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: how to configure database?

2010-11-23 Thread lom276
python manage.py sql appname just prints the create table sql
statements, but does not sync them with you DB.

user python manage.py syncdb

Michael.

On Nov 23, 2:47 pm, Reeti Pal  wrote:
> i saw the tables getting created in the terminal by using python manage.py
> sql appname
> but when on entering the urlhttp://127.0.0.1:8000/admin/
> m getting dis error on the admin page
> AttributeError at /admin/
>
> 'str' object has no attribute '_meta'
>
>  Request Method: GET  Request URL:http://127.0.0.1:8000/admin/ Django
> Version: 1.3 pre-alpha SVN-14317  Exception Type: AttributeError  Exception
> Value:
>
> 'str' object has no attribute '_meta'
>
>  Exception Location:
> /usr/lib/python2.6/dist-packages/django/contrib/admin/validation.py
> in validate, line 21
> i have registered both the apps on admin.py
> i m not able to understand the error

-- 
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: Is there a way to create a new database table other than model?

2010-11-23 Thread Li You
>> Because I want to save user's info about each game. And the best way
>> is to save the info by each game.
>>
>
> It sounds like you have some db modelling confusion here.
>
> Are you sure you don't just want a many-to-many between Game and User
> with some data on an explicit through model "UserGameInfo" with some
> per-user per-game data?
>
> http://docs.djangoproject.com/en/1.2/topics/db/models/#extra-fields-on-many-to-many-relationships

ok, this is a way.

Let me describe this problem in more detail:
I have a Game model for each game. This model can be seen as a list of
all games, such as,

class Game(models.Model):
name = models.CharField(max_length = 128, unique = True)
available = models.BooleanField(default = True)
timestamp = models.DateTimeField(auto_now_add=True)

And usually a user just plays with a few of games, but there maybe
hundreds of games.
A user may have different level in different games, so I need to keep
record of the user's level in each game.

At the beginning, I want to create a table for each game. Only users
who play that game get their level logged in the game's table.

By using many-to-many field, I can record the level info of all games
in a single table. But I am a little afraid of the performance...

That is the origin of this question. Thank you all. :)

-- 
Best Regards!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Is there a way to create a new database table other than model?

2010-11-23 Thread Tom Evans
On Tue, Nov 23, 2010 at 3:13 PM, Li You  wrote:
> Let me describe this problem in more detail:
> I have a Game model for each game. This model can be seen as a list of
> all games, such as,
>
> class Game(models.Model):
>    name = models.CharField(max_length = 128, unique = True)
>    available = models.BooleanField(default = True)
>    timestamp = models.DateTimeField(auto_now_add=True)
>
> And usually a user just plays with a few of games, but there maybe
> hundreds of games.
> A user may have different level in different games, so I need to keep
> record of the user's level in each game.
>
> At the beginning, I want to create a table for each game. Only users
> who play that game get their level logged in the game's table.
>
> By using many-to-many field, I can record the level info of all games
> in a single table. But I am a little afraid of the performance...
>
> That is the origin of this question. Thank you all. :)
>

"We should forget about small efficiencies, say about 97% of the time:
premature optimization is the root of all evil. Yet we should not pass
up our opportunities in that critical 3%.A good programmer will not be
lulled into complacency by such reasoning, he will be wise to look
carefully at the critical code; but only after that code has been
identified" - Knuth

Your design actually described a through table for M2M, but you don't
want to do that because you fear that the performance will be bad.
Implement your design, and then work out whether performance will be
bad.

Even if it is, relational databases are designed to be used in this
manner. You could (depending upon the capabilities of your database)
partition the through table based upon the game type. With this
database configuration, you would have the effect of having one table
per game type, but without adding unnecessary complexity to your
software.

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: how to configure database?

2010-11-23 Thread Reeti Pal
i ve used syncdb for database creation, i think the problem is sumthing at
the admin page not at the models level.

>
>



-- 
reeti

-- 
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.



tutorial part 4: ImportError

2010-11-23 Thread steph
Hi group,

I'm new - just worked thgough the tutorial. In part 4 about the use of
generic views I've got a problem - I can't import ListView and
DetailView:

>>> from django.views.generic import DetailView
Traceback (most recent call last):
  File "", line 1, in 
ImportError: cannot import name DetailView
>>> from django.views.generic import ListView
Traceback (most recent call last):
  File "", line 1, in 
ImportError: cannot import name ListView

I'm on the newest version of django: first tried with version 1.2.3,
then I upgraded to 1.3 alpha - same problem.

Any clues?

thanks,
stephan

ps: other than that it's a great tutorial!

-- 
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: tutorial part 4: ImportError

2010-11-23 Thread Michael Sprayberry
Steph, 
 
those instructions are incorrect try 
from djanog.views.generic import list_view, list_detail
 
Michael

--- On Tue, 11/23/10, steph  wrote:


From: steph 
Subject: tutorial part 4: ImportError
To: "Django users" 
Date: Tuesday, November 23, 2010, 11:06 AM


Hi group,

I'm new - just worked thgough the tutorial. In part 4 about the use of
generic views I've got a problem - I can't import ListView and
DetailView:

>>> from django.views.generic import DetailView
Traceback (most recent call last):
  File "", line 1, in 
ImportError: cannot import name DetailView
>>> from django.views.generic import ListView
Traceback (most recent call last):
  File "", line 1, in 
ImportError: cannot import name ListView

I'm on the newest version of django: first tried with version 1.2.3,
then I upgraded to 1.3 alpha - same problem.

Any clues?

thanks,
stephan

ps: other than that it's a great tutorial!

-- 
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: tutorial part 4: ImportError

2010-11-23 Thread Robbington
Firstly friend,

1.3 alpha has been released as a testing package. It isnt the most
stable version and not meant for production, I would revert back to
1.2 unless your plan is to help the django team with bug fixes.


 Also, you are reading the wrong tutorial for your version, that is
why you are getting that error.

http://docs.djangoproject.com/en/1.2/intro/tutorial04/

Here is the one you want, I can see why that would be a bit confusing
to you.

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: tutorial part 4: ImportError

2010-11-23 Thread Daniel Roseman
On Nov 23, 4:06 pm, steph  wrote:
> Hi group,
>
> I'm new - just worked thgough the tutorial. In part 4 about the use of
> generic views I've got a problem - I can't import ListView and
> DetailView:
>
> >>> from django.views.generic import DetailView
>
> Traceback (most recent call last):
>   File "", line 1, in 
> ImportError: cannot import name DetailView>>> from django.views.generic 
> import ListView
>
> Traceback (most recent call last):
>   File "", line 1, in 
> ImportError: cannot import name ListView
>
> I'm on the newest version of django: first tried with version 1.2.3,
> then I upgraded to 1.3 alpha - same problem.
>
> Any clues?
>
> thanks,
> stephan
>
> ps: other than that it's a great tutorial!

Are you sure you've upgraded correctly? It won't work at all if you
have anything less than 1.3 alpha - the tutorial you're using is for
the development version only (there's a big link at the top of the
page for the one that works in previous versions), and generic views
are one big element that has changed since 1.2. How did you install
1.3?
--
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: how to configure database?

2010-11-23 Thread Michael Sprayberry
share a little bit of your code so that we know what you are seeing. Just 
saying that you aren't getting things in your admin does not provide enough 
information.

--- On Tue, 11/23/10, Reeti Pal  wrote:


From: Reeti Pal 
Subject: Re: how to configure database?
To: django-users@googlegroups.com
Date: Tuesday, November 23, 2010, 11:09 AM




i ve used syncdb for database creation, i think the problem is sumthing at the 
admin page not at the models level.









-- 
reeti

-- 
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: how to configure database?

2010-11-23 Thread rattanpriya bhasin
Me n reeti have been working on same project.
So it was like we made two independent projects with independent application
and dedicated independent server to each.Now i want to link my application
with reeti's n vice versa.
So to do that,she included my app name in her settings.py and modified her
models.py by including my models.py
We are not able to proceed affter this.
So basically can u suggest the way ,i can link my app with hers?
Do i need to devise a new database and assign the same to both the apps.?


On Tue, Nov 23, 2010 at 10:26 PM, Michael Sprayberry <
michaelspraybe...@yahoo.com> wrote:

> share a little bit of your code so that we know what you are seeing. Just
> saying that you aren't getting things in your admin does not provide enough
> information.
>
> --- On *Tue, 11/23/10, Reeti Pal * wrote:
>
>
> From: Reeti Pal 
> Subject: Re: how to configure database?
> To: django-users@googlegroups.com
> Date: Tuesday, November 23, 2010, 11:09 AM
>
>
>
>
> i ve used syncdb for database creation, i think the problem is sumthing at
> the admin page not at the models level.
>
>
>
>
>
>
> --
> reeti
> --
> 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.
>

-- 
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: Problem with Mysql Queries in django

2010-11-23 Thread Jagdeep Singh Malhi


On Nov 22, 11:28 pm, Rogério Carrasqueira
 wrote:
> Hi Jagdeep,
>
> Consider to use a query like this example:
>
> sales =
> Sale.objects.extra(select={'month':'month(date_created)','year':'year(date_created)'}).values('year','month').annotate(month=11,year=2010)
>
Not working

Error :

File "", line 1, in 
  File "/usr/local/lib/python2.6/dist-packages/django/db/models/
query.py", line 632, in annotate
is_summary=False)
  File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/
query.py", line 911, in add_aggregate
field_list = aggregate.lookup.split(LOOKUP_SEP)
AttributeError: 'int' object has no attribute 'lookup'


> It works on mysql.
>
> More informationhttp://docs.djangoproject.com/en/dev/ref/models/querysets/

-- 
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.



HELP NEEDED

2010-11-23 Thread Dipo Elegbede
Hi,
I have done some extensive reading on python.
i want to design a classifieds site for jobs.
The service is meant to send people who register an sms with available jobs
that fit their criteria/cv.
But the main idea is that people come and register for quick jobs(like
www.freelancer.com) and put up their
criteria,age,location,qualificationsand when a company or employer posts
a job,the people that fall into the category that was specified get sms and
email alerts as to the availability of the job.
I am taking this as my first project and would appreciate any help.
I am looking in the direction of python, maybe django.
Thanks.

-- 
Elegbede Muhammed Oladipupo
OCA
+2348077682428
+2347042171716
www.dudupay.com
Mobile Banking Solutions | Transaction Processing | Enterprise Application
Development

-- 
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.



Cheetah templates

2010-11-23 Thread Tim
Hi,
I use the conventional Django template system for everything except
for one task in which I would like to use Cheetah.
I've got the following code in a view:
source, loader =
django.template.loader.find_template_source('tools/example.tmpl')
contents=Cheetah.Template.Template(source,searchList=[logo])
return HttpResponse(contents)

and I get this response:
... lib/python2.6/django/template/loader.py", line 149, in
find_template_source
   raise Exception("Found a compiled template that is incompatible
with the deprecated `django.template.loaders.find_template_source`
function.")

The "tools/example.tmpl" is a subdirectory under my templates dir,
which is configured in the settings TEMPLATE_DIRS and django has no
problem finding other templates in those subdirectories.

Can someone point out what I'm doing wrong here?
thanks,
--Tim Arnold

-- 
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: HELP NEEDED

2010-11-23 Thread Huy Ton That
I would recommend selecting an easier first project. Good luck.

On Nov 23, 2010 1:28 PM, "Dipo Elegbede"  wrote:

Hi,
I have done some extensive reading on python.
i want to design a classifieds site for jobs.
The service is meant to send people who register an sms with available jobs
that fit their criteria/cv.
But the main idea is that people come and register for quick jobs(like
www.freelancer.com) and put up their
criteria,age,location,qualificationsand when a company or employer posts
a job,the people that fall into the category that was specified get sms and
email alerts as to the availability of the job.
I am taking this as my first project and would appreciate any help.
I am looking in the direction of python, maybe django.
Thanks.

-- 
Elegbede Muhammed Oladipupo
OCA
+2348077682428
+2347042171716
www.dudupay.com
Mobile Banking Solutions | Transaction Processing | Enterprise Application
Development

-- 
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.



list_filter doesn't appear for model with ForeignKey to auth.models.User

2010-11-23 Thread Carsten Fuchs

Hi all,

developing my app with Django 1.2.1 and having completed large parts of 
the main functionality already, I've now started with familiarizing 
myself with user authentication.


I understand that django.contrib.auth.models.User is best extended as 
described at 
, 
but I also want to associate users with some of my regular models. For 
example:




from django.db import models
from django.contrib.auth.models import User

class Department(models.Model):
benutzer = models.ManyToManyField(User)

class Team(models.Model):
 head = models.ForeignKey(User)



Unfortunately, with this admin.py



class DepAdmin(admin.ModelAdmin):
list_filter = ['benutzer']

admin.site.register(Department, DepAdmin)

class TeamAdmin(admin.ModelAdmin):
list_filter = ['head']

admin.site.register(Team, TeamAdmin)



none of the two list filters appears in the side bar (other filters that 
are similar but whose "target" model is not User work fine).



Thus, my question is, is there something about model "User" that 
prevents it from being used with list_filter?

What can I do to have "Departments" and "Teams" filtered by "User"?

Best regards,
Carsten



--
   Cafu - the open-source Game and Graphics Engine
for multiplayer, cross-platform, real-time 3D Action
  Learn more at http://www.cafu.de

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

2010-11-23 Thread VB
Thanks, Joseph and Scot. I'll take a look at using Django's User
model.

VB

On Nov 21, 9:29 am, Scot Hacker  wrote:
> On Nov 20, 2:55 pm, VB  wrote:
>
> > If I intend to write my own authentication, can I use my define my own
> > User model? Or, am I better off naming the model something else?
>
> Why write your own authentication? That wheel's been invented so
> excellently by  django-registration (and its equally indispensable
> cousin django-profiles). I'd recommend sticking with the Django User
> object, and doing your auth with django-registration - they're
> fundamentals of most Django projects.
>
> ./s

-- 
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: how to configure database?

2010-11-23 Thread Reeti Pal
tnkuu ppl... the problem has been solved...

-- 
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: HELP NEEDED

2010-11-23 Thread Michael Sprayberry
I would definitely go Django for this project and maybe divide out the project 
and get some people to help you seeing as this is your first project. Not only 
do you have to take into account the look up the website, the models for 
employers and freelancers, but you are also going to need to take into acount a 
Link to get these emails sent to the freelancers and also the replys to the 
employers and assumming you don't want to be giving out personal information 
this requires some allisoning. 
 
Good luck to you on this project and if you want help get back to me.
 
Michael Sprayberry

--- On Tue, 11/23/10, Dipo Elegbede  wrote:


From: Dipo Elegbede 
Subject: HELP NEEDED
To: django-users@googlegroups.com
Date: Tuesday, November 23, 2010, 1:26 PM


Hi,
I have done some extensive reading on python.
i want to design a classifieds site for jobs.
The service is meant to send people who register an sms with available jobs 
that fit their criteria/cv.
But the main idea is that people come and register for quick jobs(like 
www.freelancer.com) and put up their 
criteria,age,location,qualificationsand when a company or employer posts a 
job,the people that fall into the category that was specified get sms and email 
alerts as to the availability of the job.
I am taking this as my first project and would appreciate any help.
I am looking in the direction of python, maybe django.
Thanks.

-- 
Elegbede Muhammed Oladipupo
OCA
+2348077682428
+2347042171716
www.dudupay.com
Mobile Banking Solutions | Transaction Processing | Enterprise Application 
Development

-- 
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.



How do I get tracebacks printed to terminal?

2010-11-23 Thread Markus Barth
I am using quite a lot of asynchronous calls for updating a page. The
problem is that this way you never see a traceback. In turbogears the
development server prints all tracebacks to the terminal. Is there any
way to get a similar behaviour with 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.



Re: How do I get tracebacks printed to terminal?

2010-11-23 Thread Javier Guerra Giraldez
On Tue, Nov 23, 2010 at 3:48 PM, Markus Barth
 wrote:
> I am using quite a lot of asynchronous calls for updating a page. The
> problem is that this way you never see a traceback. In turbogears the
> development server prints all tracebacks to the terminal. Is there any
> way to get a similar behaviour with django?

firebug can show the content of any request/response, including AJAX
ones.  it also renders any HTML content, like those generated by the
Django error pages

-- 
Javier

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: How do I get tracebacks printed to terminal?

2010-11-23 Thread Markus Barth
I have just found a post from beginning of last year pointing out that
this feature got "lost" during the transition from 0.9 to 1.0. I have
digged a bit through the code but must admit that fixing this
definitely should be done by someone who is familiar with django
internals.

Tracebacks are one of the strongest features of python and without
them the slogan that Django is for "perfectionists with deadlines" is
not applicable in case of ajax/json apps - because you spend more time
trying to blindly find your bug than actually developping.

-- 
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: How do I get tracebacks printed to terminal?

2010-11-23 Thread Markus Barth


On 23 nov, 23:19, Javier Guerra Giraldez  wrote:
> On Tue, Nov 23, 2010 at 3:48 PM, Markus Barth
>
>  wrote:
> > I am using quite a lot of asynchronous calls for updating a page. The
> > problem is that this way you never see a traceback. In turbogears the
> > development server prints all tracebacks to the terminal. Is there any
> > way to get a similar behaviour with django?
>
> firebug can show the content of any request/response, including AJAX
> ones.  it also renders any HTML content, like those generated by the
> Django error pages
>
> --
> Javier

This is only helpful if the request is answerered by the server, but
as soon as you have an exception, all you see on the console is a 500
Error and Firebug  tells you "status: aborted"

For example I have just spend an hour chasing a bug just to find out
that syncdb didn't sync a table. With a traceback I would have seen
the problem within seconds

Anyway, thanks for the hint

-- 
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: How do I get tracebacks printed to terminal?

2010-11-23 Thread Markus Barth


On 23 nov, 23:33, Markus Barth  wrote:
> On 23 nov, 23:19, Javier Guerra Giraldez  wrote:
>
> > On Tue, Nov 23, 2010 at 3:48 PM, Markus Barth
>
> >  wrote:
> > > I am using quite a lot of asynchronous calls for updating a page. The
> > > problem is that this way you never see a traceback. In turbogears the
> > > development server prints all tracebacks to the terminal. Is there any
> > > way to get a similar behaviour with django?
>
> > firebug can show the content of any request/response, including AJAX
> > ones.  it also renders any HTML content, like those generated by the
> > Django error pages
>
> > --
> > Javier
>
> This is only helpful if the request is answerered by the server, but
> as soon as you have an exception, all you see on the console is a 500
> Error and Firebug  tells you "status: aborted"
>
> For example I have just spend an hour chasing a bug just to find out
> that syncdb didn't sync a table. With a traceback I would have seen
> the problem within seconds
>
> Anyway, thanks for the hint

Sorry, I have to correct myself, in fact, I got the information
through firebug. Thanks a lot, that saved my day.

-- 
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: In-memory sorting of a QuerySet, yielding a QuerySet

2010-11-23 Thread Christophe Pettus

On Nov 23, 2010, at 2:25 AM, bruno desthuilliers wrote:
> Strictly speaking, you don't need the queryset attribute of a
> ModelChoiceField to be a QuerySet instance - as long as the object you
> pass in has a '.all()' method that returns an iterable, you should be
> fine (cf django/forms/models.py for the definition of the
> ModelChoiceField class and the companion ModelChoiceIterator class).
> 
> Also, note that if you manually set the .choices property of your
> ModelChoiceField, it will totally bypass access to the .queryset
> attribute.

Almost!  Almost!  So close, and yet so far...   It looks like ModelChoiceField 
also uses the .get method of the queryset to do the validation, and it does go 
straight to the queryset (bypassing the choices) in that situation.  Darn.  I 
might still be able to fake 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: In-memory sorting of a QuerySet, yielding a QuerySet

2010-11-23 Thread Christophe Pettus

On Nov 23, 2010, at 2:25 AM, bruno desthuilliers wrote:
> Strictly speaking, you don't need the queryset attribute of a
> ModelChoiceField to be a QuerySet instance - as long as the object you
> pass in has a '.all()' method that returns an iterable, you should be
> fine (cf django/forms/models.py for the definition of the
> ModelChoiceField class and the companion ModelChoiceIterator class).
> 
> Also, note that if you manually set the .choices property of your
> ModelChoiceField, it will totally bypass access to the .queryset
> attribute.

Of course, in struggling with this, I found myself thinking, "If only there 
were a Field that didn't use querysets, but took a list of tuples; then I could 
just use that instead..."  :)

--
-- 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.



New ManyToManyField Approach

2010-11-23 Thread sh...@bogomip.com
I've recently started using the following approach when attempting to
reduce the size of ManyToManyField type reference tables.  Currently
I'm working on implementing this in a limited fashion into my own
work.  I would like to share what I'm working on with you all and see
if it's worth a reaction at all.

Without test data I'm not sure where the trade offs are with the
following.  However it should improve the ability to look up items
that reference a certain set of keys as well as easily check to see if
a set already exists.  This should also help reduce the number of rows
in a reference table.

Item 1 references Users 1,2,3,4
Item 2 references Users 1,2,3,4
Item 3 references Users 2,3,4

Item 1 would attempt to see if the following long exists in the
reference table for reference.

"""
>>> long(str(adler32('1|2|3|4')) + "000")
150274623000L
"""

No?  Add it.

"""
INSERT INTO "apps_app_reference" VALUES(1,150274623000,1);
INSERT INTO "apps_app_reference" VALUES(2,150274623000,2);
INSERT INTO "apps_app" VALUES(1,...,150274623000)
"""

Item 2 would do the same.. it exists and the set is identical.. so
simply use its reference.

"""
INSERT INTO "apps_app" VALUES(2,...,150274623000)
"""

Item 3 checks to see if it's set exists already in the reference
table.

"""
>>> long(str(adler32('2|3|4')) + "000")
78905746000L
"""

No? Add it.

"""
INSERT INTO "apps_app_reference" VALUES(3,78905746000,1);
INSERT INTO "apps_app_reference" VALUES(4,78905746000,2);
INSERT INTO "apps_app" VALUES(3,...,78905746000)
"""

Adding 000 to the end allows me to use the same adler32 result for
multiple sets that collide.  If I find a collision then check for the
adler32 result with 001 at the end and so on until no more collisions
occur, allowing up to 999 collisions which may not be enough for some
situations.. more than enough for mine after exhausting 15 gigs of
memory testing the limits of this approach.  In my testing if I assume
that any one item will only reference a maximum of 2**7 different
elements, each element ranging between 1 and 2**32.. then after random
testing and 5 million reference IDs nearly 8000 sets were duplicated
and referenced correctly and the collision offset marker for any hash
maxed out at 003.

I decided to try out using adler32 instead of MD5 or SHA based hashes
since selecting data using numeric indexes as equal or between values
seems faster than selecting an equal or like long string.  That and it
reduces storage space if you don't expect the need for as many
distinct reference IDs as MD5 or other cryptographic hashes can offer.

In my own project I needed a quick method of selecting Items that
relate to a certain distinct set.  I'm unsure of any extra benefit
anyone else can get out of this method.  I really like the existing
way that ManyToMany fields work.  Especially since the reference table
does all the referencing leaving base table very simple in layout.

- Shane

-- 
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.



makemessages failing to extract all strings from Javascript

2010-11-23 Thread Lau
I'm having some trouble with makemessages failing while parsing my
javascript files. I'm running it with domain set to djangojs and it's
successfully finding all my javascript files but keeps halting during
the parsing.

I did a bit of debugging in the makemessages command (Django version
1.2.1 and trunk) and found that when running in djangojs mode it
pythonizes the javascript files with pythonize_re.sub('\n#', src), but
then runs the xgettext shell command with language "Perl". Why is
this?

The javascript code it's bailing out on is stuff like this:

  message.css("margin-left", -1*message.width()/2);
  $(".action", form).val(id ? "change" : "create");

The outcome is a bit random, for some javascript functions the parser
just skips the function, which also skips the gettext calls in it, and
at other times it just breaks out of the whole file with no further
processing. So I'm not entirely sure what the makemessages command is
supposed to be doing ("converting" the javascript to python and
running xgettext on it as if it were perl?).

Any clarification on this would be great, thanks!

-Lau

-- 
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: New ManyToManyField Approach

2010-11-23 Thread Christophe Pettus

On Nov 23, 2010, at 5:40 PM, sh...@bogomip.com wrote:
> Without test data I'm not sure where the trade offs are with the
> following.  However it should improve the ability to look up items
> that reference a certain set of keys as well as easily check to see if
> a set already exists.  This should also help reduce the number of rows
> in a reference table.

It definitely does that.  The downsides are:

1. Selects that are looking for a particular individual value ("all items that 
reference user 1") are going to be a sequential scan.

2. You might get collisions on the adler32 function in real life; I'm not 
familiar enough with that particular function.

If you are using PostgreSQL, you might look at using intarray or hstore fields 
instead; those have the same advantages you enumerate, but you can also index 
on them in ways that will speed up searches for individual values.

--
-- 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: New ManyToManyField Approach

2010-11-23 Thread sh...@bogomip.com
On Nov 23, 6:42 pm, Christophe Pettus  wrote:
> On Nov 23, 2010, at 5:40 PM, sh...@bogomip.com wrote:
>
> > Without test data I'm not sure where the trade offs are with the
> > following.  However it should improve the ability to look up items
> > that reference a certain set of keys as well as easily check to see if
> > a set already exists.  This should also help reduce the number of rows
> > in a reference table.
>
> It definitely does that.  The downsides are:
>
> 1. Selects that are looking for a particular individual value ("all items 
> that reference user 1") are going to be a sequential scan.

Since you've noticed it I have to ask.. since I didn't think it would
be any different.. how does this differ from the current Django
method?

> 2. You might get collisions on the adler32 function in real life; I'm not 
> familiar enough with that particular function.

Oh.. it's pretty easy to get a collision.. only takes around 1000
iterations of random sets in my case.  Thats the point of adding a 0
padded number, starting at 0, to the end of the adler32 result.
Allows for padded length amount of collisions.

> If you are using PostgreSQL, you might look at using intarray or hstore 
> fields instead; those have the same advantages you enumerate, but you can 
> also index on them in ways that will speed up searches for individual values.

Outside of the ORM I'll play around with this.

- Shane

-- 
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: New ManyToManyField Approach

2010-11-23 Thread Christophe Pettus

On Nov 23, 2010, at 9:09 PM, sh...@bogomip.com wrote:
> Since you've noticed it I have to ask.. since I didn't think it would
> be any different.. how does this differ from the current Django
> method?

The standard Django implementation creates an intermediate table with foreign 
keys back to the tables on each side, so it's simple to do a query against that 
intermediate model to handle queries like that.  (This is the standard SQL way 
of handling a many-to-many relationship.)

In fact, in your structure, I'm not sure you can actually answer the question 
"which items refer to user 1," since that information is lost into the hash.  
If the only question you ever need to answer is "does item 1 refer to this 
particular set of users?", then that's not a big deal.

>> If you are using PostgreSQL, you might look at using intarray or hstore 
>> fields instead; those have the same advantages you enumerate, but you can 
>> also index on them in ways that will speed up searches for individual values.
> 
> Outside of the ORM I'll play around with this.

You don't need to abandon the ORM to use hstore or intarray; they adapt very 
nicely to Pyython types and Django model types.

--
-- 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.