Re: problem with sorl-thumbnail invalid image

2009-03-22 Thread Nate Reed
No, I didn't create the image.  I'm guessing you chose the "Interlaced"
option, or that "Adobe Photoshop PNG" is an interlaced PNG format.  I'm not
that familiar with Photoshop.

On Sun, Mar 22, 2009 at 4:22 PM, DLitgo  wrote:

>
> Nate,
>
> I had a similar problem to this, I'm not sure if its the exact same
> issue, but by any chance did you use Photoshop to create/save the
> image as png? I noticed that by default Photoshop saves the image as
> an "Adobe Photoshop PNG File" as opposed to "Portable Networks Graphic
> Image" file. There's apparently some difference between the two.
> Anyways making sure my image wasn't an *Adobe PNG fixed the problem
> with me.
>
> On Mar 21, 11:18 pm, Nate Reed  wrote:
> > As a workaround I used Gimp to convert this image to a compatible format
> > before uploading it.  Hopefully my users won't mind this limitation.  It
> > does seem a rather glaring omission from PIL, though, doesn't it?
> >
> > Nate
> >
> > On Sat, Mar 21, 2009 at 5:38 PM, Malcolm Tredinnick <
> >
> > malc...@pointy-stick.com> wrote:
> >
> > > On Sat, 2009-03-21 at 17:33 -0700, Nate Reed wrote:
> > > [...]
> > > > Is there some way I can work with interlaced PNG's in PIL?
> >
> > > Typing "PIL interlaced PNG" into Google suggests not. That's one of
> > > those problems that will be fixed by somebody with sufficient
> motivation
> > > to write a patch for PIL, I suspect.
> >
> > > 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Model Relationship Causing Error

2009-03-22 Thread Malcolm Tredinnick

On Sun, 2009-03-22 at 22:17 -0700, Super McFly wrote:
[...]
> Of course I was just doing something silly. I was using
> 'myproject.media.models.Image' when I only needed 'media.Image'. It's
> still not clear to me why this format is used but it works.

That's what this bit of the documentation means:

"To refer to models defined in another application, you must
instead explicitly specify the application label."

Django refers to a lot of model information using
. format, which looks a bit confusing if you're
not paying attention, because it looks like a Python import path. Not
the decision I would have made, but it's not too hard to get used to and
it's too late to change now. One of those things that are clearer with
hindsight.

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



Re: Model Relationship Causing Error

2009-03-22 Thread Super McFly

> The solutions isn't too hard, though. Use the "string format" for
> referencing from, say, Image -> Container. 
> Seehttp://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkeyfor
> documentation about this.

Thank you for replying. I tried that method before but I received an
error saying it " has either not been installed or is abstract".

Of course I was just doing something silly. I was using
'myproject.media.models.Image' when I only needed 'media.Image'. It's
still not clear to me why this format is used but it works.

I actually ran into this problem sometime last year and it caused me
to give up. But now I'm back, and hopefully I'll be the one giving
advice next time.

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



Re: If less than in template language

2009-03-22 Thread Alex Gaynor
On Sun, Mar 22, 2009 at 10:01 PM, Robert  wrote:

>
> Looks great!
> Stupid question... it's been a while since i've worked in django.
> Where's a good place to physically store that document on the server?
> sorry!
>
> On Mar 22, 8:16 pm, Alex Gaynor  wrote:
> > On Sun, Mar 22, 2009 at 8:15 PM, Robert  wrote:
> >
> > > Hey,
> > > I'm trying to make a template that only reveals the first four items
> > > of a list, and then handles the rest of the list in a different
> > > respect, ie:
> >
> > > for item in list
> > > if forloop.counter < 3 {
> > > do something
> > > } else {
> > > do something else
> > > }
> >
> > > but I can't come up with an eloquent way to do this in the django
> > > template language. My ideas so far are as follows:
> > > 1. sending two lists from the view file (a bad idea because this has
> > > to be repeated for five different lists)
> > > 2. doing an
> > > {% ifequal __ %}
> >
> > > {% endifequal %}
> >
> > > {% ifequal __something else %}
> >
> > > {% endifequal %}
> >
> > > and so on, also not a terrific idea because it would mean having
> > > like... 20 decision structures, and whatnot.
> >
> > > Any ideas are greatly appreciated!
> > > Thanks
> > > -Robert
> >
> > Check out james bennet's template-utils libarary which contains an {%
> > iflessthan %} template tag.
> >
> > Alex
> >
> > --
> > "I disapprove of what you say, but I will defend to the death your right
> to
> > say it." --Voltaire
> > "The people's good is the highest law."--Cicero
> >
>
Django applications are normal python modules, so anywhere on your
PythonPath(it's an enviromental variable).  Personally I keep a django_apps
directory that's all symlinked into my site-packages directory.

Alex

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

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



Re: If less than in template language

2009-03-22 Thread Robert

Looks great!
Stupid question... it's been a while since i've worked in django.
Where's a good place to physically store that document on the server?
sorry!

On Mar 22, 8:16 pm, Alex Gaynor  wrote:
> On Sun, Mar 22, 2009 at 8:15 PM, Robert  wrote:
>
> > Hey,
> > I'm trying to make a template that only reveals the first four items
> > of a list, and then handles the rest of the list in a different
> > respect, ie:
>
> > for item in list
> > if forloop.counter < 3 {
> > do something
> > } else {
> > do something else
> > }
>
> > but I can't come up with an eloquent way to do this in the django
> > template language. My ideas so far are as follows:
> > 1. sending two lists from the view file (a bad idea because this has
> > to be repeated for five different lists)
> > 2. doing an
> > {% ifequal __ %}
>
> > {% endifequal %}
>
> > {% ifequal __something else %}
>
> > {% endifequal %}
>
> > and so on, also not a terrific idea because it would mean having
> > like... 20 decision structures, and whatnot.
>
> > Any ideas are greatly appreciated!
> > Thanks
> > -Robert
>
> Check out james bennet's template-utils libarary which contains an {%
> iflessthan %} template tag.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: If less than in template language

2009-03-22 Thread Alex Gaynor
On Sun, Mar 22, 2009 at 8:15 PM, Robert  wrote:

>
> Hey,
> I'm trying to make a template that only reveals the first four items
> of a list, and then handles the rest of the list in a different
> respect, ie:
>
> for item in list
> if forloop.counter < 3 {
> do something
> } else {
> do something else
> }
>
> but I can't come up with an eloquent way to do this in the django
> template language. My ideas so far are as follows:
> 1. sending two lists from the view file (a bad idea because this has
> to be repeated for five different lists)
> 2. doing an
> {% ifequal __ %}
>
> {% endifequal %}
>
> {% ifequal __something else %}
>
> {% endifequal %}
>
> and so on, also not a terrific idea because it would mean having
> like... 20 decision structures, and whatnot.
>
> Any ideas are greatly appreciated!
> Thanks
> -Robert
>
>
> >
>
Check out james bennet's template-utils libarary which contains an {%
iflessthan %} template tag.

Alex

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

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



Re: Creating bound form and sending it to the page without validation

2009-03-22 Thread Malcolm Tredinnick

On Mon, 2009-03-23 at 00:59 +0100, Marek Wawrzyczek wrote:
> Hi
> 
> Is there any possibility, to create an bound instance of a form (even if 
> it contains fields with incorrect data) and then resend the form to the 
> page without validating ?
> 

Almost certainly yes, since there's nothing to stop you overriding any
methods you like in your Form subclass and if a user submits invalid
data it's already sent back to the web page (so Django already does
something like that). However, what's the problem you're really trying
to solve here? There might be a better approach that requires less
hacking at the internals.

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



If less than in template language

2009-03-22 Thread Robert

Hey,
I'm trying to make a template that only reveals the first four items
of a list, and then handles the rest of the list in a different
respect, ie:

for item in list
if forloop.counter < 3 {
do something
} else {
do something else
}

but I can't come up with an eloquent way to do this in the django
template language. My ideas so far are as follows:
1. sending two lists from the view file (a bad idea because this has
to be repeated for five different lists)
2. doing an
{% ifequal __ %}

{% endifequal %}

{% ifequal __something else %}

{% endifequal %}

and so on, also not a terrific idea because it would mean having
like... 20 decision structures, and whatnot.

Any ideas are greatly appreciated!
Thanks
-Robert


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



Creating bound form and sending it to the page without validation

2009-03-22 Thread Marek Wawrzyczek

Hi

Is there any possibility, to create an bound instance of a form (even if 
it contains fields with incorrect data) and then resend the form to the 
page without validating ?

Regards,
Marek

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



Re: i18n escape-able quote marks

2009-03-22 Thread Malcolm Tredinnick

On Sun, 2009-03-22 at 21:38 +, John Handelaar wrote:
> Hello
> 
> So if my translation string in a template currently looks like this:
> 
>   A book called "Gulliver's Travels"
> 
> ...how do I convert that into something starting with "{% trans"   ?

