mod_wsgi or mod_fcgi

2011-02-24 Thread Shamail Tayyab
Hi,

   I am going to deploy a site today on an Amazon's large instance.
Our setup is like this:

server 1: mongoDB + redis server
server 2: django + nodejs

We are using node for server push things. Can you please suggest what
would be the best way to deploy django as? (via wsgi or fcgi). We've
planned to use lighttpd (apache can also be used if required).


Thanks and regards

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

2011-02-24 Thread Kenneth Gonsalves
On Thu, 2011-02-24 at 00:54 -0800, luca72 wrote:
> I get CSRF verification failed. Request aborted. after the submit

you have to use RequestContext if you are using csrf - also make sure
csrf middleware is loaded.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: Problem with unicode in form posts

2011-02-24 Thread Tom Evans
On Wed, Feb 23, 2011 at 9:17 PM, Lee Hinde  wrote:
> Except, now the data that's in the database for the username field
> goes from looking like this:
> leehinde
> to this
> (u'leehinde',)
>
> I'd like it to be 'leehinde' again
> so, clearly objects.create is more clever than my pure post. But I'm
> not sure where in the food chain I should be interceding..
>

http://docs.djangoproject.com/en/1.2/ref/unicode/#general-string-handling

"""
In most cases when Django is dealing with strings, it will convert
them to Unicode strings before doing anything else. So, as a general
rule, if you pass in a bytestring, be prepared to receive a Unicode
string back in the result.
"""

Be prepared :)

Cheers

Tom

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

2011-02-24 Thread Kenneth Gonsalves
On Thu, 2011-02-24 at 01:20 -0800, luca72 wrote:
> @csrf_protect

try removing this
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: Problem with unicode in form posts

2011-02-24 Thread Mike Ramirez
On Thursday, February 24, 2011 01:32:11 am Tom Evans wrote:
> On Wed, Feb 23, 2011 at 9:17 PM, Lee Hinde  wrote:
> > Except, now the data that's in the database for the username field
> > goes from looking like this:
> > leehinde
> > to this
> > (u'leehinde',)
> > 
> > I'd like it to be 'leehinde' again
> > so, clearly objects.create is more clever than my pure post. But I'm
> > not sure where in the food chain I should be interceding..
> 
> http://docs.djangoproject.com/en/1.2/ref/unicode/#general-string-handling
> 
> """
> In most cases when Django is dealing with strings, it will convert
> them to Unicode strings before doing anything else. So, as a general
> rule, if you pass in a bytestring, be prepared to receive a Unicode
> string back in the result.
> """
> 
> Be prepared :)
> 
> Cheers
> 
> Tom

But that doesn't explain the tuple form, (u'', ) of the return value. 

That's what got me.

Mike
-- 
Now is the time for all good men to come to.
-- Walt Kelly

-- 
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: CSRF verification failed. Request aborted.

2011-02-24 Thread luca72
removing @crsf_protect i get the same error

On 24 Feb, 10:34, Kenneth Gonsalves  wrote:
> On Thu, 2011-02-24 at 01:20 -0800, luca72 wrote:
> > @csrf_protect
>
> try removing this
> --
> regards
> KGhttp://lawgon.livejournal.com
> Coimbatore LUG roxhttp://ilugcbe.techstud.org/

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



Re: CSRF verification failed. Request aborted.

2011-02-24 Thread Ankit Rai
after removing add @csrf_exempt, it will work retsart the server.

Which version of django are you using
to know version
type follwoing cmd
python
import django
django.VERSION


On Thu, Feb 24, 2011 at 3:18 PM, luca72  wrote:

> removing @crsf_protect i get the same error
>
> On 24 Feb, 10:34, Kenneth Gonsalves  wrote:
> > On Thu, 2011-02-24 at 01:20 -0800, luca72 wrote:
> > > @csrf_protect
> >
> > try removing this
> > --
> > regards
> > KGhttp://lawgon.livejournal.com
> > Coimbatore LUG roxhttp://ilugcbe.techstud.org/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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

2011-02-24 Thread luca72
(1, 2, 5, 'final', 0)

Thanks

Luca

On 24 Feb, 10:50, Ankit Rai  wrote:
> after removing add @csrf_exempt, it will work retsart the server.
>
> Which version of django are you using
> to know version
> type follwoing cmd
> python
> import django
> django.VERSION
>
> On Thu, Feb 24, 2011 at 3:18 PM, luca72  wrote:
> > removing @crsf_protect i get the same error
>
> > On 24 Feb, 10:34, Kenneth Gonsalves  wrote:
> > > On Thu, 2011-02-24 at 01:20 -0800, luca72 wrote:
> > > > @csrf_protect
>
> > > try removing this
> > > --
> > > regards
> > > KGhttp://lawgon.livejournal.com
> > > Coimbatore LUG roxhttp://ilugcbe.techstud.org/
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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

2011-02-24 Thread Kenneth Gonsalves
On Thu, 2011-02-24 at 01:55 -0800, luca72 wrote:
> (1, 2, 5, 'final', 0)

and one more thing - how are you deploying? 
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: Problems with serving static files

2011-02-24 Thread Tom Evans
On Thu, Feb 24, 2011 at 1:39 AM, Roy Smith  wrote:
> I'm running r15624, OSX-10.6.5, Python-2.6.1
>
> In my top-level urls.py, I have:
>
>    # Serve static
> files
>    (r'^static/(?P.*)$',
>     'django.views.static.serve',
>     {'document_root': '/Users/roy/dev/try.django/mysite/static',
>      'show_indexes': True}),
>
> If I go to http://localhost:8000/static/, I see a listing of my only
> static file:
>
> Index of /
> site.css
>
> but when I click on the site.css link, I get a 404 ('site.css' could
> not be found).  Any ideas what might be going wrong?
>

I suspect it is trying to load
/Users/roy/dev/try.django/mysite/staticsite.css'. Try adding a '/' to
the end of your document root, or capturing the initial '/' as part of
the path in your urlconf.

Cheers

Tom

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

2011-02-24 Thread Ankit Rai
There is the problem "django1.2.5"  has some more security updates beacuse
of which your old code may break .

Your code will start working after you add @csrf_exempt in all your views
.And cross check your settings.py middleware classes

('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',)




close your browser and rstart the serve and the try to open your application




---Ankit Rai






On Thu, Feb 24, 2011 at 3:25 PM, luca72  wrote:

> (1, 2, 5, 'final', 0)
>
> Thanks
>
> Luca
>
> On 24 Feb, 10:50, Ankit Rai  wrote:
> > after removing add @csrf_exempt, it will work retsart the server.
> >
> > Which version of django are you using
> > to know version
> > type follwoing cmd
> > python
> > import django
> > django.VERSION
> >
> > On Thu, Feb 24, 2011 at 3:18 PM, luca72  wrote:
> > > removing @crsf_protect i get the same error
> >
> > > On 24 Feb, 10:34, Kenneth Gonsalves  wrote:
> > > > On Thu, 2011-02-24 at 01:20 -0800, luca72 wrote:
> > > > > @csrf_protect
> >
> > > > try removing this
> > > > --
> > > > regards
> > > > KGhttp://lawgon.livejournal.com
> > > > Coimbatore LUG roxhttp://ilugcbe.techstud.org/
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Django users" group.
> > > To post to this group, send email to django-users@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-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.
>
>

-- 
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: CSRF verification failed. Request aborted.

2011-02-24 Thread Kenneth Gonsalves
On Thu, 2011-02-24 at 15:30 +0530, Ankit Rai wrote:
> Your code will start working after you add @csrf_exempt in all your
> views

