Re: NewForms Choice Field Working ?

2007-10-04 Thread Chris Brand

staff-gmail wrote:
> I'm using vers .96
> I converted a char field to have choices
>
> old: prefix = models.CharField(maxlength=100, default = 'Mr.')
>
> I then changed my model:
> SALUTATION=(
>   ('Mr.','Mr.'),
>   ('Ms.','Ms.'),
> )
> ...
> prefix = models.CharField(maxlength=100, choices=SALUTATION, default='Mr.')
>
> I then ran manage.py syncdb - result was okay.
>
> now when I run a form_for_instance it correctly puts in all the field 
> information but the NewForm prefix field shows simply as a input field 
> not as a select box. 
>
> Should this work ?  Am I doing something wrong or is this a bug ?  Or 
> should I be running SVN ? 
>
>   
I'm pretty sure this is a known limitation of 0.96 that's fixed in 
trunk. I don't have a bug # to hand, though.

You can work around it in 0.96 by explicitly setting the widget :
Myform.base_fields['prefix'].widget = widgets.Select(choices=SALUTATION)

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: Problem with nesh.thumbnail

2007-10-04 Thread Divan Roulant

Thank you so much Jake for pointing me on this valuable source. That
was the problem.

Divan

On Oct 4, 12:11 pm, jake elliott <[EMAIL PROTECTED]> wrote:
> hi divan,
>
> Divan Roulant wrote:
> > "'myproject.thumbnail' is not a valid tag library: Could not load
> > template library from django.templatetags.apparto.thumbnail, No module
> > named myproject.thumbnail"
>
> here's the change that's tripping you 
> up:http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Templ...
>
> that page is an invaluable reference when living on the trunk!
>
> best
> jake


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



NewForms Choice Field Working ?

2007-10-04 Thread staff-gmail

I'm using vers .96
I converted a char field to have choices

old: prefix = models.CharField(maxlength=100, default = 'Mr.')

I then changed my model:
SALUTATION=(
  ('Mr.','Mr.'),
  ('Ms.','Ms.'),
)
...
prefix = models.CharField(maxlength=100, choices=SALUTATION, default='Mr.')

I then ran manage.py syncdb - result was okay.

now when I run a form_for_instance it correctly puts in all the field 
information but the NewForm prefix field shows simply as a input field 
not as a select box. 

Should this work ?  Am I doing something wrong or is this a bug ?  Or 
should I be running SVN ? 


--~--~-~--~~~---~--~~
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: custom method for view

2007-10-04 Thread Goon

Looks like that works!  Thanks very much



>
> i.e.
>
> my_model_instance = myClass.objects.get(pk=12)
> my_model_instance.getValue()
>
> -joe
>
> On 10/4/07, Goon <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > probably a dumb question, what's the syntax for calling a method in
> > models.py from views.py?
>
> > so like:
>
> > #models.py
> > class myClass (models.Model):
> >   value = 24
> >   def getValue(self):
> >return value
>
> > #views.py
> > def myFunction():
> >   myData = ###what do I put here to call "getValue()" instead of
> > looking up the value field itself?
>
> > thanks- Hide quoted text -
>
> - Show quoted text -


--~--~-~--~~~---~--~~
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: custom method for view

2007-10-04 Thread Joseph Heck

Get an instance of the model and call getValue() on it.

i.e.

my_model_instance = myClass.objects.get(pk=12)
my_model_instance.getValue()

-joe

On 10/4/07, Goon <[EMAIL PROTECTED]> wrote:
>
> probably a dumb question, what's the syntax for calling a method in
> models.py from views.py?
>
> so like:
>
> #models.py
> class myClass (models.Model):
>   value = 24
>   def getValue(self):
>return value
>
>
> #views.py
> def myFunction():
>   myData = ###what do I put here to call "getValue()" instead of
> looking up the value field itself?
>
>
> 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
-~--~~~~--~~--~--~---



custom method for view

2007-10-04 Thread Goon

probably a dumb question, what's the syntax for calling a method in
models.py from views.py?

so like:

#models.py
class myClass (models.Model):
  value = 24
  def getValue(self):
   return value


#views.py
def myFunction():
  myData = ###what do I put here to call "getValue()" instead of
looking up the value field itself?


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: Plz, I am just new to Python...

2007-10-04 Thread Derek Payton

> > I tried downloading Django and installing it on my windows looks very
> > difficult. Plsease can anyone help me on how to install Django and how
> > to go about starting web development in Phyton?

I think your best bet would be to follow John's advice:

> I'm not sure of the details for doing it on MS Windows. GNU/Linux is a
> good environment for development of all sorts. I recommend upgrading
> to Ubuntu.

I can vouch for this. Like you, I started with PHP and moved to
Python, and I had a heckuva time getting Django setup on Windows. I
would have a go at it, fiddle with it for a day or two, then leave it
alone for weeks or months at a time (in the meantime, I was using
web.py which was a little simpler for me to setup). Then, about 6
months ago, I made the switch. I ditched Windows and installed Ubuntu.
Not only was I able to get Django up and running with relative ease,
but my life in general as a developer has been much better. When it
comes to programming, you can't really beat a Linux setup (unless, of
course, you're programming specifically *for* Windows -- which is
certainly not the case for web development).

Good luck!

--D.


--~--~-~--~~~---~--~~
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: Sending encrypted email

2007-10-04 Thread Joseph Heck

Sorry - Its worth noting that you could start by working with the
EmailMultiAlternatives class in django.core.mail. It has a method
"attach_alternative()" that works on the EmailMessage subclass to
attach alternative representations of the content. I'm not sure what
the "right" way to send an encrypted message with GPG is, but that
might be something of use...

-joe

On 10/4/07, Joseph Heck <[EMAIL PROTECTED]> wrote:
> Nothing built in - You're going to have to head towards the low-level
> libraries to make this happen.
>
> -joe
>
> On 10/4/07, Francis <[EMAIL PROTECTED]> wrote:
> >
> > Hello,
> >
> > I need to send an email with a encrypted part in it. Is there a built-
> > in way to do this in python or django (since it is a django apps).
> > Maybe the entire can be encrypted, but it is only a piece that
> > requires it.
> >
> > i look at some encryption mechanism, but nothing seem to be
> > straightforward. (PGP, OTP)
> >
> > Francis
> >
> >
> > > >
> >
>

--~--~-~--~~~---~--~~
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: Sending encrypted email

2007-10-04 Thread Joseph Heck

Nothing built in - You're going to have to head towards the low-level
libraries to make this happen.

-joe

On 10/4/07, Francis <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> I need to send an email with a encrypted part in it. Is there a built-
> in way to do this in python or django (since it is a django apps).
> Maybe the entire can be encrypted, but it is only a piece that
> requires it.
>
> i look at some encryption mechanism, but nothing seem to be
> straightforward. (PGP, OTP)
>
> Francis
>
>
> >
>

--~--~-~--~~~---~--~~
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: Something like an "all in" for filter of related set

2007-10-04 Thread Bill Dawson

On Thu, 2007-10-04 at 16:38 -0400, Malcolm Tredinnick wrote:
> On Thu, 2007-10-04 at 20:08 +, bill wrote:
> > Hi folks,
> > I've reviewed the db api documentation page, and I'm pretty sure it
> > didn't have an example that would help me with this request.  I'd like
> > something like the "IN" operator that can be used in a lookup on a
> > field in a related model, but more like something that I guess could
> > be called something like "ALL_IN".  Example:
> > Models:
> > Article (title, pub_date, etc...)
> > TaggedArticle (article_id, tag)
> > 
> > One article can of course have multiple tags.  What if I wanted to
> > find Articles that have _all_ the tags in a particular set.  Similar
> > to IN:
> > 
> > Article.objects.filter(taggedarticle__tag__in=['python', 'perl',
> > 'java'])
> > 
> > That would give me articles that have tags for python OR perl OR
> > java.  But what if I want a quick way to find all articles that have
> > all three of those tags (they may have more tags, but they at least
> > have all of those three.)
> > 
> > I've learned about making my own Manager class, so that's definitely
> > possible, but does there happen to be a built-in way?
> 
> At the moment, this isn't possible. You can use the method in [1] to do
> it right now, though. In the near future, once the queryset refactor is
> finished, you'll be able to do this as
> 
>  A. 
> Article.objects.filter(tag='python').filter(tag='perl').filter(tag='java')
> 
> or something like (I've possibly screwed up the syntax, but you get the
> idea):
> 
> Article.objects.filter(Q(tag='python'), Q(tag='perl'), Q(tag='java'))
> 
> because many-to-many filters will successively restrict the result set.
> However, that doesn't work right now because we don't do the correct
> self-joins to form the right SQL. [By the way, it will also be possible
> to construct this
> 
> [1] http://www.pointy-stick.com/blog/2006/06/14/custom-sql-django/
> 
> Regards,
> Malcolm

Thanks so much, Malcolm, your article was really spot-on. It's exactly
what I want to do.  Looking forward to the django enhancements, but in
the meantime this customer manager approach looks great.


--~--~-~--~~~---~--~~
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: Plz, I am just new to Python...

2007-10-04 Thread John

On Oct 4, 11:09 am, Emperor of thought <[EMAIL PROTECTED]>
wrote:
> Please i am just new to python and i will like to know how i can go
> about in web development. I am migrating from PHP and phyton web
> environment does not look very familiar.

Python has a number of frameworks and libraries for web development.
Django is but one of your choices. I think it's a good choice.

Note that Django is a framework. So, that means instead of writing a
file for each web page, you'll be writing:

* a file for your models (classes),
* a file for your views (functions),
* a file mapping urls to view functions (a list), and
* some files for your templates (html with some extra bits thrown in).
The template files look like php files, but with {% ... %} blocks in
them instead of  blocks.

Then the framework takes care of having the right view get called
(which then grabs one of the templates) and returns the page to the
user that requested it.

> I tried downloading Django and installing it on my windows looks very
> difficult. Plsease can anyone help me on how to install Django and how
> to go about starting web development in Phyton?

I'm not sure of the details for doing it on MS Windows. GNU/Linux is a
good environment for development of all sorts. I recommend upgrading
to Ubuntu.

---John


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



Sending encrypted email

2007-10-04 Thread Francis

Hello,

I need to send an email with a encrypted part in it. Is there a built-
in way to do this in python or django (since it is a django apps).
Maybe the entire can be encrypted, but it is only a piece that
requires it.

i look at some encryption mechanism, but nothing seem to be
straightforward. (PGP, OTP)

Francis


--~--~-~--~~~---~--~~
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: Completely caching ContentType into memory

2007-10-04 Thread Alexander Solovyov

On 4 окт, 22:16, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> Have a look at CONTENT_TYPE_CACHE in
> django/contrib/contenttypes/models.py.

I've done .get method with caching by model and app_label (and even
without
app_label). I'm not sure it is clean to be added as ticket with patch
for Django,
but maybe it will be interesting for someone, so here is the code:
http://trac.piranha.org.ua/browser/byteflow/lib/db.py

