Re: Can fields access other field's data before saving to database?

2009-03-14 Thread Malcolm Tredinnick
On Sat, 2009-03-14 at 22:17 -0700, Michael Strickland wrote: > I'm building an app to serve the main pages for each category of a > news site. For this, I need to have several different ways to display > article teasers. For example, in one part of a page I might want to > display the teasers for

Can fields access other field's data before saving to database?

2009-03-14 Thread Michael Strickland
I'm building an app to serve the main pages for each category of a news site. For this, I need to have several different ways to display article teasers. For example, in one part of a page I might want to display the teasers for five specific articles; in another part of the page, I'd want to

Re: Model problem, default not progagating to SQL

2009-03-14 Thread Malcolm Tredinnick
On Sat, 2009-03-14 at 21:51 -0700, kpeters wrote: > default (see active field) does not seem to propagate - see below > (Postgres 8.3.6 - current Django as of yesterday) > > Any ideas? That's normal behaviour; Django has never set up the default value on the database column. There are at least

Model problem, default not propagating to SQL

2009-03-14 Thread kpeters
default (active field) does not seem to propagate - see below (Postgres 8.3.6 - current Django as of yesterday) Any ideas? TIA Kai class Client(models.Model): login = models.CharField(max_length = 20, unique=True) password = models.CharField(max_length = 10) created=

Model problem, default not progagating to SQL

2009-03-14 Thread kpeters
default (see active field) does not seem to propagate - see below (Postgres 8.3.6 - current Django as of yesterday) Any ideas? TIA Kai class Client(models.Model): login = models.CharField(max_length = 20, unique=True) password = models.CharField(max_length = 10) created=

Re: Moving a Django project to another directory/server

2009-03-14 Thread Carlos A. Carnero Delgado
Hello, what follows is NOT a solution to your needs, but I wanted to chime in with a workflow that has proved effective to my three-developers team. We have two "environments": developer and production. Each developer has, in their respective home directory (be that Windows or Linux,) a file

Re: JSON Model Serialization

2009-03-14 Thread bruno desthuilliers
On 14 mar, 22:14, MartinBorthiry wrote: > Hello: > > I'm Trying to serialize a dict which have a list of Model's instance. > The format that i need is json. Something like that: > > people = Person.objects.all() > res = {'res':0, 'msg':'Ok','data': people} >

ModelForm for User allowing username with non-alpha characters

2009-03-14 Thread jeff
I have the ModelForm below to let the user edit some of their basic User fields like username, first/last name and email. During testing, I discovered that I could edit and save a username that included non- alpha characters. When I log into the admin system, the username is set to the new

Re: Can't run django on Apache

2009-03-14 Thread Malcolm Tredinnick
On Sat, 2009-03-14 at 19:52 -0700, Rex wrote: [...] > > SetHandler python-program > PythonHandler django.core.handlers.modpython > SetEnv DJANGO_SETTINGS_MODULE mysite.settings > PythonOption django.root /home/rex/django/mturk *sigh* Will people please stop

Re: Can't run django on Apache