why should he exempt all his views from csrf checking?
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: CSRF verification failed. Request aborted.

2011-02-24 Thread Tom Evans
On Thu, Feb 24, 2011 at 10:00 AM, Ankit Rai  wrote:
> There is the problem "django1.2.5"  has some more security updates beacuse
> of which your old code may break .

Citation?

>
> Your code will start working after you add @csrf_exempt in all your views
> .And cross check your settings.py middleware classes

This is daft advice. All your views would then be csrf exempt, and
nothing is protected from csrf.

Cheers

Tom

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



WSGI eating search args?

2011-02-24 Thread Christoph Pingel
My app runs with mod_wsgi behind Apache.

A local configuration of the app runs without problems, but behind
Apache every call involving GET args results in a HTTP 500 error.

The url config is
(r'^sem/search/$', 'paragon.sem.views.search'),

and in my view, I get the search param with
query = request.GET.get('q', '')

Strange thing is, if I call the view without query args, the page
renders beautifully, but with query args, I get HTTP 500.

The problem seems to be systematic, none of the urls that use GET args
seems to work. Any ideas what the problem could be?
django 1.2.5, apache2.

TIA,
best regards,
Christoph

-- 
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: WSGI eating search args?

2011-02-24 Thread Tom Evans
On Thu, Feb 24, 2011 at 11:13 AM, Christoph Pingel
 wrote:
> My app runs with mod_wsgi behind Apache.
>
> A local configuration of the app runs without problems, but behind
> Apache every call involving GET args results in a HTTP 500 error.
>
> The url config is
> (r'^sem/search/$', 'paragon.sem.views.search'),
>
> and in my view, I get the search param with
> query = request.GET.get('q', '')
>
> Strange thing is, if I call the view without query args, the page
> renders beautifully, but with query args, I get HTTP 500.
>
> The problem seems to be systematic, none of the urls that use GET args
> seems to work. Any ideas what the problem could be?
> django 1.2.5, apache2.
>
> TIA,
> best regards,
> Christoph
>

You get a 500 if your view raises an exception. Since you aren't
showing the exception traceback, any advice would be speculation.

Cheers

Tom

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



field choices() as queryset?

2011-02-24 Thread galago
I need to make a form, which have 1 select and 1 text input. Select must be 
taken from database.
model looks like this:
class Province(models.Model):
name = models.CharField(max_length=30)
slug = models.SlugField(max_length=30)

def __unicode__(self):
return self.name

It's rows to this are added only by admin, but all users can see it in 
forms.
I want to make a ModelForm from that. I made something like this:
class ProvinceForm(ModelForm):
class Meta:
CHOICES = Province.objects.all()

model = Province
fields = ('name',)
widgets = {
'name': Select(choices=CHOICES),
}

but it doesn't work. The select tag is not displayed in html. What did I 
wrong?

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



pgadmin vs schema migration

2011-02-24 Thread ggavy

Hello everyone,
if I have a live app running off a postgres db (containing data)
and I want to make reasonably simple schema (and possibly data
content) changes, are there any dangers in just using pgadmin (e.g
adding a column) as opposed to using some type of migration software,
e.g. south. I'd keep my models.py up-to-date with any changes I make
to the database (in case of future uses of the app). I haven't seen
anything online warning me not to do it, but the separation worries me
slightly

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: pgadmin vs schema migration

2011-02-24 Thread Kenneth Gonsalves
On Thu, 2011-02-24 at 03:48 -0800, ggavy wrote:
> I'd keep my models.py up-to-date with any changes I make
> to the database (in case of future uses of the app). I haven't seen
> anything online warning me not to do it, but the separation worries me
> slightly 

well, that is the way django does it (not exactly pgadmin, but psql), do
not forget that South etc are third party apps. The way I do it is
generate sql.all both before and after a change in a model, generate a
diff and manually create an sql script to run.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: pgadmin vs schema migration

2011-02-24 Thread Mike Ramirez
On Thursday, February 24, 2011 03:48:18 am ggavy wrote:
> Hello everyone,
> if I have a live app running off a postgres db (containing data)
> and I want to make reasonably simple schema (and possibly data
> content) changes, are there any dangers in just using pgadmin (e.g
> adding a column) as opposed to using some type of migration software,
> e.g. south. I'd keep my models.py up-to-date with any changes I make
> to the database (in case of future uses of the app). I haven't seen
> anything online warning me not to do it, but the separation worries me
> slightly
> 
> Thanks

prior to the migration systems (south/evolution) and even after that for 
awhile, it was the defualt way, to manage it manually. The migration tools 
just make it easier.

As long as you keep your table and model definitions, and create/insert/update 
statements all in line, it's safe.

Personally,I'm with all the others and suggest you use migration tools, unless 
this is a one off and not going to be doing this a lot, Then I do find it just 
faster and easier to do it manually.

Mike.

-- 
Vermouth always makes me brilliant unless it makes me idiotic.
-- E.F. Benson

-- 
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: field choices() as queryset?

2011-02-24 Thread Mike Ramirez
On Thursday, February 24, 2011 03:53:03 am galago wrote:
> I need to make a form, which have 1 select and 1 text input. Select must be
> taken from database.
> model looks like this:
> class Province(models.Model):
> name = models.CharField(max_length=30)
> slug = models.SlugField(max_length=30)
> 
> def __unicode__(self):
> return self.name
> 
> It's rows to this are added only by admin, but all users can see it in
> forms.
> I want to make a ModelForm from that. I made something like this:
> class ProvinceForm(ModelForm):
> class Meta:
> CHOICES = Province.objects.all()
> 
> model = Province
> fields = ('name',)
> widgets = {
> 'name': Select(choices=CHOICES),
> }
> 
> but it doesn't work. The select tag is not displayed in html. What did I
> wrong?

I haven't done this one in a while, but you need to make the CHOICES a tuple 
or a list[1], not a queryset (unless there has been changes in this specific 
area).

something like this:

def make_choices():
choices = []
for item in Province.objects.all()
choices.append((item.name, item.name))
   return choices

# your form stuff
  ...
widgets = { 'name': Select(choices=make_choices()), }

The first value is the value stored, the second one is the human readable form 
in the tuple.

Mike

[1] http://docs.djangoproject.com/en/1.2/ref/models/fields/#field-choices


-- 
Banacek's Eighteenth Polish Proverb:
The hippo has no sting, but the wise man would rather be sat upon
by the bee.

-- 
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: Problem with unicode in form posts

2011-02-24 Thread Lachlan Musicman
On Thu, Feb 24, 2011 at 20:41, Mike Ramirez  wrote:
> On Thursday, February 24, 2011 01:32:11 am Tom Evans wrote:
> But that doesn't explain the tuple form, (u'', ) of the return value.

That's how unicode strings are marked in django

cheers
L.

-- 
Crunchiness is the gustatory sensation of muffled grinding of a
foodstuff. Crunchiness differs from crispiness in that a crispy item
is quickly atomized, while a crunchy one offers sustained, granular
resistance to jaw action. While crispiness is difficult to maintain,
crunchiness is difficult to overcome.
from The Best of Wikipedia http://bestofwikipedia.tumblr.com/

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



Re: field choices() as queryset?

2011-02-24 Thread galago
Thanks, that's the way I'll do it:)
But now I have 1 more problem. In ModelForm I want to get some data about 
user from DB. I nedd to filter user provinces. How canI call the user  id in 
my query? I pass request.user as form instance in view: form = 
ProvinceForm(instance=request.user)
How to read that inside my form? self.instance.id doesn't work:/

-- 
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: field choices() as queryset?