it is applied here:
http://trac.piranha.org.ua/browser/byteflow/patches.py

P.S. Malcolm, if you think it is clean and good enough to be added as
patch, I'd like
to do that! - maybe after cleaning up from `get_without_app`.

--
Alexander


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

2007-10-04 Thread Joe

On Oct 4, 3:39 pm, Jonathan Ballet <[EMAIL PROTECTED]> wrote:
>   * I have methods on instances of my class which should not be there
> (.create, .delete, .save) (at least, I'm not using materialized
> views).

I think a good thing to do with these would be to override the methods
and raise a NotImplemented exception (or do nothing, if you like the
silent but deadly approach).


--~--~-~--~~~---~--~~
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: Something like an "all in" for filter of related set

2007-10-04 Thread Malcolm Tredinnick

On Thu, 2007-10-04 at 20:08 +, bill wrote:
> Hi folks,
> I've reviewed the db api documentation page, and I'm pretty sure it
> didn't have an example that would help me with this request.  I'd like
> something like the "IN" operator that can be used in a lookup on a
> field in a related model, but more like something that I guess could
> be called something like "ALL_IN".  Example:
> Models:
> Article (title, pub_date, etc...)
> TaggedArticle (article_id, tag)
> 
> One article can of course have multiple tags.  What if I wanted to
> find Articles that have _all_ the tags in a particular set.  Similar
> to IN:
> 
> Article.objects.filter(taggedarticle__tag__in=['python', 'perl',
> 'java'])
> 
> That would give me articles that have tags for python OR perl OR
> java.  But what if I want a quick way to find all articles that have
> all three of those tags (they may have more tags, but they at least
> have all of those three.)
> 
> I've learned about making my own Manager class, so that's definitely
> possible, but does there happen to be a built-in way?

At the moment, this isn't possible. You can use the method in [1] to do
it right now, though. In the near future, once the queryset refactor is
finished, you'll be able to do this as

 A. 
Article.objects.filter(tag='python').filter(tag='perl').filter(tag='java')

or something like (I've possibly screwed up the syntax, but you get the
idea):

Article.objects.filter(Q(tag='python'), Q(tag='perl'), Q(tag='java'))

because many-to-many filters will successively restrict the result set.
However, that doesn't work right now because we don't do the correct
self-joins to form the right SQL. [By the way, it will also be possible
to construct this

[1] http://www.pointy-stick.com/blog/2006/06/14/custom-sql-django/

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



En Güzel Kızlar , en yakışıklı Erkekler

2007-10-04 Thread turk970

Clubzuzu www.clubzuzu.com

 Yeni arkadaşlıklar ,dostluklar ,ilişkilermi arıyorsunuz? Clubzuzu ile
bu çok kolay ve ücretsiz. Arkadaşlarınızla chat yapabilir, mail
gönderebilir,beğendiğiniz kişileri listenize ekleyebilir, profillerine
bakarak size en uygun arkadaşı bulabilirsiniz.

Ayrıca Ücretli üyelik aylık sadece 15.-ytl buna karşılık  Üyelik
yanında bedava 30 sms (ceptelefon mesajı) kazanın. İster beğendiğiniz
üyelere , isterseniz istediğiniz diğer cep telefonlarına mesaj
gönderin. Ayrıca Dunyanın en guzel  ve yakışılı erkeleri canlı
görüntülü sohbet edin.

Arkadaşlarınızıda davet etmeyi unutmayın. Çümkü davet ettiğiniz  her
arkadaşınız için 3 sms  bedava hesabınıza yuklenecektir.

Hemen Başlayın.. İyi eğlenceler.

www.clubzuzu.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: Using VIEWs from a database

2007-10-04 Thread Marty Alchin

On the other side of it, this could almost be done by simply creating
a new base class which your view-based model could subclass, instead
of models.Model. It could share much of the existing Model code,
allowing for declarative syntax, adding in the default manager,
processing Meta options, etc. It just wouldn't have the extra methods
that would normally write to the database.

The reason I say "almost" is that the only way I can see to avoid
syncdb processing is to skip the model registration, but that would
then also cause it to disappear from the admin, which probably isn't
what you want.

Well, at any rate, if there is eventually a way to avoid having a
table created for a model, you can in fact go this route if you'd
really like to avoid having save/delete/etc on your models. Also keep
in mind that you'd have to create a new default manager as well, in
order to get rid of the create method.

All that said, I agree with Malcolm on not bothering to remove
create/save/delete. After all, trying to call them will raise an error
regardless of whether they exist. Removing them would basically just
swap out a DatabaseError for an AttributeError. Six of one, half-dozen
of the other.

-Gul

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



Something like an "all in" for filter of related set

2007-10-04 Thread bill

Hi folks,
I've reviewed the db api documentation page, and I'm pretty sure it
didn't have an example that would help me with this request.  I'd like
something like the "IN" operator that can be used in a lookup on a
field in a related model, but more like something that I guess could
be called something like "ALL_IN".  Example:
Models:
Article (title, pub_date, etc...)
TaggedArticle (article_id, tag)

One article can of course have multiple tags.  What if I wanted to
find Articles that have _all_ the tags in a particular set.  Similar
to IN:

Article.objects.filter(taggedarticle__tag__in=['python', 'perl',
'java'])

That would give me articles that have tags for python OR perl OR
java.  But what if I want a quick way to find all articles that have
all three of those tags (they may have more tags, but they at least
have all of those three.)

I've learned about making my own Manager class, so that's definitely
possible, but does there happen to be a built-in way?

Thx much,
bill


--~--~-~--~~~---~--~~
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 VIEWs from a database

2007-10-04 Thread Malcolm Tredinnick

On Thu, 2007-10-04 at 12:39 -0700, Jonathan Ballet wrote:
> Hi everyone,
> 
> I have a project which uses a PostgreSQL database with several tables,
> and I have created VIEWs in this database.
> 
> Now, I would like to be able to use those views from my Django
> project. Is there any "official" way to do this ?
> 
> Currently, I made a new Model class, with the same fields as in my
> view, but this has several disadvantages :
>   * I can't use syncdb anymore (or I must ensure that the view is
> created _before_ doing syncdb) ;

There's a ticket open to find a way to say "don't create a table for
this model", precisely for the view case. I remember reading it during
the sprint and debating a few points with somebody. It's tended towards
over-engineering at some places in the comments (particularly the
solution linked to from the ticket), but the concept is sound.

>   * I have methods on instances of my class which should not be there
> (.create, .delete, .save) (at least, I'm not using materialized
> views).

Life's like that. Deal with it. :-)

There's plenty of stuff you can do in Python that won't raise an error
until you call try the action. This is another one of those. Don't call
those methods and you'll be fine. Do call those methods and it will just
be a different error from if the function was missing altogether.

So the first point is an annoyance; currently you have to work as you
indicate. The second point is really a non-issue and it's unlikely we'll
be doing much about it in the near future. The reason it's not
completely trivial is that you need a way to tell the difference between
"this table already exists, so don't create it with syncdb" and "this
thing already exists *and* it's not writable". It's probably not worth
adding more and more settings options for a case where the existence of
a couple of extra methods causes no genuine harm.

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



Using VIEWs from a database

2007-10-04 Thread Jonathan Ballet

Hi everyone,

I have a project which uses a PostgreSQL database with several tables,
and I have created VIEWs in this database.

