Re: Is it really this hard?

2007-05-16 Thread John Matthew
Wow, very cool, I didn't know that James!  Again, thank you!

I was trying

obj.portfolio = portid  and then
obj.portfolio.id = portid < that was really bad according to django :-)

J

On 5/16/07, James Bennett <[EMAIL PROTECTED]> wrote:
>
>
> On 5/16/07, John M <[EMAIL PROTECTED]> wrote:
> > portfolio = Portfolio.objects.get(pk=portid)
> >
> > obj.portfolio = portfolio
>
> Somewhat undocumented, but you should be able to do
>
> obj.portfolio_id = portid
>
> Instead of doing the lookup and assigning the object, if you're
> concerned about the extra DB hit.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of
> correct."
>
> >
>

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



Re: Is it really this hard?

2007-05-16 Thread James Bennett

On 5/16/07, John M <[EMAIL PROTECTED]> wrote:
> portfolio = Portfolio.objects.get(pk=portid)
>
> obj.portfolio = portfolio

Somewhat undocumented, but you should be able to do

obj.portfolio_id = portid

Instead of doing the lookup and assigning the object, if you're
concerned about the extra DB hit.

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

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



Re: Many2Many question about Database API

2007-05-16 Thread Ben Jones

I see where this has already been addressed in ticket #2457

http://code.djangoproject.com/ticket/2457

Apparently it's a bug in the version of sqlite that's bundled with the
Windows installer (3.3.4).

The command line version of sqlite that I'm running is much more
recent, which explains the different results.

I originally thought it was just a misunderstanding on my part of the
docs or else I would have researched it a little more before posting.

Thanks for the help.