You would mark the whole string for translation and, in the course of
translating it, the translators would replace "..." with «...» or „...“
or whatever. It's generally ill-advised (and very fragile) to mark only
a portion of a sentence for translation, since context is lost: for
example telling the initial and trailing quotes apart in this case.
Also, as word order varies between languages, translators have to have
the freedom to rearrange things at least at the sentence level (at the
paragraph level or greater when translating documentation).

If that doesn't answer your question, could you explain a bit more what
the problem is?

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



Re: Model Relationship Causing Error

2009-03-22 Thread Malcolm Tredinnick

On Sun, 2009-03-22 at 14:37 -0700, Super McFly wrote:
> This is a bit of a tricky one but I need help solving the following
> error:
> 
> ImportError: cannot import name Container
> 
> I'm sure it has something to do with the unusual relationships I have
> between two models. I'll put a simplified version below.

You've got a circlar import going on. The containers/models.py file
needs to import the "Image" name from media/models.py, but in the course
of importing that latter file, it needs to import the "Container" name
from containers/models.py. However, containers/models.py hasn't been
imported properly yet by this point, so hilarity results.

The solutions isn't too hard, though. Use the "string format" for
referencing from, say, Image -> Container. See
http://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkey for
documentation about this.

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



Re: Howto create related objects in one shot?

2009-03-22 Thread Malcolm Tredinnick

On Sun, 2009-03-22 at 05:39 -0700, nivhab wrote:
> Hi,
> 
> I have the following model:
> 
>class product(models.Model):
>   productId   = models.AutoField(primary_key=True)
>   name= models.CharField(max_length=200, unique=True)
>   description  = models.CharField(max_length=200, blank=True)
> 
>   class Wishlist(models.Model):
>   wishId = models.AutoField(primary_key=True)
>   product   = models.ForeignKey(Product)
>   for_user  = models.ForeignKey(User)
>   notes  = models.CharField(max_length=200, blank=True)
> 
> I would like to create one form that lets the user (unknowingly) to
> create new product and a wish list related to this product in one
> request. The form needs to contain fields for both models.
> 
> I have some very ugly method for doing it but there has to be a
> cleaner way. I simply couldn't find any in the docs or examples.

You're probably over-thinking this.

You want a form with some fields in it. When the form is submitted, your
view takes the cleaned data from the form, uses that to determine the
appropriates values to use to create each model instance and then saves
the models.

So create a normal Form subclass (that's documented in the forms
documentation), then use the cleaned data (forms documentation) to
create model instances (model documentation or the tutorial) and save
those.

When you forms don't map directly onto models, then that's fine. That's
why the form module is separate from the model module in Django, so that
you're not required to only create forms based on models.

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



Re: django ORM not compatible with postgres

2009-03-22 Thread Mike Ramirez
On Sunday 22 March 2009 03:59:10 pm Joshua Partogi wrote:
> On Mar 23, 6:56 am, Mike Ramirez  wrote:
> > I think what you want to do with this style is:
> >
> >         obj.user = User.objects.get(username=request.user.username)
> >
> > > or maybe just
> > >
> > > obj.user = request.user
>
> Hi Mike. Thank you very much.
> This syntax works with psycopg2. I wonder why the previous ones that I
> posted works with MySQL.
>

I really can't say.  Maybe one of the contributors can enlighten us on this. 

But as a general rule of thumb, I try to be exact (even to the point of adding 
__exact) in these situations, just so I don't have to worry. 

> Thank you very much anyhow. Really appreciate it.
>

you're welcome.

Mike



-- 
Politics is the ability to foretell what is going to happen tomorrow, next
week, next month and next year.  And to have the ability afterwards to
explain why it didn't happen.
-- Winston Churchill


signature.asc
Description: This is a digitally signed message part.


Re: problem with sorl-thumbnail invalid image

2009-03-22 Thread DLitgo

Nate,

I had a similar problem to this, I'm not sure if its the exact same
issue, but by any chance did you use Photoshop to create/save the
image as png? I noticed that by default Photoshop saves the image as
an "Adobe Photoshop PNG File" as opposed to "Portable Networks Graphic
Image" file. There's apparently some difference between the two.
Anyways making sure my image wasn't an *Adobe PNG fixed the problem
with me.

On Mar 21, 11:18 pm, Nate Reed  wrote:
> As a workaround I used Gimp to convert this image to a compatible format
> before uploading it.  Hopefully my users won't mind this limitation.  It
> does seem a rather glaring omission from PIL, though, doesn't it?
>
> Nate
>
> On Sat, Mar 21, 2009 at 5:38 PM, Malcolm Tredinnick <
>
> malc...@pointy-stick.com> wrote:
>
> > On Sat, 2009-03-21 at 17:33 -0700, Nate Reed wrote:
> > [...]
> > > Is there some way I can work with interlaced PNG's in PIL?
>
> > Typing "PIL interlaced PNG" into Google suggests not. That's one of
> > those problems that will be fixed by somebody with sufficient motivation
> > to write a patch for PIL, I suspect.
>
> > 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django ORM not compatible with postgres

2009-03-22 Thread Mike Ramirez
On Sunday 22 March 2009 03:33:41 pm Brian Neal wrote:
> On Mar 22, 2:56 pm, Mike Ramirez  wrote:
> > On Sunday 22 March 2009 09:25:42 am Brian Neal wrote:
> > > But from what you posted, I'm guessing that line needs to read:
> > >
> > > obj.user = User.objects.get(username=request.user)
> >
> > I think what you want to do with this style is:
> >
> >         obj.user = User.objects.get(username=request.user.username)
>
> Yes, my mistake, thanks.
>
> > > or maybe just
> > >
> > > obj.user = request.user
> >
> > yeah, I think this is best.
>
> Agreed.
>
> >Tho if you're the type that sanitizes everything,
> > the upper one is better.
>
> I don't think so. request.user gets set by Django based on cookies, so
> it should be trustworthy as request.user.username.

Agreed, I just meant getting a new/recent user object to work with, which does 
depend on how intricate your system is and if you're updating things based 
off signals that affect what you're doing. example: Other user makes a change 
somewhere, this change, makes updates across multiple tables and you just 
want to be sure that this is the most recent version.

Mike

-- 
This is a good time to punt work.


signature.asc
Description: This is a digitally signed message part.


Re: django ORM not compatible with postgres

2009-03-22 Thread Joshua Partogi



On Mar 23, 6:56 am, Mike Ramirez  wrote:
> I think what you want to do with this style is:
>
>         obj.user = User.objects.get(username=request.user.username)
>
> > or maybe just
>
> > obj.user = request.user

Hi Mike. Thank you very much.
This syntax works with psycopg2. I wonder why the previous ones that I
posted works with MySQL.

Thank you very much anyhow. Really appreciate 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django ORM not compatible with postgres

2009-03-22 Thread Brian Neal

On Mar 22, 2:56 pm, Mike Ramirez  wrote:
> On Sunday 22 March 2009 09:25:42 am Brian Neal wrote:
>
>
> > But from what you posted, I'm guessing that line needs to read:
>
> > obj.user = User.objects.get(username=request.user)
>
> I think what you want to do with this style is:
>
>         obj.user = User.objects.get(username=request.user.username)

Yes, my mistake, thanks.

>
> > or maybe just
>
> > obj.user = request.user
>
> yeah, I think this is best.

Agreed.

>Tho if you're the type that sanitizes everything,
> the upper one is better.

I don't think so. request.user gets set by Django based on cookies, so
it should be trustworthy as request.user.username.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Read-only in admin

2009-03-22 Thread legutierr

Thanks for the reply, Karen.

Yeah, I posted this before seeing that the feature list for 1.1
included read-only fields.  It was my mistake to only search through
the newsgroup and neglect searching the wiki before posting this (you
can never be too thorough, I guess).  It's just that so much of what I
have read in the newsgroup has been negative towards read-only
functionality in admin (meaning, it seems that people asking for it
have been getting shut down).  I was surprised it made it into the
"maybe" list at all (although very happy).  Thank you for your
advocacy.

I actually tried to update the 1.1 feature list page in the wiki last
night but I must have forgotten to press submit because the update
didn't take.  I just now updated the feature list page again so it
points to ticket #342, which discusses this feature (people have been
asking for it for a long time).

Nonetheless, part of the idea behind this thread was also to see who
might be interested in aiding with any implementation that could be
done, or at least in giving some ideas of how it should ideally work.
Maybe if people wanted to post their ideas here, that might make
sense, I don't know.

In terms of assigning an implementer and fleshing out a design/
implementation proposal, I would be happy to tackle that over the next
couple of weeks for consideration after you all finish the 1.1 roll-
out.  I'll open up a wiki page and get started, if that makes sense,
and then wait for you and everyone else to provide feeback on the
matter once 1.1 has gone out the door.  I would then be very happy to
do the coding.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Model Relationship Causing Error

2009-03-22 Thread Super McFly

This is a bit of a tricky one but I need help solving the following
error:

ImportError: cannot import name Container

I'm sure it has something to do with the unusual relationships I have
between two models. I'll put a simplified version below.