Now, I would like to be able to use those views from my Django
project. Is there any "official" way to do this ?

Currently, I made a new Model class, with the same fields as in my
view, but this has several disadvantages :
  * I can't use syncdb anymore (or I must ensure that the view is
created _before_ doing syncdb) ;
  * I have methods on instances of my class which should not be there
(.create, .delete, .save) (at least, I'm not using materialized
views).

Nothing insurmountable, but this is not very pretty.

So, is there anyone using database View's with Django ? How are you
doing ?


Thanks for your comments;
 - Jonathan


--~--~-~--~~~---~--~~
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: Completely caching ContentType into memory

2007-10-04 Thread Alexander Solovyov

On 4 окт, 22:16, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> On Thu, 2007-10-04 at 12:11 -0700, Alexander Solovyov wrote:
> > Hi,
>
> > I'm working on some big site and we are using content types very often
> > (for generic relations). And there are one idea appeared - why not
> > cache content types in the memory completely.
>
> > Just replacing default manager of ContentType class (with monkey-
> > patching) with another, which will cache retrieved objects will remove
> > this query to database completely.
>
> > So I'm wondering - maybe someone already have done something like
> > this? Or maybe someone have thoughts?
>
> We are already doing that (caching them in memory) and for exactly the
> use-case you have discovered: generic relations are otherwise very
> costly.

Yeah, but there is no way to avoid them in many cases (tags, ratings,
reviews for
various types of objects). We already have helpers for speeding up
them and I think
we will release them to public after cleanup (and running site ;))

> Have a look at CONTENT_TYPE_CACHE in
> django/contrib/contenttypes/models.py.

Thanks, I've seen that earlier, but forgot about it. But this is
unusable for me, because
most of queries to ContentType are done this way:

def some_view(request, content_type, *args, **kwargs):
ctype = get_object_or_404(ContentType, model=content_type)

So this cache will not work. But, I've just thought, I don't need
generic solution and can
cache just by model name...

--
Alexander


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



All secret recipes of top fast food resturants free

2007-10-04 Thread [EMAIL PROTECTED]

All secret recipes of top fast food resturants free i.e McDonald's,
KFC, Wendy's, Papa john's, chili's, Heinz, kellogs all available at

http://secretrecipesleaked.blogspot.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
-~--~~~~--~~--~--~---



All secret recipes of top fast food resturants free

2007-10-04 Thread [EMAIL PROTECTED]

All secret recipes of top fast food resturants free i.e McDonald's,
KFC, Wendy's, Papa john's, chili's, Heinz, kellogs all available at

http://secretrecipesleaked.blogspot.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: Completely caching ContentType into memory

2007-10-04 Thread Malcolm Tredinnick

On Thu, 2007-10-04 at 12:11 -0700, Alexander Solovyov wrote:
> Hi,
> 
> I'm working on some big site and we are using content types very often
> (for generic relations). And there are one idea appeared - why not
> cache content types in the memory completely.
> 
> Just replacing default manager of ContentType class (with monkey-
> patching) with another, which will cache retrieved objects will remove
> this query to database completely.
> 
> So I'm wondering - maybe someone already have done something like
> this? Or maybe someone have thoughts?

We are already doing that (caching them in memory) and for exactly the
use-case you have discovered: generic relations are otherwise very
costly. This was added back in January of this year, so it's even in the
0.96 release.

Have a look at CONTENT_TYPE_CACHE in
django/contrib/contenttypes/models.py.

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



Completely caching ContentType into memory

2007-10-04 Thread Alexander Solovyov

Hi,

I'm working on some big site and we are using content types very often
(for generic relations). And there are one idea appeared - why not
cache content types in the memory completely.

Just replacing default manager of ContentType class (with monkey-
patching) with another, which will cache retrieved objects will remove
this query to database completely.

So I'm wondering - maybe someone already have done something like
this? Or maybe someone have thoughts?

--
Alexander


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



Using edit_inline DateField is not showing up

2007-10-04 Thread Greg

Hello,
I have a table called Orders.  Which stores information about each
order that I get.  It also has the ability to send email's to the
customer's email address.  I also have another table called EmailSent
that store information about each email that I send through the
admin.  My EmailSent class has a ForeignKey to Orders class which also
has edit_inline.  So when i look at an order I'm able to see all the
emails that I've sent tied to that order.  I have a coulumn in
EmailSent that looks like this:

thetime = models.DateField(auto_now_add=True)

This does not show up when I look at the emails tied to an order.  I'm
able to see all my other fields in the EmailSent class.

Anybody have any suggestions?  Below is my code:

class EmailSent(models.Model):
type = models.CharField(maxlength=100, core=True)
message = models.TextField("Message", maxlength=1000)
thetime = models.DateField(auto_now_add=True)
order = models.ForeignKey(Orders, edit_inline=models.TABULAR)

/

This is my code from within my save method of my orders class

def save(self):
message = ''
if self.send_email <> "":
o = EmailSent()
o.type = type
o.message = message
o.order = self.id
o.save()
super(Orders, self).save()

///

Thanks for any help


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



Re: Apache2/mod_python can't import project settings

2007-10-04 Thread Malcolm Tredinnick

On Thu, 2007-10-04 at 09:34 -0700, juampa wrote:
> Hello all:
> 
> I am deploying a Django project with Apache 2.0.55 and mod_python
> 3.3.1 on Mac OS X Panther 10.3.9 server.
> The problem is that when I try to load the page on my browser, I get a
> mod_python debug error indicating that my project's settings cannot be
> imported by django/conf/__init__.py (Line 85, Environment Error). But
> I know the path is correct. I even added an assert line to
> django.conf.__init__.py to dump the sys.path and it has indeed the
> proper path to my project, as loaded in httpd.conf with:
> 
> PythonPath "['/path/to/project'] + sys.path"
> setEnv DJANGO_SETTINGS_MODULE project.settings

This is going to be a little hard to debug because I presume your *real*
path isn't /path/to/project. So I'll just point out the problem in your
example here: You need to be able execute "import project.settings" once
your Python path is set up. So the *parent directory* of 'project' needs
to be in your Python path. If settings.py is inside project/ and your
Python path is /path/to/project, then the settings module setting would
be just 'settings' (not 'projects.settings').

At all times, the *parent* of any directories you are importing from
need to be in the Python path.

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: Updating multiple records from one HTML form

2007-10-04 Thread James Mulholland

It worked, first time :-) For the record, this is what the code looks
like now:

urls.py:

(r'address/edit/(?P\d+)/', 'testdb.mtable.views.edit_address')


views.py:

def edit_address(request, id=None):
address = Address.objects.get(pk=id)
country = address.country

AddressForm = form_for_instance(address, fields=('address_1',
'address_2', 'town', 'county'))
CountryForm = form_for_instance(country, fields=('iso', 'name'))

class FullForm(forms.Form, AddressForm, CountryForm):
def save(self):
AddressForm.save(self)
CountryForm.save(self)
def is_valid(self):
return AddressForm.is_valid(self) and
CountryForm.is_valid(self)

if request.method == 'POST':
form = FullForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('/address/edit/' + str(id) +
'/')
else:
form = FullForm()

return render_to_response('address/edit.html', locals())

Probably needs more refinement, but it works.

--
James

On Oct 4, 4:05 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote:
> On 10/4/07, Marty Alchin <[EMAIL PROTECTED]> wrote:
>
> > It's using the save() method from AddressForm, which only knows about
> > its own fields.
>
> You should also verify that is_valid() is in fact checking all the
> fields as well. I suspect that, like save(), it's only looking at the
> AddressForm fields. Fixing it would be similar to save(), just add
> another method, like so:
>
> def is_valid(self):
> return AddressForm.is_valid(self) and CountryForm.is_valid(self)
>
> -Gul


--~--~-~--~~~---~--~~
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 database setup problem

2007-10-04 Thread Joseph Heck

I'd recommend installing
http://download.fedora.redhat.com/pub/fedora/linux/core/4/i386/os/Fedora/RPMS/MySQL-python-1.2.0-1.i386.rpm

If I remember correctly, Fedora (RPM) has no trouble with using a
remote RPM file - so the following should do the trick:

rpm -Uvh 
http://download.fedora.redhat.com/pub/fedora/linux/core/4/i386/os/Fedora/RPMS/MySQL-python-1.2.0-1.i386.rpm

-joe

