Re: What is `sys.path` supposed to be?

2010-09-17 Thread bruno desthuilliers
On 16 sep, 18:06, cool-RR  wrote:
> Hello!
>
> There's something that's bothering me:
>
> When developing a Django application, what is `sys.path` supposed to
> contain? The directory which contains the project, or the directory of
> the project, or both?

sys.path always starts with the directory where the current script
lives - so when running './manage.py runserver', sys.path will always
starts with your project's directory. This is teh default Python
behaviour. Also and IIRC, django adds the project's parent directory
to sys.path too.

> What led me to this question is a failure when using
> `urlresolvers.reverse`. It's giving me a `NoReverseMatch` error, and
> it seems that the reason is that there are two different versions of
> my view function; One with a `__module__` of `my_app.views` and one
> with a `__module__` of `my_project.my_app.views`.

I bet you have a full import (=> 'myproject.my_app.views') somewhere
in your sources.

As far as I'm concerned, I *never* use any reference to the project's
package in my imports - this gives much more flexibility (you can
rename your project's directory, move apps outside the project's
directory etc without having to update all your imports). The only
caveat is that, when deploying with mod_wsgi, you have to make sure
you add the project's directory itself to sys.path (which is no bige
deal).

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



Re: Multi-table + Abstract Model Inheritance

2010-09-17 Thread bruno desthuilliers
On 16 sep, 22:11, ringemup  wrote:
> Is it possible for a model to inherit from an abstract model, which in
> turn inherits from a non-abstract model?

I don't thinks so, but I may be wrong. Now nothing prevents you from
trying by yourself, it shouldn't take long to find out !-)

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



Re: Unit testing in django without using test client

2010-09-17 Thread Carlton Gibson
Hi Girish,

On 17 Sep 2010, at 06:28, girish shabadimath wrote:

> thanks for d reply,,,but im new to python n django,,,dint do ne python unit 
> testing before,,can u plz give me some links or hints to start with...


IN that case I'd recommend this book: 

http://www.amazon.com/Django-Testing-Debugging-Karen-Tracey/dp/1847197566/

It's very good. It says 1.1 in the title but it'll be good for any 1.x at 
least. 

If you don't want the paper version, I know Packt do ebooks too.

Regards,
Carlton

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



django-mailer truncate my log file

2010-09-17 Thread ferran
hello,
I don't understand because django-mailer truncate my log file every
time run cronjob for send email, this is my config in settings.py
import logging

LOGFILE = "site.log"
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(name)-12s %(levelname)-8s %
(lineno)d %(message)s',
datefmt='%a, %d %b %Y %H:%M:%S',
filename=os.path.join(PROJECT_PATH, LOGFILE),
filemode='w')

and in models or view i use:
import logging
log = logging.getLogger("order.views")
log.debug("hello")

, any idea?
thanks in advanced

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



gunicorn not print debug info as run_server command

2010-09-17 Thread ferran
Howto config gunicorn for view in the console debug info, as the same,
run_server command?

Thanks in advanced

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



Re: Mudar Senha de um usuário

2010-09-17 Thread Nuno Maltez
Hi,

If the user is logged in, instead of

user = User.objects.get(username=nome)

you can use

user = request.user

See:
http://docs.djangoproject.com/en/dev/topics/auth/#authentication-in-web-requests

Nuno



2010/9/17 Giovanna Ronzé :
> Dado que um usuário está logado e quer mudar sua senha, como eu faço
> para o django mudar a senha daquele user sem que seja preciso que ele
> preencha esse campo (do nick)?
>
> Bem, para resolver esse problema, primeiro eu fiz de uma forma que
> necessitava do user dizer o nick.
> Pesquisando, eu vi que tinha uma classe PasswordChangeForm e tentei
> usar. Olha, se alguém me ensinar como se usa de fato (tanto no
> urls.py, no html e no views.py se possível ^.^) tudo bem. Mas eu
> realmente não consegui aplicar essa classe.
>
> Diante disso, voltei para ideia inicial de construir minha própria
> função. O problema voltou a ser o tal do campo user. Já que o usuário
> está logado, como eu 'pego' seu campo de username pelo views.py?
>
> Aí está a tentativa dessa função e os trechos de código relativos:
>
> [views.py]
>
> @login_required
> def mudar_senha (request):
>        return render_to_response('matematica/mudar_senha.html')
>
> @login_required
> def mudar_senha_dados (request):
>        erro = False
>        nome = request.POST['username']
>        user = User.objects.get(username=nome)
>
>        if request.POST['password'] == '':
>                erro = True
>                return render_to_response('matematica/mudar_senha.html', 
> {'erro':
> erro})
>        else:
>                user.set_password(request.POST['new_password'])
>                user.save()
>                return HttpResponseRedirect('/')
>
> [mudar_senha.html]
>
>                 method="post">
>
>                        Nova senha 
>                                 type="password">
>                                        {{ form.new_password }}
>                        
>
>
>                        
>                        
>
> [urls.py]
>
>        (r'^mudar_senha/', 'projeto.matematica.views.mudar_senha'),
>        (r'^mudar_senha_dados/',
> 'projeto.matematica.views.mudar_senha_dados'),
>
> Bem. Desde já agradeço a atenção.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Mudar Senha de um usuário