2011-02-24 Thread Chris Matthews
Typo
choices.append((item.name, item.name))
should be
choices.append((item.id, item.name))

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Mike Ramirez
Sent: 24 February 2011 14:10
To: django-users@googlegroups.com
Subject: Re: field choices() as queryset?


On Thursday, February 24, 2011 03:53:03 am galago wrote:

> I need to make a form, which have 1 select and 1 text input. Select must be

> taken from database.

> model looks like this:

> class Province(models.Model):

> name = models.CharField(max_length=30)

> slug = models.SlugField(max_length=30)

>

> def __unicode__(self):

> return self.name

>

> It's rows to this are added only by admin, but all users can see it in

> forms.

> I want to make a ModelForm from that. I made something like this:

> class ProvinceForm(ModelForm):

> class Meta:

> CHOICES = Province.objects.all()

>

> model = Province

> fields = ('name',)

> widgets = {

> 'name': Select(choices=CHOICES),

> }

>

> but it doesn't work. The select tag is not displayed in html. What did I

> wrong?

I haven't done this one in a while, but you need to make the CHOICES a tuple or 
a list[1], not a queryset (unless there has been changes in this specific area).

something like this:

def make_choices():

choices = []

for item in Province.objects.all()

choices.append((item.name, item.name))

return choices

# your form stuff

...

widgets = { 'name': Select(choices=make_choices()), }

The first value is the value stored, the second one is the human readable form 
in the tuple.

Mike

[1] http://docs.djangoproject.com/en/1.2/ref/models/fields/#field-choices

--

Banacek's Eighteenth Polish Proverb:

The hippo has no sting, but the wise man would rather be sat upon

by the bee.
--
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.

-- 
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: field choices() as queryset?

2011-02-24 Thread Mike Ramirez
On Thursday, February 24, 2011 04:21:46 am galago wrote:
> Thanks, that's the way I'll do it:)
> But now I have 1 more problem. In ModelForm I want to get some data about
> user from DB. I nedd to filter user provinces. How canI call the user  id
> in my query? I pass request.user as form instance in view: form =
> ProvinceForm(instance=request.user)
> How to read that inside my form? self.instance.id doesn't work:/

Whats the forms __init__ method look like?

Mike
-- 
Q:  What's hard going in and soft and sticky coming out?
A:  Chewing gum.

-- 
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: field choices() as queryset?

2011-02-24 Thread galago
I made it that way but i get empty select list

class ProvinceForm(ModelForm):
def __init__(self, *args, **kwargs):
super(ProvinceForm, self).__init__(*args, **kwargs)
user_provinces = 
UserProvince.objects.select_related().filter(user__exact=self.instance.id).values_list('province')
self.fields['name'].choices = 
Province.objects.exclude(id__in=user_provinces).values_list('id', 'name')

class Meta:
model = Province
fields = ('name',)
widgets = {
'name': Select(),
}

-- 
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: field choices() as queryset?

2011-02-24 Thread galago
hmm, that solutoin works great:)
class ProvinceForm(ModelForm):
def __init__(self, *args, **kwargs):
super(ProvinceForm, self).__init__(*args, **kwargs)
user_provinces = 
UserProvince.objects.select_related().filter(user__exact=self.instance.id).values_list('province')
self.fields['name'].queryset = 
Province.objects.exclude(id__in=user_provinces).only('id', 'name')

name = forms.ModelChoiceField(queryset=None, empty_label=None)

class Meta:
model = Province
fields = ('name',)

-- 
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: field choices() as queryset?

2011-02-24 Thread Mike Ramirez
On Thursday, February 24, 2011 05:00:23 am galago wrote:
> I made it that way but i get empty select list
> 
> class ProvinceForm(ModelForm):
> def __init__(self, *args, **kwargs):
> super(ProvinceForm, self).__init__(*args, **kwargs)
> user_provinces =
> UserProvince.objects.select_related().filter(user__exact=self.instance.id).
> values_list('province') self.fields['name'].choices =
> Province.objects.exclude(id__in=user_provinces).values_list('id', 'name')
> 
> class Meta:
> model = Province
> fields = ('name',)
> widgets = {
> 'name': Select(),
> }

for self.instance, you'll wnat to do something like this:


self.instance = kwargs.pop('instance')
or add:
def __init__(self, instance, *args, **kwargs):
self.instance = instance



as for the blank items, verify your query works as expected.  After that I'm 
not sure.

Mike
-- 
If I felt any more SOPHISTICATED I would DIE of EMBARRASSMENT!

-- 
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: Problems with permissions in the admin panel.

2011-02-24 Thread Adam Tonks
Assigning every permission in the list still gave the same 'You don't
have permission' message.

I think it's all sorted now though - I had a custom authentication
backend to allow case insensitive login (http://djangosnippets.org/
snippets/1368/), and I assumed it would just override the two
functions it specified. It looks like it prevented all the other
functions in the usual ModelBackend though, which prevented the
permissions from being loaded. Copying the other functions not
specified in the custom backend from the original source leaves it
working great.

I'm not sure why it didn't just override, but at least it's working
now.

Thanks

On Feb 23, 11:50 pm, Mike Ramirez  wrote:
> On Wednesday, February 23, 2011 02:56:52 pm Adam Tonks wrote:
>
>
>
>
>
>
>
>
>
> > Hello,
>
> > I'm having some fustrating problems with setting permissions for a
> > user within the django administration panel.  I create a new user, set
> > it as staff, and assign it permissions.  The problem is, when I login
> > as them, I get the "You don't have permission to edit anything."
> > error.
>
> > I'm looking for help from anyone who can point me to where I could
> > have broken the system, and where to look for me to be able to fix it.
> > I've been stuck on this a good few days now, and I'm not getting
> > anywhere.
>
> > Let me know what extra information would be useful.
>
> > Thanks for your help.
>
> The actual permissions you're assigning the users.
>
> But just make sure that the user in questions has the `app|model|can change
> model` option selected.
>
> I just tested this out assigning the user the just "can change" permission and
> was able to to change only the app|model in question and removed that and
> added the "can add" permission to the same model, worked as expected. using
> django 1.3 alpha.
>
> Mike.
> --
> "Only a brain-damaged operating system would support task switching and not
> make the simple next step of supporting multitasking."
> -- George McFry

-- 
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: unittest problems

2011-02-24 Thread Renne Rocha
  You ran the tests and they are telling you what is wrong. Read the
test result!

  You have the django.contrib.auth app installed in your project. But
it seems that you haven't create the default templates needed for this
app works.

  For these tests work, you need to define some templates (read the
errors to see what templates are needed). For example:
   TemplateDoesNotExist: registration/password_change_form.html

  If you won't use the django.contrib.auth app in your project, remove
it from INSTALLED_APPS in settings.py.

  Renne Rocha
  http://about.me/rennerocha/