It started when I added the 'image' field to the container model.

*** media/models.py ***

from django.db import models, transaction, IntegrityError
from django.contrib.auth.models import User
from myproject.containers.models import Container
import tempfile

class Image(models.Model):
title = models.CharField('title', max_length=255)
image = models.ImageField(upload_to='uploads/images')
caption = models.TextField(blank=True)
profiles = models.ManyToManyField(Container, limit_choices_to =
{'container_type__url': 'profiles'}, related_name='image_profiles',
blank=True)

*** end ***

*** containers/models.py ***

from django.db import models
from django.contrib.auth.models import User
from myproject.media.models import Image

class Container(models.Model):
title = models.CharField(max_length=255)
url = models.CharField(max_length=64)
image = models.ForeignKey(Image, blank=True, null=True,
related_name='profile_image')
description = models.CharField(max_length=255, blank=True)
user = models.ForeignKey(User, null=True, blank=True)

*** end ***

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



i18n escape-able quote marks

2009-03-22 Thread John Handelaar

Hello

So if my translation string in a template currently looks like this:

  A book called "Gulliver's Travels"

...how do I convert that into something starting with "{% trans"   ?


jh

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



Re: Contact Enquiry model expecting identity value

2009-03-22 Thread grimmus

Sorry, i am a bit of a beginner at Django and Python.

I am following the contact form tutorial from chapter 7 of the new
book and instead of emailing the form contents i want to save it to a
database.

I referenced the model part from the main Django tutorial on the
website.

Ill have a look into ModelForm, i havent heard of it before

Thanks

On Mar 22, 8:59 pm, Alex Gaynor  wrote:
> On Sun, Mar 22, 2009 at 3:57 PM, grimmus  wrote:
>
> > I am creating an instance of the model in a view like so:
>
> > form = ContactForm(request.POST)
> >        if form.is_valid():
> >            cd = form.cleaned_data
>
> >            c = ContactEnquiry(cd['name'],cd['subject'],cd['email'],cd
> > ['message'],datetime.datetime.now())
> >            c.save()
>
> >            return HttpResponseRedirect('/contact/thanks/')
>
> > if i enter an integer before cd['name'] the instance gets saved in the
> > database but this integer should be an identity/autonumber value.
>
> > On Mar 22, 8:06 pm, Alex Gaynor  wrote:
> > > On Sun, Mar 22, 2009 at 3:00 PM, grimmus 
> > wrote:
>
> > > > Hi,
>
> > > > I have a class like so
>
> > > > class ContactEnquiry(models.Model):
> > > >    name = models.CharField(max_length=100)
> > > >    subject = models.CharField(max_length=100)
> > > >    email = models.EmailField()
> > > >    message = models.CharField(max_length=100)
> > > >    enquiry_date = models.DateTimeField('enquiry date')
> > > >    def __unicode__(self):
> > > >        return self.name
>
> > > > when i make an instance of this class it throws the error :
>
> > > > invalid literal for int() with base 10: 'name value'
>
> > > > when i pass an int as the first parameter it works fine but i thought
> > > > an autonumber would be passed as the id value ?
>
> > > > Thanks for any help
>
> > > How are you creating an instance of the model, can you paste the code you
> > > are running and the full traceback.
>
> > > Alex
>
> > > --
> > > "I disapprove of what you say, but I will defend to the death your right
> > to
> > > say it." --Voltaire
> > > "The people's good is the highest law."--Cicero
>
> You're passing the name as the first param, which is by default the primary
> key.  You can avoid that by passing everything as kwargs.
>
> Is there any reason you aren't using a ModelForm though?
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: cannot import name ugettext

2009-03-22 Thread Karen Tracey
On Sun, Mar 22, 2009 at 2:53 PM, dbbarua  wrote:

>
> Hi Karen,
>  I am sorry if my messages seem confusing to you , it is
> to me too...
> I changes Django to 1.0 and i get the following errors related to core
> like you said should not happen
>
> r...@portable:/usr/local/rapidsmsdev/rapidsms/rapidsms# python
> manage.py runserver 127.0.0.1:8000
> Validating models...
> [snip]

File "/usr/lib/python2.5/site-packages/rapidsms/balert/models.py",
> line 9, in 
>class Recipient(models.Model):
>  File "/usr/lib/python2.5/site-packages/rapidsms/balert/models.py",
> line 11, in Recipient
>phone_number = models.CharField('phone number', maxlength=15,
> core=True)
> TypeError: __init__() got an unexpected keyword argument 'core'
>
>
> Does this mean that the svn version of the app is not compatible with
> Django-1.0 ? and maybe i should try older versions of the app?


It means you are not running the svn version of rapidsms, at least, not the
one I found online at sourceforge.  You can see that models.py here:

http://svn.mepemepe.com/rapidsms/trunk/balert/models.py

and the phone_number field in the Recipient model does not have core=True
specified.  Further, the one I'm pointing to uses max_length (compatible
with Django 1.0) while the version you are running uses maxlength
(compatible with an older Django).

You need to update your rapidsms code, I believe.

Karen

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



Re: Contact Enquiry model expecting identity value

2009-03-22 Thread Alex Gaynor
On Sun, Mar 22, 2009 at 3:57 PM, grimmus  wrote:

>
> I am creating an instance of the model in a view like so:
>
> form = ContactForm(request.POST)
>if form.is_valid():
>cd = form.cleaned_data
>
>c = ContactEnquiry(cd['name'],cd['subject'],cd['email'],cd
> ['message'],datetime.datetime.now())
>c.save()
>
>return HttpResponseRedirect('/contact/thanks/')
>
> if i enter an integer before cd['name'] the instance gets saved in the
> database but this integer should be an identity/autonumber value.
>
> On Mar 22, 8:06 pm, Alex Gaynor  wrote:
> > On Sun, Mar 22, 2009 at 3:00 PM, grimmus 
> wrote:
> >
> > > Hi,
> >
> > > I have a class like so
> >
> > > class ContactEnquiry(models.Model):
> > >name = models.CharField(max_length=100)
> > >subject = models.CharField(max_length=100)
> > >email = models.EmailField()
> > >message = models.CharField(max_length=100)
> > >enquiry_date = models.DateTimeField('enquiry date')
> > >def __unicode__(self):
> > >return self.name
> >
> > > when i make an instance of this class it throws the error :
> >
> > > invalid literal for int() with base 10: 'name value'
> >
> > > when i pass an int as the first parameter it works fine but i thought
> > > an autonumber would be passed as the id value ?
> >
> > > Thanks for any help
> >
> > How are you creating an instance of the model, can you paste the code you
> > are running and the full traceback.
> >
> > Alex
> >
> > --
> > "I disapprove of what you say, but I will defend to the death your right
> to
> > say it." --Voltaire
> > "The people's good is the highest law."--Cicero
> >
>
You're passing the name as the first param, which is by default the primary
key.  You can avoid that by passing everything as kwargs.

Is there any reason you aren't using a ModelForm though?

Alex

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

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



Re: Contact Enquiry model expecting identity value

2009-03-22 Thread grimmus

I am creating an instance of the model in a view like so:

form = ContactForm(request.POST)
if form.is_valid():
cd = form.cleaned_data

c = ContactEnquiry(cd['name'],cd['subject'],cd['email'],cd
['message'],datetime.datetime.now())
c.save()

return HttpResponseRedirect('/contact/thanks/')

if i enter an integer before cd['name'] the instance gets saved in the
database but this integer should be an identity/autonumber value.

On Mar 22, 8:06 pm, Alex Gaynor  wrote:
> On Sun, Mar 22, 2009 at 3:00 PM, grimmus  wrote:
>
> > Hi,
>
> > I have a class like so
>
> > class ContactEnquiry(models.Model):
> >    name = models.CharField(max_length=100)
> >    subject = models.CharField(max_length=100)
> >    email = models.EmailField()
> >    message = models.CharField(max_length=100)
> >    enquiry_date = models.DateTimeField('enquiry date')
> >    def __unicode__(self):
> >        return self.name
>
> > when i make an instance of this class it throws the error :
>
> > invalid literal for int() with base 10: 'name value'
>
> > when i pass an int as the first parameter it works fine but i thought
> > an autonumber would be passed as the id value ?
>
> > Thanks for any help
>
> How are you creating an instance of the model, can you paste the code you
> are running and the full traceback.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django ORM not compatible with postgres

2009-03-22 Thread Mike Ramirez
On Sunday 22 March 2009 09:25:42 am Brian Neal wrote:
> On Mar 22, 8:15 am, Joshua Partogi  wrote:
> > Dear all,
> >
> > I just encounter this error using pyscopg2 as my db adapter
> > Exception Type:         ProgrammingError
> > Exception Value:        can't adapt
> > Exception Location:
> >         /usr/lib/python2.5/site-packages/django/db/backends/util.py in
> > execute, line 19
> >
> > The query that I'm trying to run from admin is as such:
> >     def save_model(self, request, obj, form, change):
> >         user = User.objects.get(username=request.user)
> >
> > Does anybody know how I can run this with psycopg? What's wrong with
> > these statements? What did I miss here?
>
> It would help if you posted your model.
>
> But from what you posted, I'm guessing that line needs to read:
>
> obj.user = User.objects.get(username=request.user)
>