On 10/4/07, swati <[EMAIL PROTECTED]> wrote:
>
> Thanks Joe, I recompiled the python with zlib support and tried to
> install mysqldb, now I am not getting the error of zlib anymore. But
> got error with gcc compiler. Part of the error is something like,-
>
> 
> _mysql.c:2475: warning: passing argument 1 of âstrlenâ from
> incompatible pointer type
> _mysql.c:2475: error: invalid operands to binary -
> _mysql.c:2475: warning: comparison between pointer and integer
> _mysql.c:2475: warning: passing argument 2 of â__builtin_strcmpâ from
> incompatible pointer type
> _mysql.c:2475: error: invalid operands to binary -
> _mysql.c:2475: warning: comparison between pointer and integer
> _mysql.c:2475: warning: passing argument 2 of â__builtin_strcmpâ from
> incompatible pointer type
> _mysql.c:2475: error: invalid operands to binary -
> _mysql.c:2475: warning: comparison between pointer and integer
> _mysql.c:2475: warning: passing argument 1 of âstrlenâ from
> incompatible pointer type
> _mysql.c:2475: warning: passing argument 2 of â__builtin_strcmpâ from
> incompatible pointer type
> _mysql.c:2475: error: invalid operands to binary -
> _mysql.c:2475: error: invalid operands to binary -
> _mysql.c:2475: warning: statement with no effect
> _mysql.c:2475: error: invalid operands to binary -
> _mysql.c:2475: warning: statement with no effect
> _mysql.c:2475: error: invalid operands to binary -
> _mysql.c:2475: warning: statement with no effect
> _mysql.c:2475: warning: passing argument 2 of â__builtin_strcmpâ from
> incompatible pointer type
> _mysql.c:2476: warning: passing argument 1 of âPyMember_GetOneâ from
> incompatible pointer type
> _mysql.c:2478: warning: passing argument 2 of âPyErr_SetStringâ from
> incompatible pointer type
> _mysql.c: At top level:
> _mysql.c:2486: error: syntax error before â*â token
> _mysql.c:2489: warning: function declaration isnât a prototype
> _mysql.c: In function â_mysql_ConnectionObject_setattrâ:
> _mysql.c:2490: error: âvâ undeclared (first use in this function)
> _mysql.c:2501: error: ânameâ undeclared (first use in this function)
> _mysql.c:2501: warning: passing argument 1 of âstrlenâ from
> incompatible pointer type
> _mysql.c:2501: error: invalid operands to binary -
> _mysql.c:2501: warning: comparison between pointer and integer
> _mysql.c:2501: warning: passing argument 2 of â__builtin_strcmpâ from
> incompatible pointer type
> _mysql.c:2501: error: invalid operands to binary -
> _mysql.c:2501: warning: comparison between pointer and integer
> _mysql.c:2501: warning: passing argument 2 of â__builtin_strcmpâ from
> incompatible pointer type
> _mysql.c:2501: error: invalid operands to binary -
> _mysql.c:2501: warning: comparison between pointer and integer
> _mysql.c:2501: warning: passing argument 1 of âstrlenâ from
> incompatible pointer type
> _mysql.c:2501: warning: passing argument 2 of â__builtin_strcmpâ from
> incompatible pointer type
> _mysql.c:2501: error: invalid operands to binary -
> _mysql.c:2501: error: invalid operands to binary -
> _mysql.c:2501: warning: statement with no effect
> _mysql.c:2501: error: invalid operands to binary -
> _mysql.c:2501: warning: statement with no effect
> _mysql.c:2501: error: invalid operands to binary -
> _mysql.c:2501: warning: statement with no effect
> _mysql.c:2501: warning: passing argument 2 of â__builtin_strcmpâ from
> incompatible pointer type
> _mysql.c:2502: error: âselfâ undeclared (first use in this function)
> _mysql.c:2502: warning: passing argument 1 of âPyMember_SetOneâ from
> incompatible pointer type
> _mysql.c:2502: warning: passing argument 3 of âPyMember_SetOneâ from
> incompatible pointer type
> _mysql.c:2504: warning: passing argument 2 of âPyErr_SetStringâ from
> incompatible pointer type
> _mysql.c: At top level:
> _mysql.c:2511: error: syntax error before â*â token
> _mysql.c:2514: warning: function declaration isnât a prototype
> _mysql.c: In function â_mysql_ResultObject_setattrâ:
> _mysql.c:2515: error: âvâ undeclared (first use in this function)
> _mysql.c:2526: error: ânameâ undeclared (first use in this function)
> _mysql.c:2526: warning: passing argument 1 of âstrlenâ from
> incompatible pointer type
> _mysql.c:2526: error: invalid operands to binary -
> _mysql.c:2526: warning: comparison between pointer and integer
> _mysql.c:2526: warning: passing argument 2 of â__builtin_strcmpâ from
> incompatible pointer type
> _mysql.c:2526: error: invalid operands 

Re: Plz, I am just new to Python...

2007-10-04 Thread cjl

EOT:

You may want to check out my project:

http://www.instantdjango.com

It is a Windows based, no-installation-required Django setup. I also
have a basic tutorial, which should take you about 30 minutes to work
through. It's not great, but it should give you a basic understanding
of web development with Django.  If you work through the tutorial and
like what you see, head on over to the Django project web site, and
work through the installation instructions and tutorial.

-CJL


--~--~-~--~~~---~--~~
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: Updating multiple records from one HTML form

2007-10-04 Thread James Mulholland

Thanks -- I'll try those ideas as well.

On Oct 4, 4:05 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote:
> On 10/4/07, Marty Alchin <[EMAIL PROTECTED]> wrote:
>
> > It's using the save() method from AddressForm, which only knows about
> > its own fields.
>
> You should also verify that is_valid() is in fact checking all the
> fields as well. I suspect that, like save(), it's only looking at the
> AddressForm fields. Fixing it would be similar to save(), just add
> another method, like so:
>
> def is_valid(self):
> return AddressForm.is_valid(self) and CountryForm.is_valid(self)
>
> -Gul


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



Apache2/mod_python can't import project settings

2007-10-04 Thread juampa

Hello all:

I am deploying a Django project with Apache 2.0.55 and mod_python
3.3.1 on Mac OS X Panther 10.3.9 server.
The problem is that when I try to load the page on my browser, I get a
mod_python debug error indicating that my project's settings cannot be
imported by django/conf/__init__.py (Line 85, Environment Error). But
I know the path is correct. I even added an assert line to
django.conf.__init__.py to dump the sys.path and it has indeed the
proper path to my project, as loaded in httpd.conf with:

PythonPath "['/path/to/project'] + sys.path"
setEnv DJANGO_SETTINGS_MODULE project.settings

To confirm that things are OK, I managed to run the project by putting
it in the site-packages directory off the python2.5 installation
directory. The project directory has 755 permissions so anyone should
be able to run it (same permissions as python itself).

I installed python 2.5 by compiling it from source, because the
universal binary installer gave me trouble for compiling mod_python
later on. I did a "sudo make install" for python, so it was all
installed as root and group wheel. The path to python is the first
item in the PATH environment variable in /etc/profile, so any user
should be running python 2.5. I am running the Apache 2.0.55 that came
with Panther server.

Any ideas as to what is going on?

Thanks,

Juampa


--~--~-~--~~~---~--~~
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: Plz, I am just new to Python...

2007-10-04 Thread Chris Hoeppner

El jue, 04-10-2007 a las 15:09 +, Emperor of thought escribió:
> Please i am just new to python and i will like to know how i can go
> about in web development. I am migrating from PHP and phyton web
> environment does not look very familiar.
> I tried downloading Django and installing it on my windows looks very
> difficult. Plsease can anyone help me on how to install Django and how
> to go about starting web development in Phyton?

First of all, I'd like to point out that windows is IMHO not a nice
development environment. Anyway, if you'd like to do it, you might have
a look at the e text editor [1], which is good for newbies and advanced
folks.

As for the system, you'll need at least a database. SQLite is pretty
straight forward, but is a bit limited. I have never done a postgre
setup on windows, so what I can tell you about is mysql[2], which even
has a nice configuration GUI, and a neat administration interface [3].

I don't feel really urged to give detailed installation guides for any
of them, since there is plenty of the kind on the net. Just ask Google
(tm) ;)

If you're serious about programming, you might want to migrate over to
linux (keep your flamethrowers, sons of M$!!), or finally make the step
for a mac. You'll never look back, believe me.

I hope all of this didn't sound too vague.

~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: QuerySet.extra() and bind variables

2007-10-04 Thread tzeskimo

Thanks for letting me know.  I was afraid I was missing something
obvious.