On 5/16/07, Ben Jones <[EMAIL PROTECTED]> wrote:
> > Might be worthwhile having a look at the SQL Django is generating. From
> > the shell prompt import db.connection and have a look at
> > db.connection.queries after running the query.
> >
> > I wouldn't be too surprised to discover this is a bug caused by using a
> > left outer join here, in which case it's already in the pipeline to be
> > fixed (there are a couple of cases where that's happening). However, it
> > would be good to confirm that.
>
> The query is below. Django is still showing me all three content
> records, however when I run this query on the sqlite command line I
> only get the single record I am expecting. To get it to run on the
> cli, however, I did have to quote the "list-1" in the WHERE clause --
> I'm guessing that Django did that prior to executing it.
>
>
> SELECT "train_content"."id","train_content"."slug",
> "train_content"."title","train_content"."author",
> "train_content"."body","train_content"."pub_date",
> "train_content"."add_date","train_content"."mod_date",
> "train_content"."template","train_content"."status"
>
> FROM "train_content"
>
> LEFT OUTER JOIN "train_content_categories"
> AS "m2m_train_content__categories"
> ON "train_content"."id" = "m2m_train_content__categories"."content_id"
>
> INNER JOIN "train_category"
> AS "train_content__categories"
> ON "m2m_train_content__categories"."category_id" =
> "train_content__categories"."id"
>
> WHERE ("train_content__categories"."slug" = list-1)
>
> --
> -Ben
>


-- 
 -Ben

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



Re: Scalability / Traffic-Volume Numbers

2007-05-16 Thread Ray Dookie

I'm starting off with everything on 1 server.
As for traffic at the start I'm looking at 2000-3000 hits/10K - 20K
page views per day.

Maybe I should have asked this instead :
If you used one of www.slicehost.com VPS's (say the 512MB ram one)..
from any experience you may have on similar setups, running everything
on a single server.. how would you configure it for optiminal
performance?
assuming it was a very dynamic Django + MySql site.

And.. what you think visits/pageviews wise... how many this server
would be able to handle (just off the top of your head - no hard facts
needed)..

thanks
cheers.


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



Re: Scalability / Traffic-Volume Numbers

2007-05-16 Thread Ray Dookie

Thanks... I'll check out the article.
As for what kinda of data i'm serving, the site would be pretty
dynamic and as for the level of caching, i'm not sure as yet.


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



Re: Many2Many question about Database API

2007-05-16 Thread Malcolm Tredinnick

On Wed, 2007-05-16 at 20:53 -0500, Ben Jones wrote:
> Thanks for the help, Russ.
> 
> 
> > > For test data, I have entered 3 categories and 3 pieces of content
> > > (one in each of the 3 categories).
> >
> > You have 3 categories and 3 content objects, but what is in the m2m
> > table between them? What is the matrix of category/content
> > relationships?
> 
> It's the content_categories relationship table the Django so kindly
> creates for me.

Russell was asking what is in the table and how do the table entries map
to the models on either end (i.e. just knowing the id values in the
intermediate table doesn't tell us anything much).

> > > In my understanding of the docs, I expected to be able to use the line
> > > of code below to retrieve all pieces of content in the category with a
> > > slug of 'list-1'. However, that appears to not be the case, as every
> > > record from Content is returned.
> > >
> > > >>> Content.objects.filter(categories__slug__exact = 'list-1')
> > > [, , ]
> >
> > The syntax appears right for the problem you are describing;
> 
> . . . and strangely enough it seems to work just fine in MySQL.
> However, in sqlite I get the results previously described -- even
> after resetting the database and re-adding the records and verifying
> the expected result on the command line (1 record each in the
> relationship table)
> 
> Very odd. Or maybe not so odd to somebody that's more familiar with
> sqlite than I am. This is actually the first time I've ever used it
> for anything.

Might be worthwhile having a look at the SQL Django is generating. From
the shell prompt import db.connection and have a look at
db.connection.queries after running the query.

I wouldn't be too surprised to discover this is a bug caused by using a
left outer join here, in which case it's already in the pipeline to be
fixed (there are a couple of cases where that's happening). However, it
would be good to confirm that.

Regards,
Malcolm


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



Re: Scalability / Traffic-Volume Numbers

2007-05-16 Thread James Bennett

On 5/16/07, Ray Dookie <[EMAIL PROTECTED]> wrote:
> I'm interested to know how much load can a django box say with 512MB
> ram handle.

The biggest question to ask here is what level of traffic you're
expecting, and how quickly you expect that traffic to go; there are
lots of things you can do to your setup to optimize for different
traffic levels, so it's very hard to give a concise answer to "what
can this server handle".

Generally your biggest RAM sinks are going to be (not necessarily in
this order):

* memcached, if you're using it
* Apache/mod_python, if you opt for that as the web server setup
* Your database server

For most situations, focus first on how much RAM you give to the
database, because the database is almost always the first bottleneck
in scaling (and because a huge memcached instance with a blazing-fast
web server is no good if you can't get at the data to put it in the
cache), then look at other concerns.

If memory is a significant concern, you may also want to look at using
lighttpd and FastCGI; lighttpd isn't always the ideal choice, but you
can squeeze a little extra performance out of it by taking advantage
of its relatively low memory use compared to Apache with prefork MPM
(though bear in mind that you'll still have memory overhead from
FastCGI processes).

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

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



Re: Many2Many question about Database API

2007-05-16 Thread Ben Jones

Thanks for the help, Russ.


> > For test data, I have entered 3 categories and 3 pieces of content
> > (one in each of the 3 categories).
>
> You have 3 categories and 3 content objects, but what is in the m2m
> table between them? What is the matrix of category/content
> relationships?

It's the content_categories relationship table the Django so kindly
creates for me.


> > In my understanding of the docs, I expected to be able to use the line
> > of code below to retrieve all pieces of content in the category with a
> > slug of 'list-1'. However, that appears to not be the case, as every
> > record from Content is returned.
> >
> > >>> Content.objects.filter(categories__slug__exact = 'list-1')
> > [, , ]
>
> The syntax appears right for the problem you are describing;

. . . and strangely enough it seems to work just fine in MySQL.
However, in sqlite I get the results previously described -- even
after resetting the database and re-adding the records and verifying
the expected result on the command line (1 record each in the
relationship table)

Very odd. Or maybe not so odd to somebody that's more familiar with
sqlite than I am. This is actually the first time I've ever used it
for anything.

-- 
 -Ben

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



Re: Scalability / Traffic-Volume Numbers

2007-05-16 Thread Kelvin Nicholson

Ray Dookie wrote:
> Guys guide me a bit here..
> I'm interested to know how much load can a django box say with 512MB
> ram handle.
> I'm brining out a site soon, and was planning on taking either the
> 256mb or 512mb (VPS) setup that www.slicehost.com offers.
> 

I'm certainly not a guru, but one question popped up automatically: what 
type of data are you going to serve (how dynamic will your site be), and 
what will your level of caching be?

> what i was wondering, is with a box with those specs (on average),
> what i could expect in terms of what is the vists/pageviews i could
> handle on that single sever (VPS) set up before i have need to get
> more servers.
> 

You might be interested to see the following benchmark, yet remember it 
is just a benchmark.

http://superjared.com/entry/quick-django-benching/

Cheers,

Kelvin


-- 
Kelvin Nicholson
Voice: +886 9 52152 336
Voice: +1 503 715 5535
GPG Keyid: 27449C8C
Data: [EMAIL PROTECTED]
Skype: yj_kelvin
Site: http://www.kelvinism.com

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



Re: Scalability / Traffic-Volume Numbers

2007-05-16 Thread Ray Dookie

Guys guide me a bit here..
I'm interested to know how much load can a django box say with 512MB
ram handle.
I'm brining out a site soon, and was planning on taking either the
256mb or 512mb (VPS) setup that www.slicehost.com offers.

what i was wondering, is with a box with those specs (on average),
what i could expect in terms of what is the vists/pageviews i could
handle on that single sever (VPS) set up before i have need to get
more servers.

Also.. from you expereiences. For any single server (dedicated or VPS)
setup..
what specs can handle what load?

Thanks.
Cheers


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



Re: Many2Many question about Database API

2007-05-16 Thread Russell Keith-Magee

On 5/17/07, Ben Jones <[EMAIL PROTECTED]> wrote:
>
> I have 2 models that I'm using "for training": Content and Category
> with a ManyToMany field in Content to relate them.
>
> For test data, I have entered 3 categories and 3 pieces of content
> (one in each of the 3 categories).

You have 3 categories and 3 content objects, but what is in the m2m
table between them? What is the matrix of category/content
relationships?

> In my understanding of the docs, I expected to be able to use the line
> of code below to retrieve all pieces of content in the category with a
> slug of 'list-1'. However, that appears to not be the case, as every
> record from Content is returned.
>
> >>> Content.objects.filter(categories__slug__exact = 'list-1')
> [, , ]

The syntax appears right for the problem you are describing;

> Should I expect these to be the same (in which case I'm doing
> something wrong)

They will only be the same if the m2m relations between the objects
are correct. At is, it looks like all three content objects are
related to the first category.

> or does the section in the docs here ("Lookups that
> span relationships") . . .
>
> http://www.djangoproject.com/documentation/db-api/#lookups-that-span-relationships
>
> . . . only apply to One-to-many relationships?

No - they apply to both. The query language makes no distinction
between M2M and M2O relations.

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



Re: extends blocks don't cache parent templates?

2007-05-16 Thread Chris Slowe

Hi Malcolm,

Thanks for the reply.  This issue is definitely seems to responsible
for a good chunk of the time it takes for django to return a response
in my app, about 70 ms to be precise.

Basically, I'm rendering a page which has a list of Template'd
objects, each of which inherits/extends from a base template.  This
means that in the course of a listing of, say, 25 things, I'm seeing
27 disk-hits/read/parse/tokenize (two for the page's own template, and
then one for each of the items, all of which inherit from the same
base template), which in total account for the 70 ms of CPU time.
Perhaps this is a "pathological" use of the templating engine, but
seeing as I'd like each item in the listing to be one of a variety of
object types (with some shared UI components), it seemed reasonable to
use template inheritance.

Having made a bit of a forray into the source code, the behavior I'm
looking for seems possible by changing the return call at the end of
ExtendsNode.get_parent from
return get_template_from_string(source, origin, parent)
to
self.parent_name = get_template_from_string(source,
origin, parent)
return self.parent_name
This seems to make everything down the line render happily, given that
the case of self.parent_name being a Template is handled already
properly, but, of course, I can't tell if it will instead break
features that I'm not currently using.  It cuts out the 70 ms lag, at
least.

Regards,
Chris

On May 16, 2:52 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Wed, 2007-05-16 at 21:27 +, Chris Slowe wrote:
> > I'm working on a project which is making rather copious use of extends
> > blocks, and I've noticed that every time an extends block is executed,
> > django seems to hit the file system, reads the file, and compiles the
> > parent template.  This behavior seems to be independent of whether
> > that particular parent template has been seen and compiled before.
>
> > I've traced the problem to ExtendsNode in loader_tags.py, where
> > get_parent is called when render is executed.  It seems like the
> > resulting rendered parent Template object is never cached, so
> > subsequent hits to render end up reloading the template from file
> > again.
>
> Is this behaviour a critical slowdown in the performance of your
> application?
>
> There are many micro optimisations that are possible in the template
> system (including caching pre-compiled templates), but the experience
> from the original developers was that they simply weren't necessary. It
> isn't a huge performance hit, in general.
>
> If you have performance numbers that show it really is a major component
> of the time budget for a request on templates that are "reasonable" (not
> pathological cases), that would be interesting to see so that we could
> look at what might be necessary.
>
> Regards,
> Malcolm


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



Re: Making a copy of an object

2007-05-16 Thread Forest Bond
On Wed, May 16, 2007 at 08:38:01PM +0300, Matti Haavikko wrote:
> I have the following scenario:
> - I have retrieved an object from the database
> - I want to create another object based on this one, with minor modifications.

This seems like a pretty common use case, doesn't it?

Maybe something like my_other_instance = my_instance.copy() would be a good
addition to the django core?  It would be simple enough to implement.

-Forest


signature.asc
Description: Digital signature


Re: __str__() returning unicode strings

2007-05-16 Thread Malcolm Tredinnick

On Wed, 2007-05-16 at 23:29 +0200, Andreas Ahlenstorf wrote:
> Hi,
> 
> I've some models where the strings returned by __str__() are unicode  
> strings 

For a start, you can *never* return anything other than a bytestring
from the __str__ method. You may think you're trying to return unicode,
but Python will always force it to have type "str". So even attempting
to return unicode form __str__ is a bug in your code.

> and contain non-ascii characters, especially umlauts. With a  
> recent Django version, this causes UnicodeEncodeErrors all over the  
> place. Could anybody give me a hint on what I have to do to work  
> around this issues except using ascii characters only?

See http://code.djangoproject.com/wiki/UnicodeBranch .

For many cases, that branch is usable at the moment, although you can
see from the "todo" section that there is still a little work to do. Try
it out. Report bugs (prefix any bug ticket titles with "unicode:" so
that they show up in searches).

See the "Porting Applications" section for changes you'll need to make
to your code (and I'd like to hear reports -- via Trac -- of anything
I've omitted there).

The one big case where it won't behave correctly is if you have a site
where the content can be in multiple languages that are decided at
request time (some things won't be translated correctly). It's a known
problem, obviously, and will be fixed before the branch is finished.

Regards,
Malcolm


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



Re: extends blocks don't cache parent templates?

2007-05-16 Thread Malcolm Tredinnick

On Wed, 2007-05-16 at 21:27 +, Chris Slowe wrote:
> I'm working on a project which is making rather copious use of extends
> blocks, and I've noticed that every time an extends block is executed,
> django seems to hit the file system, reads the file, and compiles the
> parent template.  This behavior seems to be independent of whether
> that particular parent template has been seen and compiled before.
> 
> I've traced the problem to ExtendsNode in loader_tags.py, where
> get_parent is called when render is executed.  It seems like the
> resulting rendered parent Template object is never cached, so
> subsequent hits to render end up reloading the template from file
> again.

Is this behaviour a critical slowdown in the performance of your
application?

There are many micro optimisations that are possible in the template
system (including caching pre-compiled templates), but the experience
from the original developers was that they simply weren't necessary. It
isn't a huge performance hit, in general.

If you have performance numbers that show it really is a major component
of the time budget for a request on templates that are "reasonable" (not
pathological cases), that would be interesting to see so that we could
look at what might be necessary.

Regards,
Malcolm


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



Re: Is it really this hard?

2007-05-16 Thread James Bennett

On 5/16/07, John Matthew <[EMAIL PROTECTED]> wrote:
> So, assuming my commit=false works, i should be able to say something like:
>
> form.clean_data['fk_id'] = fkobjid

No; you want your form to not have any field at all for the foreign
key, because you want the form to completely ignore the fact that it
exists. Trying to have that field in the form and surreptitiously slip
values into it after the fact will lead to a world of pain.

Use 'save()' with 'commit=False' to return a model object, then
directly manipulate that object to set the foreign key correctly
before calling the model object's 'save()' method to write to the
database.

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

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



Re: __str__() returning unicode strings

2007-05-16 Thread James Bennett

On 5/16/07, Andreas Ahlenstorf <[EMAIL PROTECTED]> wrote:
> I've some models where the strings returned by __str__() are unicode
> strings and contain non-ascii characters, especially umlauts. With a
> recent Django version, this causes UnicodeEncodeErrors all over the
> place. Could anybody give me a hint on what I have to do to work
> around this issues except using ascii characters only?

Generally, you don't want __str__ to return a Unicode string; if you
need to get Unicode out of it, have it return a UTF-8-encoded
bytestring. To return a Unicode string directly, instead define the
__unicode__ method to return that, and probably a __str__ which
returns the result of __unicode__ encoded as a UTF-8 bytestring.

The notes here may also be of some help:

http://code.djangoproject.com/wiki/UnicodeBranch

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

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



Re: isolating karma score from comments

2007-05-16 Thread omat

Thanks a lot for sharing... This really helped.

omat



On 16 Mayıs, 18:38, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> OK. My app is called "karma". The model looks like this:
>
> from django.db import models
> from django.http import Http404, HttpResponse
> from django.contrib.contenttypes.models import ContentType
> from django.contrib.auth.models import User
> import datetime
>
> class KarmaScoreManager(models.Manager):
> def vote(self, user_id, content_type, object_id, rating):
> try:
>  karma =
> self.get(content_type__pk=content_type,object_id=object_id,user__pk=user_id)
> except self.model.DoesNotExist:
> karma = self.model(None, user_id=user_id,
> content_type_id=content_type, object_id=object_id, score=rating,
> scored_date=datetime.datetime.now())
> karma.save()
> else:
> karma.score = rating
> karma.scored_date = datetime.datetime.now()
> karma.save()
>
> def get_pretty_score(self, score):
> """
> Given a score between -1 and 1 (inclusive), returns the same
> score on a
> scale between 1 and 10 (inclusive), as an integer.
> """
> if score is None:
> return DEFAULT_KARMA
> return int(round((4.5 * score) + 5.5))
>
> class KarmaScore(models.Model):
> user = models.ForeignKey(User, related_name="karma_user",)
> content_type = models.ForeignKey(ContentType)
> content_object = models.GenericForeignKey()
> object_id = models.IntegerField(_('object ID'))
> score = models.SmallIntegerField(_('score'), db_index=True)
> scored_date = models.DateTimeField(_('score date'), auto_now=True)
> objects = KarmaScoreManager()
> class Meta:
> verbose_name = _('karma score')
> verbose_name_plural = _('karma scores')
>
> class Admin:
> list_display = ('user', 'content_type',
> 'object_id','scored_date')
>
> def __repr__(self):
> return _("%(score)d rating by %(user)s") % {'score':
> self.score, 'user': self.user}
>
> And The view is:
>
> from django.http import Http404, HttpResponse
> from django.shortcuts import render_to_response
> from django.template import RequestContext
> from django.contrib.contenttypes.models import ContentType
> from gretschpages.karma.models import KarmaScore
>
> def vote(request, content_type, obj_id, vote, js=""):
> ctype = ContentType.objects.get(model=content_type)
> thisObject = ctype.get_object_for_this_type(pk=obj_id)
> rating = {'up': 1, 'down': -1}.get(vote, False)
>
> if not rating:
> raise Http404, "Invalid vote"
> if not request.user.is_authenticated():
> return HttpResponse("Anonymous users cannot vote",
> mimetype="text/html")
> try:
> obj = KarmaScore.objects.filter(content_type=ctype.id,
> object_id=obj_id)
>
> except:
> raise Http404, _("Invalid comment ID")
>
> if thisObject.id == request.user.id:
> return HttpResponse("No voting for yourself", mimetype="text/
> html")
>
> KarmaScore.objects.vote(request.user.id, ctype.id, obj_id, rating)
>
> if js == "js":
> return HttpResponse(str(thisObject.get_karma_total()),
> mimetype="text/html")
> else:
> return render_to_response('comments/karma_vote_accepted.html',
> {'obj': obj}, context_instance=RequestContext(request))
>
> Then, in the model of the thing you want karma for, you need these
> helper functions:
>
> def _fill_karma_cache(self):
> "Helper function that populates good/bad karma caches"
> good, bad = 0, 0
> from django.contrib.contenttypes.models import ContentType
> from gretschpages.karma.models import KarmaScore
> ctype = ContentType.objects.get(model='post')
>
> #for k in self.karmascore_set:
> for k in KarmaScore.objects.filter(content_type=ctype.id,
> object_id=self.id):
> if k.score == -1:
> bad +=1
> elif k.score == 1:
> good +=1
> self._karma_total_good, self._karma_total_bad = good, bad
>
> def get_good_karma_total(self):
> if not hasattr(self, "_karma_total_good"):
> self._fill_karma_cache()
> return self._karma_total_good
>
> def get_bad_karma_total(self):
> if not hasattr(self, "_karma_total_bad"):
> self._fill_karma_cache()
> return self._karma_total_bad
>
> def get_karma_total(self):
> if not hasattr(self, "_karma_total_good") or not
> hasattr(self, "_karma_total_bad"):
> self._fill_karma_cache()
> karma = self._karma_total_good - self._karma_total_bad
> if karma < 0:
> if karma < -3:
>elif k.score == 1:
> good +=1
> self._karma_total_good, self._karma_total_bad = good, bad
>

Re: Is it really this hard?

2007-05-16 Thread John M

I also have to add that this forum is the BEST!  Responses are so
quick and give the greatest info I've found so far.

Thanks to everyone who's replied.

John

On May 16, 1:48 pm, "John Matthew" <[EMAIL PROTECTED]> wrote:
> WOW, I hadn't seen that first one, and the second one is the 'standard' for
> most newforms replies, great work!
>
> Thanks again Michael.
>
> John
>
> On 5/16/07, Michael Trier <[EMAIL PROTECTED]> wrote:
>
>
>
> > These two posts gave me everything I needed to tackle these type of
> > issues:
>
> >http://weblog.bignerdranch.com/?p=31
>
> >http://code.pui.ch/2007/01/07/using-djangos-newforms/
>
> > Michael
>
> > On 5/16/07, James Bennett <[EMAIL PROTECTED]> wrote:
>
> > > On 5/16/07, John M <[EMAIL PROTECTED]> wrote:
> > > > Thanks for info, but what happens when the form.save() is called,
> > > > since the FK isn't part of the clean_data, it will fail no?
>
> > > Form.save accepts a 'commit' keyword argument, which default to True;
> > > when it's True the form will try to actually save to the database, and
> > > when it's False it won't. So if you know that you don't yet have
> > > enough data to correctly save to the DB, you can do:
>
> > > new_obj = form.save(commit=False)
> > > #...do more stuff with the object before saving to the DB
>
> > > Either way, 'save()' will return the object, but passing commit=False
> > > will tell it you're not ready to hit the DB just yet.
>
> > > --
> > > "Bureaucrat Conrad, you are technically correct -- the best kind of
> > correct."


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



__str__() returning unicode strings

2007-05-16 Thread Andreas Ahlenstorf

Hi,

I've some models where the strings returned by __str__() are unicode  
strings and contain non-ascii characters, especially umlauts. With a  
recent Django version, this causes UnicodeEncodeErrors all over the  
place. Could anybody give me a hint on what I have to do to work  
around this issues except using ascii characters only?

A.

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



extends blocks don't cache parent templates?

2007-05-16 Thread Chris Slowe

I'm working on a project which is making rather copious use of extends
blocks, and I've noticed that every time an extends block is executed,
django seems to hit the file system, reads the file, and compiles the
parent template.  This behavior seems to be independent of whether
that particular parent template has been seen and compiled before.

I've traced the problem to ExtendsNode in loader_tags.py, where
get_parent is called when render is executed.  It seems like the
resulting rendered parent Template object is never cached, so
subsequent hits to render end up reloading the template from file
again.

Is there a settings flag that I'm missing to enable caching?  Has
anyone seen this before?
Thanks in advance,
Chris


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



Many2Many question about Database API

2007-05-16 Thread Ben Jones

First, since this is my first post to this group, let me say that
Django is phenomenal. So serious. In fact, "phenomenal" doesn't even
begin to scratch the surface . . . using that phrase to describe it is
an insult! Many, many thanks to everyone who has contributed!

On to business . . .

I have 2 models that I'm using "for training": Content and Category
with a ManyToMany field in Content to relate them.

For test data, I have entered 3 categories and 3 pieces of content
(one in each of the 3 categories).

In my understanding of the docs, I expected to be able to use the line
of code below to retrieve all pieces of content in the category with a
slug of 'list-1'. However, that appears to not be the case, as every
record from Content is returned.

>>> Content.objects.filter(categories__slug__exact = 'list-1')
[, , ]


The results I actually want to get are accomplished via the following:

>>> a = Category.objects.get(slug = 'list-1')
>>> a.content_set.all()
[]


Should I expect these to be the same (in which case I'm doing
something wrong) or does the section in the docs here ("Lookups that
span relationships") . . .

http://www.djangoproject.com/documentation/db-api/#lookups-that-span-relationships

. . . only apply to One-to-many relationships?

Thanks for any help.

BTW, I'm using 0.96

-- 
 -Ben

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



Re: Pickle model fields

2007-05-16 Thread Malcolm Tredinnick

On Wed, 2007-05-16 at 09:42 -0700, [EMAIL PROTECTED] wrote:
> *sigh* posted to quickly. The solution was to define get_internal_type
> to return TextField.__name__
> 
> On May 16, 12:40 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> > Turns out I decided to go with the Field class since I'll be needing
> > them in a few different models. The issue I'm running into now is that
> > the new field name isn't defined in the data_types list (from db/
> > backends/*/creation.py).
> >
> > Obviously I can just add an entry for the backend I'm using, but that
> > seems wrong. I inherit from TextField, is there anyway to tell it to
> > just use that type?

Remember how I said there were a few pieces of machinery missing to make
subclassing Fields easy? You just found one of them. :-)

Yes, it has a solution, but it should be automatic in a perfect
solution.

Malcolm



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



Re: Making a copy of an object

2007-05-16 Thread Malcolm Tredinnick

On Wed, 2007-05-16 at 20:38 +0300, Matti Haavikko wrote:
> Hi,
> 
> I have the following scenario:
> - I have retrieved an object from the database
> - I want to create another object based on this one, with minor modifications.
> 
> What I'm doing is:
> - Get the existing object
> - Set its "id" to None
> - Modify any other fields and relations I need to
> - Save the object
> 
> My question is, is it advisable to copy objects this way? Would there
> be problems with e.g. foreign keys and generic relations?

Experiment and see what happens is the usual answer for simple cases
like this.

Off the top of my head, one thing is that many-to-many fields won't
work, since there won't be entries in the intermediate table
corresponding to the new id you will get. So you'll have to save your
model and then update the many-to-many entries as well.

Malcolm



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



Re: Is it really this hard?

2007-05-16 Thread John Matthew
WOW, I hadn't seen that first one, and the second one is the 'standard' for
most newforms replies, great work!

Thanks again Michael.

John

On 5/16/07, Michael Trier <[EMAIL PROTECTED]> wrote:
>
>
> These two posts gave me everything I needed to tackle these type of
> issues:
>
> http://weblog.bignerdranch.com/?p=31
>
> http://code.pui.ch/2007/01/07/using-djangos-newforms/
>
> Michael
>
> On 5/16/07, James Bennett <[EMAIL PROTECTED]> wrote:
> >
> > On 5/16/07, John M <[EMAIL PROTECTED]> wrote:
> > > Thanks for info, but what happens when the form.save() is called,
> > > since the FK isn't part of the clean_data, it will fail no?
> >
> > Form.save accepts a 'commit' keyword argument, which default to True;
> > when it's True the form will try to actually save to the database, and
> > when it's False it won't. So if you know that you don't yet have
> > enough data to correctly save to the DB, you can do:
> >
> > new_obj = form.save(commit=False)
> > #...do more stuff with the object before saving to the DB
> >
> > Either way, 'save()' will return the object, but passing commit=False
> > will tell it you're not ready to hit the DB just yet.
> >
> >
> > --
> > "Bureaucrat Conrad, you are technically correct -- the best kind of
> correct."
> >
> > >
> >
>
> >
>

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



Re: Is it really this hard?

2007-05-16 Thread John Matthew
James,

Thanks again so much.

I think i tried the commit=False bit but it still didn't like my FK being
blank for some reason.  I'll have to look through the django source and
double check.

So, assuming my commit=false works, i should be able to say something like:

form.clean_data['fk_id'] = fkobjid

?

Thanks

John

On 5/16/07, James Bennett <[EMAIL PROTECTED]> wrote:
>
>
> On 5/16/07, John M <[EMAIL PROTECTED]> wrote:
> > Thanks for info, but what happens when the form.save() is called,
> > since the FK isn't part of the clean_data, it will fail no?
>
> Form.save accepts a 'commit' keyword argument, which default to True;
> when it's True the form will try to actually save to the database, and
> when it's False it won't. So if you know that you don't yet have
> enough data to correctly save to the DB, you can do:
>
> new_obj = form.save(commit=False)
> #...do more stuff with the object before saving to the DB
>
> Either way, 'save()' will return the object, but passing commit=False
> will tell it you're not ready to hit the DB just yet.
>
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of
> correct."
>
> >
>

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



Re: Constraints to a model

2007-05-16 Thread dballanc

The simplest way I can think of is to override the model .save()
method and enforce your constraint there before calling the parent
class save method.

def save(self,*args,**kwargs):
if bool(self.arts_id) |  bool(self.pics_id):
super(Post,self).save(*args,**kwargs)
else:
raise some kind of validation error here


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



Re: Pickle model fields

2007-05-16 Thread [EMAIL PROTECTED]

Here's the final code that seems to be working:

from django.core import validators
from django.utils.translation import gettext
from django.db.models.fields import TextField
import cPickle

class PickleField(TextField):
  def __init__(self, *args, **kwargs):
kwargs['editable'] = False
TextField.__init__(self, *args, **kwargs)

  def to_python(self, value):
if isinstance( value, basestring ):
  try:
return cPickle.loads(value)
  except:
raise validators.ValidationError, gettext("Field must be
pickle string")

  def get_db_prep_save(self, value):
return cPickle.dumps(value)

  def get_db_prep_lookup(self, lookup_type, value):
raise TypeError("Field has invalid lookup: %s (Pickle does not
support lookups)" % lookup_type)

  def get_internal_type(self):
return TextField.__name__


On May 16, 12:42 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> *sigh* posted to quickly. The solution was to define get_internal_type
> to return TextField.__name__
>
> On May 16, 12:40 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > Turns out I decided to go with the Field class since I'll be needing
> > them in a few different models. The issue I'm running into now is that
> > the new field name isn't defined in the data_types list (from db/
> > backends/*/creation.py).
>
> > Obviously I can just add an entry for the backend I'm using, but that
> > seems wrong. I inherit from TextField, is there anyway to tell it to
> > just use that type?
>
> > --Lucki
>
> > On May 16, 10:54 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > > Thank you both for your help. I really should have thought of the
> > > proxy attribute myself. I use Property objects all over the place
> > > already. I'll probably go with that solution since I'm a bit time
> > > crunched and can do that one quickly. Though I think the Field class
> > > would be the 'better' 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Flatpages not working on Apache+mod_python

2007-05-16 Thread Nimrod A. Abing

On 5/17/07, Jeremy Dunck <[EMAIL PROTECTED]> wrote:
>
> On 5/16/07, Jeremy Dunck <[EMAIL PROTECTED]> wrote:
> > Already done, though under-documented.
> > http://www.djangoproject.com/documentation/templates/#django-contrib-markup
>
> Ah, here, too:
> http://www.djangoproject.com/documentation/add_ons/#markup

Thanks for all the pointers. I am incorporating them into my app now :)
-- 
_nimrod_a_abing_

http://abing.gotdns.com/
http://www.preownedcar.com/

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



Re: Flatpages not working on Apache+mod_python

2007-05-16 Thread Jeremy Dunck

On 5/16/07, Jeremy Dunck <[EMAIL PROTECTED]> wrote:
> Already done, though under-documented.
> http://www.djangoproject.com/documentation/templates/#django-contrib-markup

Ah, here, too:
http://www.djangoproject.com/documentation/add_ons/#markup

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



Re: Flatpages not working on Apache+mod_python

2007-05-16 Thread Jeremy Dunck

On 5/16/07, Nimrod A. Abing <[EMAIL PROTECTED]> wrote:
...
> I am using middleware as described in the docs. I don't see how to use
> flatpages as a view in the docs. How do you do that?

As the last entry in your urlpatterns, include this:
(r'^(.*)/$','django.contrib.flatpages.views.flatpage'),

> Also how does one
> inject custom Context variables when rendering flatpages?

Flatpages render using RequestContext, so you'd use a template context
processor:
http://www.djangoproject.com/documentation/settings/#template-context-processors
http://www.djangoproject.com/documentation/templates_python/#subclassing-context-requestcontext

> As for using textile, I am planning on creating a filter for it. But
> if someone has already done so already please point the way.

Already done, though under-documented.
http://www.djangoproject.com/documentation/templates/#django-contrib-markup

Add this to INSTALLED_APPS:
'django.contrib.markup'

And in your templates, do this:

{% load markup %}
{{ yourvar|textile }}

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



Re: django vps hosting

2007-05-16 Thread Michael Trier

I love Rimuhosting.  They've been great.

I'm also using EC2, but in a similar place as Frederic.  There are a
lot of issues to work through, but they're actually very good issues
to address early on.

Michael

On 5/16/07, Frédéric Sidler <[EMAIL PROTECTED]> wrote:
> I do use Amazon EC2 for our project and I plan to go very big
> http://media.djangobook.com/content/chapter21/scaling-5.png
>
> For the moment, i have everything running on one instance
> http://media.djangobook.com/content/chapter21/scaling-1.png
>
> But that is just the start, the problems are
>
> host negociation because of dynamic IP (intern & extern)
> non persistent data in case of instance failure
> dynamic load of instance in case of charge (see http://weoceo.weogeo.com). I
> have access to their system.I'm happy for now. I will keep you informed.
> This is the future of web hosting. You pay as you use/earn.
>
> 2007/5/16, John M <[EMAIL PROTECTED]>:
> >
> > Im really suprised no one has tried Amazon's EC infrastructure, it's
> > pretty sweet, for production I would think!
> >
> > On May 15, 8:12 am, urielka <[EMAIL PROTECTED] > wrote:
> > > I am running two django sites with vpsland(good support) for the last
> > > 7 days, but since i having problems with their ssh(running really
> > > slow) i thinking about switching to other host.
> > >
> > > Is there any good vps hosting? it probably be better if it is in
> > > Europe for lower latency.
> > >
> > > thx,
> > > Uriel
> >
> >
> > > >
> >
>

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



Re: django vps hosting

2007-05-16 Thread Frédéric Sidler
I do use Amazon EC2 for our project and I plan to go very big
http://media.djangobook.com/content/chapter21/scaling-5.png

For the moment, i have everything running on one instance
http://media.djangobook.com/content/chapter21/scaling-1.png

But that is just the start, the problems are

   - host negociation because of dynamic IP (intern & extern)
   - non persistent data in case of instance failure
   - dynamic load of instance in case of charge (see
   http://weoceo.weogeo.com). I have access to their system.

I'm happy for now. I will keep you informed. This is the future of web
hosting. You pay as you use/earn.

2007/5/16, John M <[EMAIL PROTECTED]>:
>
>
> Im really suprised no one has tried Amazon's EC infrastructure, it's
> pretty sweet, for production I would think!
>
> On May 15, 8:12 am, urielka <[EMAIL PROTECTED]> wrote:
> > I am running two django sites with vpsland(good support) for the last
> > 7 days, but since i having problems with their ssh(running really
> > slow) i thinking about switching to other host.
> >
> > Is there any good vps hosting? it probably be better if it is in
> > Europe for lower latency.
> >
> > thx,
> > Uriel
>
>
> >
>

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



Re: Is it really this hard?

2007-05-16 Thread Michael Trier

These two posts gave me everything I needed to tackle these type of issues:

http://weblog.bignerdranch.com/?p=31

http://code.pui.ch/2007/01/07/using-djangos-newforms/

Michael

On 5/16/07, James Bennett <[EMAIL PROTECTED]> wrote:
>
> On 5/16/07, John M <[EMAIL PROTECTED]> wrote:
> > Thanks for info, but what happens when the form.save() is called,
> > since the FK isn't part of the clean_data, it will fail no?
>
> Form.save accepts a 'commit' keyword argument, which default to True;
> when it's True the form will try to actually save to the database, and
> when it's False it won't. So if you know that you don't yet have
> enough data to correctly save to the DB, you can do:
>
> new_obj = form.save(commit=False)
> #...do more stuff with the object before saving to the DB
>
> Either way, 'save()' will return the object, but passing commit=False
> will tell it you're not ready to hit the DB just yet.
>
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
>
> >
>

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



Re: Flatpages not working on Apache+mod_python

2007-05-16 Thread Nimrod A. Abing

On 5/17/07, Jeremy Dunck <[EMAIL PROTECTED]> wrote:
>
> On 5/16/07, Nimrod A. Abing <[EMAIL PROTECTED]> wrote:
> > Can anyone here provide pointers on how to get flatpages to work
> > properly under Apache and mod_python?
>
> From your custom 404, you'll want to return
> django.http.HttpResponseNotFound rather that HttpResponse.

Ah, that fixed it! Thanks! Also fixed my custom 500 handler to return
HttpResponseServerError.

> Also, are you using flatpage middleware or view?

I am using middleware as described in the docs. I don't see how to use
flatpages as a view in the docs. How do you do that? Also how does one
inject custom Context variables when rendering flatpages?

As for using textile, I am planning on creating a filter for it. But
if someone has already done so already please point the way.

Thanks.
-- 
_nimrod_a_abing_

http://abing.gotdns.com/
http://www.preownedcar.com/

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



Re: Is it really this hard?

2007-05-16 Thread James Bennett

On 5/16/07, John M <[EMAIL PROTECTED]> wrote:
> Thanks for info, but what happens when the form.save() is called,
> since the FK isn't part of the clean_data, it will fail no?

Form.save accepts a 'commit' keyword argument, which default to True;
when it's True the form will try to actually save to the database, and
when it's False it won't. So if you know that you don't yet have
enough data to correctly save to the DB, you can do:

new_obj = form.save(commit=False)
#...do more stuff with the object before saving to the DB

Either way, 'save()' will return the object, but passing commit=False
will tell it you're not ready to hit the DB just yet.


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

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



Re: Flatpages not working on Apache+mod_python

2007-05-16 Thread Jeremy Dunck

On 5/16/07, Nimrod A. Abing <[EMAIL PROTECTED]> wrote:
> Can anyone here provide pointers on how to get flatpages to work
> properly under Apache and mod_python?

>From your custom 404, you'll want to return
django.http.HttpResponseNotFound rather that HttpResponse.

Also, are you using flatpage middleware or view?
What's your root urlconf module and settings.MIDDLEWARE_CLASSES look like?

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



Re: Is it really this hard?

2007-05-16 Thread John M

Russ,

Thanks for info, but what happens when the form.save() is called,
since the FK isn't part of the clean_data, it will fail no?

I think i've gotten to the point where I can get it off the form, but
now how do I make it so I can update the FK in code on the POST?

Thanks everyone for continuing on this thread, but I still don't like
the portion of the newforms stuff, and I know it's not done, so I hope
this can help improve it.

The other option is using a charfield widget that is hidden with the
FK, but doesn't that lend myself to hacking?  I'm SO new to web stuff
that I don't want to write a site that is vulnerable.

John

On May 15, 7:31 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 5/16/07, anders conbere <[EMAIL PROTECTED]> wrote:
>
>
>
> > As far as I know the officially recommended way of accomplishing this
> > while still using the form_for_* helper functions is through the use
> > of a formfield_callback, a function that takes field instances and
> > mucks with them.
>
> > def form_callback(field, **kwargs):
> > if field.name == "field_name":
> > return None
>
> > my_instance = MyClass.objects.get(pk=x)
> > form = form_for_instance(instance, formfield_callback= form_callback)
>
> > will remove the field named "field_name" from the form
>
> Alternatively, you can use the recently added 'fields' attribute:
>
> Form = form_for_instance(instance, fields=('field1','field2'))
> myform = Form()
>
> will produce a form for 'instance' that contains only the fields
> 'field1' and 'field2', populated with initial data from the instance.
>
> 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Book, how did you do that?

2007-05-16 Thread Jeremy Dunck

On 5/16/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I did some digging around and found this site: 
> http://code.google.com/p/openbookplatform/
>
> If that the same thing?  Can you point me somewhere else.

It's not the same codebase, but has similar goals.  The DjBook site
code isn't open, though AFAIK, it's under consideration.

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



Making a copy of an object

2007-05-16 Thread Matti Haavikko

Hi,

I have the following scenario:
- I have retrieved an object from the database
- I want to create another object based on this one, with minor modifications.

What I'm doing is:
- Get the existing object
- Set its "id" to None
- Modify any other fields and relations I need to
- Save the object

My question is, is it advisable to copy objects this way? Would there
be problems with e.g. foreign keys and generic relations?

Thanks,

- Matti Haavikko

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



Flatpages not working on Apache+mod_python

2007-05-16 Thread Nimrod A. Abing

Hello,

I am using Django 0.96 and I am currently having problems getting
flatpages middleware to work under Apache with mod_python. I am pretty
sure this is mod_python related since flatpages work fine using the
development server.

I have found at least one thread the mentions this problem, it's from
Aug 2006. The OP said he would take a look to see what the problem was
but did not post a follow-up.

http://groups.google.com/group/django-users/browse_thread/thread/eddadaacfc34aef9/194ee9abebecf6b6?lnk=gst=flatpages=5

The gist of it is that instead of rendering the flatpage it just keeps
rendering the 404 page when I run it on the production server.
However, using the development server flatpages work as expected. If
it helps any, I also have handler404 and handler500 point to a custom
handler.

below is the custom handler404:

def page_not_found(request):
c = getDefaultContext(request)
t = loader.get_template('404.thtml')
return HttpResponse(t.render(c))

Note I am using .thtml extension for templates only because Eclipse
with WTP chokes when editing Django templates.

getDefaultContext() above sets up the Context object containing
important variables used in the templates.

Can anyone here provide pointers on how to get flatpages to work
properly under Apache and mod_python?

One other thing... Is it possible to use Textile for flatpages too?

http://cheeseshop.python.org/pypi/textile

Thanks in advance.
--
_nimrod_a_abing_

http://abing.gotdns.com/
http://www.preownedcar.com/

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



Re: Adding fields dinamically to a model

2007-05-16 Thread Marty Alchin

Well, it turns out this would've been possible even without #4144, but
now that it's in CVS, I wrote up a wiki article[1] on dynamic models,
which should give you some clues on how to dynamically generate a
model. For this case, it would suffice to use the generic approach
listed there, created the field list dynamically, then creating the
model with it. Be sure to use the same app_label as the current app,
or you'll have problems with syncdb and admin.

-Gul

[1] http://code.djangoproject.com/wiki/DynamicModels

On May 3, 12:56 pm, Mike Axiak <[EMAIL PROTECTED]> wrote:
> Sandro,
>
> I'm not sure #4144 would help.
> However, I think there are limits to what you can do with python
> descriptors, and thus Django models. At the risk of giving up all the
> niceties of having an actual SQL field, can you do what you need by
> pickling dictionaries? If you really wanted to be lazy/magical, you
> can write careful __getattribute__ and __setattribute__ to emulate
> fields.
>
> Cheers,
> Mike Axiak
>
> On May 3, 12:50 pm, Gulopine <[EMAIL PROTECTED]> wrote:
>
> > I know of one way of going about this, but it relies on a Django patch
> > (#4144) that hasn't been integrated yet. There are probably ways I'm
> > not aware of, though.
>
> > -Gul
>
> > On May 3, 9:49 am, sandro dentella <[EMAIL PROTECTED]> wrote:
>
> > > hi,
>
> > >i'd like to dinamycally add fields to a model (UserProfile) so that
> > >it gets populated wit all the field needed by each application.
>
> > >Any idea of how to accomplish this? A first try that cannot work
> > >would have been:
>
> > >class UserProfile(models.Model):
> > >user = models.OneToOneField(User)
> > >for name, value in app_contrib_from_settings().iteritems():
> > >setattr(self, name, value)
>
> > >but 'self' is not availabe of course...
> > >Any idea? (it's more a python question than django, I know...)
>
> > > sandro
> > > *:-)
>
> > > PS: sorry for the have way post...


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



Re: posting programmaticaly on a Django blog

2007-05-16 Thread Christian M Hoeppner

> Hi,
>
> I would like to now if it's possible to make a Python script (one
> argument a text file name)
> witch will upload a post on a basic blog (asking for title and post
> itself, with options: image, template language).
>
> If so, what should I study ?
>
> Thanks.
 If from a remote box, you might want to have a look to implementing some 
xmlrpc support into your project. If local, just use the django models.

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



Re: Pickle model fields

2007-05-16 Thread [EMAIL PROTECTED]

*sigh* posted to quickly. The solution was to define get_internal_type
to return TextField.__name__

On May 16, 12:40 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Turns out I decided to go with the Field class since I'll be needing
> them in a few different models. The issue I'm running into now is that
> the new field name isn't defined in the data_types list (from db/
> backends/*/creation.py).
>
> Obviously I can just add an entry for the backend I'm using, but that
> seems wrong. I inherit from TextField, is there anyway to tell it to
> just use that type?
>
> --Lucki
>
> On May 16, 10:54 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > Thank you both for your help. I really should have thought of the
> > proxy attribute myself. I use Property objects all over the place
> > already. I'll probably go with that solution since I'm a bit time
> > crunched and can do that one quickly. Though I think the Field class
> > would be the 'better' 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pickle model fields

2007-05-16 Thread [EMAIL PROTECTED]

Turns out I decided to go with the Field class since I'll be needing
them in a few different models. The issue I'm running into now is that
the new field name isn't defined in the data_types list (from db/
backends/*/creation.py).

Obviously I can just add an entry for the backend I'm using, but that
seems wrong. I inherit from TextField, is there anyway to tell it to
just use that type?

--Lucki

On May 16, 10:54 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Thank you both for your help. I really should have thought of the
> proxy attribute myself. I use Property objects all over the place
> already. I'll probably go with that solution since I'm a bit time
> crunched and can do that one quickly. Though I think the Field class
> would be the 'better' 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



posting programmaticaly on a Django blog

2007-05-16 Thread Tool69

Hi,

I would like to now if it's possible to make a Python script (one
argument a text file name)
witch will upload a post on a basic blog (asking for title and post
itself, with options: image, template language).

If so, what should I study ?

Thanks.


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



Re: More info in Django server logs

2007-05-16 Thread Atilla

On 15/05/07, Kostadin Cholakov <[EMAIL PROTECTED]> wrote:
>
> Hi
>
> We are using the development server only! Can you give me some
> reference for the necessary changes in the code? Thanks!
>
> On 5/15/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> >
> > On Tue, 2007-05-15 at 19:14 +, Kostadin Cholakov wrote:
> > > Hello,
> > >
> > > We are currently using Django for access to a linguistic database
> > > where people can validate certain entries by checking certain
> > > checkboxes! We have the problem that the users are not in our
> > > departament and they are connected to Internet through a different
> > > proxy server. When the annotators check boxes and go to the next page
> > > and then again go back, the boxes are not checked anymore. We tried to
> > > reproduce this error with different browsers but we were not able to
> > > do this! So, we susspect that their server caches some pages and when
> > > the annotators go back to a previous page, it doesn't invoke GET to
> > > get a fresh page with the updated entries and checkboxes but rather
> > > their server takes the original cached page! We would like to see
> > > which machine exactly accesses our database and see what kind of
> > > request it makes... But the log files just show the URL which is being
> > > used, the time and POST or GET... Is there any way that one could
> > > retrieve more information like IP for example? I am new to Django and
> > > I was not able to find something on this issue! Thanks!
> >
> > It depends on what web server you are using. Every web server has ways
> > to configure what information is logged.
> >
> > If you are just using the development server, then you're out of luck
> > without changing the code.
> >
> > Regards,
> > Malcolm
> >

If this application is not going to be very limited use, in-house
only, with no more than 1 person making requests at a time,  then
you'd better consider hosting it in a proper environment. Where proper
is anything to your liking, except the development server. If people
are going to use this thing, you'll run in a lot more issues than the
current one you're having.

I'd say that catching up with the documentation about deployment,
instead of applying duct-tape patches will result in a lot less
trouble for you.

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



Re: isolating karma score from comments

2007-05-16 Thread [EMAIL PROTECTED]

OK. My app is called "karma". The model looks like this:

from django.db import models
from django.http import Http404, HttpResponse
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import User
import datetime

class KarmaScoreManager(models.Manager):
def vote(self, user_id, content_type, object_id, rating):
try:
 karma =
self.get(content_type__pk=content_type,object_id=object_id,user__pk=user_id)
except self.model.DoesNotExist:
karma = self.model(None, user_id=user_id,
content_type_id=content_type, object_id=object_id, score=rating,
scored_date=datetime.datetime.now())
karma.save()
else:
karma.score = rating
karma.scored_date = datetime.datetime.now()
karma.save()

def get_pretty_score(self, score):
"""
Given a score between -1 and 1 (inclusive), returns the same
score on a
scale between 1 and 10 (inclusive), as an integer.
"""
if score is None:
return DEFAULT_KARMA
return int(round((4.5 * score) + 5.5))

class KarmaScore(models.Model):
user = models.ForeignKey(User, related_name="karma_user",)
content_type = models.ForeignKey(ContentType)
content_object = models.GenericForeignKey()
object_id = models.IntegerField(_('object ID'))
score = models.SmallIntegerField(_('score'), db_index=True)
scored_date = models.DateTimeField(_('score date'), auto_now=True)
objects = KarmaScoreManager()
class Meta:
verbose_name = _('karma score')
verbose_name_plural = _('karma scores')

class Admin:
list_display = ('user', 'content_type',
'object_id','scored_date')

def __repr__(self):
return _("%(score)d rating by %(user)s") % {'score':
self.score, 'user': self.user}


And The view is:

from django.http import Http404, HttpResponse
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.contrib.contenttypes.models import ContentType
from gretschpages.karma.models import KarmaScore

def vote(request, content_type, obj_id, vote, js=""):
ctype = ContentType.objects.get(model=content_type)
thisObject = ctype.get_object_for_this_type(pk=obj_id)
rating = {'up': 1, 'down': -1}.get(vote, False)

if not rating:
raise Http404, "Invalid vote"
if not request.user.is_authenticated():
return HttpResponse("Anonymous users cannot vote",
mimetype="text/html")
try:
obj = KarmaScore.objects.filter(content_type=ctype.id,
object_id=obj_id)

except:
raise Http404, _("Invalid comment ID")

if thisObject.id == request.user.id:
return HttpResponse("No voting for yourself", mimetype="text/
html")

KarmaScore.objects.vote(request.user.id, ctype.id, obj_id, rating)

if js == "js":
return HttpResponse(str(thisObject.get_karma_total()),
mimetype="text/html")
else:
return render_to_response('comments/karma_vote_accepted.html',
{'obj': obj}, context_instance=RequestContext(request))


Then, in the model of the thing you want karma for, you need these
helper functions:

def _fill_karma_cache(self):
"Helper function that populates good/bad karma caches"
good, bad = 0, 0
from django.contrib.contenttypes.models import ContentType
from gretschpages.karma.models import KarmaScore
ctype = ContentType.objects.get(model='post')

#for k in self.karmascore_set:
for k in KarmaScore.objects.filter(content_type=ctype.id,
object_id=self.id):
if k.score == -1:
bad +=1
elif k.score == 1:
good +=1
self._karma_total_good, self._karma_total_bad = good, bad

def get_good_karma_total(self):
if not hasattr(self, "_karma_total_good"):
self._fill_karma_cache()
return self._karma_total_good

def get_bad_karma_total(self):
if not hasattr(self, "_karma_total_bad"):
self._fill_karma_cache()
return self._karma_total_bad

def get_karma_total(self):
if not hasattr(self, "_karma_total_good") or not
hasattr(self, "_karma_total_bad"):
self._fill_karma_cache()
karma = self._karma_total_good - self._karma_total_bad
if karma < 0:
if karma < -3:
   elif k.score == 1:
good +=1
self._karma_total_good, self._karma_total_bad = good, bad

def get_good_karma_total(self):
if not hasattr(self, "_karma_total_good"):
self._fill_karma_cache()
return self._karma_total_good

def get_bad_karma_total(self):
if not hasattr(self, "_karma_total_bad"):
self._fill_karma_cache()
return self._karma_total_bad


Re: Maintainance Middleware

2007-05-16 Thread Christian M Hoeppner

Just for the record:

** settings.py in $project_path:

# Maintenance Mode Switch
MAINTENANCE = True

# Login paths
LOGIN_REDIRECT_URL = '/admin/'
LOGIN_URL = '/admin/'
LOGOUT_URL = '/admin/logout/'

# This will be shown to unauthorised users when the site is in maintenance 
mode
MAINTENANCE_PATH = '/maintenance/'

** middleware.py in $project_path:

class MaintenanceMiddleware(object):
def process_request(self, request):
from django.conf import settings
from django.http import HttpResponseRedirect


is_login = request.path in (
settings.LOGIN_REDIRECT_URL,
settings.LOGIN_URL,
settings.LOGOUT_URL,
settings.MAINTENANCE_PATH,
)
if ((not is_login) and settings.MAINTENANCE and (not 
request.user.is_authenticated())):
return HttpResponseRedirect(settings.MAINTENANCE_PATH)
return None

I have added the MAINTENANCE_PATH setting, and included it in the path check. 
If this one is not checked to be false, we get an endless redirect loop.

I'll be posting this into my new blog (as soon as I get it up) and if you like 
it and find it usefull, you might also tell me to post it at Django Snippets.

Thank you everyone!

Chris Hoeppner
www.pixware.org

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



Django Book, how did you do that?

2007-05-16 Thread [EMAIL PROTECTED]

I am interested in the code / project behind the DjangoBook so I can
do something similar.

I did some digging around and found this site: 
http://code.google.com/p/openbookplatform/

If that the same thing?  Can you point me somewhere else.

I am a newbie...

Thanks

Lance


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



Re: How to set FORLOOP.COUNTER=0?

2007-05-16 Thread [EMAIL PROTECTED]

Thanks James.

On May 16, 12:13 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 5/16/07, Renato Lipi <[EMAIL PROTECTED]> wrote:
>
> > I am using FORLOOP built-in tag. There is a time that I need to restart this
> > count, setting forloop.counter=0. How can I do something like that?
>
> The plain template language (deliberately) cannot perform variable
> assignments; custom template tags can, though, so you might look into
> writing a tag to "reset" the loop.
>
> You might also consider whether there's some logic missing in your
> view which would make this template loop reset unnecessary.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."


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



Re: How to set FORLOOP.COUNTER=0?

2007-05-16 Thread James Bennett

On 5/16/07, Renato Lipi <[EMAIL PROTECTED]> wrote:
> I am using FORLOOP built-in tag. There is a time that I need to restart this
> count, setting forloop.counter=0. How can I do something like that?

The plain template language (deliberately) cannot perform variable
assignments; custom template tags can, though, so you might look into
writing a tag to "reset" the loop.

You might also consider whether there's some logic missing in your
view which would make this template loop reset unnecessary.

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

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



Re: Search tables related by a foreign key in admin

2007-05-16 Thread Kent Johnson

RajeshD wrote:
> 
>> search_fields = ['question', 'choice_choice']
>>
>> Where choice_choice is supposed to be pointing to the choice field in
>> the choice model, but something is not working with that.  I am sure
>> that I am missing something very easy and I was wondering if someone
>> could point it out to me.
> 
> Try two underscores:
> 
> search_fields = ['question', 'choice__choice']

This doesn't work correctly because it searches the result of an inner 
join of the poll and choice tables. Consequently
- it will not find polls that have no choices, even if the search term 
is found in the question field, because the polls will not be in the join.
- polls with multiple choices will be listed multiple times in the 
result if the search term is found in the question field, because the 
poll appears in the join once for each choice.

Is there a way to get this to work correctly?

Thanks,
Kent


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



Re: Admin, edit_inline, and saving

2007-05-16 Thread Tyson Tate

It'd be helpful if you supplied us with a few more details:

1. What is MEDIA_ROOT and MEDIA_URL set to?
2. What is the Picture object's ImageField;s "upload_to" attribute  
set to?
3. Did you define your own "get_absolute_path(self)" method in the  
Picture model?
4. What version of Django are you running?
5. What server are you running Django through (Apache, built-in dev  
server, etc.)

I'd assume that perhaps your MEDIA_ROOT or upload_to attributes are  
set incorrectly.

Regards,
Tyson

On May 8, 2007, at 12:01 PM, jules wrote:

> I am having a problem saving in Admin.
> I have two models, Picture and Post. (One to Many)
> The picture model has a foreign_key (post) which is using edit_inline.
>
> When I add a post in Admin,  the  4 picture field show up like they
> are suppose to.
> Then, I hit the save buttton, and none of the pictures are saved.


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



Re: Pickle model fields

2007-05-16 Thread [EMAIL PROTECTED]

Thank you both for your help. I really should have thought of the
proxy attribute myself. I use Property objects all over the place
already. I'll probably go with that solution since I'm a bit time
crunched and can do that one quickly. Though I think the Field class
would be the 'better' 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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



admin and custom filter

2007-05-16 Thread portoms

Hello there,

I have two models, Network and Address and have setup a filter (in the
admin interface, which I like) for Address, to show only free
addresses which works. I also have a filter on network, which works,
however this is not really dynamic, because if I have 2 networks
10.0.0.0/8 and 10.10.10.0/24, and address of 10.10.10.20 would be part
of both networks!

class Network(models.Model):
ip = models.CharField('IP', maxlength=15)
mask_len = models.PositiveIntegerField('mask length')

class Address(models.Model):
ip = models.CharField('IP', maxlength=15)
is_free = models.BooleanField('free')
network = models.ForeignKey(Network)
class Admin:
list_filter = ('is_free', 'network')

I now would like to have a similar filter in the Address part of the
admin interface, to display a list of all addresses that are part of a
network. From what I read/understood, I can setup a manager method,
but this requires also that I setup a view, template and more, and
then it would not even be integrated into the admin interface. Does
anyone have a idea on how to do this?

I hope I explained clearly enough what I would like to accomplish and
thank you for your input.


tom


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



Re: Shopping cart application for django

2007-05-16 Thread Chris Moffitt

The current url for the satchmo project is
http://www.satchmoproject.com

We have basic integration with paypal and are working on more as we speak.

-Chris

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



Re: How to set FORLOOP.COUNTER=0?

2007-05-16 Thread [EMAIL PROTECTED]

Ok then...

So, actually I'm "plotting" tables with only 1 row and 15 columns,
table below table. Often, when I change the subject I working with,
there's a row that has less then 15 columns. Let's say the last line
(table) had 2 columns. If the next line is in the "for" that created
last line, the new one will contain 13 columns (and it should have
15).

Was it clear? Sorry about my English. I'll try to improve it next
time.

Nice to meet you Malcolm! I read some reply you sent to a friend of
mine.
Regards,
Renato.

On May 16, 11:04 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Wed, 2007-05-16 at 10:57 -0300, Renato Lipi wrote:
> > Hi there,
>
> > I am using FORLOOP built-in tag. There is a time that I need to
> > restart this count, setting forloop.counter=0. How can I do something
> > like that?
>
> You can't do this with the existing "for" tag. It crosses the line into
> trying to program with templates.
>
> Maybe if you describe the problem you're trying to solve, we can suggest
> a different approach.
>
> Regards,
> Malcolm


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



Re: redirect error to home page

2007-05-16 Thread [EMAIL PROTECTED]

Easiest way would be to just set up a redirect from your custom 404
page.

But I wouldn't do it at all... if someone hits a 404, they deserve to
be told they've gotten off track, and they deserve your help in
getting back on track (via search box, site map, whatever).


On May 16, 7:49 am, Mary <[EMAIL PROTECTED]> wrote:
> Dear All ;
>
> I would like to do the following and i need your help:
>
> I have created my application using django framework and i need that
> is there is any 404 error so the application will be directed to home
> page directly
>
> How can i do that ??
> Thank you in advance ;
> mary Adel


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



Re: SQLite - unsupported file format

2007-05-16 Thread Panos Laganakos

For reference purposes:

http://jtauber.com/blog/2006/11/25/incompatible_sqlite_in_os_x_and_python

On May 15, 9:17 pm, Panos Laganakos <[EMAIL PROTECTED]> wrote:
> I haven't installed any pysqlite versions since I moved to 2.5 (from
> OS X's default 2.3) Python, as sqlite3 is included in the lib module
> by default.
>
> I uploaded the db on the production server though, and sqlite3 client:
> 3.3.5 seems to open the file just fine. So as you mentioned it must be
> a type mismatch? I'll if I can an updated binary of SQLite3 > 3.1.3
> for OS X.
>
> On May 15, 1:47 pm, Lars Stavholm <[EMAIL PROTECTED]> wrote:
>
> > Panos Laganakos wrote:
> > > OS: Mac OS X - 10.4
> > > SQLite: 3.1.3
> > > Django: 0.96
> > > Python: 2.5
>
> > > I've set the DATABASE_ENGINE to 'sqlite3', and the db gets created
> > > when I call
>
> > > $manage.py syncdb
>
> > > And the project/apps all work fine.
>
> > > When I try to connect to it from the commandline 'sqlite3' tool, or
> > > pipe manage.py clearsql [appname], etc. I get an 'error: unsupported
> > > file format', when I try to execute any statement or view tables etc.
>
> > > Same thing happens if I try to pipe output into sqlite3, ie:
>
> > > $manage.py sqlclear [appname] | sqlite3 my.db
>
> > > Can't figure out what seems to be the problem here.
>
> > Version mismatch maybe? Try sqlite/sqlite2 on the created db.
> > If that works, the db is sqlite version 2.
> > What version of python sqlite bindings are you using?
> > I have the following and it works just great:
>
> > SuSE Linux 10.2
> > sqlite 3.3.8
> > Django from SVN a week ago.
> > Python 2.5
> > pysqlite 2.3.2
>
> > Cheers
> > /Lars


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



Re: How to set FORLOOP.COUNTER=0?

2007-05-16 Thread Malcolm Tredinnick

On Wed, 2007-05-16 at 10:57 -0300, Renato Lipi wrote:
> Hi there,
> 
> I am using FORLOOP built-in tag. There is a time that I need to
> restart this count, setting forloop.counter=0. How can I do something
> like that?

You can't do this with the existing "for" tag. It crosses the line into
trying to program with templates.

Maybe if you describe the problem you're trying to solve, we can suggest
a different approach.

Regards,
Malcolm



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



Re: isolating karma score from comments

2007-05-16 Thread omat

I am trying to avoid coupling with the model of the content so I am
trying it with ContentTypes. Though, yours can be more practical to
start with.




On 16 Mayıs, 16:54, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I did... well, sorta semi-standalone. Much like the comments system,
> there's a couple of functions that have to be put in the model of the
> thing you're doing karma voting on... at least the way I did it.
>
> Wasn't too tough.
>
> On May 16, 6:31 am, omat <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > Neat design of the karma scoring application in the comments framework
> > of the contributed application is quite appealing. But it is tided to
> > the comments application.
>
> > I am trying to isolate it and make a more generic karma application
> > for any content (photos, blog entries, etc.) contributed by users.
>
> > I wonder if anybody has already did this or built a standalone
> > karmascore application...
>
> > oMat


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



How to set FORLOOP.COUNTER=0?

2007-05-16 Thread Renato Lipi
Hi there,

I am using FORLOOP built-in tag. There is a time that I need to restart this
count, setting forloop.counter=0. How can I do something like that?

Thanks.
Renato.

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



Re: isolating karma score from comments

2007-05-16 Thread [EMAIL PROTECTED]

I did... well, sorta semi-standalone. Much like the comments system,
there's a couple of functions that have to be put in the model of the
thing you're doing karma voting on... at least the way I did it.

Wasn't too tough.

On May 16, 6:31 am, omat <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Neat design of the karma scoring application in the comments framework
> of the contributed application is quite appealing. But it is tided to
> the comments application.
>
> I am trying to isolate it and make a more generic karma application
> for any content (photos, blog entries, etc.) contributed by users.
>
> I wonder if anybody has already did this or built a standalone
> karmascore application...
>
> oMat


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



Re: Is it really this hard?

2007-05-16 Thread John Matthew
Thank you Grigoriy,  It's given me some new ideas.

John

On 5/16/07, Grigoriy Petukhov <[EMAIL PROTECTED]> wrote:
>
>
> John M wrote:
> > I have checked the forum, and still can't believe I can't find a
> > solution to what I perceive as a simple problem:
> >
> > I have two models:
> >
> > Customer
> >Name
> >phone
> >
> > Order
> >Customer (foreign key to Customer)
> >date
> >product
> >
> > When I put up the form for order, I don't want the Customer (foreign
> > key) to appear.  I've not seen anything on the forum that shows you
> > can easily eliminate a field from the form?
> >
> > Unless I'm missing how to create a custom form, bind it to the DB's
> > data and use it like I can form_for_instance() and form_for_model().
> >
> > using FFI with a customer form, it doesn't seem to bind any data to
> > the fields, unless I'm missing something big, cause that would be
> > perfect, no?
> >
> > Hoping someone can help
> >
> >
> > >
> >
> Check this thread: http://softwaremaniacs.org/forum/viewtopic.php?id=596
> Here is the solution for exactly the same problem as you have described.
> Thread in russian but there is a lot of code )
>
> >
>

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



Re: Shopping cart application for django

2007-05-16 Thread Jeremy Dunck

On 5/16/07, Nathan Harmston <[EMAIL PROTECTED]> wrote:
...
> So far I am thinking of storing the whole shopping cart as a
> dictionary in session where it is simply
>
> { product_id:amount },

Assuming low site concurrrency, no.  I don't know why you'd want to
take that approach as opposed to having a cart model, but if it floats
your boat, go for it.

If you have high concurrency, just realize that session storage and
retrieval involves deserialization of the state bag out of the DB,
which is an additional overhead compared to general models, whose data
marshalling is performed by the (highly optimized) DB server and
client code.  Your session table could also become a hot spot in the
DB since you'll be writing a larg-ish single row rather than many
smaller rows.

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



Re: Maintainance Middleware

2007-05-16 Thread Jeremy Dunck

On 5/16/07, Christian M Hoeppner <[EMAIL PROTECTED]> wrote:
...
> I wonder... There isn't a way in a middleware to access some name path from
> the urlconf, is there? That way I wouldn't have to set those settings, by
> letting the admin-path bypass the maintenance middleware.

Not as far as I can see now, but it does seem like a good idea.

New ticket:
http://code.djangoproject.com/ticket/4311

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



Re: get objects in templates

2007-05-16 Thread plungerman

hey alessandro,

check out the catch tag over at djangosnippets.com:

http://www.djangosnippets.org/snippets/10/

i use it for something similar and works quite well.  thanks limodou!

laters,

steve


On May 9, 3:51 pm, "va:patrick.kranzlmueller"
<[EMAIL PROTECTED]> wrote:
> just a guess.
>
> for the first image:
> {% for image in object.images.all.0 %}
> ...
> and for the rest:
> {% for image in object.images.all %}
> {% if not forloop.first %}
> ...
>
> note: what you described here (object.images.all) is not a foreignkey
> but a m2m-relationship.
>
> patrick.
>
> Am 09.05.2007 um 14:52 schrieb Alessandro Ronchi:
>
>
>
> > I have an item in my model with one or more photos, linked by a
> > foreign key.
> > I want to put in my template the first image at the head of the page,
> > and the second in another place.
>
> > The result i need is that:
> > ixx
> > ixx
> > x
> > iii
> > iii
> > iii
>
> > where x is text and i is image
> > and so on.
>
> > I can't use the default
> > {% for image in object.images.all  %}
> >  > %}{{image.get_image_url}}{% endfilter %}" />
> > {% endfor %}
>
> > because it gets all the images.
>
> > Is it possible to select the first, the second and so on image of the
> > list object.images.all ?
> > --
> > Alessandro Ronchi
> > Skype: aronchi - Wengo: aleronchi
> >http://www.alessandroronchi.net- Il mio sito personale
> >http://www.soasi.com- Sviluppo Software e Sistemi Open Source


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



Re: Django-l10n-Portuguese

2007-05-16 Thread Filipe Correia

Don't know if you know about this, but there's already a Portugal
Portuguese translation, contributed by Nuno Mariz:
http://code.djangoproject.com/ticket/3745
I guess it's probably be a good start point to make a Brazil
Portuguese translation.

Filipe

On May 15, 5:53 pm, "Alexandre Klostermann"
<[EMAIL PROTECTED]> wrote:
> I would like to announce a Brazilian initiative on creating a task force
> (read: Brazilian Django Community [1]) to translate django's documentation
> to portuguese in a official manner.*
>
> To do it we created the django-l10n-portuguese group in google.groups [2],
> and linked all portuguese translations in [3] to our site on google groups
> to concentrate the translations.
>
> The question is, what should we do to make this activity official in
> Django?
>
> By the way, this email is also to let Django users and developers to know
> our intentions.
>
> Thanks.
>
> Please reply just to me, do not reply to the group.
>
> [1] -http://groups.google.com/group/django-brasil
> [2] -http://groups.google.com/group/django-l10n-portuguese
> [3] -http://code.djangoproject.com/wiki/TranslateDocumentation
>
> --
> Alexandre Martins Klostermann
> --
> [EMAIL PROTECTED]://xaeroworld.org- My Worldhttp://imotion-info.com/projects- 
> Imotion-Info Projects
> Linux User: 436047


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



redirect error to home page

2007-05-16 Thread Mary

Dear All ;

I would like to do the following and i need your help:

I have created my application using django framework and i need that
is there is any 404 error so the application will be directed to home
page directly

How can i do that ??
Thank you in advance ;
mary Adel


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



Re: Status of the trunk? Ok to use it?

2007-05-16 Thread Loïc d'Anterroches

Hello,

> However, that doesn't mean that Django trunk is unstable - it just
> means you need to be careful to check the changelogs before you do an
> SVN update, because an update could have consequences that require
> some fixes to your application. If you keep a close eye on the
> changesets, and follow the advice on the wiki page, using and tracking
> the SVN trunk should not be a major problem. Whether this is feasible
> depends entirely on how much time you are able to dedicate to checking
> and fixing the consequences of following the changes required by
> trunk.

Sorry for the long time after your answer. Thanks a lot for the info,
I will go the trunk way with regular updates as for the moment it is
not for production purposes that I need it. That way I will be able to
report bugs too.

Thanks,
loïc


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



Re: geographical data in models

2007-05-16 Thread omat

This is great news for me!

I had a look at this branch, and this is surely the right way to
develop geographical applications.




On 16 Mayıs, 14:51, "Ramiro Morales" <[EMAIL PROTECTED]> wrote:
> On 5/16/07, omat <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Hi all,
>
> > I am developing an application with django that requires some
> > geographical data, both some points and tracks. I have some questions
> > regarding the model design.
>
> > I know Postgres and MySQL have geographic extensions. I have used
> > MySQL's in the past but now I am mostly interested in Postgres.
>
> > Should I design using those db extension? They provide some handy
> > geographical calculations but maybe those should be better done in the
> > views, not in the db. But, I guess, the indexing in the db will be
> > optimized for geo data, which can improve the db performance.
>
> > Also, using those extensions, points and tracks can all be defined as
> > the same geo type column, which will allow me to store both points and
> > tracks (list of points) in one single table. A workaround to avoid
> > using geo specific db extensions but keeping data in one single table
> > can be pickling the list of points and storing it, but I don't have
> > much practical experience. My application will be using Google Maps
> > API. The API supports a method of encoding point arrays which convert
> > a track info into an ascii sequence. I may be storing this encoded
> > data in a text field in the db.
>
> > One more: Is the best way of defining a geographical point in a model
> > defining lat / lng fields separately? Postgres has a Point data type.
> > Can I use it in my models?
>
> > I feel like avoiding db specific extensions and going with the basic
> > model types would be the best. And ideas and experiences to share?
>
> Disclaimer: I have zero knowledge about this domain, jut wantet to point
> you to the gis branch of Django:
>
> http://code.djangoproject.com/browser/django/branches/gis
>
> From what can be seen in the change log it is being actively
> developed/maintained.
>
> This related wiki page has some valuable information relating to
> geographical data
> tools and libraries:
>
> http://code.djangoproject.com/wiki/GeoDjango
>
> Regards,
>
> --
>  Ramiro Morales


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



Re: geographical data in models

2007-05-16 Thread Margaret

django support GIS??

On 5/16/07, Ramiro Morales <[EMAIL PROTECTED]> wrote:
>
> On 5/16/07, omat <[EMAIL PROTECTED]> wrote:
> >
> > Hi all,
> >
> > I am developing an application with django that requires some
> > geographical data, both some points and tracks. I have some questions
> > regarding the model design.
> >
> > I know Postgres and MySQL have geographic extensions. I have used
> > MySQL's in the past but now I am mostly interested in Postgres.
> >
> > Should I design using those db extension? They provide some handy
> > geographical calculations but maybe those should be better done in the
> > views, not in the db. But, I guess, the indexing in the db will be
> > optimized for geo data, which can improve the db performance.
> >
> > Also, using those extensions, points and tracks can all be defined as
> > the same geo type column, which will allow me to store both points and
> > tracks (list of points) in one single table. A workaround to avoid
> > using geo specific db extensions but keeping data in one single table
> > can be pickling the list of points and storing it, but I don't have
> > much practical experience. My application will be using Google Maps
> > API. The API supports a method of encoding point arrays which convert
> > a track info into an ascii sequence. I may be storing this encoded
> > data in a text field in the db.
> >
> > One more: Is the best way of defining a geographical point in a model
> > defining lat / lng fields separately? Postgres has a Point data type.
> > Can I use it in my models?
> >
> > I feel like avoiding db specific extensions and going with the basic
> > model types would be the best. And ideas and experiences to share?
> >
>
> Disclaimer: I have zero knowledge about this domain, jut wantet to point
> you to the gis branch of Django:
>
> http://code.djangoproject.com/browser/django/branches/gis
>
> From what can be seen in the change log it is being actively
> developed/maintained.
>
> This related wiki page has some valuable information relating to
> geographical data
> tools and libraries:
>
> http://code.djangoproject.com/wiki/GeoDjango
>
> Regards,
>
> --
>  Ramiro Morales
>
> >
>


-- 
[EMAIL PROTECTED]
13585201588

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



Re: geographical data in models

2007-05-16 Thread Ramiro Morales

On 5/16/07, omat <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> I am developing an application with django that requires some
> geographical data, both some points and tracks. I have some questions
> regarding the model design.
>
> I know Postgres and MySQL have geographic extensions. I have used
> MySQL's in the past but now I am mostly interested in Postgres.
>
> Should I design using those db extension? They provide some handy
> geographical calculations but maybe those should be better done in the
> views, not in the db. But, I guess, the indexing in the db will be
> optimized for geo data, which can improve the db performance.
>
> Also, using those extensions, points and tracks can all be defined as
> the same geo type column, which will allow me to store both points and
> tracks (list of points) in one single table. A workaround to avoid
> using geo specific db extensions but keeping data in one single table
> can be pickling the list of points and storing it, but I don't have
> much practical experience. My application will be using Google Maps
> API. The API supports a method of encoding point arrays which convert
> a track info into an ascii sequence. I may be storing this encoded
> data in a text field in the db.
>
> One more: Is the best way of defining a geographical point in a model
> defining lat / lng fields separately? Postgres has a Point data type.
> Can I use it in my models?
>
> I feel like avoiding db specific extensions and going with the basic
> model types would be the best. And ideas and experiences to share?
>

Disclaimer: I have zero knowledge about this domain, jut wantet to point
you to the gis branch of Django:

http://code.djangoproject.com/browser/django/branches/gis

>From what can be seen in the change log it is being actively
developed/maintained.

This related wiki page has some valuable information relating to
geographical data
tools and libraries:

http://code.djangoproject.com/wiki/GeoDjango

Regards,

-- 
 Ramiro Morales

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



Re: Shopping cart application for django

2007-05-16 Thread yml

Hello,

It seems that you are looking for this:
http://satchmo.python-hosting.com/
There is also a google group for that project.
I hope that will help you.
Regards,


On May 16, 1:16 pm, "Nathan Harmston" <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> I m currently building an e-commerce site and I was wondering if there
> are any shopping cart apps out there for django that I can have a look
> at and work through. I am trying to build one that can integrate with
> paypal but any ideas would be cool.
>
> So far I am thinking of storing the whole shopping cart as a
> dictionary in session where it is simply
>
> { product_id:amount },
>
> is this a good way to proceed or do you believe there are some
> problems with this approach?
>
> Many Thanks in advance
>
> Nathan


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



Re: making custom exceptions like Http404?

2007-05-16 Thread Bram - Smartelectronix

omat wrote:
> Add a middleware class like this:

oh, duh!!

thanks a lot :-)

  - bram

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



Re: Cannot resolve keyword '___' into field

2007-05-16 Thread freshraisin

I'm getting the same problem as well.  Very frustrating, can't find a
work around.. essentially makes django useless at this point.

Malcolm Tredinnick wrote:
> On Tue, 2007-05-15 at 16:54 +1000, Mark Jarecki wrote:
> > The temporary fix that I've employed at the moment is e.g.:
> >
> >
> > Instead of
> >
> >
> > > > osIcons =
> > > > product.productOSIcons.filter(isPublished=True).order_by('osIconName')
> >
> >
> > I've got:
> >
> >
> > icons = ProductOSIcons.objects.filter(isPublished=True)
> > osIcons2 = []
> > for icon in icons:
> > if Products.objects.filter(id=product.id, productOSIcons=icon,
> > isPublished=True):
> > osIcons2.append(icon)
> >
> >
> > Which is a REALLY ugly solution, but hopefully I wont have to use it
> > for too long.
>
> As the ticket you found suggests, we're aware of the problem and I think
> we understand the latest reason it's not working (middleware is
> introducing an extra curve-ball for some reason). Fixing it is very hard
> because the problem is so non-reproducible. It's quite likely that
> somebody running your exact code on a different machine or with a
> different version of Python will not be able to reproduce the problem.
>
> At the moment, I'm probably the most likely person to end up fixing
> this. However all my free time for Django is taken at the moment on some
> other items, so all I can encourage people who find these problems to do
> is try to shuffle things around a little, as you've done, in the hope of
> finding a workaround.
>
> Regards,
> Malcolm
>
> >


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



isolating karma score from comments

2007-05-16 Thread omat

Hi,

Neat design of the karma scoring application in the comments framework
of the contributed application is quite appealing. But it is tided to
the comments application.

I am trying to isolate it and make a more generic karma application
for any content (photos, blog entries, etc.) contributed by users.

I wonder if anybody has already did this or built a standalone
karmascore application...

oMat


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



Constraints to a model

2007-05-16 Thread Nathan Harmston

Hi,

I have a model Post, which has the following structure:

class Post(models.Model):
body = models.TextField()
arts = models.ForeignKey(Article, blank=True, null=True)
pics = models.ForeignKey(Gallery, blank=True, null=True)

A post can be made from an article or a gallery or both. Is there
anywhere to add a constraint to force there to be either an article or
gallery associated with a post in the actual declaration of the model?

Many Thanks in advance,

Nathan

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



Shopping cart application for django

2007-05-16 Thread Nathan Harmston

Hi,

I m currently building an e-commerce site and I was wondering if there
are any shopping cart apps out there for django that I can have a look
at and work through. I am trying to build one that can integrate with
paypal but any ideas would be cool.

So far I am thinking of storing the whole shopping cart as a
dictionary in session where it is simply

{ product_id:amount },

is this a good way to proceed or do you believe there are some
problems with this approach?

Many Thanks in advance

Nathan

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



Re: making custom exceptions like Http404?

2007-05-16 Thread omat

Add a middleware class like this:

from django.http import HttpResponseForbidden
from django.template import loader, RequestContext

class Http403(Exception):
pass

class ForbiddenMiddleware:
def process_exception(self, request, exception):
if not isinstance(exception, Http403):
return

try:
template = loader.get_template('403.html')
context = RequestContext(request, {'message':
str(exception)})
return HttpResponseForbidden(template.render(context))
except:
pass # Let Django show the exception


Then you can throw a 403 simply by "raise Http403" in your view
functions.



On 16 Mayıs, 13:42, Bram - Smartelectronix <[EMAIL PROTECTED]>
wrote:
> hey everyone,
>
> looking at the source code this isn't immediately clear to me... What if
> I wanted to make a HttpPermissionError or HttpThisPageIsBeingUpdated or
> ... exception that has it's own template?
>
> This way, from anywhere in the code you could throw your very own
> exception...
>
> Am I correct in assuming this is NOT possible w/out editing the django code?
>
>   - bram


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



making custom exceptions like Http404?

2007-05-16 Thread Bram - Smartelectronix

hey everyone,

looking at the source code this isn't immediately clear to me... What if 
I wanted to make a HttpPermissionError or HttpThisPageIsBeingUpdated or 
... exception that has it's own template?

This way, from anywhere in the code you could throw your very own 
exception...

Am I correct in assuming this is NOT possible w/out editing the django code?


  - bram

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



Re: django vps hosting

2007-05-16 Thread Christian M Hoeppner

I'm using a dedicated virtual at mediatemple. They're working on 
Django-containers, which would be a sweet feature if the ETA was anywhen 
soon.

It's been easy to get django rolling, since you get a CentOS installation (a 
free clone of RedHat Enterprise). Yum is not installed by default, but a 
google gives you the right rpm's to get it up. I'm also writing up a post for 
my blog about this.

It's fairly expensive (I pay $50/month for a (dv) base), but the support is 
awesome. I've been a pleased (mt) customer for years.

Still... Apache gives me headaches over and over again. Once, after adding a 
virtual host, I got the same project displayed on all my domains/subdomains. 
Never got to figure out what the problem was.

Chris Hoeppner
www.pixware.org

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



Re: Maintainance Middleware

2007-05-16 Thread Christian M Hoeppner

> You're more likely to get working code if all the requirements are stated. 
> :)