2010-09-17 Thread werefr0g

 Hello,

I don't accuratly understand what your asking for, sorry. Have you seen 
what's in http://docs.djangoproject.com/en/1.2/topics/auth/ ? I think 
that views.password_change already manages what your describing. If not, 
could you express what doesn't fit your expectations, please?


Regards

Le 17/09/2010 04:25, Giovanna Ronzé a écrit :

Dado que um usuário está logado e quer mudar sua senha, como eu faço
para o django mudar a senha daquele user sem que seja preciso que ele
preencha esse campo (do nick)?

Bem, para resolver esse problema, primeiro eu fiz de uma forma que
necessitava do user dizer o nick.
Pesquisando, eu vi que tinha uma classe PasswordChangeForm e tentei
usar. Olha, se alguém me ensinar como se usa de fato (tanto no
urls.py, no html e no views.py se possível ^.^) tudo bem. Mas eu
realmente não consegui aplicar essa classe.

Diante disso, voltei para ideia inicial de construir minha própria
função. O problema voltou a ser o tal do campo user. Já que o usuário
está logado, como eu 'pego' seu campo de username pelo views.py?

Aí está a tentativa dessa função e os trechos de código relativos:

[views.py]

@login_required
def mudar_senha (request):
return render_to_response('matematica/mudar_senha.html')

@login_required
def mudar_senha_dados (request):
erro = False
nome = request.POST['username']
user = User.objects.get(username=nome)

if request.POST['password'] == '':
erro = True
return render_to_response('matematica/mudar_senha.html', 
{'erro':
erro})
else:
user.set_password(request.POST['new_password'])
user.save()
return HttpResponseRedirect('/')

[mudar_senha.html]



Nova senha

{{ form.new_password }}






[urls.py]

(r'^mudar_senha/', 'projeto.matematica.views.mudar_senha'),
(r'^mudar_senha_dados/',
'projeto.matematica.views.mudar_senha_dados'),

Bem. Desde já agradeço a atenção.



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



CRUD with FormWizard

2010-09-17 Thread MarcoS
Hi!
I've a Create-Read-Update-Delete application and some form with
multiple pages created with FormWizard.

How can i allow users to update data using a FormWizard?
With singles forms I'm using generic_views, but I can't figure how to
do this with FormWizards..

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



tracking changes of a model's attributes

2010-09-17 Thread Julian
hi,

i'm writing a little statistical app for a django-project. everytime a
very model is saved, something's stored in the db, depending on the
model's attributes. if one of the attributes changes, I have to change
the statisitical data otherwise it would leed to inconsistency. I need
to know the old value of the attribute. how do I get it?

for example: I have a model

class AModel(models.Model):
a = models.CharField(...)

class StatisticModel(models.Model):
a_value = models.CharField(...)
a_counter = mdoels.IntegerField(...)

on post_save() of a = AModel(a='a') I select the StatisticModel with
a_value = 'a' and increase a_counter by 1. If then a is saved again
with a = 'b', I have to decrease a_counter of the StatisticModel with
a_value = 'a' by 1 and increase it by 1 on another instance.

How can I do this?

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



Re: What is `sys.path` supposed to be?

2010-09-17 Thread cool-RR
On Sep 17, 10:13 am, bruno desthuilliers
 wrote:
> On 16 sep, 18:06, cool-RR  wrote:
>
> > Hello!
>
> > There's something that's bothering me:
>
> > When developing a Django application, what is `sys.path` supposed to
> > contain? The directory which contains the project, or the directory of
> > the project, or both?
>
> sys.path always starts with the directory where the current script
> lives - so when running './manage.py runserver', sys.path will always
> starts with your project's directory. This is teh default Python
> behaviour. Also and IIRC, django adds the project's parent directory
> to sys.path too.
>
> > What led me to this question is a failure when using
> > `urlresolvers.reverse`. It's giving me a `NoReverseMatch` error, and
> > it seems that the reason is that there are two different versions of
> > my view function; One with a `__module__` of `my_app.views` and one
> > with a `__module__` of `my_project.my_app.views`.
>
> I bet you have a full import (=> 'myproject.my_app.views') somewhere
> in your sources.
>
> As far as I'm concerned, I *never* use any reference to the project's
> package in my imports - this gives much more flexibility (you can
> rename your project's directory, move apps outside the project's
> directory etc without having to update all your imports). The only
> caveat is that, when deploying with mod_wsgi, you have to make sure
> you add the project's directory itself to sys.path (which is no bige
> deal).

Bruno, look at this line in `django/core/management/__init__.py`:

project_module = import_module(project_name)

It's importing the project. Isn't this a problem? I mean, every object
obtained from the imported project will be different from its
counterpart which was imported through an app. So what's going on?


Ram.

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



Annotate on a FK reverse relation gives FieldError: Cannot resolve keyword

2010-09-17 Thread martync
Hi,
I am experiencing an issue on annotate function only on my production
site only when executing the code on a normal navigation (the shell
command on production has no problem).

This is the pseudo code :

# models
class Competition(model):
title = char
published = bool
date = date
discipline = FK('Discipline')

class Discipline(model):
title = char

class Photo(model);
pict = image
competition = FK(Competition)


# views
def competition_list(request, competition_id):
cs =
Competition.objects.all(published=True).annotate(photo_count=Count('photo'))
\
 .select_related("discipline").order_by('-date')
# rendering ...

This view above works fine through the command line.
When it's executed with normal http request (a browser), it causes a
field error :
---
FieldError: Cannot resolve keyword 'photo' into field. Choices are :
(...All the choices including other reversed FK...)
---
Removing the annotate() removes the error.
I checked the db Indexes and they are all correct.

My actual configuration :
Django 1.1
Postgresql 8.3
Nginx
Gunicorn

Does anybody encountered the same issue ?

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



Re: How to clear wrong form data (e.g password field), but still show error?

2010-09-17 Thread Karen Tracey
On Thu, Sep 16, 2010 at 10:55 PM, Brian Neal  wrote:

> On Sep 16, 7:37 pm, Karen Tracey  wrote:
> >
> > Use this widget for the field:
> >
> > http://docs.djangoproject.com/en/1.2/ref/forms/widgets/#django.forms
> >
> > with render_value=False
> >
> Note that the docs indicate the default value for render_value is True
> but in the code it is False:
>
>
> http://code.djangoproject.com/browser/django/trunk/django/forms/widgets.py#L232