On Oct 4, 5:48 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Wed, 2007-10-03 at 22:44 +, tzeskimo wrote:
> > I'm trying to write a custom QuerySet, but I'm a bit confused about
> > how to properly use the method extra().  From my understanding,
> > extra() accepts both "select" and "where" arguments, both of which can
> > contain bind variables.  You then pass the appropriate bind variable
> > values to the "param" argument.
>
> > This method seems like it will fall apart if two QuerySets are chained
> > together, both of which pass "select" and "where" arguments to extra.
> > For example, wouldn't the following cause an issue:
>
> > class FooQuerySet:
>
> > def query1(self):
>
> >  self.extra(select = {'something': "item * %s"}, where = "item
> > < %s", params = (3, 5))
>
> > def query2(self):
>
> > self.extra(select = {'something_else': "item / %s"}, where =
> > "item > %s", params = (3, 5))
>
> > model.custom_manager.all().query1().query2()
>
> The "select" portion of extra() was never really intended to support
> parameters. There are bigger problems than the one you've noticed here:
> since "select" is a dictionary, it's ordering is indeterminate and so
> when you have multiple items in the dictionary, there is no way to
> reliably map the parameters to those items.
>
> I've been toying with a couple of ideas in the context of the
> queryset-refactor branch to possibly try and make this work (with a
> little more effort on the side of the programmer), but it's never going
> to be particularly neat and tidy.
>
> For now, you can't do that. It's unsupported. You will need to write
> custom SQL.
>
> 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
-~--~~~~--~~--~--~---



Custom View to save file

2007-10-04 Thread jacoberg2

Hey, i had issues with this before but i fixed the login problem i
believe. I cant seem to get my view to work it is supposed to take the
file from the form on the template and save it to my database and
directory. saving a file in the admin works just fine so i need some
help fixing the view and its interface with the template. The form is
created onthe site but it doesnt redirect or save anything to the
database when i hit submit. so here is the view:

@login_required
def bulk_reg(request):
"""Add large numbers of registrations by uploading a file"""
manipulator = FileManipulator()
data_domain = get_object_or_404(DataDomain, user=request.user.id)
new_data = {}
errors = {}

if request.POST:
new_data = request.POST.copy()
new_data.update(request.FILES)
errors = manipulator.get_validation_errors(new_data)

if not errors:
manipulator.do_html2python(new_data)

fi = BulkDataRegFile(user = request.user.id,
 domain = data_domain,
 bulk = new_data['bulk'],)
fi.save()

return HttpResponseRedirect('/provider/')

form = forms.FormWrapper(manipulator, new_data, errors)
return render_to_response('provider/dataset/bulkreg.dht',
  {'form': form},
 
context_instance=RequestContext(request))


and the following is the part of the template that concerns the form:

{% if form.has_errors %}
Please correct the form
{% endif %}





Select File:

{{ form.bulk }}{{ form.bulk_file }}




So if anyone can help me out that owuld be great.


--~--~-~--~~~---~--~~
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: Problem with nesh.thumbnail

2007-10-04 Thread jake elliott

hi divan,

Divan Roulant wrote:
> "'myproject.thumbnail' is not a valid tag library: Could not load
> template library from django.templatetags.apparto.thumbnail, No module
> named myproject.thumbnail"

here's the change that's tripping you up:
http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Templatetagloadingrespectsdottednotation

that page is an invaluable reference when living on the trunk!

best
jake

--~--~-~--~~~---~--~~
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: No tests for newforms

2007-10-04 Thread Malcolm Tredinnick

On Thu, 2007-10-04 at 17:33 +0200, Thomas Güttler wrote:
> Hi,
> 
> I was told to include a test in my newforms patch:
> 
> http://code.djangoproject.com/ticket/5335
> 
> I couldn't find any tests for newforms. Am I blind?

They are in tests/regressiontests/forms/. 

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: Random objects in view

2007-10-04 Thread RajeshD

Hi Alessandro,

Replace: items.filter(provincia__iexact=provincia)  with
items = items.filter(provincia__iexact=provincia)

Similarly, replace items.filter(tipo__iexact=tipo) with
items = items.filter(tipo__iexact=tipo)

Remember that whenever you filter an existing queryset in order to
progressively develop a query, you get a new queryset. So, you need to
assign it back to a variable otherwise it's lost in the ether :)

-Rajesh


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



ANN: A Django template tag for integrating a Flash based flv player

2007-10-04 Thread peschler

I'm happy to announce the release of my Django template tag for
integrating a Flash based flv player into Django templates.

The application including documentation and sourcecode can be found
at:
http://pyjax.net/blog/1/2007/09/28/django-template-tag-integrating-flash-based-flv-pl/

The application uses the Flash-based JW FLV Player by Jeroen Wijering
(http://www.jeroenwijering.com/?item=Flash_video_Player).

Feedback and bug reports are welcome.

Cheers,
Peter


--~--~-~--~~~---~--~~
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 scale

2007-10-04 Thread James Bennett

On 10/4/07, Andrey Khavryuchenko <[EMAIL PROTECTED]> wrote:
>  JB> You mean no projects using MySQL Replication,
>
> Did I?  I think I've said exactly opposite.

You jumped from "MySQL Replication won't work" to "no big projects
will use Django". Big projects already are using Django, therefore the
only think could argue for is "no projects using MySQL Replication
will use Django".

> Perhaps.  The company I've had in mind is not my company, instead it is a
> leading search engine player in other country.

I wouldn't write a search engine using Django or any web framework, personally.

> I am interested in technical discussion, and not "you shouldn't use this
> (mysql replication), you should use that (mysql clustering)" - I know at
> least two people that are interested specifically in using mysql
> replication in django projects.

And I'm simply saying that MySQL's default position on scaling is
"rewrite your application when you need to do this". My comments on
that come not from a personal "I think X sucks" standpoint, but from a
professional "this pretty much embodies worst practices" standpoint.
You should not have to mingle the details of how many DB servers you
have into your application layer, and you shouldn't have to rewrite
your application when you hit N > 1.

-- 
"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
-~--~~~~--~~--~--~---



newform-Question

2007-10-04 Thread Andreas Madsack

Hello django-users,

I am experimenting a bit with the newforms library.

My problem is, that I use a Foreign-Key in a Table and want to view
(and edit) only one entry of this Table.

The request.POST gives no user-value and the form is not valid,
because of this missing value.
How can I add the foreignkey (user-id) to the form? Using a hidden-field? How?

Thanks for your help.


The Modell:

class UserProfile(models.Model):
GENDER_CHOICES = (
('M', 'Male'),
('F', 'Female'),
)

gender = models.CharField(max_length=1, choices=GENDER_CHOICES, blank=True)
user = models.ForeignKey(User, unique=True, verbose_name=_('user'))
birthday = models.DateField(null=True, blank=True)


The View:

def edit_profile(request, uid=None):
if uid:
auth_user = User.object.get(username=uid)
elif request.user:
auth_user = request.user
# TODO else missing!!

user_id = auth_user.id

if request.method == 'POST':
UserForm = forms.form_for_model(UserProfile)
form = UserForm(request.POST)
if form.is_valid():
form.save()
# Do form processing here...
return HttpResponseRedirect('/')
else:
UserObject = get_object_or_404(UserProfile, user=user_id)
UserForm = forms.form_for_instance(UserObject,
fields=('gender', 'birthday'))
form = UserForm()
return render_to_response('edit.html', {'form': form})




-- 
Andreas Madsack

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



No tests for newforms

2007-10-04 Thread Thomas Güttler

Hi,

I was told to include a test in my newforms patch:

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

I couldn't find any tests for newforms. Am I blind?

 Thomas

-- 
Thomas Güttler, http://www.tbz-pariv.de/ 
Bernsdorfer Str. 210-212, 09126 Chemnitz, Tel.: 0371/5347-917
TBZ-PARIV GmbH  Geschäftsführer: Dr. Reiner Wohlgemuth
Sitz der Gesellschaft: Chemnitz Registergericht: Chemnitz HRB 8543

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



Plz, I am just new to Python...

2007-10-04 Thread Emperor of thought

Please i am just new to python and i will like to know how i can go
about in web development. I am migrating from PHP and phyton web
environment does not look very familiar.
I tried downloading Django and installing it on my windows looks very
difficult. Plsease can anyone help me on how to install Django and how
to go about starting web development in Phyton?


--~--~-~--~~~---~--~~
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: Updating multiple records from one HTML form

2007-10-04 Thread Marty Alchin

On 10/4/07, Marty Alchin <[EMAIL PROTECTED]> wrote:
> It's using the save() method from AddressForm, which only knows about
> its own fields.

You should also verify that is_valid() is in fact checking all the
fields as well. I suspect that, like save(), it's only looking at the
AddressForm fields. Fixing it would be similar to save(), just add
another method, like so:

def is_valid(self):
return AddressForm.is_valid(self) and CountryForm.is_valid(self)

-Gul

--~--~-~--~~~---~--~~
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: Updating multiple records from one HTML form

2007-10-04 Thread Marty Alchin

On 10/4/07, James Mulholland <[EMAIL PROTECTED]> wrote:
> The form is rendered OK, and any changes to the 'Address' record are
> saved. Changes to the 'Country' record aren't, however, and I wondered
> if there's a way to do this. Any help much appreciated :)

It's using the save() method from AddressForm, which only knows about
its own fields. Try adding this method to your FullForm class and see
if it helps. The rest of your code should be able to remain intact.

class FullForm(forms.Form, AddressForm, CountryForm):
def save(self):
AddressForm.save(self)
CountryForm.save(self)

I make no guarantees, but it should get you on the right track.

-Gul

--~--~-~--~~~---~--~~
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 database setup problem

2007-10-04 Thread swati

Thanks Joe, I recompiled the python with zlib support and tried to
install mysqldb, now I am not getting the error of zlib anymore. But
got error with gcc compiler. Part of the error is something like,-


_mysql.c:2475: warning: passing argument 1 of âstrlenâ from
incompatible pointer type
_mysql.c:2475: error: invalid operands to binary -
_mysql.c:2475: warning: comparison between pointer and integer
_mysql.c:2475: warning: passing argument 2 of â__builtin_strcmpâ from
incompatible pointer type
_mysql.c:2475: error: invalid operands to binary -
_mysql.c:2475: warning: comparison between pointer and integer
_mysql.c:2475: warning: passing argument 2 of â__builtin_strcmpâ from
incompatible pointer type
_mysql.c:2475: error: invalid operands to binary -
_mysql.c:2475: warning: comparison between pointer and integer
_mysql.c:2475: warning: passing argument 1 of âstrlenâ from
incompatible pointer type
_mysql.c:2475: warning: passing argument 2 of â__builtin_strcmpâ from
incompatible pointer type
_mysql.c:2475: error: invalid operands to binary -
_mysql.c:2475: error: invalid operands to binary -
_mysql.c:2475: warning: statement with no effect
_mysql.c:2475: error: invalid operands to binary -
_mysql.c:2475: warning: statement with no effect
_mysql.c:2475: error: invalid operands to binary -
_mysql.c:2475: warning: statement with no effect
_mysql.c:2475: warning: passing argument 2 of â__builtin_strcmpâ from
incompatible pointer type
_mysql.c:2476: warning: passing argument 1 of âPyMember_GetOneâ from
incompatible pointer type
_mysql.c:2478: warning: passing argument 2 of âPyErr_SetStringâ from
incompatible pointer type
_mysql.c: At top level:
_mysql.c:2486: error: syntax error before â*â token
_mysql.c:2489: warning: function declaration isnât a prototype
_mysql.c: In function â_mysql_ConnectionObject_setattrâ:
_mysql.c:2490: error: âvâ undeclared (first use in this function)
_mysql.c:2501: error: ânameâ undeclared (first use in this function)
_mysql.c:2501: warning: passing argument 1 of âstrlenâ from
incompatible pointer type
_mysql.c:2501: error: invalid operands to binary -
_mysql.c:2501: warning: comparison between pointer and integer
_mysql.c:2501: warning: passing argument 2 of â__builtin_strcmpâ from
incompatible pointer type
_mysql.c:2501: error: invalid operands to binary -
_mysql.c:2501: warning: comparison between pointer and integer
_mysql.c:2501: warning: passing argument 2 of â__builtin_strcmpâ from
incompatible pointer type
_mysql.c:2501: error: invalid operands to binary -
_mysql.c:2501: warning: comparison between pointer and integer
_mysql.c:2501: warning: passing argument 1 of âstrlenâ from
incompatible pointer type
_mysql.c:2501: warning: passing argument 2 of â__builtin_strcmpâ from
incompatible pointer type
_mysql.c:2501: error: invalid operands to binary -
_mysql.c:2501: error: invalid operands to binary -
_mysql.c:2501: warning: statement with no effect
_mysql.c:2501: error: invalid operands to binary -
_mysql.c:2501: warning: statement with no effect
_mysql.c:2501: error: invalid operands to binary -
_mysql.c:2501: warning: statement with no effect
_mysql.c:2501: warning: passing argument 2 of â__builtin_strcmpâ from
incompatible pointer type
_mysql.c:2502: error: âselfâ undeclared (first use in this function)
_mysql.c:2502: warning: passing argument 1 of âPyMember_SetOneâ from
incompatible pointer type
_mysql.c:2502: warning: passing argument 3 of âPyMember_SetOneâ from
incompatible pointer type
_mysql.c:2504: warning: passing argument 2 of âPyErr_SetStringâ from
incompatible pointer type
_mysql.c: At top level:
_mysql.c:2511: error: syntax error before â*â token
_mysql.c:2514: warning: function declaration isnât a prototype
_mysql.c: In function â_mysql_ResultObject_setattrâ:
_mysql.c:2515: error: âvâ undeclared (first use in this function)
_mysql.c:2526: error: ânameâ undeclared (first use in this function)
_mysql.c:2526: warning: passing argument 1 of âstrlenâ from
incompatible pointer type
_mysql.c:2526: error: invalid operands to binary -
_mysql.c:2526: warning: comparison between pointer and integer
_mysql.c:2526: warning: passing argument 2 of â__builtin_strcmpâ from
incompatible pointer type
_mysql.c:2526: error: invalid operands to binary -
_mysql.c:2526: warning: comparison between pointer and integer
_mysql.c:2526: warning: passing argument 2 of â__builtin_strcmpâ from
incompatible pointer type
_mysql.c:2526: error: invalid operands to binary -
_mysql.c:2526: warning: comparison between pointer and integer
_mysql.c:2526: warning: passing argument 1 of âstrlenâ from
incompatible pointer type
_mysql.c:2526: warning: passing argument 2 of â__builtin_strcmpâ from
incompatible pointer type
_mysql.c:2526: error: invalid operands to binary -
_mysql.c:2526: error: invalid operands to binary -
_mysql.c:2526: warning: state

Re: Updating multiple records from one HTML form

2007-10-04 Thread James Mulholland

Thanks for the help :) Seems like a very sound approach, not least
because I understand it!

--
James

On Oct 4, 3:53 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Thu, 2007-10-04 at 07:37 -0700, James Mulholland wrote:
> > Hi,
>
> > [Note: apologies for the double post. Google didn't offer to preview
> > the message, which is what I was trying to do...]
>
> > I'm starting to investigate newforms in detail (having previously used
> > the old forms library) since I have a job to convert an Access DB to
> > web format. The client wants to maintain a similar layout to what they
> > have in Access, which in places means having one page which has
> > several records on it. To test out some ideas, I've made a simple app
> > which attempts to edit two database records from the same web page.
>
> > models.py
>
> > class Country(models.Model):
> > name = models.CharField(maxlength=100)
> > iso  = models.CharField(maxlength=2)
>
> > class Address(models.Model):
> > address_1 = models.CharField(maxlength=60)
> > address_2 = models.CharField(maxlength=60, null=True, blank=True)
> > town  = models.CharField(maxlength=30)
> > county= models.CharField(maxlength=40)
> > country   = models.ForeignKey(Country)
>
> > views.py
>
> > def edit_address(request, id=None):
> > address = Address.objects.get(pk=id)
> > country = address.country
>
> > AddressForm = form_for_instance(address, fields=('address_1',
> > 'address_2', 'town', 'county'))
> > CountryForm = form_for_instance(country, fields=('iso', 'name'))
>
> > class FullForm(forms.Form, AddressForm, CountryForm):
> > pass
>
> This is the problem line. You are hoping for behaviour from multiple
> inheritance works in Python that isn't valid. Firstly, there would be
> some problems here because the save() method will only call the save()
> method on one of the subclasses, not all of them. Probably other
> unintended side-effects as well.
>
> Instead of trying to create a mega-form like this, just work with the
> two forms independently. You can initialise a form using a data
> dictionary (request.POST in this case) that contains more information
> than is required for the form. The form class will only use the fields
> it requires.
>
> So after creating AddressForm and CountryForm, the continue with:
>
> address_form = AddressForm(request.POST)
> country_from = CountryForm(request.POST)
>
> and so forth. You can happily pass both forms to the template for
> rendering and everything like that.
>
> Alternatively, if you truly do want only a single form class, you can
> write your own variation on form_for_instance that takes multiple
> instances from different classes and does whatever you expect. I would
> expect that just using two form classes will generally lead to more
> readable code, though, unless you are doing this a lot with lots of
> classes on a page (in which case I'd write the helper function).
>
> 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: Updating multiple records from one HTML form

2007-10-04 Thread Malcolm Tredinnick

On Thu, 2007-10-04 at 07:37 -0700, James Mulholland wrote:
> Hi,
> 
> [Note: apologies for the double post. Google didn't offer to preview
> the message, which is what I was trying to do...]
> 
> I'm starting to investigate newforms in detail (having previously used
> the old forms library) since I have a job to convert an Access DB to
> web format. The client wants to maintain a similar layout to what they
> have in Access, which in places means having one page which has
> several records on it. To test out some ideas, I've made a simple app
> which attempts to edit two database records from the same web page.
> 
> models.py
> 
> class Country(models.Model):
> name = models.CharField(maxlength=100)
> iso  = models.CharField(maxlength=2)
> 
> class Address(models.Model):
> address_1 = models.CharField(maxlength=60)
> address_2 = models.CharField(maxlength=60, null=True, blank=True)
> town  = models.CharField(maxlength=30)
> county= models.CharField(maxlength=40)
> country   = models.ForeignKey(Country)
> 
> 
> views.py
> 
> def edit_address(request, id=None):
> address = Address.objects.get(pk=id)
> country = address.country
> 
> AddressForm = form_for_instance(address, fields=('address_1',
> 'address_2', 'town', 'county'))
> CountryForm = form_for_instance(country, fields=('iso', 'name'))
> 
> class FullForm(forms.Form, AddressForm, CountryForm):
> pass