On Wed, Feb 23, 2011 at 6:20 PM, refreegrata  wrote:
> Yeahh , I already try this. The number of errors decreases, but I
> still have some errors (15)
> -
> ==
> ERROR: test_password_change_fails_with_invalid_old_password
> (django.contrib.auth.tests.views.ChangePasswordTest)
> --
> Traceback (most recent call last):
>  File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
> tests/views.py", line 147, in
> test_password_change_fails_with_invalid_old_password
>    'new_password2': 'password1',
>  File "/usr/local/lib/python2.6/dist-packages/django/test/client.py",
> line 322, in post
>    response = self.request(**r)
>  File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
> base.py", line 100, in get_response
>    response = callback(request, *callback_args, **callback_kwargs)
>  File "/usr/local/lib/python2.6/dist-packages/django/utils/
> decorators.py", line 76, in _wrapped_view
>    response = view_func(request, *args, **kwargs)
>  File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
> decorators.py", line 25, in _wrapped_view
>    return view_func(request, *args, **kwargs)
>  File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
> views.py", line 187, in password_change
>    }, context_instance=RequestContext(request))
>  File "/usr/local/lib/python2.6/dist-packages/django/shortcuts/
> __init__.py", line 20, in render_to_response
>    return HttpResponse(loader.render_to_string(*args, **kwargs),
> **httpresponse_kwargs)
>  File "/usr/local/lib/python2.6/dist-packages/django/template/
> loader.py", line 181, in render_to_string
>    t = get_template(template_name)
>  File "/usr/local/lib/python2.6/dist-packages/django/template/
> loader.py", line 157, in get_template
>    template, origin = find_template(template_name)
>  File "/usr/local/lib/python2.6/dist-packages/django/template/
> loader.py", line 138, in find_template
>    raise TemplateDoesNotExist(name)
> TemplateDoesNotExist: registration/password_change_form.html
>
> ==
> ERROR: test_password_change_fails_with_mismatched_passwords
> (django.contrib.auth.tests.views.ChangePasswordTest)
> --
> Traceback (most recent call last):
>  File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
> tests/views.py", line 158, in
> test_password_change_fails_with_mismatched_passwords
>    'new_password2': 'donuts',
>  File "/usr/local/lib/python2.6/dist-packages/django/test/client.py",
> line 322, in post
>    response = self.request(**r)
>  File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
> base.py", line 100, in get_response
>    response = callback(request, *callback_args, **callback_kwargs)
>  File "/usr/local/lib/python2.6/dist-packages/django/utils/
> decorators.py", line 76, in _wrapped_view
>    response = view_func(request, *args, **kwargs)
>  File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
> decorators.py", line 25, in _wrapped_view
>    return view_func(request, *args, **kwargs)
>  File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
> views.py", line 187, in password_change
>    }, context_instance=RequestContext(request))
>  File "/usr/local/lib/python2.6/dist-packages/django/shortcuts/
> __init__.py", line 20, in render_to_response
>    return HttpResponse(loader.render_to_string(*args, **kwargs),
> **httpresponse_kwargs)
>  File "/usr/local/lib/python2.6/dist-packages/django/template/
> loader.py", line 181, in render_to_string
>    t = get_template(template_name)
>  File "/usr/local/lib/python2.6/dist-packages/django/template/
> loader.py", line 157, in get_template
>    template, origin = find_template(template_name)
>  File "/usr/local/lib/python2.6/dist-packages/django/template/
> loader.py", line 138, in find_template
>    raise TemplateDoesNotExist(name)
> TemplateDoesNotExist: registration/password_change_form.html
>
> ==
> ERROR: Logout without next_page option renders the default template
> --
> Traceback (most 

Re: unittest problems

2011-02-24 Thread refreegrata
I add this to my settings:
---
TEMPLATE_CONTEXT_PROCESSORS = (
   .
'django.contrib.messages.context_processors.messages',
<- new line
)

I don't know the utility of this but now I only have 3 errors

---
==
ERROR: test_password_change_fails_with_invalid_old_password
(django.contrib.auth.tests.views.ChangePasswordTest)
--
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
tests/views.py", line 147, in
test_password_change_fails_with_invalid_old_password
'new_password2': 'password1',
  File "/usr/local/lib/python2.6/dist-packages/django/test/client.py",
line 322, in post
response = self.request(**r)
  File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
base.py", line 100, in get_response
response = callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python2.6/dist-packages/django/utils/
decorators.py", line 76, in _wrapped_view
response = view_func(request, *args, **kwargs)
  File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
decorators.py", line 25, in _wrapped_view
return view_func(request, *args, **kwargs)
  File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
views.py", line 187, in password_change
}, context_instance=RequestContext(request))
  File "/usr/local/lib/python2.6/dist-packages/django/shortcuts/
__init__.py", line 20, in render_to_response
return HttpResponse(loader.render_to_string(*args, **kwargs),
**httpresponse_kwargs)
  File "/usr/local/lib/python2.6/dist-packages/django/template/
loader.py", line 181, in render_to_string
t = get_template(template_name)
  File "/usr/local/lib/python2.6/dist-packages/django/template/
loader.py", line 157, in get_template
template, origin = find_template(template_name)
  File "/usr/local/lib/python2.6/dist-packages/django/template/
loader.py", line 138, in find_template
raise TemplateDoesNotExist(name)
TemplateDoesNotExist: registration/password_change_form.html

==
ERROR: test_password_change_fails_with_mismatched_passwords
(django.contrib.auth.tests.views.ChangePasswordTest)
--
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
tests/views.py", line 158, in
test_password_change_fails_with_mismatched_passwords
'new_password2': 'donuts',
  File "/usr/local/lib/python2.6/dist-packages/django/test/client.py",
line 322, in post
response = self.request(**r)
  File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
base.py", line 100, in get_response
response = callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python2.6/dist-packages/django/utils/
decorators.py", line 76, in _wrapped_view
response = view_func(request, *args, **kwargs)
  File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
decorators.py", line 25, in _wrapped_view
return view_func(request, *args, **kwargs)
  File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
views.py", line 187, in password_change
}, context_instance=RequestContext(request))
  File "/usr/local/lib/python2.6/dist-packages/django/shortcuts/
__init__.py", line 20, in render_to_response
return HttpResponse(loader.render_to_string(*args, **kwargs),
**httpresponse_kwargs)
  File "/usr/local/lib/python2.6/dist-packages/django/template/
loader.py", line 181, in render_to_string
t = get_template(template_name)
  File "/usr/local/lib/python2.6/dist-packages/django/template/
loader.py", line 157, in get_template
template, origin = find_template(template_name)
  File "/usr/local/lib/python2.6/dist-packages/django/template/
loader.py", line 138, in find_template
raise TemplateDoesNotExist(name)
TemplateDoesNotExist: registration/password_change_form.html

==
ERROR: Logout without next_page option renders the default template
--
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
tests/views.py", line 247, in test_logout_default
response = self.client.get('/logout/')
  File "/usr/local/lib/python2.6/dist-packages/django/test/client.py",
line 290, in get
response = self.request(**r)
  File "/usr/local/lib/python2.6/dist-packages/django/test/client.py",
line 230, in request
response = self.handler(environ)
  File "/us

Re: field choices() as queryset?

2011-02-24 Thread Tom Evans
On Thu, Feb 24, 2011 at 1:07 PM, Mike Ramirez  wrote:
> On Thursday, February 24, 2011 05:00:23 am galago wrote:
>> class ProvinceForm(ModelForm):
>
>> def __init__(self, *args, **kwargs):
>> 
>
> for self.instance, you'll wnat to do something like this:
>
> self.instance = kwargs.pop('instance')
>
> or add:
>
> def __init__(self, instance, *args, **kwargs):
>
> self.instance = instance
>
> as for the blank items, verify your query works as expected. After that I'm
> not sure.
>
> Mike
>

Er, no, he should be calling the super-class (ModelForm) constructor,
which would correctly handle instance being in kwargs and set
self.instance - which the OP is doing. Cargo cult programming is bad.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: field choices() as queryset?

2011-02-24 Thread Mike Ramirez
On Thursday, February 24, 2011 05:15:09 am Tom Evans wrote:
> Cargo cult programming is bad.
> 
> Cheers
> 
> Tom

Not going to really argue the point, it's valid, but it could be based on 
habits taught by others, mentors... 