Yeah, you're right, Jeremy. Thank you a lot for your help.

I wonder... There isn't a way in a middleware to access some name path from 
the urlconf, is there? That way I wouldn't have to set those settings, by 
letting the admin-path bypass the maintenance middleware.

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



Re: Using Django Models outside of Django

2007-05-16 Thread Grigoriy Petukhov

johnny wrote:
> Doing the following:
> 
> from os import environ
> environ['DJANGO_SETTINGS_MODULE'] = 'settings'
> from settings import *
> 
> Only works at the parent folder level.  What if you have script in sub
> folder level?  I tried it at sub folder level and got error:
> 
> from os import environ
> environ['DJANGO_SETTINGS_MODULE'] = '../settings'
> from settings import *
 from apps.mail.models import Email
> Traceback (most recent call last):
>   File "", line 1, in ?
> ImportError: No module named apps.mail.models
> 
> 
> > 
> 

import os
# "keeno.ru" directory contains my project directory "web_site"
sys.path.append('/web/keeno.ru')
os.environ["DJANGO_SETTINGS_MODULE"] = 'web_site.settings'

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



Re: geographical data in models

2007-05-16 Thread Sam

I didn't go with PostGIS because i only needed basic functionality and
approximative data.

In my models, i have :
lat = models.FloatField(max_digits=7, decimal_places=4, blank=True,
null=True)
lng = models.FloatField(max_digits=7, decimal_places=4, blank=True,
null=True)