This is the problem line. You are hoping for behaviour from multiple
inheritance works in Python that isn't valid. Firstly, there would be
some problems here because the save() method will only call the save()
method on one of the subclasses, not all of them. Probably other
unintended side-effects as well.

Instead of trying to create a mega-form like this, just work with the
two forms independently. You can initialise a form using a data
dictionary (request.POST in this case) that contains more information
than is required for the form. The form class will only use the fields
it requires.

So after creating AddressForm and CountryForm, the continue with:

address_form = AddressForm(request.POST)
country_from = CountryForm(request.POST)

and so forth. You can happily pass both forms to the template for
rendering and everything like that.

Alternatively, if you truly do want only a single form class, you can
write your own variation on form_for_instance that takes multiple
instances from different classes and does whatever you expect. I would
expect that just using two form classes will generally lead to more
readable code, though, unless you are doing this a lot with lots of
classes on a page (in which case I'd write the helper function).

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



Updating multiple records from one HTML form

2007-10-04 Thread James Mulholland

Hi,

[Note: apologies for the double post. Google didn't offer to preview
the message, which is what I was trying to do...]

I'm starting to investigate newforms in detail (having previously used
the old forms library) since I have a job to convert an Access DB to
web format. The client wants to maintain a similar layout to what they
have in Access, which in places means having one page which has
several records on it. To test out some ideas, I've made a simple app
which attempts to edit two database records from the same web page.