Mike

-- 
Never, ever lie to someone you love unless you're absolutely sure they'll
never find out the truth.

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



Python/Django AMQP?

2011-02-24 Thread ju


I have a django web application which creates and saves jobs in a database. 
For every job I have to send email and export data to another system. I want 
to make it asynchronously.

What is the recommended way to do it?

   - It have to be reliable (no jobs missed).
   - There have to be easy way to find (log) if something goes wrong.
   - 
   
   I want to be able to easy add more workers that will process the jobs.
   - 
   
   May be it will be better if job queue is the same database table, so I 
   can easy cancel jobs by simply changing their status in database?
   - 
   
   May be it will be better if the solution is somehow related to django 
   framework?
   

-- 
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 pagination is repeating results

2011-02-24 Thread diogobaeder
Nevermind, it is a SQL Server problem. (I hate SQL Server. There, I
said it.)

I had to first filter manually by the m2m objects, then apply the
pagination to the results.

Thanks!

On Feb 18, 2:53 pm, David De La Harpe Golden
 wrote:
> On 18/02/11 17:38,diogobaederwrote:
>
> > Hi,
> > Any ideas of what might be happening?
>
> Have you set a Meta.ordering on your Model (or applied an .order_by()
> to the QuerySet?)

-- 
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: Python/Django AMQP?

2011-02-24 Thread Tom Evans
On Thu, Feb 24, 2011 at 1:29 PM, ju  wrote:
> I have a django web application which creates and saves jobs in a database.
> For every job I have to send email and export data to another system. I want
> to make it asynchronously.
>
> What is the recommended way to do it?
>
> It have to be reliable (no jobs missed).
> There have to be easy way to find (log) if something goes wrong.
>
> I want to be able to easy add more workers that will process the jobs.
>
> May be it will be better if job queue is the same database table, so I can
> easy cancel jobs by simply changing their status in database?
>
> May be it will be better if the solution is somehow related to django
> framework?
>

celery / django-celery uses AMQP as a transport for providing
asynchronous workers. Google will tell you more.

If you want a more bare bones solution, pika is an excellent python
amqp library from the rabbitmq developers.

Cheers

Tom

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

2011-02-24 Thread Cal Leeming [Simplicity Media Ltd]
Personally, I *always* use WSGI with uWSGI by unbit. Always proven stable.

On Thu, Feb 24, 2011 at 7:10 AM, Shamail Tayyab  wrote:

> Hi,
>
>   I am going to deploy a site today on an Amazon's large instance.
> Our setup is like this:
>
> server 1: mongoDB + redis server
> server 2: django + nodejs
>
> We are using node for server push things. Can you please suggest what
> would be the best way to deploy django as? (via wsgi or fcgi). We've
> planned to use lighttpd (apache can also be used if required).
>
>
> Thanks and regards
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-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.
>
>

-- 
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: Python/Django AMQP?

2011-02-24 Thread Shawn Milochik
+1 on Celery and django-celery. I use them both.

-- 
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: field choices() as queryset?

2011-02-24 Thread galago
Now I have some strange thing. I display my form, send post and try to save 
it. But it doesn't save:/
Here's my code:
model:
class UserProvince(models.Model):
user = models.ForeignKey(User)
province = models.ForeignKey(Province)

class Meta:
unique_together = (('user', 'province'), )

def __unicode__(self):
return self.user.username + '/' + self.province.name

form:
class ProvinceForm(ModelForm):
def __init__(self, *args, **kwargs):
super(ProvinceForm, self).__init__(*args, **kwargs)
user_provinces = 
UserProvince.objects.select_related().filter(user__exact=self.instance.id).values_list('province')
self.fields['province'].queryset = 
Province.objects.exclude(id__in=user_provinces).only('id', 'name')

province = forms.ModelChoiceField(queryset=None, empty_label=None)
range_type = forms.CharField(initial='province', 
widget=forms.HiddenInput())

class Meta:
model = UserProvince
fields = ('province',)

view:
if request.POST:
form = ProvinceForm(request.POST, instance=request.user)
if form.is_valid():
obj = form.save(commit=False)
obj.user = request.user
obj.save()

form is valid, but save method makes no effect :/

-- 
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: field choices() as queryset?

2011-02-24 Thread Tom Evans
On Thu, Feb 24, 2011 at 2:17 PM, galago  wrote:
> Now I have some strange thing. I display my form, send post and try to save
> it. But it doesn't save:/
> Here's my code:
> model:
> class UserProvince(models.Model):
>     user = models.ForeignKey(User)
>     province = models.ForeignKey(Province)
>     class Meta:
>         unique_together = (('user', 'province'), )
>     def __unicode__(self):
>         return self.user.username + '/' + self.province.name
> form:
> class ProvinceForm(ModelForm):
>     def __init__(self, *args, **kwargs):
>         super(ProvinceForm, self).__init__(*args, **kwargs)
>         user_provinces =
> UserProvince.objects.select_related().filter(user__exact=self.instance.id).values_list('province')
>         self.fields['province'].queryset =
> Province.objects.exclude(id__in=user_provinces).only('id', 'name')
>     province = forms.ModelChoiceField(queryset=None, empty_label=None)
>     range_type = forms.CharField(initial='province',
> widget=forms.HiddenInput())
>     class Meta:
>         model = UserProvince
>         fields = ('province',)
> view:
> if request.POST:
>         form = ProvinceForm(request.POST, instance=request.user)
>         if form.is_valid():
>             obj = form.save(commit=False)
>             obj.user = request.user
>             obj.save()
> form is valid, but save method makes no effect :/
>

Your form is a ModelForm for a UserProvince model, and you are passing
in an django.contrib.auth.User instance as the instance. This is
wrong!
If you are editing an existing UserProvince instance, then pass that
object to the form as the instance. If you are creating a new
UserProvince instance, then do not pass in instance.

If you want your form to automatically associate the user with the
instance, then that user should be passed to the form's constructor,
and override save() to associate it with the instance, eg:

class FooForm(forms.ModelForm):
 def __init__(self, *args, **kwargs):
   self.user = kwargs.pop('user')
   super(FooForm, self).__init__(*args, **kwargs)
 def save(commit=False):
   foo = super(FooForm, self).save(commit=False)
   if not foo.user:
 foo.user = self.user
   if commit:
 foo.save()
   return foo

Cheers

Tom

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

2011-02-24 Thread urukay
Hi,

maybe you can try to use autocomplete function with JQuery, but i
don't fully understand what you mean.

Radovan