I'm using it together with GeoPy to find distances
http://exogen.case.edu/projects/geopy/

For locations in a neighbourhood, i only use less and greater than on
both fields.

I'm also interested to see how others dealt with geolocation.




On 16 mai, 09:48, omat <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I am developing an application with django that requires some
> geographical data, both some points and tracks. I have some questions
> regarding the model design.
>
> I know Postgres and MySQL have geographic extensions. I have used
> MySQL's in the past but now I am mostly interested in Postgres.
>
> Should I design using those db extension? They provide some handy
> geographical calculations but maybe those should be better done in the
> views, not in the db. But, I guess, the indexing in the db will be
> optimized for geo data, which can improve the db performance.
>
> Also, using those extensions, points and tracks can all be defined as
> the same geo type column, which will allow me to store both points and
> tracks (list of points) in one single table. A workaround to avoid
> using geo specific db extensions but keeping data in one single table
> can be pickling the list of points and storing it, but I don't have
> much practical experience. My application will be using Google Maps
> API. The API supports a method of encoding point arrays which convert
> a track info into an ascii sequence. I may be storing this encoded
> data in a text field in the db.
>
> One more: Is the best way of defining a geographical point in a model
> defining lat / lng fields separately? Postgres has a Point data type.
> Can I use it in my models?
>
> I feel like avoiding db specific extensions and going with the basic
> model types would be the best. And ideas and experiences to share?


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