2009-03-14 Thread Rex
On Mar 4, 12:47 pm, John Maines wrote: > Hello: > > I've installed Django 1.0 on Ubuntu and am trying to get it to run on > Apache. Apache is installed, working fine, with mod-python also in > place. I'm new at everything Linux. > > But when I try to run my app (a test

Re: ImportError: Could not import settings, but with an EACCES puzzle

2009-03-14 Thread Jim Hickstein
Alex Gaynor wrote: > This isn't stricly related, probably, but you generally shouldn't be putting > your django projects in your docs root: DocumentRoot is /var/www/html in fact. So it's not. But thanks for the reference. > http://www.djangobook.com/en/2.0/chapter02/#cn76 explains why not.

Re: Apache Integration?

2009-03-14 Thread timlash
Ferg, Thanks for such a thoughtful reply! Your point about placing my directive inside a directive was well taken. In fact, I did finally find a thread within the group that also spoke well to my problem:

Re: ImportError: Could not import settings, but with an EACCES puzzle

2009-03-14 Thread Alex Gaynor
On Sat, Mar 14, 2009 at 9:16 PM, Jim Hickstein wrote: > > I am trying to set up my Django app behind Apache with mod_python, and > you may have seen this error many times before, but the underlying > EACCES really puzzles me. > > CentOS 5.2, Apache 2.2.3, mod_python 2.4.3.

ImportError: Could not import settings, but with an EACCES puzzle

2009-03-14 Thread Jim Hickstein
I am trying to set up my Django app behind Apache with mod_python, and you may have seen this error many times before, but the underlying EACCES really puzzles me. CentOS 5.2, Apache 2.2.3, mod_python 2.4.3. /etc/httpd/conf/ httpd.conf says, in part: SetHandler python-program

Re: http 404 is replaced by http 500----------Django-1.0.2-final

2009-03-14 Thread Fergus
On 14 Mar, 04:30, Malcolm Tredinnick wrote: > On Fri, 2009-03-13 at 21:27 -0700, Flank wrote: > > in order to use django/conf/urls/defaults.py, handler404, i did 2 > > things: > > 1:change DEBUG = False in settings.py > > 2:create a 404.html template in the root of

Re: Apache Integration?

2009-03-14 Thread Fergus
> everything works great with the test server. This tells you that the problem is most likely not with your urls.py or any of your Django code, so you've cracked that part. > I again cycled Apache off and on. My "Under Construction" message is > gone but only the only thing returned to a

Re: Moving a Django project to another directory/server

2009-03-14 Thread Fergus
On 14 Mar, 21:42, Rex wrote: > I'd like to use a revision control system to keep up to 3 versions of > my Django project: ... > So far I have been planning to use Bazaar for version control. Good choice. > - How can I simultaneously run two versions of the same

Re: Localhost does not work with django web server but works with Tomcat

2009-03-14 Thread CG
Karen, Apologize for the late reply. Thanks for the excellent catch, it was indeed an IPv6 issue. I just had to update my hosts file on windows vista to include an entry for 127.0.0.1 and it worked! Thanks again CG On Mar 10, 10:02 pm, Karen Tracey wrote: > On Tue, Mar 10,

Re: GET vs POST?

2009-03-14 Thread Alex Gaynor
On Sat, Mar 14, 2009 at 4:54 PM, ihome wrote: > > Hi, > > I defined a form to load data from HttpRequest in views.py. For the > same function, sometimes, I need to pass a POST request while some > times I need to pass in a GET request. > > For POST, I used > >

Re: foreign key id as part of models.FileField(upload_to=...)

2009-03-14 Thread Christoph Wegscheider
On 14 Mrz., 22:42, Dirk Eschler wrote: > Am Samstag 14 März 2009 22:29:16 schrieb Dirk Eschler: > > > def get_img_storage_path(instance, filename): > >     return '%salbums/images/%s/' % (settings.MEDIA_ROOT, instance.album.pk) > > Forgot the filename in my example... > >

GET vs POST?

2009-03-14 Thread ihome
Hi, I defined a form to load data from HttpRequest in views.py. For the same function, sometimes, I need to pass a POST request while some times I need to pass in a GET request. For POST, I used MyForm(request.POST) to load the data and it works well. For GET method, MyForm(request.POST)

Re: foreign key id as part of models.FileField(upload_to=...)

2009-03-14 Thread Dirk Eschler
Am Samstag 14 März 2009 22:29:16 schrieb Dirk Eschler: > def get_img_storage_path(instance, filename): > return '%salbums/images/%s/' % (settings.MEDIA_ROOT, instance.album.pk) Forgot the filename in my example... def get_img_storage_path(instance, filename): return

Moving a Django project to another directory/server

2009-03-14 Thread Rex
I'd like to use a revision control system to keep up to 3 versions of my Django project: - A production version, which will be running on a remote Linux server - A test version, which will be running on the same remote server for my colleagues to test out before I make it public - (Possibly) a

Re: foreign key id as part of models.FileField(upload_to=...)

2009-03-14 Thread Dirk Eschler
Am Samstag 14 März 2009 22:13:39 schrieb Christoph Wegscheider: > Hi, > I want to upload photos to directories structured by the album primary > key. I have the following model: > > class Photo(models.Model): > album = models.ForeignKey(Album) > img =

Re: foreign key id as part of models.FileField(upload_to=...)

2009-03-14 Thread Alex Gaynor
On Sat, Mar 14, 2009 at 4:13 PM, Christoph Wegscheider < christoph.wegschei...@gmail.com> wrote: > > Hi, > I want to upload photos to directories structured by the album primary > key. I have the following model: > > class Photo(models.Model): >album = models.ForeignKey(Album) >img =

JSON Model Serialization

2009-03-14 Thread MartinBorthiry
Hello: I'm Trying to serialize a dict which have a list of Model's instance. The format that i need is json. Something like that: people = Person.objects.all() res = {'res':0, 'msg':'Ok','data': people} but, i need that result: {'res':0, 'msg':'Ok','data':

foreign key id as part of models.FileField(upload_to=...)

2009-03-14 Thread Christoph Wegscheider
Hi, I want to upload photos to directories structured by the album primary key. I have the following model: class Photo(models.Model): album = models.ForeignKey(Album) img = models.FileField(upload_to='albums/images/' + str(album.pk) + '/', blank=True) The str(album.pk) part is not

Re: problem with django-voting

2009-03-14 Thread Frank Wiles
On Fri, Mar 13, 2009 at 6:03 PM, Shantp wrote: > > I'm getting this error: > > AttributeError: 'NoneType' object has no attribute 'append' > > It's coming from this line in my template: > > {% scores_for_objects share_list as score_dict %} > > If I remove this line everything

Re: precision for float values in template rendering

2009-03-14 Thread ihomest...@gmail.com
thanks! this is exactly what i need. On Mar 14, 12:04 pm, Alex Gaynor wrote: > On Sat, Mar 14, 2009 at 11:02 AM, ihome wrote: > > > is there an easy way to control the precision for float values? for > > example, i have this in my template: > > > >

Re: Custom save for excluded inline fields

2009-03-14 Thread Dirk Eschler
Am Samstag 14 März 2009 12:44:11 schrieb Dirk Eschler: > myproject.news.models: > == > class Post(models.Model): > date = models.DateTimeField(default=datetime.now()) > release = models.ForeignKey(Release, null=True, blank=True) > > myproject.downloads.models: >

Re: about checking if CharField value is empty

2009-03-14 Thread Ian Kelly
On Mar 14, 8:04 am, Sergio wrote: > wow, that's interesting. I was not aware if this. > > So, coming to the real question, here is my use case which raised this > questions: > > I've a class in the model with two CharFields. When validating data > inputs, I need to check

Apache Integration?

2009-03-14 Thread timlash
I'm running Python 2.4, Django 1.0.2 and Apache2 on my Debian Etch box. I have Apache configured to run multiple websites using the VirtualHost paradigm. I've had an "Under Construction" message in index.html at /var/www/mysitehome/htdocs. Apache served this without problems whenever

Re: Development server starting two processes

2009-03-14 Thread Guillermo
> Nope -- two is normal behavior. One's the server itself, and the other > is the process that monitors your code on disk and reloads the server > when you make code changes. I see. There must be some case where the automatic reload doesn't work, then. I created the Powershell script because I

Re: Martin Winkler's "Captcha for Django"

2009-03-14 Thread Alex Gaynor
On Sat, Mar 14, 2009 at 11:23 AM, bendavis78 wrote: > > EDIT: Oops! where did I get "Martin Fowler" from? It was "Martin > Winkler"!! (sorry Martin W) > > On Mar 14, 11:21 am, bendavis78 wrote: > > Hi django-heads, I found Martin Fowler's

Re: Martin Winkler's "Captcha for Django"

2009-03-14 Thread bendavis78
EDIT: Oops! where did I get "Martin Fowler" from? It was "Martin Winkler"!! (sorry Martin W) On Mar 14, 11:21 am, bendavis78 wrote: > Hi django-heads,  I found Martin Fowler's "Captcha for Django" > here:http://django.agami.at/media/captcha/.   This is by far the

Martin Fowler's "Captcha for Django"

2009-03-14 Thread bendavis78
Hi django-heads, I found Martin Fowler's "Captcha for Django" here: http://django.agami.at/media/captcha/. This is by far the easiest to use captcha system for django that I've found on the 'net, but I found it was outdated (not working w/ 1.0 or 1.1). If anyone is interested, I've created

Re: precision for float values in template rendering

2009-03-14 Thread Alex Gaynor
On Sat, Mar 14, 2009 at 11:02 AM, ihome wrote: > > is there an easy way to control the precision for float values? for > example, i have this in my template: > > > > where float p = 0.1234123413 but i only want to show p with 3 digits > after dot like 0.123. is there a

precision for float values in template rendering

2009-03-14 Thread ihome
is there an easy way to control the precision for float values? for example, i have this in my template: where float p = 0.1234123413 but i only want to show p with 3 digits after dot like 0.123. is there a predefined way to control the precision in the rendering of template instead of having

Re: weird behaviour of forms in render_to_response

2009-03-14 Thread ihomest...@gmail.com
thanks for the info. I'll track the ticket. for now, I just convert the values to a dict and pass it over to my template. On Mar 14, 12:27 am, Malcolm Tredinnick wrote: > On Fri, 2009-03-13 at 21:08 -0700, ihome wrote: > > Hi, > > > I am using the latest django

Re: Viewing related table columns in django Admin

2009-03-14 Thread JoeManFoo
Thank you so very much for the insight and help...figured I was missing something very obvious, and I was :) As to the __unicode__ matter: I do have in the Market class that function defined, but needed to pass additional information when returning the string, but on the Admin of Aliases, it

Re: Best practise of using custom sql with Stored Procedure

2009-03-14 Thread Alex Gaynor
On Sat, Mar 14, 2009 at 6:47 AM, timc3 wrote: > > > > So is that the list that you are talking about? > > > > I'm assuming those values corropond tot he fields on the model, any > reason > > you can't do: > > > > self.model(**cursor.fetchone()) > > > Just tried to do that but it

Re: Understanding sessions

2009-03-14 Thread sotirac
Thanks Stephen. That helps a lot. On Mar 13, 4:29 pm, Stephen DeGrace wrote: > It's not putting anything into the session. The session is basically a > jazzed-up dictionary, and the get method works pretty much just like it does > with the dictionary, it will try and get the

Re: about checking if CharField value is empty

2009-03-14 Thread Sergio
wow, that's interesting. I was not aware if this. So, coming to the real question, here is my use case which raised this questions: I've a class in the model with two CharFields. When validating data inputs, I need to check that, if the user filled field A, then also field B should contains

Re: Newbie: Trying to apply JS code to Django forms code

2009-03-14 Thread timc3
Checkout the forms documentation for information on how to change what the ModelForms generates: http://docs.djangoproject.com/en/dev/topics/forms/#topics-forms-index You should be able to change the types of fields and fields names/ids/ class names to then hook into your javascript.

Re: Where do we put our templates?

2009-03-14 Thread timc3
I usually create a template directory in the application directory, and then sub directories underneath that. Helps when you need to start translating I have found. Or you could check out Bradley's GitHub project here: http://github.com/bradleywright/django-layout/tree/master

Re: Subquery has too many columns

2009-03-14 Thread timc3
Well I fixed this by updating to the latest django trunk. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from

Re: Development server starting two processes

2009-03-14 Thread Jacob Kaplan-Moss
On Sat, Mar 14, 2009 at 5:53 AM, Guillermo wrote: > Should I be seeing only one process instead of two when I start the > dev server? Nope -- two is normal behavior. One's the server itself, and the other is the process that monitors your code on disk and

Re: Where do we put our templates?

2009-03-14 Thread Dougal Matthews
You can put them where you want but generally they go inside the application folder that uses that template. You may find this an interesting/helpful read; http://www.djangobook.com/en/2.0/chapter04/ Dougal --- Dougal Matthews - @d0ugal http://www.dougalmatthews.com/ 2009/3/14 Joshua

Re: Static files in development is not picked up

2009-03-14 Thread Joshua Partogi
Darn, It turns out that media/ is already used for admin :-( Using site_media and it's running now. On Mar 14, 11:55 pm, Joshua Partogi wrote: > Dear all, > > I've already followed in the docs as instructed > herehttp://docs.djangoproject.com/en/dev/howto/static-files >

Static files in development is not picked up

2009-03-14 Thread Joshua Partogi
Dear all, I've already followed in the docs as instructed here http://docs.djangoproject.com/en/dev/howto/static-files And configured as following in my urls.py if settings.DEBUG: urlpatterns += patterns('', (r'^media/(?P.*)$', 'django.views.static.serve', {'document_root':

Subquery has too many columns

2009-03-14 Thread timc3
This is a continuation of a thread I started a couple of months ago but didn't have time to investigate more: http://groups.google.com/group/django-users/browse_frm/thread/dc2e49515ddcbf73?hl=en=1 It seems to be some problem with psycopg2 on my Ubuntu production test machines as I am not

Where do we put our templates?

2009-03-14 Thread Joshua Partogi
Dear all, As I am still new to django, I have a question about the best practice for placing templates. Do we put it inside the project folder or under webserver directory? Best regards, -- If you can't believe in God the chances are your God is too small. Read my blog:

Re: Best practise of using custom sql with Stored Procedure

2009-03-14 Thread timc3
> > So is that the list that you are talking about? > > I'm assuming those values corropond tot he fields on the model, any reason > you can't do: > > self.model(**cursor.fetchone()) Just tried to do that but it seems to be returning things as a tuple so I get the error: ModelBase object

Custom save for excluded inline fields

2009-03-14 Thread Dirk Eschler
Hello, i've been away from django for quite a while. First of all, i'm really impressed about the current state of django. After porting most of my code to the current stable, i'm now trying to understand how the save method of inlines can be overwritten. Here's a stripped down version of my

Re: Sending a filtered array to HTML

2009-03-14 Thread Ned Batchelder
This is a Python question. Python doesn't have "arrays", you are using lists. Lists are indexed only by integers. What you want is a dictionary, which can be indexed by any value. Change your first line to: people = {} and you should be all set. --Ned. http://nedbatchelder.com Ted

Re: Type 'django-admin.py help. For usage.

2009-03-14 Thread Guillermo
Hi, > When I try to set up my first Django project, I receive the following > message: > > cd C:\DjangoProjects > C:\DjangoProjects>django-admin.py startproject myproject > Type 'django-admin.py help. For usage. Have you tried this? http://docs.python.org/using/windows.html#executing-scripts

Development server starting two processes

2009-03-14 Thread Guillermo
Hi, I'm trying to automate the restarting of Django's dev server with Powershell. I've noticed that the server starts two processes. I can retrieve and store the PID for just one of them, and I've found a workaround that lets me kill the other before restart too, but not entirely reliably (the

Newbie: Trying to apply JS code to Django forms code

2009-03-14 Thread ldm999
My Django form looks like this: --- Type: {{ form.syslist }} Name: {{ form.name }} --- My JS copy droplist value to text field code looks like this: --- books movies restaurants --- I'm

Re: Test Client Missing Response Meta Data

2009-03-14 Thread Russell Keith-Magee
On Sat, Mar 14, 2009 at 5:21 AM, Chris wrote: > > I'm trying to test an email sending feature, and the email text > requires the current domain, which I'm getting from request.META > ['HTTP_HOST']. On a normal system, this works fine, but when I access > it using the test

Sending a filtered array to HTML

2009-03-14 Thread Ted
I want to take a table like People with entires id, Name, Sex and send it to HTML to do something like this: {% for name in people.filter(sex='M') %} Male: {{ People.Name }} {% end %} But, it's too late to do this in HTML. So, I'm trying to create an array of pre-sorted lists in views.py to

Re: Viewing related table columns in django Admin

2009-03-14 Thread Karen Tracey
On Fri, Mar 13, 2009 at 2:53 PM, joemanfoo wrote: > > Hi there, > > I'm very new to both Python and Django, so please pardon my ignorance > > > Here's what I'd like to do... > I've two models, one foriegnKey'ed to the other. > > in models.py: > class Market(models.model): >