On 23. Feb, 20:02 h., yuri2k  wrote:
> Anyone?
>
> On 23 Fev, 10:14, yuri2k  wrote:
>
> > I need to find a way to use a glossary (sort of 
> > likehttps://github.com/kcunning/django-glossary) but that can be called
> > when you insert a new entry elsewhere on the data structure (i.e., any
> > page with text). The ideal would be to use a tag system to make this
> > insertion simple, but ultimately, an html link with a specific class
> > will do. The objective is to then have them displayed on the front end
> > as tooltips or something similar. Any clues appreciated.
>
>

-- 
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: field choices() as queryset?

2011-02-24 Thread galago
I think it works. Thanks. What I did:
changed the form cal in view:
form_provinces_to_add = ProvinceForm(request.POST, user=request.user)

changed a form a little:
class ProvinceForm(ModelForm):
def __init__(self, *args, **kwargs):
self.user = kwargs.pop('user')
super(ProvinceForm, self).__init__(*args, **kwargs)
user_provinces = 
UserProvince.objects.select_related().filter(user__exact=self.user.id).values_list('province')
self.fields['province'].queryset = 
Province.objects.exclude(id__in=user_provinces).only('id', 'name')

province = forms.ModelChoiceField(queryset=None, empty_label=None, 
label=_(u'Wybierz województwo'))
range_type = forms.CharField(initial='province', 
widget=forms.HiddenInput())

class Meta:
model = UserProvince
fields = ('province',)

def save(self, commit=True):
foo = super(ProvinceForm, self).save(commit=False)
foo.user = self.user
if commit:
foo.save()
return foo

The line You wrote: if not foo.user:  makes an error when posting:

No exception supplied

Exception Type:
  DoesNotExist

\django\db\models\fields\related.py in __get__, line 301

commit True
self 
foo Error in formatting: 

-- 
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: pgadmin vs schema migration

2011-02-24 Thread ggavy

Thanks. It's good to get a little second opinion. I'm sure I'll make
the switch to migration tools eventually as things become a little
more involved.

Cheers
gav



On Feb 24, 11:58 am, Mike Ramirez  wrote:
> On Thursday, February 24, 2011 03:48:18 am ggavy wrote:
>
> > Hello everyone,
> >     if I have a live app running off a postgres db (containing data)
> > and I want to make reasonably simple schema (and possibly data
> > content) changes, are there any dangers in just using pgadmin (e.g
> > adding a column) as opposed to using some type of migration software,
> > e.g. south. I'd keep my models.py up-to-date with any changes I make
> > to the database (in case of future uses of the app). I haven't seen
> > anything online warning me not to do it, but the separation worries me
> > slightly
>
> > Thanks
>
> prior to the migration systems (south/evolution) and even after that for
> awhile, it was the defualt way, to manage it manually. The migration tools
> just make it easier.
>
> As long as you keep your table and model definitions, and create/insert/update
> statements all in line, it's safe.
>
> Personally,I'm with all the others and suggest you use migration tools, unless
> this is a one off and not going to be doing this a lot, Then I do find it just
> faster and easier to do it manually.
>
> Mike.
>
> --
> Vermouth always makes me brilliant unless it makes me idiotic.
>                 -- E.F. Benson

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



CSRF question

2011-02-24 Thread CristiM1
Hi,

how can I make a RESTful interface working with CSRF if there are
multiple servers involved. So we have a REST API that will be deployed
on one server and multiple servers for retrieving the HTML (this HTML
will use AJAX to call the REST)

thanks,
Cristian

-- 
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-pluggables urlconf problem (NoReverseMatch TemplateSyntaxError)

2011-02-24 Thread Andre Terra
Hello, folks


I'm trying to use django-pluggables (
https://github.com/nowells/django-pluggables) and I'm having a very hard
time figuring out how to set it up. The documentation is slender and the
example app has the same name as its one and only model, which is very
different from my case. So far, a lot is working, but the pluggable urlconf
has been giving me a real hard time for a couple of days now.

I have a main app called 'analysis' that defines models Order and Customer.
I also have a secondary app called 'report' which I would like to use to
generate statistics on Orders and Customers on a table-level.

The problem is that I can't do an url reverse on urls defined on that
'report' app, no matter how I try to import its urls. If anyone could please
explain how django-pluggables expects me set this up, I'd be eternally
thankful.

Here are some tiny, yet relevant parts of my code which should make my case
clearer:

http://tinyurl.com/analysis-urls
http://tinyurl.com/analysis-views
http://tinyurl.com/report-urls-traditional

I think one of the issues that needs attention is this line from the example
app:
https://github.com/nowells/django-pluggables/blob/master/examples/sillywalks/views.py#L62

What exactly am I supposed to pass to my version of that class?

Finally, my traceback:
http://dpaste.com/444858/

FTR, using {% url %} instead of {% pluggable_url %} yields the same error.

Thanks again in advance!


Sincerely,
Andre Terra

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



date_hierarchy with datetime field stored in another model

2011-02-24 Thread Marc Aymerich
Hi,
I want to provide an admin date_hierarchy filter for a model that
actually doesn't have a datetime field itself. The datetime value for
each object is stored in another model. It's possible to define a
date_hierarchy filter in this scenario?

I've tried to use date_hierarchy with a property that retrieves the
datetime value for each object, but django raise this exception:
ImproperlyConfigured 'ContactAdmin.date_hierarchy' refers to field
'subscribe' that is missing from model 'Contact'.

Any idea?
Thanks!!!



--
Marc

-- 
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: mod_wsgi or mod_fcgi

2011-02-24 Thread Eugene MechanisM
I'll advice you to use nginx+uwsgi stack.

-- 
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: WSGI eating search args?

2011-02-24 Thread Christoph Pingel
Thanks,
I tracked it down. Nothing to do with WSGI, it's just that SQLite
doesn't support REGEXP on the target platform.

best regards,
Christoph


On Feb 24, 12:22 pm, Tom Evans  wrote:

>
> You get a 500 if your view raises an exception. Since you aren't
> showing the exception traceback, any advice would be speculation.
>
> Cheers
>
> Tom

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

2011-02-24 Thread Greg Corey
Pardon the continued confusion, but the problem is that I don't know how to
access the model field to get it's associated label like I can when
rendering a form. I don't want to manually type out each label text in my
template because I like knowing that if I do need to change the label, I can
change it in the model and then I don't have to worry about my templates
because they just reference the model (DRY).

Thanks for you help.

Greg

On Wed, Feb 23, 2011 at 5:22 PM, Mike Ramirez  wrote:

>  On Wednesday, February 23, 2011 04:16:51 pm Greg Corey wrote:
>
> > Thanks for your reply. One question.
>
> >
>
> > > make sure to reference the model field you want as the label if
>
> > > 'Requester' isn't it.
>
> >
>
> > Not sure what you mean by this. Do you just mean manually change
>
> > 'Requester' to whatever I want, or that I really can reference the model
>
> > field to get the label?
>
> >
>
> > Greg
>
> >
>
> Both, what ever fits your needs.
>
> Mike
>
> --
>
> To be trusted is a greater compliment than to be loved.
>
>  --
> 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.
>

-- 
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: Queryset cloning is very expensive

2011-02-24 Thread myx
I found a solution which is suitable for me.
As it turns out, all those methods just clone queryset, and then call
appropriate methods of Query object.
So, for example, to set ordering and to get a slice without cloning
queryset, I can do the following:

qs.query.add_ordering('-created')
qs.query.set_limits(high=10)

-- 
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: label_tag in queryset

2011-02-24 Thread Greg Corey
Ok. So it seems you can't access the field verbose_name without a little
trickery. So here is how I did it.

Model:
def get_fields(self):
return [(field.name, field.value_to_string(self)) for field in
self._meta.fields]

Template Filter:
@register.filter
def get_verbose_name(model, field):
return send = model._meta.get_field('%s' % field).verbose_name
get_verbose_name.is_safe = True

Template:
{% for name, value in inspection.get_fields %}

{{ inspection|get_verbose_name:name }}

{{ value }}


{% endfor %}

If anyone sees any major problems with this please let me know. But it seems
to work quite well.

Greg

On Thu, Feb 24, 2011 at 9:15 AM, Greg Corey  wrote:

> Pardon the continued confusion, but the problem is that I don't know how to
> access the model field to get it's associated label like I can when
> rendering a form. I don't want to manually type out each label text in my
> template because I like knowing that if I do need to change the label, I can
> change it in the model and then I don't have to worry about my templates
> because they just reference the model (DRY).
>
> Thanks for you help.
>
> Greg
>
>
> On Wed, Feb 23, 2011 at 5:22 PM, Mike Ramirez  wrote:
>
>>  On Wednesday, February 23, 2011 04:16:51 pm Greg Corey wrote:
>>
>> > Thanks for your reply. One question.
>>
>> >
>>
>> > > make sure to reference the model field you want as the label if
>>
>> > > 'Requester' isn't it.
>>
>> >
>>
>> > Not sure what you mean by this. Do you just mean manually change
>>
>> > 'Requester' to whatever I want, or that I really can reference the model
>>
>> > field to get the label?
>>
>> >
>>
>> > Greg
>>
>> >
>>
>> Both, what ever fits your needs.
>>
>> Mike
>>
>> --
>>
>> To be trusted is a greater compliment than to be loved.
>>
>>  --
>> 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.
>>
>
>

-- 
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: Python/Django AMQP?

2011-02-24 Thread Brian Bouterse
+1 for Celery and django-celery.  I use them also.

On Thu, Feb 24, 2011 at 9:07 AM, Shawn Milochik  wrote:

> +1 on Celery and django-celery. I use them both.
>
> --
> 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.
>
>


-- 
Brian Bouterse
ITng Services

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

2011-02-24 Thread Lee Hinde
On Thu, Feb 24, 2011 at 1:32 AM, Tom Evans  wrote:
> On Wed, Feb 23, 2011 at 9:17 PM, Lee Hinde  wrote:
>> Except, now the data that's in the database for the username field
>> goes from looking like this:
>> leehinde
>> to this
>> (u'leehinde',)
>>
>> I'd like it to be 'leehinde' again
>> so, clearly objects.create is more clever than my pure post. But I'm
>> not sure where in the food chain I should be interceding..
>>
>
> http://docs.djangoproject.com/en/1.2/ref/unicode/#general-string-handling
>
> """
> In most cases when Django is dealing with strings, it will convert
> them to Unicode strings before doing anything else. So, as a general
> rule, if you pass in a bytestring, be prepared to receive a Unicode
> string back in the result.
> """
>
> Be prepared :)
>

