Variables between Form and views

2009-05-13 Thread Yang
Hi guys, I am a beginner of Django, a problem has been unsolved for a long time, can you help me. I have a file forms.py: from django import forms from views import dllist_choice class DLForm(forms.Form): distribution_list=forms.ChoiceField

Re: Variables between Form and views

2009-05-13 Thread google torp
Hi It seems your problem with dlist_choice is caused by an incorrect you of global vars. I've not used globals much myself, but I believe that you don't import them, but instead in every function that needs them do a global var_name. the other traceback seems irrelevant, but the problem you that

Re: What debugger do you use?

2009-05-13 Thread Dougal Matthews
pyDev and Wing IDE - I swap between them for a reason I can't quite fathom. Dougal --- Dougal Matthews - @d0ugal http://www.dougalmatthews.com/ 2009/5/13 Gath : > > I use pyDev for eclipse, i think its the best debugger for Python/ > Django. > > Gath > > On May 12,

Re: Design Question

2009-05-13 Thread Dougal Matthews
Alex Gaynors talk at EuroDjangoCon will probably help you out with some handy Form tips. The slides are here; http://lazypython.blogspot.com/2009/05/eurodjangocon-2009.html The video should be online somewhere at some point. Cheers, Dougal --- Dougal Matthews - @d0ugal

Re: App not found

2009-05-13 Thread Daniel Roseman
On May 13, 3:32 am, "neri...@gmail.com" wrote: > Hello, > > I'm working on my first project and for some reason I keep getting > "Error: App with label orders could not be found. Are you sure your > INSTALLED_APPS setting is correct?". I've verified this many times by >

Re: What debugger do you use?

2009-05-13 Thread Daniel Roseman
On May 12, 4:13 pm, Stef Mientki wrote: > On Tue, May 12, 2009 at 11:28 AM, Daniel Roseman < > > roseman.dan...@googlemail.com> wrote: > > I've never seen the need for anything better than plain old pdb. > > That you've never seen winpdb. > > cheers, > Stef Er, you

Re: Does the objects.get method automatically escape single quote?

2009-05-13 Thread Daniel Roseman
On May 13, 2:25 am, Thierry wrote: > My table has the following entry: > > id      name > 1       foo's > > I'm currently trying the following: > > value = "foo's" > > MyModel.objects.get(name = value) > > The above is raising the exception DoesNotExist.  Doesn't the get >

how to provide fixtures for django site framework?

2009-05-13 Thread tzangms
I read the django document, I know how to create fixtures for app, but how can I provide initial_data for django site framework? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this

Re: Variables between Form and views

2009-05-13 Thread Yang
Hi Jakob, First thanks a lot for your reply I modify my forms.py like the following: from django import forms from views import * class DLForm(forms.Form): global dllist_choice choice=dllist_choice distribution_list=forms.ChoiceField(choices=choice,

Custom Save and calculating totals - weird behaviour

2009-05-13 Thread Alfonso
Discovered a weird bug in my custom save method for a model. Setup is a simple invoice model linked to multiple invoice order models (fk to invoice) and the invoice model holds data like total number of units of ordered... i.e. Invoice order 1: 2 x X DVD @$9.99 Invoice order 2: 5 x Y DVD @$9.99

Re: Mysterious problem with pydoc

2009-05-13 Thread aaronelliotross
On May 12, 7:18 pm, Karen Tracey wrote: > On Mon, May 11, 2009 at 7:02 PM, aaronelliotross wrote: > > > Ah ha! It's triggered by ForeignKey columns, creating a super simple > > project ( no db data, no nothin' ) with this models.py shows the > > problem. > >

Using a subset of a queryset in a template

2009-05-13 Thread Alex Rades
Hi, in one of my templates I'd like to show the last images taken from a queryset. So the equivalent of: images.all()[:5] in a template. Is there a simple way to do this? Do i need a templatetag? --~--~-~--~~~---~--~~ You received this message because you are

Form errors manipulation - autofill values in case of error