cloned admin behind apache proxy - firefox doesnot want to import base.css from login.css

2007-05-16 Thread Jan Stavel

Hello,
I cloned admin media and templates of django:

cp -a python-django/django/contrib/admin/media /opt/cedecka/app/
cp -a python-django/django/contrib/admin/templates \ /opt/cedecka/app/admin/

I customized a little templates (mainly title, ...).

The applications is started:
./manage.py runserver antares.site.xx:8000 \ 
--adminmedia=/opt/cedecka/app/media

(I setup template directory at /opt/cedecka/app/template).

The application runs at server inside internal network.

My goal is to have access to this application from internet.

I tried to set up proxy at www server:


...
   RewriteEngine on
   RewriteRule ^/(.*) http://antares.brailcom.xx:8000/$1 [P,L]
...


It works, but firefox does not want to load styles that are imported in 
main style.

E.g.  login.html loads login.css.

@import url('base.css');
@import url('layout.css');

/* LOGIN FORM */
body.login { background:#eee; }
.login #container { background:white; border:1px solid #ccc;

...

Firefox loads it but it neither tries to load base.css, layout.css.
I check by tcpdump plus tcptrace whether there is an attempt to load 
them. No attempt. It ignores these import lines.

If I give firefox an url to load: 
http://cedecka.pracovni.net/media/base.css, it loads it without problem.


If I made tunnel (ssh -L 8000:antares:8000 antares),
firefox loads all styles including imported ones.


IF I use IE, it loads all stylesheets and admin looks nice.
Firefox does not and admin is just textual (without any layout).

Please give me a hint to set up proxy/tunnel, for django application.

Thanks,
Jan Stavel

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



geographical data in models

2007-05-16 Thread omat

Hi all,

I am developing an application with django that requires some
geographical data, both some points and tracks. I have some questions
regarding the model design.

I know Postgres and MySQL have geographic extensions. I have used
MySQL's in the past but now I am mostly interested in Postgres.

Should I design using those db extension? They provide some handy
geographical calculations but maybe those should be better done in the
views, not in the db. But, I guess, the indexing in the db will be
optimized for geo data, which can improve the db performance.

Also, using those extensions, points and tracks can all be defined as
the same geo type column, which will allow me to store both points and
tracks (list of points) in one single table. A workaround to avoid
using geo specific db extensions but keeping data in one single table
can be pickling the list of points and storing it, but I don't have
much practical experience. My application will be using Google Maps
API. The API supports a method of encoding point arrays which convert
a track info into an ascii sequence. I may be storing this encoded
data in a text field in the db.

One more: Is the best way of defining a geographical point in a model
defining lat / lng fields separately? Postgres has a Point data type.
Can I use it in my models?

I feel like avoiding db specific extensions and going with the basic
model types would be the best. And ideas and experiences to share?


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



Re: Pydev users: Undefined variable from import: objects

2007-05-16 Thread olive

On 16 mai, 08:25, Margaret <[EMAIL PROTECTED]> wrote:
> Undefined from import:objects
> may you need to config your path.

I guess yes, but how ?

These directories are already in my path: django and my_project.

What else ?

Olive.


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



Re: Pydev users: Undefined variable from import: objects

2007-05-16 Thread Margaret

Undefined from import:objects
may you need to config your path.

On 5/16/07, olive <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> this is a question for Pydev/Django users.
>
> Do you have this problem (see subject) ?
>
> Do you know how to solve it ?
>
> Thx,
>
> Olive.
>
>
> >
>


-- 
[EMAIL PROTECTED]
13585201588

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



Pydev users: Undefined variable from import: objects

2007-05-16 Thread olive

Hi,

this is a question for Pydev/Django users.

Do you have this problem (see subject) ?

Do you know how to solve it ?

Thx,

Olive.


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



Re: Tricky context question

2007-05-16 Thread Wolfram Kriesing

thank you very much.
the important piece here was the "translation.get_language()" i oversaw that ...

thanks

wolfram

On 5/15/07, Aidas Bendoraitis <[EMAIL PROTECTED]> wrote:
>
> This should help you to solve almost all your multilingual problems:
> http://www.djangosnippets.org/snippets/51/
>
> Regards,
> Aidas Bendoraitis aka Archatas
>
>
>
> On 5/15/07, Wolfram Kriesing <[EMAIL PROTECTED]> wrote:
> >
> > I have a bi-language (english and german) site. I try to hide the
> > multi language part as best as I can from the programmer, by
> > encapsulating it as best as I can in the model.
> > An example:
> >
> > class Tag(models.Model):
> >name_en = models.SlugField()
> >name_de = models.SlugField()
> >
> >@property
> >def name(self):
> >"Return the name depending on the users language"
> >if user_language=="en": # how can i get user_language?
> >return self.name_en
> >else:
> >return self.name_de
> >
> > This would allow me to use the Tag-model anywhere without knowing the
> > user's language, by accessing the property "name" and it handles the
> > language stuff.
> > This is a very much simplified example of what I actually need.
> > It shows that inside a template I could simply write:
> > {{ tag.name }}
> > and get the proper translation.
> >
> > The problem:
> > Here is the problem I don't get "user_language" without having access
> > to the request! :-(
> >
> >
> > The simple example above would solve small translation tasks, but I
> > have another model, that has some more complex translation logic. I
> > constructed this by using DB-views, and creating models that map
> > directly to appropriate view.
> > To demonstrate this:
> > class DataEnglish(models.Model):
> >  id = 
> >  title = 
> >  abstract = .
> >  class Meta:
> >  db_table = "core_dataenglishview"
> >
> > class DataGerman(models.Model):
> >  id = 
> >  title = 
> >  abstract = .
> >  class Meta:
> >  db_table = "core_datagermanview"
> >
> > To abstract the language stuff, I would like to only access a model
> > called "Data" which in turn maps to "DataGerman" for a german user and
> > to "DataEnglish" to an english user. Unfortunately I only have access
> > to the language via django.utils.translation.get_language_from_request
> > when I have the request available.
> > But I would like to use:
> >  Data.objects.all()
> >  Data.objects.filter()
> > inside my code, without worrying about the language setting in the
> > place where I read from the objects (of course for updating the
> > objects I have to use DataGerman or DataEnglish explicitly, and I do).
> >
> > How can I achieve this in a clean way, without passsing the request
> > around every time?
> >
> >
> > My hacky solution:
> > Write a middleware, that sets some "global" variable i.e. in
> > settings.current_language and use this as language. That would work
> > since every request has its thread/process that is running in apache,
> > but that seems quite dirty.
> >
> > Any ideas? Or have my thoughts been going a completely wrong way?
> >
> > --
> > cu
> >
> > Wolfram
> >
> > >
> >
>
>
> >
>


-- 
cu

Wolfram

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