I think what you want to do with this style is:

obj.user = User.objects.get(username=request.user.username)

 

> or maybe just
>
> obj.user = request.user
>

yeah, I think this is best. Tho if you're the type that sanitizes everything, 
the upper one is better.

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

Mike

-- 
Didn't I buy a 1951 Packard from you last March in Cairo?


signature.asc
Description: This is a digitally signed message part.


Re: Contact Enquiry model expecting identity value

2009-03-22 Thread Alex Gaynor
On Sun, Mar 22, 2009 at 3:00 PM, grimmus  wrote:

>
> Hi,
>
> I have a class like so
>
> class ContactEnquiry(models.Model):
>name = models.CharField(max_length=100)
>subject = models.CharField(max_length=100)
>email = models.EmailField()
>message = models.CharField(max_length=100)
>enquiry_date = models.DateTimeField('enquiry date')
>def __unicode__(self):
>return self.name
>
> when i make an instance of this class it throws the error :
>
> invalid literal for int() with base 10: 'name value'
>
> when i pass an int as the first parameter it works fine but i thought
> an autonumber would be passed as the id value ?
>
> Thanks for any help
>
> >
>
How are you creating an instance of the model, can you paste the code you
are running and the full traceback.

Alex

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

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



Contact Enquiry model expecting identity value

2009-03-22 Thread grimmus

Hi,

I have a class like so

class ContactEnquiry(models.Model):
name = models.CharField(max_length=100)
subject = models.CharField(max_length=100)
email = models.EmailField()
message = models.CharField(max_length=100)
enquiry_date = models.DateTimeField('enquiry date')
def __unicode__(self):
return self.name

when i make an instance of this class it throws the error :

invalid literal for int() with base 10: 'name value'

when i pass an int as the first parameter it works fine but i thought
an autonumber would be passed as the id value ?

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



Re: cannot import name ugettext

2009-03-22 Thread dbbarua

Hi Karen,
  I am sorry if my messages seem confusing to you , it is
to me too...
I changes Django to 1.0 and i get the following errors related to core
like you said should not happen

r...@portable:/usr/local/rapidsmsdev/rapidsms/rapidsms# python
manage.py runserver 127.0.0.1:8000
Validating models...
Unhandled exception in thread started by 
Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/django/core/management/
commands/runserver.py", line 48, in inner_run
self.validate(display_num_errors=True)
  File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 122, in validate
num_errors = get_validation_errors(s, app)
  File "/usr/lib/python2.5/site-packages/django/core/management/
validation.py", line 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 128, in get_app_errors
self._populate()
  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 57, in _populate
self.load_app(app_name, True)
  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 72, in load_app
mod = __import__(app_name, {}, {}, ['models'])
  File "/usr/lib/python2.5/site-packages/rapidsms/balert/models.py",
line 9, in 
class Recipient(models.Model):
  File "/usr/lib/python2.5/site-packages/rapidsms/balert/models.py",
line 11, in Recipient
phone_number = models.CharField('phone number', maxlength=15,
core=True)
TypeError: __init__() got an unexpected keyword argument 'core'


Does this mean that the svn version of the app is not compatible with
Django-1.0 ? and maybe i should try older versions of the app?

Regards
Deepak