That was a recent change (http://code.djangoproject.com/changeset/13498) and
is why I pointed to the 1.2 docs instead of the dev ones in answering. For
anyone using an official release, it is necessary to pass render_value=False
to get the desired behavior; for anyone using current trunk, it is not
necessary but also not harmful. For a while it will be safest for anyone
really desiring this behavior to pass render_value=False, that way the code
will work as intended on both current and older levels 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django v1.1

2010-09-17 Thread Robbington
Hey,

I keep getting this annoying problem that when I download and install
a new django package, say django-registration it reverts django from
version 1.2 to 1.1... Is there anyway to avoid this as it messes up my
databases each time for each django project I am running.

I've used a variety of methods for getting these packages,
easy_install, aptitude install, pip install all of the seem to do it..

And does any one know the best way to upgrade django back to version
1.2, do I have to delete it and start again?

Thanks

Rob

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



Re: Django v1.1

2010-09-17 Thread Piotr Zalewa
 Hi Robbington.

I'd suggest to use virtualenv and keep to use *only* pip
that way only you have the power to change anything
to update Django to a version above 1.2 simply
pip -E your_virtual_environment install Django>=1.2

zalun

On 09/17/10 13:02, Robbington wrote:
> Hey,
>
> I keep getting this annoying problem that when I download and install
> a new django package, say django-registration it reverts django from
> version 1.2 to 1.1... Is there anyway to avoid this as it messes up my
> databases each time for each django project I am running.
>
> I've used a variety of methods for getting these packages,
> easy_install, aptitude install, pip install all of the seem to do it..
>
> And does any one know the best way to upgrade django back to version
> 1.2, do I have to delete it and start again?
>
> Thanks
>
> Rob
>


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



template problem with login.html

2010-09-17 Thread ozgur yilmaz
Hi,

I built a site with django. Now i have a stupid (i couldnt understand) problem.

Everything works perfect but when i try to login and
registration/login.html is rendered, there is a margin at the top of
the login.html. And the font size increases 1 or 2 points. Font family
and other css elements remains same...

Any idea?

Thanks to all,

Ozgur

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



Re: Django v1.1

2010-09-17 Thread Robbington
Cool, thanks.

I guess I will have to start using virtualenv, it came installed with
my vps stack script, but I disabled it as I was having probs using
postgres. I guess I never gave it a great deal of time.

I just dont get why its now reverted to v1.1, its not even on my
python path, print sys.path shows only djangov1.2.egg on there..

Frustrating.

Rob

On Sep 17, 1:04 pm, Piotr Zalewa  wrote:
>  Hi Robbington.
>
> I'd suggest to use virtualenv and keep to use *only* pip
> that way only you have the power to change anything
> to update Django to a version above 1.2 simply
> pip -E your_virtual_environment install Django>=1.2
>
> zalun
>
> On 09/17/10 13:02, Robbington wrote:
>
>
>
>
>
> > Hey,
>
> > I keep getting this annoying problem that when I download and install
> > a new django package, say django-registration it reverts django from
> > version 1.2 to 1.1... Is there anyway to avoid this as it messes up my
> > databases each time for each django project I am running.
>
> > I've used a variety of methods for getting these packages,
> > easy_install, aptitude install, pip install all of the seem to do it..
>
> > And does any one know the best way to upgrade django back to version
> > 1.2, do I have to delete it and start again?
>
> > Thanks
>
> > Rob
>
> --
> blog  http://piotr.zalewa.info
> jobs  http://webdev.zalewa.info
> twit  http://twitter.com/zalun
> face  http://facebook.com/zaloon- Hide quoted text -
>
> - Show quoted text -

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



Re: Multi-table + Abstract Model Inheritance

2010-09-17 Thread ringemup

Sure, it's easy enough to find out if it works in a general sense --
but I'm also concerned about running into subtle bugs down the road,
and having to restructure my entire database as a result.


On Sep 17, 4:15 am, bruno desthuilliers
 wrote:
> On 16 sep, 22:11, ringemup  wrote:
>
> > Is it possible for a model to inherit from an abstract model, which in
> > turn inherits from a non-abstract model?
>
> I don't thinks so, but I may be wrong. Now nothing prevents you from
> trying by yourself, it shouldn't take long to find out !-)

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



Re: template problem with login.html

2010-09-17 Thread failuch

style of html documents depends on browser defaults which may take
precedence other your styles.

I rememer vaquely that there are browser rendering and some other
component rendering which affect resulted document appearence.
Try different browser at least.

On Sep 17, 2:19 pm, ozgur yilmaz  wrote:
> Hi,
>
> I built a site with django. Now i have a stupid (i couldnt understand) 
> problem.
>
> Everything works perfect but when i try to login and
> registration/login.html is rendered, there is a margin at the top of
> the login.html. And the font size increases 1 or 2 points. Font family
> and other css elements remains same...
>
> Any idea?
>
> Thanks to all,
>
> Ozgur

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



Re: tracking changes of a model's attributes

2010-09-17 Thread failuch
just an idea - use database triggers

On Sep 17, 12:53 pm, Julian  wrote:
> hi,
>
> i'm writing a little statistical app for a django-project. everytime a
> very model is saved, something's stored in the db, depending on the
> model's attributes. if one of the attributes changes, I have to change
> the statisitical data otherwise it would leed to inconsistency. I need
> to know the old value of the attribute. how do I get it?
>
> for example: I have a model
>
> class AModel(models.Model):
>     a = models.CharField(...)
>
> class StatisticModel(models.Model):
>     a_value = models.CharField(...)
>     a_counter = mdoels.IntegerField(...)
>
> on post_save() of a = AModel(a='a') I select the StatisticModel with
> a_value = 'a' and increase a_counter by 1. If then a is saved again
> with a = 'b', I have to decrease a_counter of the StatisticModel with
> a_value = 'a' by 1 and increase it by 1 on another instance.
>
> How can I do this?

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



Tying a model to a specific database using the model's meta data?

2010-09-17 Thread Stodge
I have a bunch of models and I want to specify which models (tables)
are stored on which PostgreSQL database. I've read the documentation
and I know I can use the using() function. I'm just wondering this
can't be specified in the model's meta data:

class Meta:
using = 'db_name'

or:


class Meta:
db_server = 'db_name'

Where the db_name maps to the name specified in settings.py. I'm
adding in Django support to an existing application so this would
avoid littering my code with using() function calls. I know I could
use a database router but that seems like overkill when it makes more
sense to define the database in the model's meta data. Any ideas why
this is?

Thanks

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



Adding username to the 500 error emails

2010-09-17 Thread Chase
I'm looking to add request.user.username to the content of the 500
error email that gets sent to settings.ADMINS. Of course, this assumes
that you're using the AuthenticationMiddleware.

I've tried the following:

 - Adding username to request.COOKIES via response.set_cookie(). This
works, but if you have several authentication mechanisms, you end up
repeating this code in various places.

 - Over-riding WSGIRequest.__repr__? No idea how this could be done.

 - Over-riding handle_uncaught_exception() in BaseHandler. Not sure
how this could be done, either.

Ideas?

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



RE: Adding username to the 500 error emails

2010-09-17 Thread Henrik Genssen
Hi,

add a middleware class and write a 

def process_exception(self, request, exception):

function where you send the mail yourself.
look at http://bitbucket.org/ashcrow/django-error-capture-middleware to get an 
idea,
of how to preceed errors yourself...

regards

Hinnack

>reply to message:
>date: 17.09.2010 09:30:00
>from: "Chase" 
>to: "Django users" 
>subject: Adding username to the 500 error emails
>
>I'm looking to add request.user.username to the content of the 500
>error email that gets sent to settings.ADMINS. Of course, this assumes
>that you're using the AuthenticationMiddleware.
>
>I've tried the following:
>
> - Adding username to request.COOKIES via response.set_cookie(). This
>works, but if you have several authentication mechanisms, you end up
>repeating this code in various places.
>
> - Over-riding WSGIRequest.__repr__? No idea how this could be done.
>
> - Over-riding handle_uncaught_exception() in BaseHandler. Not sure
>how this could be done, either.
>
>Ideas?
>
>-- 
>You received this message because you are subscribed to the Google Groups 
>"Django users" group.
>To post to this group, send email to django-us...@googlegroups.com.
>To unsubscribe from this group, send email to 
>django-users+unsubscr...@googlegroups.com.
>For more options, visit this group at 
>http://groups.google.com/group/django-users?hl=en.
>

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



How to create a base form for displaying lists

2010-09-17 Thread Thiago Padilha
  Hi,

  I'm trying to create a form that is specialized in displaying a list of
items. This form should have fields/features for filtering,  paging and
sorting. Here's what I have so far :

from django import forms
from django.db import models

class ModelListForm(forms.Form):

def display_grid(self):
qs = self.queryset()
c = self.__class__
html = ['',
''.join('%s' % ''.join(['%s' % f for f
in c.__flist__])),
''.join(['%s' % ''.join(['%s' %
getattr(r, f.__name__) for f in c.__flist__ for r in qs])]),
'']
return ''.join([tag for tag in html])


def introspect(self):
c = self.__class__
if not (hasattr(c, '__model__') and hasattr(c, '__flist__')):
if hasattr(c, 'Meta') and hasattr(c.Meta, 'model'):
c.__model__ = c.Meta.model
c.__flist__ = [field for field in dir(c.Meta.model) if
isinstance(field, models.Field)]
else:
raise Exception('No metadata about the model')

def queryset(self):
self.introspect()
model = self.__class__.__model__
return model.objects.all()


This is still very poorly written and not working(hey, I just got
started), but I guess its clear what I'm trying to do: Create a generic form
that will allow me to specify a model and perhaps some visible fields. When
rendered this form will output a table to display data for that specific
model. This would allow me to create generic templates to use with generic
views for displaying lists.
So far I have a single generic view for adding/editing instances of any
model, but these views/templates depend on me writing a proper ModelForm for
each model. Since I didnt found a 'ModelListForm' for displaying lists of
items I started trying to write one of my own.
   My question : Is there any ready-to-use solution that will allow me to do
something similar? I would rather use an existing solution for something
like that.

   Thanks in advance.

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



custom filter -- automatically apply first option

2010-09-17 Thread Julian
hi,

I've written successfully an custom filter for the admin-interface. if
I visit

http://localhost:8000/admin/usertracking/analyze/

coming from http://localhost:8000/admin/), none of the filters is
applied, although it's marked as "selected" on the right side on the
website. the reason is probably because you have to make a request
like

http://localhost:8000/admin/usertracking/analyze/?timestamp_year__isnull=True

to apply the filter. how can i automatically apply the filter? the
solution in my mind is hooking the changelist_view-method of the admin
and manipulate request.GET.

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



Re: Unit testing in django without using test client

2010-09-17 Thread Paul Winkler
On Fri, Sep 17, 2010 at 10:58:19AM +0530, girish shabadimath wrote:
> hi Paul,
> 
> thanks for d reply,,,but im new to python n django,,,dint do ne python unit
> testing before,,can u plz give me some links or hints to start with...

http://docs.djangoproject.com/en/1.2/topics/testing/ 
has plenty of examples, many without using django.test.client.

-- 

Paul Winkler
http://www.slinkp.com

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



Re: Unit testing in django without using test client

2010-09-17 Thread Paul Winkler
On Fri, Sep 17, 2010 at 10:58:19AM +0530, girish shabadimath wrote:
> hi Paul,
> 
> thanks for d reply,,,but im new to python n django,,,dint do ne python unit
> testing before,,can u plz give me some links or hints to start with...

http://docs.djangoproject.com/en/1.2/topics/testing/ 
has plenty of examples, many without using django.test.client.

-- 

Paul Winkler
http://www.slinkp.com

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



RSS Questions

2010-09-17 Thread Joel Davis
Hello,

I am trying to set up a blog on my django-based website. I followed
the examples here:

http://docs.djangoproject.com/en/1.1/ref/contrib/syndication/

The docs are great, and it was pretty easy to set up. And it sort-of
works. But there are a couple of problems I can't figure out.

First: Autodiscovery in google reader (and others). When I put most
websites with a link rel="alternate" type="application/rss+xml" tag
into Google Reader, the reader can find the RSS feed and subscribe.
However, when I try this with my site, i get "This site doesn't have a
feed, google can auto-generate one for you.." As far as I can tell
I've followed everything that google suggests for autodiscovery, I
can't tell what's different about my setup vs. others.  I'm sure I'm
doing something basic and stupid but I can't spot it.

Secondly, I'd like to include the entire post in the RSS feed, not
just the description. Looking at other feeds, it looks like these are
stuffed into a "content:encoded" tag? Is that right? How to I get the
RSS feed to generate that?

The website is at http://www.tapnik.com/ and the feed is
http://www.tapnik.com/feeds/blog

I did notice that this was all refactored in django 1.2, I'd rather
stick with 1.1 if I can, but if this might be a lot easier in 1.2 then
I'll consider that.

Thanks for any advice!
Joel

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



Proto-newbie needs Django for running an app, not for dev work

2010-09-17 Thread Thomas
My first post on this list. I wish to try out a blogging app developed
in Django, called Mango, and according to its instructions I just need
to get Django installed. I'm looking for a little guidance with this.
Also, I'd like to determine just what kind of mess I've created with
my attempts at installation so far.

I'm essentially a non-programmer, though I don't mind using the
Terminal in OS X now and then, and I've learned a little PHP. I heard
Mango mentioned on the Markdown discussion list.

Steps taken so far:

1. Per instructions at mango.io/docs/, I downloaded
Django-1.2.3.tar.gz (to my desktop, since no destination was
mentioned).

2. Uploaded it to my domain via FTP. Again, since the docs mention no
destination, I put it in the same directory as my home page. I know
this is probably not the location the developers intended, but,
finding no mention of what they DO intend, I figured this location
would either cause the subsequent steps to work or harmlessly fail.

3. Consulted my host's instructions on how to open an SSH connection,
and, using Terminal, navigated to the Django file I'd uploaded.

4. Per instructions at djangoproject.com for "Installing an official
release", I ran "tar xzvf Django-1.2.3.tar.gz", changed to the new
Django directory, and ran "sudo python setup.py install". When
authentication failed (and for what reason, I have no idea, as I used
the same password), I ran "python setup.py install" instead.

5. A lot of stuff went by on the screen, and I saw that one of the
last lines said that the command to modify "python/site-packages" (OR
SOMETHING LIKE THAT, SO PLEASE DON'T QUOTE ME) had failed due to
denial of permission.

Well, my home page still is up, and I haven't received any calls or
emails from my ISP (the always-excellent Tiger Technologies, at
tigertech.net). So even though the install command made SOMETHING
happen, it appears harmless for now. But I'd really like to know what
I just did to my server and its files, not to mention my bits of MySQL
database left over from playing with WordPress and Sphider.

If nothing else comes of this, I'd like to at least point out that the
Django documentation assumes a lot of prior knowledge about these
things. It may be common knowledge for programmers, but not for
everyone who might wish to try out a Django-dependent app.

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



Re: Proto-newbie needs Django for running an app, not for dev work

2010-09-17 Thread Brett Thomas
Thanks for the thorough email. Hopefully somebody else can tell you more
about what you did bc I'm not that familiar with the Django internals, but
shared hosting is just hard to navigate. (I assume you are using a shared
hosting account, thus the sudo command - run as administrator - doesn't
work.) I don't think it's possible to give comprehensive instructions on how
to install Django on a shared hosting account. In my experience, they all
work pretty differently. I'd open a support ticket with your hosting
provider, and see if they have advice on how to install Django.

That said, I agree that somebody with your experience should be able to go
to djangoproject.com and learn how to install a dependent app.

On Fri, Sep 17, 2010 at 1:51 PM, Thomas  wrote:

> My first post on this list. I wish to try out a blogging app developed
> in Django, called Mango, and according to its instructions I just need
> to get Django installed. I'm looking for a little guidance with this.
> Also, I'd like to determine just what kind of mess I've created with
> my attempts at installation so far.
>
> I'm essentially a non-programmer, though I don't mind using the
> Terminal in OS X now and then, and I've learned a little PHP. I heard
> Mango mentioned on the Markdown discussion list.
>
> Steps taken so far:
>
> 1. Per instructions at mango.io/docs/, I downloaded
> Django-1.2.3.tar.gz (to my desktop, since no destination was
> mentioned).
>
> 2. Uploaded it to my domain via FTP. Again, since the docs mention no
> destination, I put it in the same directory as my home page. I know
> this is probably not the location the developers intended, but,
> finding no mention of what they DO intend, I figured this location
> would either cause the subsequent steps to work or harmlessly fail.
>
> 3. Consulted my host's instructions on how to open an SSH connection,
> and, using Terminal, navigated to the Django file I'd uploaded.
>
> 4. Per instructions at djangoproject.com for "Installing an official
> release", I ran "tar xzvf Django-1.2.3.tar.gz", changed to the new
> Django directory, and ran "sudo python setup.py install". When
> authentication failed (and for what reason, I have no idea, as I used
> the same password), I ran "python setup.py install" instead.
>
> 5. A lot of stuff went by on the screen, and I saw that one of the
> last lines said that the command to modify "python/site-packages" (OR
> SOMETHING LIKE THAT, SO PLEASE DON'T QUOTE ME) had failed due to
> denial of permission.
>
> Well, my home page still is up, and I haven't received any calls or
> emails from my ISP (the always-excellent Tiger Technologies, at
> tigertech.net). So even though the install command made SOMETHING
> happen, it appears harmless for now. But I'd really like to know what
> I just did to my server and its files, not to mention my bits of MySQL
> database left over from playing with WordPress and Sphider.
>
> If nothing else comes of this, I'd like to at least point out that the
> Django documentation assumes a lot of prior knowledge about these
> things. It may be common knowledge for programmers, but not for
> everyone who might wish to try out a Django-dependent app.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Proto-newbie needs Django for running an app, not for dev work

2010-09-17 Thread CLIFFORD ILKAY

On 09/17/2010 01:51 PM, Thomas wrote:

4. Per instructions at djangoproject.com for "Installing an official
release", I ran "tar xzvf Django-1.2.3.tar.gz", changed to the new
Django directory, and ran "sudo python setup.py install". When
authentication failed (and for what reason, I have no idea, as I used
the same password), I ran "python setup.py install" instead.

5. A lot of stuff went by on the screen, and I saw that one of the
last lines said that the command to modify "python/site-packages" (OR
SOMETHING LIKE THAT, SO PLEASE DON'T QUOTE ME) had failed due to
denial of permission.


Unless you have root on the server, which I suspect yo don't have since 
you're most likely have a shared hosting account, you won't be able to 
install Django that way because you won't have sufficient permissions to 
be able to install libraries into the global Python site-packages 
directory. You will need to use something like virtualenv but even then, 
it might not be possible to install Django on that particular server 
because it may not have all the dependencies you need to create a 
virtual Python environment. It's best that you use a Django-friendly 
hosting provider. The Django wiki has lots of them and you're always 
welcome to contact me off-list, too. We host Django apps we build and 
for other developers so we can get going quickly.

--
Regards,

Clifford Ilkay
Dinamis
1419-3266 Yonge St.
Toronto, ON
Canada  M4N 3P6


+1 416-410-3326

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



Re: Proto-newbie needs Django for running an app, not for dev work

2010-09-17 Thread Shawn Milochik
Django is a Python module like any other. You won't be able to install it on 
shared hosting because you won't have permissions to the package directory. You 
can easily get around this by using virtualenv.

Here are the basics you'll need:

download virtualenv

extract the tarball

do not try to install it -- run "python virtualenv.py somepath," where somepath 
is a directory where you want to install your own private Python environment.

Run: source somepath/bin/activate

You're now in your own Python environment and can install Django and anything 
else you need.

Shawn

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



passing queryset filter as GET argument on Admin

2010-09-17 Thread Marc Aymerich
Hi,

recently I discover that is possible to pass queryset filters as GET
argument:
http://stackoverflow.com/questions/1652305/is-there-a-way-to-filter-a-queryset-in-the-django-admin/1652377#1652377

Unfortunately I'm not be able to do that trick on a TabularInline class :(,
any idea??

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



IE9 and dev server errors

2010-09-17 Thread TheIvIaxx
Hello all, I just downloaded the IE9 beta to see if everything worked
as expected.  However when going to 127.0.0.1 with IE9 using the
django dev server, i get:

[Errno 10054] An existing connection was forcibly closed by the remote
host

Not sure what is going on.  Any ideas?

Thanks

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



Re: tracking changes of a model's attributes

2010-09-17 Thread Shawn Milochik
One easy solution for this is to override the __init__() of your model
and save the values of the properties you care about in a dictionary
within your instance, such as self.orig_values.

Then, override the save() and compare the values of your model to
self.orig_values to see if they've changed.

Shawn

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



Error loading MySQLdb module with virtualenv (Virtual Python Environment builder)

2010-09-17 Thread Jagdeep Singh Malhi
I am using virtualenv 1.5 to install multiple version of django in
same PC.
My Django is works fine with virtualenv, follow this link
http://pypi.python.org/pypi/virtualenv#downloads
but me face problem with MySQLdb when i configure the database in
setting.py file.

Error is :
 ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
module: No module named MySQLdb


but  MySQLdb is already installed in my PC and work fine without using
virtualenv.
I face  this problem, when i use  Virtual Python Environment
builder(virtualenv 1.5)  for multiple pythons.

My django  mod_wsgi file is :-
{
import site
site.addsitedir('/home/jagdeep/CMS/ENV/lib/python2.6/site-packages')
import os
import sys

os.environ['DJANGO_SETTINGS_MODULE'] = 'djangocms.settings'
sys.path.append('/home/jagdeep/')
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
}

Please help.

Thanks.

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



Re: IE9 and dev server errors

2010-09-17 Thread Prashanth
Hi,

On Sat, Sep 18, 2010 at 4:41 AM, TheIvIaxx  wrote:

> Hello all, I just downloaded the IE9 beta to see if everything worked
> as expected.  However when going to 127.0.0.1 with IE9 using the
> django dev server, i get:
>
> [Errno 10054] An existing connection was forcibly closed by the remote
> host
>
> Not sure what is going on.  Any ideas?
>
>
Are you using windows? Try disabling the firewall. Make sure about the port
as well.



-- 
regards,
Prashanth
twitter: munichlinux
blog: honeycode.in
irc: munichlinux, JSLint, munichpython.

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