Thanks Tom; sadly I'm ill-prepared.

a) It's curious that the two django methods (get_or_create vs create)
do different things.
b) I tried wrapping the form fields in str() and got an error, but
I'll play with that some more and figure out why.

I'd found that page, as I really did google 'django unicode, etc.'
before posting. :-) but it assumes more python skill than I have this
week.

-- 
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: Problem with unicode in form posts

2011-02-24 Thread Tom Evans
On Thu, Feb 24, 2011 at 5:17 PM, Lee Hinde  wrote:
> On Thu, Feb 24, 2011 at 1:32 AM, Tom Evans  wrote:
>> On Wed, Feb 23, 2011 at 9:17 PM, Lee Hinde  wrote:
>>> Except, now the data that's in the database for the username field
>>> goes from looking like this:
>>> leehinde
>>> to this
>>> (u'leehinde',)
>>>
>>> I'd like it to be 'leehinde' again
>>> so, clearly objects.create is more clever than my pure post. But I'm
>>> not sure where in the food chain I should be interceding..
>>>
>>
>> http://docs.djangoproject.com/en/1.2/ref/unicode/#general-string-handling
>>
>> """
>> In most cases when Django is dealing with strings, it will convert
>> them to Unicode strings before doing anything else. So, as a general
>> rule, if you pass in a bytestring, be prepared to receive a Unicode
>> string back in the result.
>> """
>>
>> Be prepared :)
>>
>
> Thanks Tom; sadly I'm ill-prepared.
>
> a) It's curious that the two django methods (get_or_create vs create)
> do different things.
> b) I tried wrapping the form fields in str() and got an error, but
> I'll play with that some more and figure out why.
>
> I'd found that page, as I really did google 'django unicode, etc.'
> before posting. :-) but it assumes more python skill than I have this
> week.
>

Why is it curious? get_or_create() does different things to create() -
create() always tries to create a new instance with the attributes you
give it, where as get_or_create() always tries to retrieve an object
with the attributes you give it, and only if that does not exist,
tries to create it.

Accordingly, create() returns an instance of the model, and
get_or_create() returns a 2-tuple of (instance, was_created).

Why would you wrap fields in str()? Just use unicode, you are making
life more difficult for yourself by wanting to coerce everything to
ascii.

Cheers

Tom

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



TypeError: unhashable type: 'ManyToManyField'

2011-02-24 Thread Julian Hodgson
I'm getting this error message when I try to validate even a brand new
project and application.

Does this ring any bells with anyone?

Windows XP 64
I'm using Django 1.1.1 (but it still happens with 1.1.4)
Python 2.6 (winxp 64)

In my actual database I can only connect when I remove by ManyToMany
fields.

I don't mind hacking the code to fix this but I need some pointers as
to what's happening!

Check here for the error:

http://dpaste.com/444668/

Best,

Julian

-- 
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: mod_wsgi or mod_fcgi

2011-02-24 Thread Eric Chamberlain

On Feb 23, 2011, at 11:10 PM, Shamail Tayyab wrote:

> Hi,
> 
>   I am going to deploy a site today on an Amazon's large instance.
> Our setup is like this:
> 
> server 1: mongoDB + redis server
> server 2: django + nodejs
> 
> We are using node for server push things. Can you please suggest what
> would be the best way to deploy django as? (via wsgi or fcgi). We've
> planned to use lighttpd (apache can also be used if required).
> 

We've been using lighttpd with fastcgi for a few years without problems.

I'd be interested in hearing more about what others like about nginx over 
lighttpd.  We originally went with lighttpd, because that's what one of our 
developers knew how to configure.

--
Eric Chamberlain, Founder
RF.com - http://RF.com/







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



Re: Collaborative text editor with Django

2011-02-24 Thread Piotr Zalewa
On 02/23/11 08:32, Anoop Thomas Mathew wrote:
> Is there any collaborative text editing application available for django.
> Has anybody tried with etherpad(www.etherpad.org
> ) along with django?

If you'd start building it - I'd be collaborating.

zalun
-- 
blog  http://piotr.zalewa.info
jobs  http://webdev.zalewa.info
twit  http://twitter.com/zalun
face  http://facebook.com/zaloon

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



Tracking Row changes

2011-02-24 Thread Andre Terra
Hello everyone,