models.py

class Country(models.Model):
name = models.CharField(maxlength=100)
iso  = models.CharField(maxlength=2)

class Address(models.Model):
address_1 = models.CharField(maxlength=60)
address_2 = models.CharField(maxlength=60, null=True, blank=True)
town  = models.CharField(maxlength=30)
county= models.CharField(maxlength=40)
country   = models.ForeignKey(Country)


views.py

def edit_address(request, id=None):
address = Address.objects.get(pk=id)
country = address.country

AddressForm = form_for_instance(address, fields=('address_1',
'address_2', 'town', 'county'))
CountryForm = form_for_instance(country, fields=('iso', 'name'))

class FullForm(forms.Form, AddressForm, CountryForm):
pass

if request.method == 'POST':
form = FullForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('/address/edit/' + str(id) +
'/')
else:
form = FullForm()

return render_to_response('address/edit.html', locals())

The form is rendered OK, and any changes to the 'Address' record are
saved. Changes to the 'Country' record aren't, however, and I wondered
if there's a way to do this. Any help much appreciated :)

--
James


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



Updating multiple records from one HTML form

2007-10-04 Thread James Mulholland

Hi,

I'm starting to investigate newforms in detail (having previously used
the old forms library) since I have a job to convert an Access DB to
web format. The client wants to maintain a similar layout to what they
have in Access, which in places means having one page which has
several records on it. To test out some ideas, I've made a simple app
which attempts to edit two database records from the same web page.

models.py

class Country(models.Model):
name = models.CharField(maxlength=100)
iso  = models.CharField(maxlength=2)


--~--~-~--~~~---~--~~
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: Random objects in view

2007-10-04 Thread Alessandro Ronchi

2007/10/2, Tomas Kopecek <[EMAIL PROTECTED]>:

> Maybe it is worth a ticket in trac.

I tried, but it says:
500 Internal Server Error (Submission rejected as potential spam
(Maximum number of posts per hour for this IP exceeded, Akismet says
content is spam))