2009-05-13 Thread Miguel
I want to generate the following info in my html: To do that I proccess the info as follows: Peso (kg) {% ifequal fila.__str__ metodo.get_unidad_series %} {% for serie

Re: Custom Save and calculating totals - weird behaviour

2009-05-13 Thread Daniel Roseman
On May 13, 11:28 am, Alfonso wrote: > Discovered a weird bug in my custom save method for a model.  Setup is > a simple invoice model linked to multiple invoice order models (fk to > invoice) and the invoice model holds data like total number of units > of ordered...

A puzzling problem with admin

2009-05-13 Thread AndyB
I've got a strange issue and I'm not even sure how to go about tracking down the source of the problem let alone fix it. I'm posting here in the hope someone can give me a clue rather than a solution. I've got an app that runs fine on the local development server. When I run it on a live server

Re: Form errors manipulation - autofill values in case of error

2009-05-13 Thread Daniel Roseman
On May 13, 11:59 am, Miguel wrote: > I want to generate the following info in my html: > > > > To do that I proccess the info as follows: > >                                         Peso (kg) >                                         {% ifequal fila.__str__ >

Re: Form errors manipulation - autofill values in case of error

2009-05-13 Thread Miguel
ignorance, I guess. Django is a really huge framework and I am new using it.:-s Where can I find documentation about how python handle this? Miguel Sent from Madrid, Spain On Wed, May 13, 2009 at 1:24 PM, Daniel Roseman < roseman.dan...@googlemail.com> wrote: > > On May 13, 11:59 am, Miguel

Re: Using a subset of a queryset in a template

2009-05-13 Thread Alex Koshelev
On Wed, May 13, 2009 at 2:56 PM, Alex Rades wrote: > > Hi, > in one of my templates I'd like to show the last images taken from > a queryset. So the equivalent of: > > images.all()[:5] > > in a template. > Is there a simple way to do this? Do i need a templatetag? > Hi,

Re: Form errors manipulation - autofill values in case of error

2009-05-13 Thread Miguel
the problem I have is that the fields are dynamic so I can not do any model from a form django object... Miguel Sent from Madrid, Spain On Wed, May 13, 2009 at 1:27 PM, Miguel wrote: > ignorance, I guess. Django is a really huge framework and I am new using > it.:-s > >

Dynamic upload paths Based on object

2009-05-13 Thread jai_python
I want to create Dynamic Upload Path for my models as follows. Models.py. --- class Books(models.Model): no=models.IntegerField() class Collection(models.Model): Page=models.ForeignKey('Books')

Re: Does the objects.get method automatically escape single quote?

2009-05-13 Thread Thierry
Thanks for the tip on the raw sql, I'll read the faq in more details. On May 13, 5:53 am, Daniel Roseman wrote: > On May 13, 2:25 am, Thierry wrote: > > > My table has the following entry: > > > id      name > > 1       foo's > > > I'm

Re: temporarily log in as another user

2009-05-13 Thread Dave Brueck
Has anyone in this group implemented any sort of login-as-another-user functionality with Django? Maybe if I at least know it's possible it'll steer me in the right direction. On May 2, 8:42 am, Dave Brueck wrote: > Hi all, > > I would like an admin user on my site to be

Re: NoReverseMatch with Django-Profiles

2009-05-13 Thread Holger Latz
On 13 Mai, 00:50, Daniel Roseman wrote: > On May 12, 11:00 pm, Holger Latz wrote: > > > > > Hi, > > > I included the Django-Profiles Module as recommended with > > > (r'^profiles/', include('profiles.urls')), > > > in my urls.py and

Complex RSS Feeds problem

2009-05-13 Thread Joaquin Quintas
Hi all, I am facing a problem when I try to create a complex feed. These are the urls for the feeds. domain.com/stories <-- All recent stories domain.com/stories/category/[slug category] <-- All recent stories by category domain.com/stories/author/[slug author] <-- All recent stories by

if number <= othernumber

2009-05-13 Thread richardcur...@googlemail.com
Can I do in Django 0.9 something like if number <= othernumber ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To

Re: if number <= othernumber

2009-05-13 Thread Miguel
sure, you can. I am using 0.96 version. Miguel Sent from Madrid, Spain On Wed, May 13, 2009 at 2:33 PM, richardcur...@googlemail.com < richardcur...@googlemail.com> wrote: > > Can I do in Django 0.9 something like if number <= othernumber ? > > > > >

Complex RSS Feeds problem

2009-05-13 Thread Joaquin Quintas
Hi all, I am facing a problem when I try to create a complex feed. These are the urls for the feeds. domain.com/feeds/stories <-- All recent stories domain.com/feeds/stories/category/[slug category] <-- All recent stories by category domain.com/feeds/stories/author/[slug author] <-- All

Re: if number <= othernumber

2009-05-13 Thread richardcur...@googlemail.com
so the syntax is ???: {% if number <= othernumber %} {% endif %} --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To

Re: if number <= othernumber

2009-05-13 Thread Dougal Matthews
Django by default doesn't allow this. This is a design decision, comparisons like that in your template are considered 'advanced logic.' It is discussed here; http://docs.djangoproject.com/en/dev/misc/design-philosophies/#don-t-invent-a-programming-language However, this doesn't stop you having

Re: Dynamic upload paths Based on object

2009-05-13 Thread Karen Tracey
On Wed, May 13, 2009 at 8:05 AM, jai_python wrote: > > I want to create Dynamic Upload Path for my models as follows. > > Models.py. > --- > class Books(models.Model): >no=models.IntegerField() > > class

Re: if number <= othernumber

2009-05-13 Thread Miguel
ahm, you mean in the templates... I couldn't know how to do it. Usually I implement the comparison in the view and implement the if equal in the template. Miguel Sent from Madrid, Spain On Wed, May 13, 2009 at 2:49 PM, richardcur...@googlemail.com < richardcur...@googlemail.com> wrote: > > so

Time & Date calculation in template

2009-05-13 Thread Joshua Partogi
Dear all, Is it possible to do time and or date calculation in the template? Let's say I have a DateField {% now %} and want to subtract it with an IntegerField (let's say 4, to get 4 years before today) in the template. If it's possible, what is the syntax for it? Thank you very much in

Re: Does the objects.get method automatically escape single quote?

2009-05-13 Thread Karen Tracey
On Wed, May 13, 2009 at 5:53 AM, Daniel Roseman < roseman.dan...@googlemail.com> wrote: > > On May 13, 2:25 am, Thierry wrote: > > My table has the following entry: > > > > id name > > 1 foo's > > > > I'm currently trying the following: > > > > value = "foo's" >

Re: Form errors manipulation - autofill values in case of error

2009-05-13 Thread Thierry
I was able to get the user input back if there are errors but I have a customized form class which extends the UserCreationForm. I was following the example at: http://www.djangobook.com/en/2.0/chapter14/#cn176 You will notice that if the user inputs are not valid, the view re- initialize the

Re: Custom Save and calculating totals - weird behaviour

2009-05-13 Thread Alfonso
Daniel, I think that's what is happening too. I'm wondering if the save issue has something to do with my Invoice admin class: class CustomerInvoiceAdmin(admin.ModelAdmin): inlines = [ CustomerInvoiceOrderInline, ] def save_formset(self, request, form, formset,

Re: Form errors manipulation - autofill values in case of error

2009-05-13 Thread Daniel Roseman
On May 13, 12:47 pm, Miguel wrote: > the problem I have is that the fields are dynamic so I can not do any model > from a form django object... > > Miguel > Sent from Madrid, Spain > This doesn't follow. Forms don't have to be based on models, and it's perfectly possible to

django.contrib.auth tests fail

2009-05-13 Thread Luc Saffre
Hello, when I run ``manage.py test`` to test my Django applications, then I also get a lot of test failures for django.contrib.auth. Most of them are TemplateDoesNotExist errors (complete log see below). This even happens in a virgin project: 1. Run ``django-admin startproject foo`` 2. Edit oen

apache maximum users config

2009-05-13 Thread knight
Hi, I have a django application running on apache2 with default httpd.conf. Is anybody knows a simple way to configure apache2 (httpd.conf) for the best performance. I mean allow maximum amount of simultaneous users? Thanks, Alex A. --~--~-~--~~~---~--~~ You

apache maximum users config

2009-05-13 Thread knight
Hi, I have a django application running on apache2 with default httpd.conf. Is anybody knows a simple way to configure apache2 (httpd.conf) for the best performance. I mean allow maximum amount of simultaneous users? Thanks, Alex A. --~--~-~--~~~---~--~~ You

field defaults from related table

2009-05-13 Thread eric.frederich
Hello guys, I have an application where I have the same information modeled at different levels. For instance two models I have are Course and Offering. An Offering has a foreign key to a Course. I have a boolean field 'manager_approval_required' at the course level right now but I'd like the

Query by date + offset

2009-05-13 Thread eric.frederich
I have a model called Offering which has a start date and a duration in days. I want to do a query and get instances where the end date (not modeled) is in the past. I know that I can add a non-editable field end-date that is computed in the save method, but this seems denormalized. I'm curious

Re: A puzzling problem with admin

2009-05-13 Thread andybak
Getting somewhere... I'm running on Django 1.0 via nginx/fcgi When I run via the dev server (leaving everything else the same) the problem goes away. How can the effects of a POST to a model form in admin be affected purely by switching between fcgi and the dev server?

Re: What debugger do you use?

2009-05-13 Thread richard
WingIDE works very well for me on an OsX box. On May 11, 1:53 pm, Joshua Russo wrote: > I'm currently using Netbeans 6.5 with the Python plugin. I was just > wondering what everyone else is using because NB is a bit buggy with > the Python plugin at the moment.

Re: django.contrib.auth tests fail

2009-05-13 Thread Michael
On Wed, May 13, 2009 at 9:42 AM, Luc Saffre wrote: > > Hello, > > when I run ``manage.py test`` to test my Django applications, then I > also get a lot of test failures for django.contrib.auth. > > Is that normal? What can I do to get rid of these errors? > Auth leans on

Re: django.contrib.auth tests fail

2009-05-13 Thread Sean Brant
I am also having a issue with contrib.auth test errors. They errors seem to be caused by url tags in my base.html template. When I comment out all of those tags the tests pass. The url tags seem to work when i look at the site im my browser.

"View on Site" in admin

2009-05-13 Thread Alfonso
Getting a NoReverseMatch at /admin/r/14/1/ on a model in Admin Here's the traceback: Traceback: File "/home/queryclick/webapps/django/lib/python2.5/django/core/ handlers/base.py" in get_response 86. response = callback(request, *callback_args, **callback_kwargs) File

Re: A puzzling problem with admin

2009-05-13 Thread Brian Neal
On May 13, 10:13 am, andybak wrote: > Getting somewhere... > > I'm running on Django 1.0 via nginx/fcgi > > When I run via the dev server (leaving everything else the same) the > problem goes away. > > How can the effects of a POST to a model form in admin be affected > purely

Javascript Framework``

2009-05-13 Thread Guri
Hi, I need some help regarding which javascript framework will go well with Django and is better in terms of documentation, easy to use and preferred. Couple of them I know: 1. Dojo with dijit themes 2. Scriptaculous 3... any other... Thanks in Advance ~Guri

Re: Javascript Framework``

2009-05-13 Thread Ramdas S
everything goes well with django. On Wed, May 13, 2009 at 11:10 PM, Guri wrote: > > Hi, > I need some help regarding which javascript framework will go > well with Django and is better in terms of documentation, easy to use > and preferred. > Couple of them I know:

Re: Javascript Framework``

2009-05-13 Thread Matias Surdi
Ramdas S escribió: > everything goes well with django. > > > > On Wed, May 13, 2009 at 11:10 PM, Guri > wrote: > > > Hi, > I need some help regarding which javascript framework will go > well with Django and is better in

Re: A puzzling problem with admin

2009-05-13 Thread Andy Baker
Nothing. It's literally just either: manage.py runserver or manage.py runfcgi The full command is: python ~/myapp/myproject/manage.py runfcgi maxchildren=1 maxspare=1 method=prefork socket=~/myapp/myproject.sock On Wed, May 13, 2009 at 6:14 PM, Brian Neal wrote: > > On May

Re: Time & Date calculation in template

2009-05-13 Thread Michael Radziej
On Wed, May 13, Joshua Partogi wrote: > Dear all, > > Is it possible to do time and or date calculation in the template? > > Let's say I have a DateField {% now %} and want to subtract it with an > IntegerField (let's say 4, to get 4 years before today) in the template. If > it's possible,

Production install 'admin' failing with 500 internal server error

2009-05-13 Thread Vincent
Hi all: I have loaded my application on our production server but I am unable to load the supplied admin interface. What's really odd is that everything else seems to work fine. Databrowse works along with the django 'configuration success' page. When using databrowse, I can view all of my

Re: overriding change_list.html causes 'maximum recursion depth exceeded' exception

2009-05-13 Thread NickPresta
I can confirm this happens with 1.0.2 Final. On May 7, 2:44 pm, Margie wrote: > I am trying to override the admin sites' change_list.html, following > the example at: > > http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-ad... > > If I create

Re: Production install 'admin' failing with 500 internal server error

2009-05-13 Thread Vincent
Additional information: I am running Django 1.0.2 and the web host I am attempting to do this all on is Media Temple, in one of their Dedicated Virtual (DV) accounts. I followed the general guidelines for mod_wsgi setup from here: http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango

Re: get_or_create not atomic?

2009-05-13 Thread Elliott
On May 12, 12:47 pm, Phil Mocek wrote: > On Tue, May 12, 2009 at 02:25:41AM -0700, Daniel Roseman wrote: > > No, [get_or_create is] not atomic. You can see the code in > > django.db.models.query - it tries a db lookup, and then creates > > a new object if one

Seperate thread - best practices

2009-05-13 Thread Filip Gruszczyński
I would like to run additional process apart from the main server thread, so it would periodically perform some operations (basically check, if it should some info mails). Are there any best practices in Django at which point to start this thread and use it? Or can I simply run a new thread from

invalid block tag error - doesn't make sense

2009-05-13 Thread ringemup
I'm getting an "invalid block tag: 'endif'" error when rendering the following template. The error message is highlighting the last {% endif %} tag (not the {% endifequal %}). Everything's properly nested, so why the heck is it throwing this error? {% ifequal entry_mode "aggregate" %}

login decorator losing POST data

2009-05-13 Thread aa56280
Hello there, I have a form. Once it's submitted (method=POST) the view handling the submit uses the @login_required decorator. Problem is that when the login page intercepts to enforce login, it passes the user over to the view via the "next" parameter but that's no longer considered a POST

settings.LOGIN_URL not redirecting properly

2009-05-13 Thread Oliver Zheng
There is really weird. I noticed that all urls without a slash / at the end redirect to the url with a slash. Thus, users/logout becomes users/logout/. Okay. Now I made a users/login. It works great. I wanted Django to redirect to it for login_required, so I set LOGIN_URL to "users/login". Now,

Re: Production install 'admin' failing with 500 internal server error

2009-05-13 Thread Daniel Hilton
2009/5/13 Vincent : > > Additional information: > > I am running Django 1.0.2 and the web host I am attempting to do this > all on is Media Temple, in one of their Dedicated Virtual (DV) > accounts. I followed the general guidelines for mod_wsgi setup from > here: > >

Re: invalid block tag error - doesn't make sense

2009-05-13 Thread ringemup
Er, solved. It was a parenthesis instead of a curly-bracket opening the "if" tag. Now I just feel stupid. On May 13, 6:25 pm, ringemup wrote: > I'm getting an "invalid block tag: 'endif'" error when rendering the > following template. The error message is highlighting the

This Mailing list logo

2009-05-13 Thread Joshua Partogi
Hi all, Just an intermezzo question. Is there anyone here that's going the change this django-users mailing list logo to django logo instead of only computer icon from google groups? :-D Cheers. -- If you can't believe in God the chances are your God is too small. Read my blog:

Return multiple counts from the same table in one query?

2009-05-13 Thread Up2L8
Is there a way to do something like this in django? SELEC COUNT(t1.id), COUNT(t2.id) FROM Test_testrun t1 LEFT JOIN Test_testrun t2 ON t2.id = t1.id AND t2.passed=True Sorry for my newbness, I've been searching for awhile now with no luck. Eric

pos small int, admin and max value errors

2009-05-13 Thread Chris
Hi All, I've been looking for a simple way to spec a "max_value" limit on a (model) positive small integer field to prevent admin from throwing an "out of range value" error. I realize that the concept "small int" may be db specific so I sought a simple way to trap the error in admin when too

Re: apache maximum users config

2009-05-13 Thread Graham Dumpleton
On May 14, 12:08 am, knight wrote: > Hi, > > I have a django application running on apache2 with default > httpd.conf. > Is anybody knows a simple way to configure apache2 (httpd.conf) for > the best performance. > I mean allow maximum amount of simultaneous users? There

Aggregation of field properties?

2009-05-13 Thread Carlos A. Carnero Delgado
Hello, I'm trying to get an aggregate to work. These are the (abridged) domain objects: class Site(models.Model): name = models.CharField(max_length=512) class Archive(models.Model): site = models.ForeignKey(Site) file_system_object = models.FileField(upload_to='.')

Re: login decorator losing POST data

2009-05-13 Thread Tim Chase
aa56280 wrote: > Hello there, > > I have a form. Once it's submitted (method=POST) the view handling the > submit uses the @login_required decorator. > > Problem is that when the login page intercepts to enforce login, it > passes the user over to the view via the "next" parameter but that's >

Re: Aggregation of field properties?

2009-05-13 Thread Alex Gaynor
On Wed, May 13, 2009 at 7:22 PM, Carlos A. Carnero Delgado < carloscarn...@gmail.com> wrote: > > Hello, > > I'm trying to get an aggregate to work. These are the (abridged) domain > objects: > > class Site(models.Model): > name = models.CharField(max_length=512) > > class

Re: Seperate thread - best practices

2009-05-13 Thread Russell Keith-Magee
2009/5/14 Filip Gruszczyński : > > I would like to run additional process apart from the main server > thread, so it would periodically perform some operations (basically > check, if it should some info mails). Are there any best practices in > Django at which point to start

New Project - want advice

2009-05-13 Thread Technicalbard
Hi, I'm planning a new project, and I want the following feature set (eventually). It will of course be rolled out in parts as apps are completed. The purpose of this is to manage knowledge in various domains. - wiki-type knowledge-base with full audit trail - threaded forum - embedding

Re: Return multiple counts from the same table in one query?

2009-05-13 Thread raman
This is a "count()" method for querysets: http://docs.djangoproject.com/en/dev/ref/models/querysets/#count However, for this, it may be easiest to use raw sql within Django: http://docs.djangoproject.com/en/dev/topics/db/sql/ -Raman On May 13, 6:43 pm, Up2L8 wrote: >

Re: Dynamic upload paths Based on object

2009-05-13 Thread jai
Thanks for your reply. Finally i got the solution Models.py. --- class Books(models.Model): no=models.IntegerField() class Collection(models.Model): def imagepath(instance,filename): val="Book_Media/" +

strange problem in uploading image file

2009-05-13 Thread don ilicis
hi all: I was trying to rewrite the clean_XX() method like this: 1def clean_media(self): 2 3 # save from a upload file 4 data = self.cleaned_data['media'] 5 tmp = open('img.jpg','wr') 6 tmp.write(data.read()) 7 tmp.close() 8 9 # open it 10

Re: Time & Date calculation in template

2009-05-13 Thread Gath
I use javascript to do this sort of thing eg. in your template call javascript function eg. result = yearsBeforeToday('{{ model.date|date:"Y-m-d H:i:s" }}'); yearsBeforeToday is javascript function, does all the calculation for your date. model.date is the date value you are getting from