I'd like to log user changes to MyModel in an app I'm writing. What are some
third-party solutions that you recommend for this? I'm not so interested in
revision capabilities because I think that may increase the db tremendously
in a very short time (I'm working with 2000+ new rows/month). The important
thing here is that admins be allowed to see a detailed history user actions
on a per-row basis.

Thanks in advance for your help.


Sincerely,
André Terra

-- 
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: mod_wsgi or mod_fcgi

2011-02-24 Thread Eugene MechanisM
You can check out this tutorial:
http://www.jeremybowers.com/blog/post/5/django-nginx-and-uwsgi-production-serving-millions-page-views/
I prefer to use also Varnish and Memcached with this stack.
Nginx is best for static files. and will proxy non-static requests to
uwsgi.
nginx+uwsgi it's the best stack out there for deploying django.Forget
about slow apache and lighttpd.
also nice choise is cherokee+uwsgi.

-- 
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: Tracking Row changes

2011-02-24 Thread elijah rutschman
On Thu, Feb 24, 2011 at 2:54 PM, Andre Terra  wrote:
> Hello everyone,
> I'd like to log user changes to MyModel in an app I'm writing. What are some
> third-party solutions that you recommend for this?

django-activity-stream might meet your needs.
https://github.com/justquick/django-activity-stream

Regards,
Elijah

-- 
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: mod_wsgi or mod_fcgi

2011-02-24 Thread Cal Leeming [Simplicity Media Ltd]
Yeah, don't use cherokee.

I used this for several months, and encountered all kinds of horrible memory
allocation problems, crashes, etc etc.

On Thu, Feb 24, 2011 at 9:15 PM, Eugene MechanisM <
eugene.mechan...@gmail.com> wrote:

> You can check out this tutorial:
>
> http://www.jeremybowers.com/blog/post/5/django-nginx-and-uwsgi-production-serving-millions-page-views/
> I prefer to use also Varnish and Memcached with this stack.
> Nginx is best for static files. and will proxy non-static requests to
> uwsgi.
> nginx+uwsgi it's the best stack out there for deploying django.Forget
> about slow apache and lighttpd.
> also nice choise is cherokee+uwsgi.
>
> --
> 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.
>
>

-- 
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: Tracking Row changes

2011-02-24 Thread Andre Terra
Thanks a lot! Will look into it first thing tomorrow.

Meanwhile, if anyone has other suggestions, keep them coming, please. Thanks
in advance!


Sincerely,
André

On Thu, Feb 24, 2011 at 6:15 PM, elijah rutschman  wrote:

> On Thu, Feb 24, 2011 at 2:54 PM, Andre Terra  wrote:
> > Hello everyone,
> > I'd like to log user changes to MyModel in an app I'm writing. What are
> some
> > third-party solutions that you recommend for this?
>
> django-activity-stream might meet your needs.
> https://github.com/justquick/django-activity-stream
>
> Regards,
> Elijah
>

-- 
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: Queryset cloning is very expensive

2011-02-24 Thread Karen Tracey
On Thu, Feb 24, 2011 at 11:20 AM, myx  wrote:

> I found a solution which is suitable for me.
> As it turns out, all those methods just clone queryset, and then call
> appropriate methods of Query object.
> So, for example, to set ordering and to get a slice without cloning
> queryset, I can do the following:
>
> qs.query.add_ordering('-created')
> qs.query.set_limits(high=10)
>
>
Note you are now using a Django-internal API that is not guaranteed to be
stable (see http://docs.djangoproject.com/en/1.2/misc/api-stability/). Your
code could very well break in some future version of Django.

Karen
-- 
http://tracey.org/kmt/

-- 
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: mod_wsgi or mod_fcgi

2011-02-24 Thread Eugene MechanisM
> I used this for several months, and encountered all kinds of horrible memory
> allocation problems, crashes, etc etc.
it's can be posiible with any server software if this server is bad
configured.
I'll never use apache or cherokee or lighttpd, coz nginx faster and
better.

-- 
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: pgadmin vs schema migration

2011-02-24 Thread Rainy


On Feb 24, 9:54 am, ggavy  wrote:
> Thanks. It's good to get a little second opinion. I'm sure I'll make
> the switch to migration tools eventually as things become a little
> more involved.
>
> Cheers
> gav

I think the only possible danger is that you might forget to toggle
an option like IS NULL in pgadmin or use a slightly different
field type and then when you deploy somewhere else and use
syncdb, the db layout will be different, which may or may not
be a problem.

Having said that, I usually find pgadmin to be a bit easier to
use and for small changes it's just fine. South will slow down
unittests because all migrations have to be applied in
sequence, and then you might want to reset history and
that's a bit of hassle, too.

 -Rainyday

-- 
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: Tracking Row changes

2011-02-24 Thread Chris Matthews
Hi Andre,

Also have a look at:
http://code.google.com/p/django-history-tables/
and
http://qr7.com/2010/10/django-simple-history-ftw/ by Corey Bertram based on 
book ProJango by Marty Alchin Chapter 11 (page 263 onwards)

Regards
Chris
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Andre Terra
Sent: 25 February 2011 00:56
To: elijah rutschman
Cc: django-users@googlegroups.com
Subject: Re: Tracking Row changes

Thanks a lot! Will look into it first thing tomorrow.

Meanwhile, if anyone has other suggestions, keep them coming, please. Thanks in 
advance!


Sincerely,
André
On Thu, Feb 24, 2011 at 6:15 PM, elijah rutschman 
mailto:elij...@gmail.com>> wrote:
On Thu, Feb 24, 2011 at 2:54 PM, Andre Terra 
mailto:andrete...@gmail.com>> wrote:
> Hello everyone,
> I'd like to log user changes to MyModel in an app I'm writing. What are some
> third-party solutions that you recommend for this?
django-activity-stream might meet your needs.
https://github.com/justquick/django-activity-stream

Regards,
Elijah

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

-- 
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: Multi-table Inheritance: How to add child to parent model?

2011-02-24 Thread Luc Saffre
I had now a similar problem and started to write a generic solution
which is certainly not perfect, but works for me. Here is a detailed
description:

http://lino.saffre-rumma.net/autodoc/lino.test_apps.1.html

Looking forward to any comments.
Luc


On 7.11.2010 17:19, ringemup wrote:
> Thank you for the pointer to ticket #11618, Stefan.  At this point, I
> don't care if the workaround is ugly -- if it actually works, at least
> I'll be able to move forward with this project.  I'll test it out and
> check back in to confirm whether it does.
> 
> 
> On Nov 7, 9:03 am, Stefan Foulis  wrote:
>> As far as I know there is no existing api to convert a 'Place' into a
>> 'Restaurant' with multi-table inheritance in django. There is a ticket
>> about this [1]. And in another ticket [2] that is marked as a
>> duplicate but seems to have an example of how to solve this problem
>> until there is a standard api for the operation. Translated to the
>> Restaurant example this would be:
>>
>> restaurant = Restaurant(place_ptr = place)
>> for f in place._meta.local_fields: setattr(restaurant, f.name,
>> getattr(place, f.name))
>> restaurant.save()
>>
>> [1]http://code.djangoproject.com/ticket/7623
>> [2]http://code.djangoproject.com/ticket/11618
>>
>> On Nov 4, 9:25 pm, ringemup  wrote:
>>
>>> I have an existing model that I want to extend using multi-table
>>> inheritance.  I need to create a child instance for each parent
>>> instance in the database, but I can't figure out how.  I've scoured
>>> google and haven't come up with anything other than Ticket #7623[1].
>>> Here are some of the things I've tried...
>>
>>> Let's adapt the Place / Restaurant example from the docs:
>>
>>> class Place(models.Model):
>>> name = models.CharField(max_length=50)
>>> address = models.CharField(max_length=80)
>>
>>> class Restaurant(Place):
>>> place = models.OneToOneField(Place, parent_link=True,
>>> related_name='restaurant')
>>> serves_hot_dogs = models.BooleanField()
>>> serves_pizza = models.BooleanField()
>>
>>> I want to do the following, in essence:
>>
>>> for place in Place.objects.all():
>>>   restaurant = Restaurant(**{
>>> 'place': place,
>>> 'serves_hot_dogs': False,
>>> 'serves_pizza': True,
>>>   })
>>>   restaurant.save()
>>
>>> Of course, doing this tries to also create a new Place belonging to
>>> the new Restaurant, and throws an error because no values have been
>>> specified for the name and address fields.  I've also tried:
>>
>>> for place in Place.objects.all():
>>>   restaurant = Restaurant(**{
>>> 'serves_hot_dogs': False,
>>> 'serves_pizza': True,
>>>   })
>>>   place.restaurant = restaurant
>>>   place.save()
>>
>>> This, however, doesn't create any records in the restaurant table.
>>
>>> Any suggestions?
>>
>>> [1]http://code.djangoproject.com/ticket/7623
>>
>>
> 

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