(I didn't send any other post)

Your solution doesn't work for me because I need a queryset...

-- 
Alessandro Ronchi
Skype: aronchi
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: how to scale

2007-10-04 Thread Andrey Khavryuchenko

James,

 JB> On 10/3/07, Andrey Khavryuchenko <[EMAIL PROTECTED]> wrote:
 >> The only thing django app should know is that there are two different
 >> *kinds* of servers: read-only and whole access.  It doesn't matter how many
 >> servers you have - you may well have pool of masters and pool of slaves, it
 >> doesn't matter.

 JB> For *your* case. 

In my case I need no replication nor clustering: project is fairly small
now.  My blog post and question here where to that point just a mind
excercise.

 JB> But remember that Django is expected to be generic and broadly usable,
 JB> which means that actually the decorators would have to support, say,
 JB> people who are sharding and want to have this view write to that
 JB> shard, and that view read from another, etc., etc., which means that
 JB> your decorator scheme basically comes down, in the end, to hard-coding
 JB> database or cluster or shard names alongside each view.

Does django orm support sharding now?  No, as far as I know.  So let's
solve problems as they come.

 JB> And again, I'd argue that this isn't something the application layer
 JB> needs to know or should have to know.

 >> And, completely unrelated to above, some companies made *business* decision
 >> to use MySQL Replication widely.  So if django doesn't support it, no big
 >> projects using django.

 JB> You mean no projects using MySQL Replication, 

Did I?  I think I've said exactly opposite.

 JB> which is very, very, VERY far from "no big projects" -- there are
 JB> plenty of big projects using Django, they're just using smarter DB
 JB> setups. Personally, I think MySQL's standard attitude of "well, just
 JB> completely rewrite your application when you need more than one
 JB> database" is the thing that's not suitable for big projects (where you
 JB> need to be thinking about, and planning for, configurable scaling
 JB> across multiple machines from the very start, not pausing and
 JB> rewriting when it's necessary); anybody who paid a consultant to get
 JB> that recommendation should ask for their money back.

Perhaps.  The company I've had in mind is not my company, instead it is a
leading search engine player in other country.  

And I won't like to discuss *that* stuff further.  

I am interested in technical discussion, and not "you shouldn't use this
(mysql replication), you should use that (mysql clustering)" - I know at
least two people that are interested specifically in using mysql
replication in django projects.

-- 
Andrey V Khavryuchenko - http://a.khavr.com/
Django NewGate -  http://www.kds.com.ua/djiggit/
Chytach - http://www.chytach.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: how to scale

2007-10-04 Thread Andrey Khavryuchenko


 AA> Am 03.10.2007 um 12:36 schrieb Andrey Khavryuchenko:

 AA> It's possible to use circular replication together with some free  
 AA> load balancing software. 

As I've told earlier, I know perfectly about circular replication.

 AA> Then there's MySQL Proxy that allows you to manipulate queries on
 AA> their way to the server to implement load balancing and, in the near
 AA> future, connection pooling. With the embedded lua engine, it should be
 AA> even possible to do query redirection/filtering but I haven't
 AA> investigated it yet. So I think that in the middle/long term there's
 AA> no need to put more logic in this regard into Django.

Reread what you've wrote:  MySQL Proxy manipulates *queries*, not
transactions.

Imagine something like:

sql: BEGIN TRANSACTION;

sql: SELECT * FROM something WHERE id=198273;

py: if queryset.count()==0:
py:MyObject.objects.create(**data)

sql: END TRANSACTION;

MySQL proxy or any other query-level solution has no way to know that first
select should go to the master server, so it would be routed to a slave,
that, what a coinsidence, is a second behind the master and the master
*just* got that specific record.  Voila, duplicate records and you can't
reproduce it unless you already know the cause.

Transaction-level solution requires some effort from developer to tell
which transactions modify data and which don't - exactly the stuff I wrote
in the post [1].

Footnotes: 
[1]  http://a.khavr.com/2007/10/01/how-to-use-mysql-replication-in-django/

-- 
Andrey V Khavryuchenko - http://a.khavr.com/
Django NewGate -  http://www.kds.com.ua/djiggit/
Chytach - http://www.chytach.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 extra info to HttpResponseRedirect

2007-10-04 Thread Malcolm Tredinnick

On Thu, 2007-10-04 at 09:50 +, francois wrote:
> 
> 
> On 3 oct, 18:54, "James Bennett" <[EMAIL PROTECTED]> wrote:
> 
> > http://www.djangoproject.com/documentation/authentication/#messages
> >
> 
> Can I use messages with a  HttpResponseRedirect?

No. This corresponds to an HTTP 302 response and the browser will
re-request the new location specified in the Location head of the
response. The body of the response has no semantic meaning and is only
ever seen by the user in unusual circumstances.

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: What's going on with Row Level Permissions?

2007-10-04 Thread Malcolm Tredinnick

On Thu, 2007-10-04 at 12:45 +, RKnobelspies wrote:
> We are also working on projects that require some form of RLP-
> functionality but at the same time we need to work with the actual
> trunk-version of django to take advantage of the recent improvements
> with forms.
> 
> There was a conversation on the django-sprint IRC between Malcolm and
> a person, who offered to maintain the RLP-branch and keep it up-to-
> date with the trunk as he and his company is using it in a production
> environment anyways. It would certainly help to join forces and
> efforts to bring this branch to life again. Unfortunately i don´t
> remember his name and there doesn´t seem to be a log file either to
> look it up. Any idea?

I'm on the road for work at the moment and don't have access to the
right machine, but if you ping me after October 13, when I'm back home,
I'll be able to look at the logs on my desktop machine to at least find
the guy's name. Drop me a private mail around that time so I don't
forget.

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: QuerySet.extra() and bind variables

2007-10-04 Thread Malcolm Tredinnick

On Wed, 2007-10-03 at 22:44 +, tzeskimo wrote:
> I'm trying to write a custom QuerySet, but I'm a bit confused about
> how to properly use the method extra().  From my understanding,
> extra() accepts both "select" and "where" arguments, both of which can
> contain bind variables.  You then pass the appropriate bind variable
> values to the "param" argument.
> 
> This method seems like it will fall apart if two QuerySets are chained
> together, both of which pass "select" and "where" arguments to extra.
> For example, wouldn't the following cause an issue:
> 
> class FooQuerySet:
> 
> def query1(self):
> 
>  self.extra(select = {'something': "item * %s"}, where = "item
> < %s", params = (3, 5))
> 
> def query2(self):
> 
> self.extra(select = {'something_else': "item / %s"}, where =
> "item > %s", params = (3, 5))
> 
> model.custom_manager.all().query1().query2()

The "select" portion of extra() was never really intended to support
parameters. There are bigger problems than the one you've noticed here:
since "select" is a dictionary, it's ordering is indeterminate and so
when you have multiple items in the dictionary, there is no way to
reliably map the parameters to those items.

I've been toying with a couple of ideas in the context of the
queryset-refactor branch to possibly try and make this work (with a
little more effort on the side of the programmer), but it's never going
to be particularly neat and tidy.

For now, you can't do that. It's unsupported. You will need to write
custom SQL.

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: What's going on with Row Level Permissions?

2007-10-04 Thread RKnobelspies

We are also working on projects that require some form of RLP-
functionality but at the same time we need to work with the actual
trunk-version of django to take advantage of the recent improvements
with forms.

There was a conversation on the django-sprint IRC between Malcolm and
a person, who offered to maintain the RLP-branch and keep it up-to-
date with the trunk as he and his company is using it in a production
environment anyways. It would certainly help to join forces and
efforts to bring this branch to life again. Unfortunately i don´t
remember his name and there doesn´t seem to be a log file either to
look it up. Any idea?


--~--~-~--~~~---~--~~
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: Mac OS X 10.4 + Python 2.4.3 + Django + Apache2 + mod_python

2007-10-04 Thread Graham Dumpleton

On Oct 4, 6:35 pm, dstuart <[EMAIL PROTECTED]> wrote:
> Just a quick note to say mod_wsgi does support Apache 2 from the site:
>
> "The mod_wsgi package can be compiled for and used with either Apache
> 1.3, 2.0 or 2.2 on UNIX systems (including Linux), as well as Windows.
> Either the single threaded 'prefork' or multithreaded 'worker' Apache
> MPMs can be used when running on UNIX.
>
> Daemon mode of mod_wsgi will however only be available on Apache 2.0
> or 2.2 running on UNIX, and only when the Apache runtime library
> underlying Apache has been compiled with support for threading.
>
> Python 2.3 or later is required and Python must have been compiled
> with support for threading. "

FWIW, the reason I suggested that OP not use mod_python is because
when they first came to me it was about getting mod_python 2.7.11
working on MacOS X with Apache 1.3. To do this requires various
patches to be made to mod_python source code otherwise it will crash
when used. Thus the advice was based on them using Apache 1.3. It
looks like that they later decided to upgrade to Apache 2.X after I
had talked to them. Using mod_wsgi as I suggested was a way around the
need to patch old mod_python to get it working on MacOS X/Apache 1.3,
with mod_wsgi working on all major versions of Apache and Mac OS X as
is. So, bit of context was missing in the original post.

Graham


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



Check it out:Very good online resources,tons of cool men and beautiful women eager for lovers....:

2007-10-04 Thread jack

Check it out:Very good online resources,tons of cool men and beautiful
women eager for lovers:

1.Buy tickets online:
http://groups.google.com/group/all-good-things/web/want-to-buy-tickets-online-come-here

2.No 1 social network:
http://groups.google.com/group/all-good-things/web/1-social-network

3.Very good online resources:
http://groups.google.com/group/all-good-things/web/very-useful-websites

4.cool men and beautiful women eager for lovers
http://groups.google.com/group/all-good-things/web/tons-of-men-and-women-are-looking-lovers

5.Best affiliate programs:
http://www.apsense.com/abc/ymapsense/business.html


--~--~-~--~~~---~--~~
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: overriding FileField.save() to do something with the file

2007-10-04 Thread Marty Alchin

On 10/4/07, Simone Cittadini <[EMAIL PROTECTED]> wrote:
> How I get the name/path oh the "just saved" file so I can process it ?

http://www.djangoproject.com/documentation/db-api/#get-foo-filename

-Gul

--~--~-~--~~~---~--~~
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 extra info to HttpResponseRedirect

2007-10-04 Thread Samuel Adam

HttpResponseRedirect doesn't return a template so you just need to add
your message before the redirect:
request.user.message_set.create(message="Your playlist was added
successfully.")

You should implement the display of your messages on your base
template like this:
{% for message in messages %}{{ message }}{% endfor %}

This will display and remove the messages from the message queue.

The RequestContext is needed to make the "messages" variable
available.


There is another solution available here:
http://www.djangosnippets.org/snippets/319/

On Oct 4, 11:50 am, francois <[EMAIL PROTECTED]> wrote:
> On 3 oct, 18:54, "James Bennett" <[EMAIL PROTECTED]> wrote:
>
> >http://www.djangoproject.com/documentation/authentication/#messages
>
> Can I use messages with a  HttpResponseRedirect?
>
> In the example given I need to give the context_instance but how to do
> that with HttpResponseRedirect (which doesn't take any other argument
> that the url) ?
>
> """
> request.user.message_set.create(message="Your playlist was added
> successfully.")
> return render_to_response("playlists/create.html",
> context_instance=RequestContext(request))
> """
>
> francois


--~--~-~--~~~---~--~~
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: Custom validation for models in admin

2007-10-04 Thread jr

The following did it for me:

from django import newforms as forms
class yourForm(forms.BaseForm):
...
   def clean(self):
   "do your custom validation here"
   return self.cleaned_data

does it for me.
Clean is called automatically e.g. by ...is_valid().

hope it helps.
jr

On Sep 11, 10:19 pm, Mike H <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I have a model which needs some non-standard checks before it gets saved.
> The class looks like this :
>
> class Page(models.Model):
> name = models.CharField(maxlength=30)
> content = models.TextField()
> start_date = models.DateField()
> end_date = models.DateField()
>
> When I save the model, I want to check that there is no other page with
> the same name that has an overlapping start and end date, and cause some
> kind of validation error that the admin area will display.
>
> I have tried the following :
>
> def save(self):
> # check for the overlap happens here
> 
> # if the check fails...
> raise validators.ValidationError(_("A page with this name
> already exists in the time period specified"))
>
> However, the admin area does not catch the exception. I've looked
> through the djangobook which references a chapter that isn't there yet,
> and the online documentation points to a .validate() on the model which
> is marked as experimental. If it's possible, where can I put custom
> validation like that, that the admin area will pick up on? I'm currently
> using 0.96 but could easily upgrade to the svn trunk if needed.
>
> Thanks for any help,
>
> Mike


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



overriding FileField.save() to do something with the file

2007-10-04 Thread Simone Cittadini

I have such a Model :

class FileToProcess(models.Model):
file = models.FileField(upload_to='somewhere')
   
def save(self):
super(FileToProcess, self).save()
f = open([???], 'r')
for line in f.read():
  


How I get the name/path oh the "just saved" file so I can process it ?

--~--~-~--~~~---~--~~
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 extra info to HttpResponseRedirect

2007-10-04 Thread francois



On 3 oct, 18:54, "James Bennett" <[EMAIL PROTECTED]> wrote:

> http://www.djangoproject.com/documentation/authentication/#messages
>

Can I use messages with a  HttpResponseRedirect?

In the example given I need to give the context_instance but how to do
that with HttpResponseRedirect (which doesn't take any other argument
that the url) ?

"""
request.user.message_set.create(message="Your playlist was added
successfully.")
return render_to_response("playlists/create.html",
context_instance=RequestContext(request))
"""

francois


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



Problem with nesh.thumbnail

2007-10-04 Thread Divan Roulant

Hello,

recently, I upgraded to the last development version of Django from a
version dating back to around last June (I can't remember the exact
version). Since then, I can't get thumbnails and I keep getting the
message:

"'myproject.thumbnail' is not a valid tag library: Could not load
template library from django.templatetags.apparto.thumbnail, No module
named myproject.thumbnail"

I tried specifying the nesh package everywhere: in PATH, PYTHONPATH,
in a .pth file. I also tried every combination of installed apps in
settings (moving the files accordingly): nesh, nesh.thumbnail,
myproject.nesh.thumbnail, myproject.thumbnail, etc.

Is someone aware of a recent change in Django that would have modified
the use of the nesh package?

Thanks!!!

Divan


--~--~-~--~~~---~--~~
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: Mac OS X 10.4 + Python 2.4.3 + Django + Apache2 + mod_python

2007-10-04 Thread dstuart

Just a quick note to say mod_wsgi does support Apache 2 from the site:

"The mod_wsgi package can be compiled for and used with either Apache
1.3, 2.0 or 2.2 on UNIX systems (including Linux), as well as Windows.
Either the single threaded 'prefork' or multithreaded 'worker' Apache
MPMs can be used when running on UNIX.

Daemon mode of mod_wsgi will however only be available on Apache 2.0
or 2.2 running on UNIX, and only when the Apache runtime library
underlying Apache has been compiled with support for threading.

Python 2.3 or later is required and Python must have been compiled
with support for threading. "


--~--~-~--~~~---~--~~
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: Pyexcelerator VLOOKUP can't parse formula

2007-10-04 Thread pbzRPA

Found a solution for my problem. There is a patch that you can
download so that you can reference other worksheets.

https://sourceforge.net/tracker/index.php?func=detail&aid=1687510&group_id=134081&atid=730645

Hope it helps.

PB


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