On Mar 22, 10:32 pm, Karen Tracey  wrote:
> 2009/3/22 dbbarua 
>
>
>
> > Hi Karen,
> >             I am using the svn code for rapidsms and i have tried the
> > official recommended version Django 1.0 and rapidsms from svn...
>
> If you were using the svn code for rapidsms then I do not understand how you
> hit the previous error you reported.  The svn code for rapidsms does not
> have core=True anywhere in its models.py file.  (For reference I am looking
> here:http://svn.mepemepe.com/rapidsms/trunk/balert/models.py)  So, did you
> change the level of rapidsms you are using since your first problem?  If not
> then I'm very confused by what you have reported.
>
>
>
> > Yes i downgraded to 0.96.3 from 1.0 ...now it compiles fine but  when
> > i try to access the server gives me this output..
>
> > Switch to copy-and-paste view
>
> Next time you post a traceback please do use this link to switch to the
> copy-and-paste view and post that version.  The non-copy-and-paste version
> is nearly impossible to follow when pasted into an email.
>
> Do i have to upgrade to Django 1.0 again...?
>
> You need to be using compatible versions of the app and Django.  If you are
> using the svn version of rapidsms then I'd guess you need Django 1.0 to go
> with it, since it looks to me like the app has been changed in svn at least
> to run on Django 1.0, but the doc for that app should really be what
> specifies what level of Django you need for it.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Additional Javascript include in ModelAdmin

2009-03-22 Thread Daniel Roseman

On Mar 22, 4:15 pm, Roy  wrote:
> That would require the extra files be hosted on my media url though. I
> want to be able to link js externally so I can use stuff like YUI,
> etc. without having to host it.

Not at all - if you pass in an absolute path, it is left alone. See:
http://docs.djangoproject.com/en/dev/topics/forms/media/#paths-in-media-definitions

> Also, is it possible to do it without registering a new Admin class?
> I'm not sure if it's possible to just override a template somewhere.

I don't know what you mean by a 'new' admin class. You can just put
this option in the existing admin class for your model.
But yes, you can override the change_form.html template for your model
and put the 

Re: urlize

2009-03-22 Thread Alex Gaynor
On Sun, Mar 22, 2009 at 1:37 PM, nwalt...@sprynet.com
wrote:

>
> Can you point me to an example of how to write my own template
> filter?
> Where would I find the code for the existing urlize filter?  I'm new
> to Django - and don't know all the class structures yet.
>
> In my case, I want to add the phrase "target='_blank'" to the
> urlizetrunc filter.
> This isn't already available and I'm missing it?
>
> Thanks,
> Neal Walters
>
> >
>
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/  The urlize
filter can be found at django/templates/defaultfilters.py .  This is not
already available, although you could just apply the filter as usual and
then have a second filter that just altered the  tags.

Alex

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

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



GAE - facilityAddress = db.PostalAddressProperty(required=True)

2009-03-22 Thread nwalt...@sprynet.com

Using GoogleAppEngine:

I have a field defined in my model:
facilityAddress = db.PostalAddressProperty(required=True)

How should this be treated on a Django form?  It currently seems to
behave just like any other db.StringProperty.  I can enter "abc" for
the value, click the save button, and no errors or complaints about
the field.


Here are my related imports just to clarify:

from google.appengine.api import users
from google.appengine.ext import db
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
from google.appengine.ext.db import djangoforms
#from django import newforms as forms

import django
from django import http
from django import shortcuts
from django import newforms as forms

Thanks,
Neal Walters


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



Re: urlize

2009-03-22 Thread nwalt...@sprynet.com

Can you point me to an example of how to write my own template
filter?
Where would I find the code for the existing urlize filter?  I'm new
to Django - and don't know all the class structures yet.

In my case, I want to add the phrase "target='_blank'" to the
urlizetrunc filter.
This isn't already available and I'm missing it?

Thanks,
Neal Walters

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



Re: cannot import name ugettext

2009-03-22 Thread Karen Tracey
2009/3/22 dbbarua 

>
> Hi Karen,
> I am using the svn code for rapidsms and i have tried the
> official recommended version Django 1.0 and rapidsms from svn...
>

If you were using the svn code for rapidsms then I do not understand how you
hit the previous error you reported.  The svn code for rapidsms does not
have core=True anywhere in its models.py file.  (For reference I am looking
here: http://svn.mepemepe.com/rapidsms/trunk/balert/models.py)  So, did you
change the level of rapidsms you are using since your first problem?  If not
then I'm very confused by what you have reported.


>
> Yes i downgraded to 0.96.3 from 1.0 ...now it compiles fine but  when
> i try to access the server gives me this output..
>

> Switch to copy-and-paste view


Next time you post a traceback please do use this link to switch to the
copy-and-paste view and post that version.  The non-copy-and-paste version
is nearly impossible to follow when pasted into an email.

Do i have to upgrade to Django 1.0 again...?


You need to be using compatible versions of the app and Django.  If you are
using the svn version of rapidsms then I'd guess you need Django 1.0 to go
with it, since it looks to me like the app has been changed in svn at least
to run on Django 1.0, but the doc for that app should really be what
specifies what level of Django you need for it.

Karen

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



Re: cannot import name ugettext

2009-03-22 Thread dbbarua


Hi Karen,
 I am using the svn code for rapidsms and i have tried the
official recommended version Django 1.0 and rapidsms from svn...

Yes i downgraded to 0.96.3 from 1.0 ...now it compiles fine but  when
i try to access the server gives me this output..

Switch to copy-and-paste view

* /usr/lib/python2.5/site-packages/django/core/handlers/base.py in
get_response
61. return response
62.
63. # Get urlconf from request object, if available. Otherwise
use default.
64. urlconf = getattr(request, "urlconf",
settings.ROOT_URLCONF)
65.
66. resolver = urlresolvers.RegexURLResolver(r'^/', urlconf)
67. try:
68. callback, callback_args, callback_kwargs = resolver.resolve
(request.path) ...
69.
70. # Apply view middleware
71. for middleware_method in self._view_middleware:
72. response = middleware_method(request, callback,
callback_args, callback_kwargs)
73. if response:
74. return response
  ▶ Local vars
  Variable  Value
  debug
  
  exceptions
  
  mail_admins
  
  middleware_method
  >
  request
  , POST:, COOKIES:{'sessionid': '60d043645fd584be1949c5bddc1933eb'}, META:
{'COLORTERM': 'gnome-terminal', 'CONTENT_LENGTH': '', 'CONTENT_TYPE':
'text/plain', 'DISPLAY': ':0.0', 'DJANGO_SETTINGS_MODULE':
'rapidsms.settings', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HISTCONTROL':
'ignoreboth', 'HOME': '/root', 'HTTP_ACCEPT': 'text/html,application/
xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_CHARSET':
'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_ACCEPT_ENCODING':
'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'en-us,en;q=0.5',
'HTTP_CONNECTION': 'keep-alive', 'HTTP_COOKIE':
'sessionid=60d043645fd584be1949c5bddc1933eb', 'HTTP_HOST':
'127.0.0.1:8000', 'HTTP_KEEP_ALIVE': '300', 'HTTP_USER_AGENT':
'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.5) Gecko/2008121621
Ubuntu/8.04 (hardy) Firefox/3.0.5', 'LANG': 'en_IN', 'LESSCLOSE': '/
usr/bin/lesspipe %s %s', 'LESSOPEN': '| /usr/bin/lesspipe %s',
'LOGNAME': 'root', 'LS_COLORS':
'no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.svgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.
7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:',
'MAIL': '/var/mail/root', 'OLDPWD': '/usr/local/rapidsmsdev/rapidsms/
rapidsms/balert', 'PATH': '/usr/local/sbin:/usr/local/bin:/usr/sbin:/
usr/bin:/sbin:/bin:/usr/games', 'PATH_INFO': '/', 'PWD': '/usr/local/
rapidsmsdev/rapidsms/rapidsms', 'QUERY_STRING': '', 'REMOTE_ADDR':
'127.0.0.1', 'REMOTE_HOST': '', 'REQUEST_METHOD': 'GET', 'RUN_MAIN':
'true', 'SCRIPT_NAME': '', 'SERVER_NAME': 'localhost', 'SERVER_PORT':
'8000', 'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SOFTWARE': 'WSGIServer/
0.1 Python/2.5.2', 'SHELL': '/bin/bash', 'SHLVL': '1', 'SUDO_COMMAND':
'/bin/su', 'SUDO_GID': '1000', 'SUDO_UID': '1000', 'SUDO_USER':
'portable', 'TERM': 'xterm', 'TZ': 'Asia/Kolkata', 'USER': 'root',
'USERNAME': 'root', 'XAUTHORITY': '/home/portable/.Xauthority', '_': '/
usr/bin/python', 'wsgi.errors': ', mode 'w' at
0xb7d1c0b0>, 'wsgi.file_wrapper': , 'wsgi.input':
, 'wsgi.multiprocess': False,
'wsgi.multithread': True, 'wsgi.run_once': False, 'wsgi.url_scheme':
'http', 'wsgi.version': (1, 0)}>
  resolver
  
  response
  None
  self
  
  settings
  
  urlconf
  'rapidsms.urls'
  urlresolvers
  
* /usr/lib/python2.5/site-packages/django/core/urlresolvers.py in
resolve
   155. def resolve(self, path):
   156. tried = []
   157. match = self.regex.search(path)
   158. if match:
   159. new_path = path[match.end():]
   160. for pattern in self.urlconf_module.urlpatterns:
   161. try:
   162. sub_match = pattern.resolve(new_path) ...
   163. except Resolver404, e:
   164. tried.extend([(pattern.regex.pattern + ' ' + t) for t in
e.args[0]['tried']])
   165. else:
   166. if sub_match:
   167. sub_match_dict = dict(self.default_kwargs, **sub_match[2])
   168. return sub_match[0], sub_match[1], 

Re: cannot import name ugettext

2009-03-22 Thread Karen Tracey
On Sun, Mar 22, 2009 at 5:33 AM, dbbarua  wrote:

>
> Hi Everybody,
>I have a problem viewing my rapidsms django
> application
>
> when i use my locally installed django app by typing in the browser
>
> http://127.0.0.1:8000
>
> I get this error
>
> ViewDoesNotExist at /
> Could not import rapidsms.balert.views. Error was: cannot import name
> ugettext
> Request Method: GET
> Request URL:http://127.0.0.1:8000/
> Exception Type: ViewDoesNotExist
> Exception Value:Could not import rapidsms.balert.views. Error was:
> cannot import name ugettext
> Exception Location: /usr/lib/python2.5/site-packages/django/core/
> urlresolvers.py in _get_callback, line 127
>
> How do i resolve this...?
>

In a previous thread you reported a problem with this app using a pre-1.0
model parameter (core), which you note you solved by downgrading to Django
0.93 -- I'm guessing you actually  meant 0.96.3, since I've never heard of a
Django 0.93.  This one you are reporting now looks like the app is expecting
a version of Django higher than 0.96, since I'm guessing it's attempting to
import ugettext from django.utils.translation, and ugettext wasn't added to
django.utils.translation until sometime after 0.96.

I think a better fix for your original problem would be to upgrade this
rapidsms app to a version that runs on Django 1.0.  What you've got now
apparently expects some (non-official-release) version of Django between
0.96 and 1.0.  I'm not familiar with this app, but browsing the subversion
repository on sourceforge for it shows that core=True is no longer present
in the models.py file, so I'd expect it has an official release that runs on
Django 1.0.

Karen

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



Re: iterating through form.fields

2009-03-22 Thread Karen Tracey
On Sun, Mar 22, 2009 at 5:09 AM, Yaniv Haber  wrote:

>
> Thanks. It works that way although the examples in the documentation
> also show iterating through form.visible_fields which result in
> nothing. This is where I came from. Any idea why that happens?
>

What version of Django are you using?  The doc notes that visible_fields and
hidden_fields are new in development, so they are only going to be available
if you are using a recent trunk checkout or the 1.1 alpha release.

Karen

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



Re: Additional Javascript include in ModelAdmin

2009-03-22 Thread Brian Neal

On Mar 22, 11:15 am, Roy  wrote:
> That would require the extra files be hosted on my media url though. I
> want to be able to link js externally so I can use stuff like YUI,
> etc. without having to host it.

No, not if you use a fully qualified string like "http://some-url-to-
my-media".
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django ORM not compatible with postgres

2009-03-22 Thread Brian Neal

On Mar 22, 8:15 am, Joshua Partogi  wrote:
> Dear all,
>
> I just encounter this error using pyscopg2 as my db adapter
> Exception Type:         ProgrammingError
> Exception Value:        can't adapt
> Exception Location:
>         /usr/lib/python2.5/site-packages/django/db/backends/util.py in
> execute, line 19
>
> The query that I'm trying to run from admin is as such:
>     def save_model(self, request, obj, form, change):
>         user = User.objects.get(username=request.user)
>
> Does anybody know how I can run this with psycopg? What's wrong with
> these statements? What did I miss here?

It would help if you posted your model.

But from what you posted, I'm guessing that line needs to read:

obj.user = User.objects.get(username=request.user)

or maybe just

obj.user = request.user

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



Re: Additional Javascript include in ModelAdmin

2009-03-22 Thread Roy

That would require the extra files be hosted on my media url though. I
want to be able to link js externally so I can use stuff like YUI,
etc. without having to host it.

Also, is it possible to do it without registering a new Admin class?
I'm not sure if it's possible to just override a template somewhere.

On Mar 22, 11:40 pm, Daniel Roseman 
wrote:
> On Mar 22, 3:04 pm, Roy  wrote:
>
> > Hi,
>
> > Is there a way to include additional JavaScript in the admin page for
> > a particular model? I don't want to touch the model code though.
>
> > The particular scenario is I want to change the flatpage edit screen
> > in the admin to use a rich-text editor (NicEdit) instead of the plain
> > memo box.
>
> > Thanks!
>
> http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-me...
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Read-only in admin

2009-03-22 Thread Karen Tracey
On Sun, Mar 22, 2009 at 3:16 AM, legutierr  wrote:

> [snip long list of why read only fields in the admin could be useful]



I ask that other Django users or potential users that have good
> reasons for needing a read-only option in the admin post their reasons
> here, so that at least it becomes apparent to the "powers that be"
> that there is a certain level of demand to allow the inclusion of this
> functionality into the trunk when it is contributed by volunteers.
> Note that I would be happy to contribute my free time to adding this
> functionality to admin, but only if there is a good chance that the
> functionality, properly implemented, could make it into trunk.


If you look at the list of "maybe" features for 1.1 here:

http://code.djangoproject.com/wiki/Version1.1Features

you will see that "Read-only form fields" is on the list as one of the admin
enhancements.  As final feature freeze and beta for 1.1 is tomorrow, this
one is not going to make it.  My name is on it as committer, but no
implementer nor even a specific ticket with a design proposal or patch was
ever identified.  During 1.1 feature discussion, I supported this idea
primarily because I've heard a lot of people asking for it, and I can see
reasonable uses for it.  However, I haven't needed it for my own work and I
have not had the free time as yet to come up with a design
proposal/implementation on my own.  So, primarily since there wasn't
anything concrete to work off of for this, it didn't get done by me for
1.1.

I don't believe we need a thread full of people saying "yes, I wan't this".
Acceptance of the general idea by the "powers that be" isn't what's missing
here, it's a concrete proposal of how to accomplish the goal.  That would be
something to discuss and get general agreement on, though right now is
probably a bad time for such a discussion as getting 1.1 out the door is
highest priority for the next several weeks.

Karen

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



Re: Additional Javascript include in ModelAdmin

2009-03-22 Thread Daniel Roseman

On Mar 22, 3:04 pm, Roy  wrote:
> Hi,
>
> Is there a way to include additional JavaScript in the admin page for
> a particular model? I don't want to touch the model code though.
>
> The particular scenario is I want to change the flatpage edit screen
> in the admin to use a rich-text editor (NicEdit) instead of the plain
> memo box.
>
> Thanks!

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



Additional Javascript include in ModelAdmin

2009-03-22 Thread Roy

Hi,

Is there a way to include additional JavaScript in the admin page for
a particular model? I don't want to touch the model code though.

The particular scenario is I want to change the flatpage edit screen
in the admin to use a rich-text editor (NicEdit) instead of the plain
memo box.

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



Re: (solved) - coercing to Unicode: need string or buffer, Decimal found

2009-03-22 Thread Timothy

Hi Folks,

the problem was

def __unicode__(self):
  return self.b

in model-definition

Sorry for annoyance

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



coercing to Unicode: need string or buffer, Decimal found

2009-03-22 Thread Timothy

Hi Folks,

create a model

a = models.DecimalField(max_digits=7, decimal_places=2, null=True)

Try do insert values in admin-form.

Get error message shown in Subject.

What happens here? And how to avoid/solve this problem?

DecimalField is premise for that field.

Thx for any help

Timothy


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



django ORM not compatible with postgres

2009-03-22 Thread Joshua Partogi

Dear all,


I just encounter this error using pyscopg2 as my db adapter
Exception Type: ProgrammingError
Exception Value:can't adapt
Exception Location:
/usr/lib/python2.5/site-packages/django/db/backends/util.py in
execute, line 19

The query that I'm trying to run from admin is as such:
def save_model(self, request, obj, form, change):
user = User.objects.get(username=request.user)

Does anybody know how I can run this with psycopg? What's wrong with
these statements? What did I miss here?

Thanks very much in advance

-- 
If you can't believe in God the chances are your God is too small.

Read my blog: http://joshuajava.wordpress.com/
Follow me on twitter: http://twitter.com/jpartogi

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



Howto create related objects in one shot?

2009-03-22 Thread nivhab

Hi,

I have the following model:

   class product(models.Model):
  productId = models.AutoField(primary_key=True)
  name  = models.CharField(max_length=200, unique=True)
  description  = models.CharField(max_length=200, blank=True)

  class Wishlist(models.Model):
  wishId = models.AutoField(primary_key=True)
  product   = models.ForeignKey(Product)
  for_user  = models.ForeignKey(User)
  notes  = models.CharField(max_length=200, blank=True)

I would like to create one form that lets the user (unknowingly) to
create new product and a wish list related to this product in one
request. The form needs to contain fields for both models.

I have some very ugly method for doing it but there has to be a
cleaner way. I simply couldn't find any in the docs or examples.

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



Re: internationalization django app

2009-03-22 Thread Akhmat Safrudin

Malcolm Tredinnick wrote:
> That same section of the documentation describes how to create new
> language files (scroll down a bit to where it talks about running
> django-admin.py makemessages) and has a link to the contributing
> documentation.
> 
> Regards,
> Malcolm

oh.. sorry i read it less carefully,
thank's for your help.

regard.

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



Re: Multiple ModelAdmins for a single Model

2009-03-22 Thread Dan Ward

Hi,

First of all thanks for the replies. I won't be able to try anything
until tomorrow, however it has given some food for thought.

Malcom, the three admin entries is what I'm looking for. Essentially,
I'm aiming to have the admin home page display the pages block as so:

Pages (admin group)
-- Rotation (rotation model)
-- Web Page (page model)
-- Video Page (page model)
-- Message Page (page model)

The rotation page really doesn't matter. I'll look in to improvements
at a later stage, however the focus is on having three separate admin
forms for a single model. Really, looking back on it, it would have
been better in multiple models, but that's besides the point, I don't
have the time to go back on what I've done there.

I hope this clears things up a bit.

On 21 Mar, 22:04, Malcolm Tredinnick  wrote:
> On Sat, 2009-03-21 at 18:01 -0400, Alex Gaynor wrote:
>
> [...]
>
> > In the development version there's actually a more clever solution to
> > this.  You can create pure python subclasses(proxy classes) that use
> > the same DB table and fields and everything, but have their own class.
> > So you could create the relevant proxy models, and register the
> > ModelAdmins for each one of these proxy models.
>
> Only if the original poster wants three separate admin entries on the
> index page. It depends on the requirements, which hopefully the original
> poster will explain.
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



cannot import name ugettext

2009-03-22 Thread dbbarua

Hi Everybody,
I have a problem viewing my rapidsms django
application

when i use my locally installed django app by typing in the browser

http://127.0.0.1:8000

I get this error

ViewDoesNotExist at /
Could not import rapidsms.balert.views. Error was: cannot import name
ugettext
Request Method: GET
Request URL:http://127.0.0.1:8000/
Exception Type: ViewDoesNotExist
Exception Value:Could not import rapidsms.balert.views. Error was:
cannot import name ugettext
Exception Location: /usr/lib/python2.5/site-packages/django/core/
urlresolvers.py in _get_callback, line 127

How do i resolve this...?

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



Re: iterating through form.fields

2009-03-22 Thread Yaniv Haber

Thanks. It works that way although the examples in the documentation
also show iterating through form.visible_fields which result in
nothing. This is where I came from. Any idea why that happens?


On Mar 22, 10:44 am, Daniel Roseman 
wrote:
> On Mar 22, 8:20 am, nivhab  wrote:
>
>
>
> > Hi,
>
> > I have this problem which is probably right in front of my eyes but I
> > just cannot get it. Maybe someone can point me in the right direction:
>
> > I am trying to iterate through form.fields in a template.
> > The form is rather simple:
>
> > class ProductForm(forms.Form):
> >     name = forms.CharField(max_length=200)
> >     description = forms.CharField(max_length=200)
> >     url = forms.URLField('Product URL Page', verify_exists=True,
> > required=False)
>
> > Iteration in template (standard):
>
> >     {% for field in form.fields %}
> >         
> >             {{ field.errors }}
> >             {{ field.label_tag }}: {{ field }}
> >         
> >     {% endfor %}
>
> > The result of this code is EMPTY text.
> > However, the following code which reference specific fields:
>
> >  {{ form.name.label_tag}}: {{ form.name }}
>
> > (and every other field I reference) renders the expected html without
> > any issue.
>
> > Any hints why this is happening?
>
> > Thanks, Yaniv
>
> Don't loop through form.fields - as the documentation shows, you
> should loop through 
> form.http://docs.djangoproject.com/en/dev/topics/forms/#looping-over-the-f...
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



[urls bug?] django calls several views at once.

2009-03-22 Thread igor.potapenko

Is it normal behavior?
In example below, I try to call myapp2.view.cat2_view through "/a/"
url-path. It's calling, however another views myapp1.view.cat1_viewis
also calling with it at same time.


F:\igor\apps\devel\django\temp>django-admin.py startproject myproj

F:\igor\apps\devel\django\temp>cd myproj

F:\igor\apps\devel\django\temp\myproj>python manage.py startapp myapp1

F:\igor\apps\devel\django\temp\myproj>python manage.py startapp myapp2

F:\igor\apps\devel\django\temp\myproj>python manage.py syncdb
Creating table auth_permission
Creating table auth_group
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table myapp1_cats

You just installed Django's auth system, which means you don't have
any superusers defined.
Would you like to create one now? (yes/no): yes
Username: igor
E-mail address: igor
Error: That e-mail address is invalid.
E-mail address: i...@prettysin.info
Password:
Password (again):
Superuser created successfully.
Installing index for auth.Permission model
Installing index for auth.Message model

#creating models & views, editing urls, settings.py.

F:\igor\apps\devel\django\temp\myproj>python manage.py runserver
Validating models...
0 errors found

Django version 1.0.2 final, using settings 'myproj.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.

[22/Mar/2009 09:02:14] "GET /a/ HTTP/1.1" 200 0
[]
[22/Mar/2009 09:02:15] "GET /a/ HTTP/1.1" 200 4
[, ]
[22/Mar/2009 09:02:16] "GET /a/ HTTP/1.1" 200 8
[, , ]
[22/Mar/2009 09:02:17] "GET /a/ HTTP/1.1" 200 12
[, , , ]
[22/Mar/2009 09:02:18] "GET /a/ HTTP/1.1" 200 16
[, , , , ]
[22/Mar/2009 09:02:18] "GET /a/ HTTP/1.1" 200 20
[, , , , ,
]


###   myapp1.models
from django.db import models

# Create your models here.

class Cats(models.Model):
name = models.CharField(max_length=255,blank=True)

def __unicode__(self):
return u'%s' % self.name



###myapp1.views
# Create your views here.
from myapp1.models  import Cats



def cat_view(request):
cat = Cats(name="123")
cat.save()

# This prints to console!
print Cats.objects.all()

assert False
return HttpResponse("%s" % cat.name)


#  myapp2.views
# Create your views here.

from myapp1.models import Cats
from django.http import HttpResponse

def cat2_view(request):
cats = Cats.objects.all()


res = ''
for cat in cats:
res = res + '%s ' % cat.name

   return HttpResponse(res)





   urls
from django.conf.urls.defaults import *

urlpatterns = patterns('',
(r'^a/', 'myapp2.views.cat2_view'),
(r'^', 'myapp1.views.cat_view'),
)



===

I replaced " (r'^a/', 'myapp2.views.cat2_view'), " on "(r'^',
'myapp2.views.cat2_view')," and this feature has gone away.
I guess, this  isn't normal behavior.
Sorry, if this theme is discussed before. I couldn't find 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: iterating through form.fields

2009-03-22 Thread Daniel Roseman

On Mar 22, 8:20 am, nivhab  wrote:
> Hi,
>
> I have this problem which is probably right in front of my eyes but I
> just cannot get it. Maybe someone can point me in the right direction:
>
> I am trying to iterate through form.fields in a template.
> The form is rather simple:
>
> class ProductForm(forms.Form):
>     name = forms.CharField(max_length=200)
>     description = forms.CharField(max_length=200)
>     url = forms.URLField('Product URL Page', verify_exists=True,
> required=False)
>
> Iteration in template (standard):
>
>     {% for field in form.fields %}
>         
>             {{ field.errors }}
>             {{ field.label_tag }}: {{ field }}
>         
>     {% endfor %}
>
> The result of this code is EMPTY text.
> However, the following code which reference specific fields:
>
>  {{ form.name.label_tag}}: {{ form.name }}
>
> (and every other field I reference) renders the expected html without
> any issue.
>
> Any hints why this is happening?
>
> Thanks, Yaniv

Don't loop through form.fields - as the documentation shows, you
should loop through form.
http://docs.djangoproject.com/en/dev/topics/forms/#looping-over-the-form-s-fields
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



iterating through form.fields

2009-03-22 Thread nivhab

Hi,

I have this problem which is probably right in front of my eyes but I
just cannot get it. Maybe someone can point me in the right direction:

I am trying to iterate through form.fields in a template.
The form is rather simple:

class ProductForm(forms.Form):
name = forms.CharField(max_length=200)
description = forms.CharField(max_length=200)
url = forms.URLField('Product URL Page', verify_exists=True,
required=False)

Iteration in template (standard):

{% for field in form.fields %}

{{ field.errors }}
{{ field.label_tag }}: {{ field }}

{% endfor %}

The result of this code is EMPTY text.
However, the following code which reference specific fields:

 {{ form.name.label_tag}}: {{ form.name }}

(and every other field I reference) renders the expected html without
any issue.

Any hints why this is happening?

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



Re: internationalization django app

2009-03-22 Thread Malcolm Tredinnick

On Sun, 2009-03-22 at 14:42 +0700, Akhmat Safrudin wrote:
> Malcolm Tredinnick wrote:
> > No. This is documented here:
> > http://docs.djangoproject.com/en/dev/topics/i18n/#id1
> > 
> > Regards,
> > Malcolm
> 
> oh... it's well documented, sorry i missed it.
> so, how to contribute translating django to other language?

That same section of the documentation describes how to create new
language files (scroll down a bit to where it talks about running
django-admin.py makemessages) and has a link to the contributing
documentation.

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



Re: internationalization django app

2009-03-22 Thread Akhmat Safrudin

Malcolm Tredinnick wrote:
> No. This is documented here:
> http://docs.djangoproject.com/en/dev/topics/i18n/#id1
> 
> Regards,
> Malcolm

oh... it's well documented, sorry i missed it.
so, how to contribute translating django to other language?

thank's

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



Re: Does cache timeout need to be set in two places?

2009-03-22 Thread Malcolm Tredinnick

On Sun, 2009-03-22 at 00:17 -0700, rihad wrote:
> From Django Book http://www.djangobook.com/en/2.0/chapter15/ :
> 
> > CACHE_BACKEND = "locmem:///?timeout=30_entries=400"
> 
> but, a bit later:
> 
> > Then, add the following required settings to your Django settings file:
> >* CACHE_MIDDLEWARE_SECONDS — The number of seconds each page should be 
> > cached.
> 
> 
> Why have two seemingly identical settings? Do I have to make sure
> they're equal? What if they aren't? Or is the timeout= the cached
> object lifetime per se, but CACHE_MIDDLEWARE_SECONDS is what is
> actually told to web caches? 

The CACHE_MIDDLEWARE_SECONDS is used to compute the HTTP cache header
times. The caching middleware that it refers to (in the name) is for
short-circuiting computation using HTTP-level caching headers. It uses
Django's low-level cache, but is not the same thing.

> Sorry I couldn't grasp the idea after
> rereading The Book.
> 
> 
> Another relevant q'n: can I configure the cache to expire at
> appropriate time intervals, without coding the logic? Say, there's an
> external event happening every 15 minutes that updates the original
> data Django processes; can Django be configured to give web clients
> the correct cache TTL? Example: the resource is regenerated externally
> at 11:00:00. At 11:00:01 a client accesses it and it should be given
> cache timeout up until 11:15:00, that is, 899 seconds. Client
> accessing at 11:00:02 should be given timeout 898 seconds, and so on.
> Then at 11:15:00 the resource is regenerated again and it comes full
> circle until 11:30:00 this time, and so on.

No, it doesn't work this way. If you want per-object cache times to be
set specifically, you should write your own view decorator or utility
function to do so.

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



Re: Installing Django for rapidsms

2009-03-22 Thread dbbarua

Hi James,Alex
 Thank you for your help , I downgraded Django to
0.93 and it works fine.

Regards
Deepak

On Mar 22, 12:13 am, Alex Gaynor  wrote:
> On Sat, Mar 21, 2009 at 3:07 PM, dbbarua  wrote:
>
> > Hi ,
> >    I am trying to use Django for rapidsms , i get the following error
> > when i run
> > r...@portable:/usr/local/rapidsms-dev/rapidsms/rapidsms# python
> > manage.py syncdb
>
> > raceback (most recent call last):
> >  File "manage.py", line 11, in 
> >    execute_manager(settings)
> >  File "/usr/lib/python2.5/site-packages/django/core/management/
> > __init__.py", line 348, in execute_manager
> >    utility.execute()
> >  File "/usr/lib/python2.5/site-packages/django/core/management/
> > __init__.py", line 293, in execute
> >    self.fetch_command(subcommand).run_from_argv(self.argv)
> >  File "/usr/lib/python2.5/site-packages/django/core/management/
> > base.py", line 195, in run_from_argv
> >    self.execute(*args, **options.__dict__)
> >  File "/usr/lib/python2.5/site-packages/django/core/management/
> > base.py", line 221, in execute
> >    self.validate()
> >  File "/usr/lib/python2.5/site-packages/django/core/management/
> > base.py", line 249, in validate
> >    num_errors = get_validation_errors(s, app)
> >  File "/usr/lib/python2.5/site-packages/django/core/management/
> > validation.py", line 28, in get_validation_errors
> >    for (app_name, error) in get_app_errors().items():
> >  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
> > line 131, in get_app_errors
> >    self._populate()
> >  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
> > line 58, in _populate
> >    self.load_app(app_name, True)
> >  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
> > line 74, in load_app
> >    models = import_module('.models', app_name)
> >  File "/usr/lib/python2.5/site-packages/django/utils/importlib.py",
> > line 35, in import_module
> >    __import__(name)
> >  File "/usr/lib/python2.5/site-packages/rapidsms/balert/models.py",
> > line 62, in 
> >    class SentSMS(models.Model, TimestampOrderable):
> >  File "/usr/lib/python2.5/site-packages/rapidsms/balert/models.py",
> > line 65, in SentSMS
> >    sender = models.ForeignKey(User, core=True)
> >  File "/usr/lib/python2.5/site-packages/django/db/models/fields/
> > related.py", line 664, in __init__
> >    Field.__init__(self, **kwargs)
> > TypeError: __init__() got an unexpected keyword argument 'core'
>
> > Is there some patch to solve this error?
>
> > Am i doing something wrong...?
>
> > Regards
> > Deepak
>
> Whatever piece of code you've written or are using is written for an older
> version of Django(pre-1.0) where core was a kwarg on model fields for use
> with the admin, this has been supplanted by the new modeladmin system.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Read-only in admin

2009-03-22 Thread legutierr

I am posting this in hopes of highlighting the need within the
community for a read-only permissions option in the admin.  Before
anyone accuses me of not reading prior articles or simply being a
troll, let me at least state the following:

- I am aware of the philosophy that says that my proprietary
application is where general, read-only users would view my data and
that the admin is only for a select group of trusted administrators.
This philosophy assumes that if an administrator is trusted enough to
see a certain set of data, then that administrator should be able to
edit it, too.  I'm sorry, but this only makes sense when you have a
small organization with a couple of administrators.  For larger
companies, the admin interface would be perfect if it only had read-
only permissions, but without them, extensive developer time must be
allocated to accommodate mixed-permission and shifting-permission
roles within the admin userbase.  Also, this philosophy ignores the
existence of applications like Satchmo, which depend heavily on the
admin interface for the core portion of their functionality.
- I am aware of the fact that admin was designed from the very
beginning to exclude read-only functionality, and that adding read-
only permissions would be a deviation from that philosophy.  To
counter this point of view I would point out that when Django was
first created, it used validators instead of clean methods, ascii
strings instead of unicode, a high-degree of coupling between models
and the admin configuration, and was closed-source instead of open-
source.  Most significantly, Django was first conceived as the
foundation for content-management systems in newsrooms, and is now
expected to function properly in any production environment and
functional domain.  In other words, things change, and they should.
- I am aware of databrowse.  It seems like an interesting option, but
there are several problems that I see with it.  First, it is currently
in development and therefore unstable, in its feature set at least if
not in its operation.  Second, it is a separate application, and would
not integrate tightly and easily into the admin system and its
permissions.  If two groups of users within a company have read-only
and edit access to two mutually exclusive sets of data (in other
words, one group edits the data the other group can only read, and
vice-versa), then those two groups would use those two apps in
completely different ways, and make training a nightmare.  Third, it
breaks DRY.  If databrowse is seen as a solution to the read-only
problem, it is because it is a work-around that allows read-only
browsing functionality into Django.contrib without violating the
philosophy against read-only in admin.  The most important philosophy
that Django has, however is not "no read-only in admin", but DO NOT
REPEAT YOURSELF, and that seems to be violated here.
- I know I can customize admin myself.  But do I really want to make
changes to code that would break with every upgrade or new release of
Django (the required changes are not superficial)?  And even if I did
customize admin, why should I duplicate functionality that many other
people within the Django community need?  And even if I did coordinate
with other Django users to pool our resources to implementing this
functionality, why should we do that if the core team is dead-set
against ever accepting that functionality into trunk?
- I am not a troll.  I am not complaining or trying to start a fight.
I am an active and committed user of Django in my business.  However,
I do want to see Django expand its userbase and flourish.  Django is
less useful to me than it could be because of this, and I can only
assume that there is a good number of potential users (especially
corporate users) that are either turned off or dissuaded from using
Django because of the incomplete implementation of CRUD in admin.
Django suffers when such people choose other frameworks.

I ask that other Django users or potential users that have good
reasons for needing a read-only option in the admin post their reasons
here, so that at least it becomes apparent to the "powers that be"
that there is a certain level of demand to allow the inclusion of this
functionality into the trunk when it is contributed by volunteers.
Note that I would be happy to contribute my free time to adding this
functionality to admin, but only if there is a good chance that the
functionality, properly implemented, could make it into trunk.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Does cache timeout need to be set in two places?

2009-03-22 Thread rihad

>From Django Book http://www.djangobook.com/en/2.0/chapter15/ :

> CACHE_BACKEND = "locmem:///?timeout=30_entries=400"

but, a bit later:

> Then, add the following required settings to your Django settings file:
>* CACHE_MIDDLEWARE_SECONDS — The number of seconds each page should be 
> cached.


Why have two seemingly identical settings? Do I have to make sure
they're equal? What if they aren't? Or is the timeout= the cached
object lifetime per se, but CACHE_MIDDLEWARE_SECONDS is what is
actually told to web caches? Sorry I couldn't grasp the idea after
rereading The Book.


Another relevant q'n: can I configure the cache to expire at
appropriate time intervals, without coding the logic? Say, there's an
external event happening every 15 minutes that updates the original
data Django processes; can Django be configured to give web clients
the correct cache TTL? Example: the resource is regenerated externally
at 11:00:00. At 11:00:01 a client accesses it and it should be given
cache timeout up until 11:15:00, that is, 899 seconds. Client
accessing at 11:00:02 should be given timeout 898 seconds, and so on.
Then at 11:15:00 the resource is regenerated again and it comes full
circle until 11:30:00 this time, and so on.

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



Re: Installing Django for rapidsms

2009-03-22 Thread dbbarua

Hi James,Alex
 Thank you for your help , I downgraded Django to
0.93 and it works fine.

Regards
Deepak

On Mar 22, 12:13 am, Alex Gaynor  wrote:
> On Sat, Mar 21, 2009 at 3:07 PM, dbbarua  wrote:
>
> > Hi ,
> >    I am trying to use Django for rapidsms , i get the following error
> > when i run
> > r...@portable:/usr/local/rapidsms-dev/rapidsms/rapidsms# python
> > manage.py syncdb
>
> > raceback (most recent call last):
> >  File "manage.py", line 11, in 
> >    execute_manager(settings)
> >  File "/usr/lib/python2.5/site-packages/django/core/management/
> > __init__.py", line 348, in execute_manager
> >    utility.execute()
> >  File "/usr/lib/python2.5/site-packages/django/core/management/
> > __init__.py", line 293, in execute
> >    self.fetch_command(subcommand).run_from_argv(self.argv)
> >  File "/usr/lib/python2.5/site-packages/django/core/management/
> > base.py", line 195, in run_from_argv
> >    self.execute(*args, **options.__dict__)
> >  File "/usr/lib/python2.5/site-packages/django/core/management/
> > base.py", line 221, in execute
> >    self.validate()
> >  File "/usr/lib/python2.5/site-packages/django/core/management/
> > base.py", line 249, in validate
> >    num_errors = get_validation_errors(s, app)
> >  File "/usr/lib/python2.5/site-packages/django/core/management/
> > validation.py", line 28, in get_validation_errors
> >    for (app_name, error) in get_app_errors().items():
> >  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
> > line 131, in get_app_errors
> >    self._populate()
> >  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
> > line 58, in _populate
> >    self.load_app(app_name, True)
> >  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
> > line 74, in load_app
> >    models = import_module('.models', app_name)
> >  File "/usr/lib/python2.5/site-packages/django/utils/importlib.py",
> > line 35, in import_module
> >    __import__(name)
> >  File "/usr/lib/python2.5/site-packages/rapidsms/balert/models.py",
> > line 62, in 
> >    class SentSMS(models.Model, TimestampOrderable):
> >  File "/usr/lib/python2.5/site-packages/rapidsms/balert/models.py",
> > line 65, in SentSMS
> >    sender = models.ForeignKey(User, core=True)
> >  File "/usr/lib/python2.5/site-packages/django/db/models/fields/
> > related.py", line 664, in __init__
> >    Field.__init__(self, **kwargs)
> > TypeError: __init__() got an unexpected keyword argument 'core'
>
> > Is there some patch to solve this error?
>
> > Am i doing something wrong...?
>
> > Regards
> > Deepak
>
> Whatever piece of code you've written or are using is written for an older
> version of Django(pre-1.0) where core was a kwarg on model fields for use
> with the admin, this has been supplanted by the new modeladmin system.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Saving and retrieving objects in application scope

2009-03-22 Thread vanosten

Hi

After having done some research on my own without result, I would be
glad if someone could point me into the right direction for the
following:

How do I save and retrieve an object which is visible in all request/
response cycles
for all clients using the application, for as long as the application
is active? This is called "application scope" in the JavaServer Faces
world.

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



Re: internationalization django app

2009-03-22 Thread Malcolm Tredinnick

On Sun, 2009-03-22 at 12:13 +0700, Akhmat Safrudin wrote:
> Helo,
> is it available internationalize django app with the language not listed 
> under : django/conf/global_settings.py ?
> and just add the app/myapp/locale/mylang/LC_MESSAGES/django.po ?

No. This is documented here:
http://docs.djangoproject.com/en/dev/topics/i18n/#id1

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