Re: Model filter on date ranges

2011-05-24 Thread Ori Livneh
Check out the python-dateutil  module (not
in the standard lib, but available via pip and easy_install). It makes
calculating time deltas easy.

Anyways, try something like this:

#!/usr/bin/env python
from datetime import datetime
from dateutil.relativedelta import relativedelta

employees = {}
now = datetime.now()
ranges = [(0, 3), (3, 6), (6, 12), (12, 24)]

for (a, b) in ranges:
start_date = now - relativedelta(months=b)
end_date = now - relativedelta(months=a)
employees[(a, b)] = Employees.objects.filter(
doj_date__range=(start_date, end_date))

On Mon, May 23, 2011 at 3:45 PM, sushanth Reddy wrote:

> Hi,
>
> How to get model filter on date ranges. In my project using employee doj, i
> need to deign a table. like employee who have joined less than three months
> , 3-6month, 6-12 months, 12-24 months.
>
> Depart  < 3month  3-6months   6-12months  12-24months
> -  -
>
>   A dep   46 6   8
>
> --
>
> How to do this filter in django.
>
> I have gone through this link ,but its confusing .
>
> http://www.nerdydork.com/django-filter-model-on-date-range.html
>
> 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-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Authenticating from a mysql database

2011-05-24 Thread Uwe Schuerkamp


On 24 Mai, 00:17, Jonas Geiregat  wrote:

> > In case I'd decide to migrate the existing users over to the new
> > database, how could I make sure the passwords end up in django
> > correctly? All I have is the old_password()-crypted user passwords,
> > can I simply insert those as values into the auth_user db field?
>
> That might be one of the bigger things to overcome.
>
> In order to succeed you must find out how django stores passwords and how 
> your current passwords are stored.
> That way you can start converting , probably by writing some python 
> conversion script.
> You can find out more on how django stores it's passwords 
> herehttp://docs.djangoproject.com/en/dev/topics/auth/#passwords

I think I may have found a solution by simply comparing the password
the user enters to the result of the old_password() function in mysql,
and if that matches I can store the password in the auth_user table
using the set_password() call which will convert the hash to "modern"
django standards.

Once I call save() on the new user object, the user should be found in
django's auth_user table from then on, correct? I've already managed
to connect to the old database using django's multiple dababase
feature and some raw() sql queries on the old user table.



All the best, Uwe

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



Serving static file on Windows

2011-05-24 Thread Alagu Madhu
Hi,


sample/
  media/
js/jquery.1.6.1.min.js
 css/
   static/
js/jquery.1.6.1.min.js
 css/



settings.py

import os
PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))
MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media/')
MEDIA_URL = '/media/'
STATIC_ROOT = os.path.join(PROJECT_DIR, 'static/')
STATIC_URL = '/static/'


urls.py


urlpatterns = patterns('',
(r'^media/(?P.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
(r'^static/(?P.*)$', 'django.views.static.serve',
{'document_root': settings.STATIC_ROOT}),






http://192.168.1.141:44/static/js/jquery.1.6.1.min.js



Page not found (404)
'js\jquery.1.6.1.min.js' could not be found



Thanks

Madhu


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



form being deleted from base.html

2011-05-24 Thread Amit Sethi
Hi all , I am not able to understand this but it seems while extending
the base template removes form tag. Is this possible in some scenario.
This is the only explanation I am able to come up with for the
behavior I am seeing in my app.

-- 
A-M-I-T S|S

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



Re: GET/POST

2011-05-24 Thread Amit Sethi
I think this is csrfmiddleware issue . Just add {% csrf_token %} like this
 {% csrf_token %}


-- 
A-M-I-T S|S

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



Re: form being deleted from base.html

2011-05-24 Thread Amit Sethi
Hi all sorry it was an issue with my html.

-- 
A-M-I-T S|S

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



Parsing an XML feed using ElementTree

2011-05-24 Thread Sithembewena Lloyd Dube
Hi Everyone,

I am trying to parse an XML feed and display the text of each child node
without any success. My code in the python shell is as follows:

>>>import urllib
>>>from xml.etree import ElementTree as ET

>>>content = urllib.urlopen('
http://xml.matchbook.com/xmlfeed/feed?sport-id=&vendor=TEST&sport-name=&short-name=Po
')
>>>xml_content = ET.parse(content)

I then check the xml_content object as follows:

>>>xml_content


And now, to iterate through its child nodes and print out the text of each
node:

>>>for node in xml_content.getiterator('contest'):
...name = node.attrib.get('text')
...print name
...
>>>

Nothing is printed, even though the document does have 'contest' tags with
text in them. If I try to count the contest tags and increment an integer
(to see that the document is traversed) I get the same result - the int
remains at 0.

>>> i = 0
>>> for node in xml_content.getiterator('contest'):
... i += 1
...
>>> i
0

What am I getting wrong? Any hints would be appreciated.

-- 
Regards,
Sithembewena Lloyd Dube

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



Re: Model filter on date ranges

2011-05-24 Thread sushanth Reddy
Thank you for the response,Let me give a try and let you know.


Thanks & Regards
sushanth reddy


On Tue, May 24, 2011 at 12:30 PM, Ori Livneh  wrote:

> Check out the python-dateutil  module
> (not in the standard lib, but available via pip and easy_install). It makes
> calculating time deltas easy.
>
> Anyways, try something like this:
>
> #!/usr/bin/env python
> from datetime import datetime
> from dateutil.relativedelta import relativedelta
>
> employees = {}
> now = datetime.now()
> ranges = [(0, 3), (3, 6), (6, 12), (12, 24)]
>
> for (a, b) in ranges:
> start_date = now - relativedelta(months=b)
> end_date = now - relativedelta(months=a)
> employees[(a, b)] = Employees.objects.filter(
> doj_date__range=(start_date, end_date))
>
> On Mon, May 23, 2011 at 3:45 PM, sushanth Reddy wrote:
>
>> Hi,
>>
>> How to get model filter on date ranges. In my project using employee doj,
>> i need to deign a table. like employee who have joined less than three
>> months , 3-6month, 6-12 months, 12-24 months.
>>
>> Depart  < 3month  3-6months   6-12months  12-24months
>>
>>
>> -  -
>>
>>
>>
>>   A dep   46 6   8
>>
>>
>>
>> --
>>
>>
>>  How to do this filter in django.
>>
>> I have gone through this link ,but its confusing .
>>
>> http://www.nerdydork.com/django-filter-model-on-date-range.html
>>
>> 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-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Parsing an XML feed using ElementTree

2011-05-24 Thread Daniel Roseman


On Tuesday, May 24, 2011 11:13:31 AM UTC+1, Lloyd Dube wrote:
>
> Hi Everyone,
>
> I am trying to parse an XML feed and display the text of each child node 
> without any success. My code in the python shell is as follows:
>
> >>>import urllib
> >>>from xml.etree import ElementTree as ET
>
> >>>content = urllib.urlopen('
> http://xml.matchbook.com/xmlfeed/feed?sport-id=&vendor=TEST&sport-name=&short-name=Po
> ')
> >>>xml_content = ET.parse(content)
>
> I then check the xml_content object as follows:
>
> >>>xml_content
> 
>
> And now, to iterate through its child nodes and print out the text of each 
> node:
>
> >>>for node in xml_content.getiterator('contest'):
> ...name = node.attrib.get('text')
> ...print name
> ...
> >>>
>
> Nothing is printed, even though the document does have 'contest' tags with 
> text in them. If I try to count the contest tags and increment an integer 
> (to see that the document is traversed) I get the same result - the int 
> remains at 0.
>
> >>> i = 0
> >>> for node in xml_content.getiterator('contest'):
> ... i += 1
> ...
> >>> i
> 0
>
> What am I getting wrong? Any hints would be appreciated.
>
> -- 
> Regards,
> Sithembewena Lloyd Dube


This isn't really a Django question...

Nevertheless, the issue is probably in the line "name = 
node.attrib.get('text')". What this does is get the attribute of the current 
node that has the name 'text' - ie if your XML was like this:



However, what you probably have is this:

foo

in which case you just want to access the `text` property directly:

name = node.text

--
DR.

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



Autocomplete on Inlines ForeignKey

2011-05-24 Thread Vinicius Massuchetto
Have anyone been able to implement an autocomplete input field in an
inline formset? If so, please provide some references.

The main apps that do this in a normal form can't render the same
behavior in an inline.

Many thanks.
-- 
Vinicius Massuchetto
http://vinicius.soylocoporti.org.br

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



Disable debug logging for django.db.backends?

2011-05-24 Thread diafygi
Howdy all,

I have DEBUG=True in my settings.py, and I have several logging
entries in my project (Django 1.3)

However, when I am testing, there are tons of django.db.backends debug
entries that appear, and my logs gets lost in the shuffle.

Is there a way to disable django.db.backends in my settings.py? What
is an example?

Thanks,
Daniel

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



problem with intalling python 2.7.1

2011-05-24 Thread bh.hoseini
hi!
i installed python 2.7.1 on vista, then opened "command line", and
wrote "django-admin.py startproject mysite" at first, but i  faced
syntax error:invalid syntax. could you help me solve this problem?!

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



installing django

2011-05-24 Thread bh.hoseini
hi there,
i installed django on vista, but i don't know how to combine it with
python, i read installation guide but it wasn't ussefull! :(

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



Access queryset in get_context_data()?

2011-05-24 Thread Florian Hahn
Hi,

is there a way to access queryset from get_context_data without
executing the query twice in a class based view?

cheers

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



Django forms, inheritance

2011-05-24 Thread feng yu
Hi all ,i have a question about Django forms in inheritance
this is my models below

 class Database(models.Model):
TYPE_CHOICES = (
(u'0',u'Oracle'),
(u'1',u'MySQL'),
)
name = models.CharField(max_length=200,unique=True)
type = models.CharField(max_length=2,choices=TYPE_CHOICES)

class MySQLInfo(Database):
hostname = models.CharField(max_length=200)

class OracleInfo(Database):
maxconnect = models.CharField(max_length=200)

i want to do this,
when i open url:http://10.232.42.91:8000/search/appname/database/
add/''
if i select 'Oracle'' ,the fields in form will be fields in
Oracle'Info
and also if i select 'MySQL'', the fields in form will be fields in
MySQLInfo

in other words, i just add MySQLInfo or OracleInfo in one page, the
fields showed in form depends on
the value i select in field:'type'

can somebody help me?

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



Re: Experiences with virtualenv + Django?

2011-05-24 Thread Stuart MacKay

John,

Regarding Python 2.6 on CentOS you might find this article useful: 
http://blog.milford.io/2010/06/alt-installing-python-2-6-from-source-in-centos/


I use virtualenv on a VPS running Ubuntu 10.04 LTS with Django 1.2, 
django-cms and about 10 other installed apps in various combinations. 
The apps are installed using pip from either the main python repository 
or directly from source checked out out of github and bitbucket. To date 
I have had no issues.


The only problem you might come across is when updating source code from 
a repository is that any changes you make will be overwritten. So for 
example to use staticfiles with django 1.3 I had to rename directories 
in django-autocomplete so the javascript and css files would be found 
automatically. Any time I deploy a new release and update the installed 
packages using pip then I have to rename the directories again since pip 
effectively does a clean install.


Regards,

Stuart MacKay
Lisbon, Portugal


I'd like to know what kind of experience people have had, in using
virtualenv (to run a particular version of Python on a VPS) with
Django, and related packages? Not *just* Django (and Python), I'm
fairly sure that will work, but all the other bits and pieces that
tend to be required, like mod_wsgi, or mysqldb_python, and so on?

Is virtualenv really effective, or does it turn out to be a nightmare
to get everything working correctly? I've been looking around the web
(particularly StackOverflow), and it like more like a nightmare. :(

The VPS I am using, turns out to run on CentOS, which uses Python 2.4
for everything, alas. So either I downgrade all my existing 2.6 code
to 2.4, or I install 2.6 on the VPS without breaking it, which would
require virtualenv. (Or changing hosting, which I'm also seriously
considering...)

John C>



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



Re: installing django

2011-05-24 Thread Stuart MacKay
Without any more information on what problems you are experiencing it is 
very dificult to know where to start. I would recommend reading the 
First Steps section of the Django Documentation, 
http://docs.djangoproject.com/en/1.3/


That will help in two ways, first it is a good guide for installing 
Django and second it will give everybody on this list who can help you 
with a good reference point for the steps you carried out. So when you 
say "I am having trouble with X" then it will be a lot easier to 
identify what the problem might be.


Regards,

Stuart MacKay
Lisbon, Portugal

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



Re: MultiValueField and MultiWidget

2011-05-24 Thread Karen Tracey
On Mon, May 23, 2011 at 11:27 AM, CH  wrote:

> Django's documentation doesn't do a very thorough job of explaining
> how to use MultiValueField and MultiWidget. I've tried dissecting the
> one implementation [1] and haven't had good results. Would someone
> mind giving me a quick pointer in the right direction?
>
> My attempt is here: http://dpaste.com/hold/545609/
> The resulting admin: http://i54.tinypic.com/4ihbo7.png
>

You are mixing model and form fields in your model definition. Your model
should only have model fields.

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

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



Re: Testing with managed tables

2011-05-24 Thread Karen Tracey
On Mon, May 23, 2011 at 12:47 PM, Vincent  wrote:

> Whenever I try to run unit tests with my managed tables, Django
> insists on re creating the test database, and then the tables do not
> get created for testing. in providing initial data, there seems to be
> no place to create a table. How should I do unit testing on unmanaged
> tables?
>
>
You mean unmanaged, right? Django will re-create the managed tables during
testing.

This blog post might help:
http://www.caktusgroup.com/blog/2010/09/24/simplifying-the-testing-of-unmanaged-database-models-in-django/

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

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



Re: Autocomplete on Inlines ForeignKey

2011-05-24 Thread Karen Tracey
On Tue, May 24, 2011 at 6:51 AM, Vinicius Massuchetto <
viniciusmassuche...@gmail.com> wrote:

> Have anyone been able to implement an autocomplete input field in an
> inline formset? If so, please provide some references.
>
> The main apps that do this in a normal form can't render the same
> behavior in an inline.
>
>
There's a ticket open (https://code.djangoproject.com/ticket/15760) for
adding some JS hooks for dynamic inlines in admin. However your post doesn't
mention the word dynamic or admin so I'm not sure it's what you are looking
for...

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

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



Re: problem with intalling python 2.7.1

2011-05-24 Thread Karen Tracey
On Tue, May 24, 2011 at 2:00 AM, bh.hoseini  wrote:

> hi!
> i installed python 2.7.1 on vista, then opened "command line", and
> wrote "django-admin.py startproject mysite" at first, but i  faced
> syntax error:invalid syntax. could you help me solve this problem?!
>
>
It rather sounds like you've got a Python 3 install trying to interpret
django-admin.py, which is using Python 2.x syntax. Do you also have some
version of Python3 installed and is that version of Python what is
associated with the .py extension?

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

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



Re: Experiences with virtualenv + Django?

2011-05-24 Thread Simon Connah
On 24 May 2011, at 12:34, Stuart MacKay wrote:
> 
> The only problem you might come across is when updating source code from a 
> repository is that any changes you make will be overwritten. So for example 
> to use staticfiles with django 1.3 I had to rename directories in 
> django-autocomplete so the javascript and css files would be found 
> automatically. Any time I deploy a new release and update the installed 
> packages using pip then I have to rename the directories again since pip 
> effectively does a clean install.

Fabric and a simple shell script would sort that one out. Just automate the 
updating of your packages with Fabric and then once all the packages have been 
updated, use Fabric to run your shell script (or Python script) to rename the 
folders as required.

Simon.

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



Re: Autocomplete on Inlines ForeignKey

2011-05-24 Thread Vinicius Massuchetto
2011/5/24 Karen Tracey :
> On Tue, May 24, 2011 at 6:51 AM, Vinicius Massuchetto
>  wrote:
>>
>> Have anyone been able to implement an autocomplete input field in an
>> inline formset? If so, please provide some references.
>>
>> The main apps that do this in a normal form can't render the same
>> behavior in an inline.
>>
>
> There's a ticket open (https://code.djangoproject.com/ticket/15760) for
> adding some JS hooks for dynamic inlines in admin. However your post doesn't
> mention the word dynamic or admin so I'm not sure it's what you are looking
> for...

I don't think it's exactly what I'm looking for. I need to implement
ajax completion in some fields in an inline form, it would be
something like `django-autocomplete` and `django-ajax-select` can do
in usual forms.

Any help is appreciated.
Thanks.
-- 
Vinicius Massuchetto
http://vinicius.soylocoporti.org.br

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



Re: Example uses of Celery

2011-05-24 Thread Rob
I use celery for the following:

1. Expensive tasks that you don't want the user waiting on.  For
example: sending messages;
   we have triggers for SMS, Email and iPhone APN messages.  I don't
want the request/response
   waiting around while I do all of that.
2. Tasks that could fail and need to be retried.  For example:
updating settings on
   the backend, you don't need complicated retry logic.
3. Replacement for cron.  The biggest issue with cron is that it is
single server.
   Once I switched to celery I don't care which processing server
launches the task.

On May 23, 9:49 pm, br  wrote:
> I understand a lot of production systems use celery and/or cron to
> automate task queues and/or scheduling.  I am just getting involved in
> a startup and will be the go-to guy for tech stuff and am interested
> in what types of tasks people use Celery (or a celery-like platform)
> for so that when similar types of things come up in my company, I'll
> think of it first.    I've read through the manuals a bit, but its
> mostly technical and implementations.  I'd like some examples to
> analogize to and then I can apply the code  when stuff comes up.    I
> realize Celery isn't a django-specific tool, but it seems to go hand
> and hand a lot of times and we are building our platform in django.
>
> Thanks,
>
> br

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



Trouble with "event_set" syntax

2011-05-24 Thread Gchorn
Hi All,

I'm trying to create a website that aggregates information about the
various products made by different companies.  To that end, I have
models (classes) for companies, products, and events.  Since each
company has various products, each product is related to one or more
companies by a ManyToManyKey.  Each product has various news events,
so each event is related to a specific product by ForeignKey as well.

I've used Django's render_to_response shortcut to send a specific
company as a context to a template, in order to render a webpage that
lists all of the products made by that specific company in a table.
Each row in the table is occupied by a different product, and each
column in the table displays a specific piece of info about that
product.  I want the last column to display the most recent news event
object for each product, but I can't figure out how to filter for
this.  I currently have the template set to look like this (I'm
intentionally leaving out some syntax to keep it simple):

for product in company.product_set.all:
{{product.name}}
{{product.usage}}
blah blah blah
{{product.event_set.all}}

And that last line is where I'm stuck.  I want to somehow filter
"product.event_set.all" for the most recent event associated with that
product, but I'm not sure how to do that and I can't find it in the
documentation on the Django website.  One of the attributes of the
"event" class I created is the event date; is there any way to filter
for the most recent date?

Furthermore, I'd like to make a link out of that latest event that
will take you to the full story when you click on it.  (I am setting
up the website to have a webpage for each event object, in which the
full story for the event is displayed.  Each "full-story" page will be
indexed by the id of the event object in question.)  I know the basic
format of this should be:

{{product.event_set.all|
something}}

But I don't know how to set the "id" variable from within the template
so that you're automatically taken to the correct page, and I can't
think of how to set this variable (or context) from the views.py file,
since its value changes for each product listed in the table.

Can anyone help me with this?

cheers,
Gchorn

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



Re: installing django

2011-05-24 Thread Piotr Zalewa

On 05/24/11 07:40, bh.hoseini wrote:

hi there,
i installed django on vista, but i don't know how to combine it with
python, i read installation guide but it wasn't ussefull! :

I had some troubles install Django on Win7
In the end I used cygwin - it worked fine, although it's not clean Win.
I removed Windows anyway.

zalun

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



Re: Trouble with "event_set" syntax

2011-05-24 Thread Daniel Roseman
On Tuesday, May 24, 2011 1:51:30 PM UTC+1, Gchorn wrote:
>
> Hi All, 
>
> I'm trying to create a website that aggregates information about the 
> various products made by different companies.  To that end, I have 
> models (classes) for companies, products, and events.  Since each 
> company has various products, each product is related to one or more 
> companies by a ManyToManyKey.  Each product has various news events, 
> so each event is related to a specific product by ForeignKey as well. 
>
> I've used Django's render_to_response shortcut to send a specific 
> company as a context to a template, in order to render a webpage that 
> lists all of the products made by that specific company in a table. 
> Each row in the table is occupied by a different product, and each 
> column in the table displays a specific piece of info about that 
> product.  I want the last column to display the most recent news event 
> object for each product, but I can't figure out how to filter for 
> this.  I currently have the template set to look like this (I'm 
> intentionally leaving out some syntax to keep it simple): 
>
> for product in company.product_set.all: 
> {{product.name}} 
> {{product.usage}} 
> blah blah blah 
> {{product.event_set.all}} 
>
> And that last line is where I'm stuck.  I want to somehow filter 
> "product.event_set.all" for the most recent event associated with that 
> product, but I'm not sure how to do that and I can't find it in the 
> documentation on the Django website.  One of the attributes of the 
> "event" class I created is the event date; is there any way to filter 
> for the most recent date? 
>
> Furthermore, I'd like to make a link out of that latest event that 
> will take you to the full story when you click on it.  (I am setting 
> up the website to have a webpage for each event object, in which the 
> full story for the event is displayed.  Each "full-story" page will be 
> indexed by the id of the event object in question.)  I know the basic 
> format of this should be: 
>
> {{product.event_set.all| 
> something}} 
>
> But I don't know how to set the "id" variable from within the template 
> so that you're automatically taken to the correct page, and I can't 
> think of how to set this variable (or context) from the views.py file, 
> since its value changes for each product listed in the table. 
>
> Can anyone help me with this? 
>
> cheers, 
> Gchorn


What you really want to do is to call a method on the Product model which 
returns the latest event. Actually, there's a built-in queryset function for 
this, so you just need to give it the field to order by, which you can do by 
setting `get_latest_by = 'event_date'` (or whatever the field name is) in 
the Event's inner Meta class.

Then, in the template, you can call that method:

{% with product.event_set.latest as latest_event %}
{{ latest_event.name 
}}
{% endwith %}

A couple of things there - I'm using `with`, as you reference the event 
twice so that'll avoid two separate db hits; and you should always use the 
{% url %} tag to look up URLs against your urlconf, rather than hard-coding 
them.
--
DR.

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



Re: GET/POST

2011-05-24 Thread egilchri
Thanks for those pointers. I think I'll have to try using something
like csrf_exempt().

The reason is, I'm working with an API (It's for a voice application),
and the API works as follows.
You create an app, that among other things, is able to take apart the
"session" data that is initially posted
to it.

The flow of control goes like this. :
  -User calls a certain number on the phone
- That number, being associated with your app, calls a POST request to
be issued to your app
- Your app can optionally unpack that session data, if it needs piecs
of it

So you see, the POST is coming from outside of my control. It is
coming from the app engine, which is a
third party known and trusted by me.I don't think I can impose any
restrictions on them, such as including a special token or cookie that
I designate.

But I guess that raises the issue of how am I protecting my app from
being maliiciously attacked by someone other than the third party app
engine I trust? Hmm, food for thought.

Ted Gilchrist

On May 23, 10:49 pm, Gabriel Gunderson  wrote:
> On Mon, May 23, 2011 at 8:04 PM,egilchri wrote:
> > I am really new to Django. I've set up an Apache server with
> > mod_wsgi,and Django, and I've hit what is probably a common
> > roadblock.
>
> Welcome. Hope you enjoy your time spent with Django!
>
> > When I use "curl" to invoke a url using GET, it works just fine. But
> > when I invoke it using POST, I get a 403 error:
>
> > curl  http://web1.tunnlr.com:x/wsgi-scripts/index.json# works
> > fine, creates JSON
> > curl  -X POSThttp://web1.tunnlr.com:/wsgi-scripts/index.json#
> > produces a 403 error
>
> 403 is 'Forbidden' and I think it might have something to do with this:
>
> http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#rejected-requests
>
> It's a good thing :) It's trying to make the Internet a safer place
> --starting with your site.
>
> > I need to get this working because I am constructing an app that
> > returns JSON. However, this app is setup to invoked by an app engine
> > that will be POSTing to it. Right now, I see from that app engines
> > logs that it is getting back a 404, just like my "curl" test.
>
> Now, before you said 403... Did you really mean 404?  That would
> change my reply.
>
> Best,
> Gabe

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



Anyone using google closure library with django?

2011-05-24 Thread Praveen Krishna R
Hi guys,


Anybody here use closure library from google.  ?
How do u compare it to jQuery ?
I have used jQuery only yet



-- 
Thanks and Regards,
*Praveen Krishna R*

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



Re: Example uses of Celery

2011-05-24 Thread Shawn Milochik

We use Celery & RabbitMQ for the following:

Scheduling SMS & e-mail for times in the future based on appointments.

Making deposits on debit cards.

Regularly-scheduled report e-mail notifications.

Async e-mail & sms alerts to users when certain activity occurs.

Compiling report data and loading it into MongoDB so it can be used 
for all reporting; reporting does not put a drain on our application 
database.


API calls (such as checking a cardholder's balance) for display on 
the page with AJAX (for faster page loads).


The primary benefit for all of these is asynchronous processing -- we 
don't slow down page loads for our users. However, the ability to 
schedule additional attempts when exceptions are caught is great also.


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



Re: Experiences with virtualenv + Django?

2011-05-24 Thread Shawn Milochik
1. You can compile Python 2.6 (or 2.7) in your home directory and use 
that to create your virtualenvs.


2. I do 100% of my Python work with virtualenv, and would never do 
otherwise.


3. It is not a nightmare AT ALL, and is wonderful.

4. With pip install, pip freeze, and pip install -r it's super-easy to 
replicate a virtualenv.


Like you, I use Cent OS with Python 2.4 installed, but all of our apps 
run under Python 2.7.



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



Re: Experiences with virtualenv + Django?

2011-05-24 Thread Brian Bouterse
Python is embedded so deeply into operating systems these days that not
using virtualenv is a bad idea.  Here is what happened to me once:

1.  I went to pip intall a python package without virtualenv
2.  The installation failed leaving my python system raising an interpreter
error when going to run anything python
3.  Everything on the system started breaking (yum, bash were the most
noticible).
4.  I really tried to recover the box by repairing python  installing a
newer version of python  removing and reinstalling
5.  Could not recover the linux system; it ended up being faster to rebuild
it.

Don't be like me and break your system by not using virtualenv.

Brian

On Tue, May 24, 2011 at 9:42 AM, Shawn Milochik  wrote:

> 1. You can compile Python 2.6 (or 2.7) in your home directory and use that
> to create your virtualenvs.
>
> 2. I do 100% of my Python work with virtualenv, and would never do
> otherwise.
>
> 3. It is not a nightmare AT ALL, and is wonderful.
>
> 4. With pip install, pip freeze, and pip install -r it's super-easy to
> replicate a virtualenv.
>
> Like you, I use Cent OS with Python 2.4 installed, but all of our apps run
> under Python 2.7.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Brian Bouterse
ITng Services

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



Re: Experiences with virtualenv + Django?

2011-05-24 Thread Shawn Milochik

On 05/24/2011 09:53 AM, Brian Bouterse wrote:
Python is embedded so deeply into operating systems these days that 
not using virtualenv is a bad idea.  Here is what happened to me once:


1.  I went to pip intall a python package without virtualenv
2.  The installation failed leaving my python system raising an 
interpreter error when going to run anything python
3.  Everything on the system started breaking (yum, bash were the most 
noticible).
4.  I really tried to recover the box by repairing python  
installing a newer version of python  removing and reinstalling
5.  Could not recover the linux system; it ended up being faster to 
rebuild it.


Don't be like me and break your system by not using virtualenv.

Brian


To add to that, you can (and should) create each virtualenv with the 
--no-site-packages option. That way, each virtualenv is isolated from 
whatever stuff you have installed into the OS's default Python 
installation. Further, I never install anything in the base Python 
installation.


Not only do you get standalone virtualenvs for whatever purpose you 
like, it also makes upgrading a lot easier.


And an additional side note: If you are in a place (like a VPS) where 
you have root access, you should install Python2.7 with configure, make, 
sudo make altinstall. The altinstall will install Python2.7 on your 
system in an alternate location, leaving the default version alone so 
everything else in the OS continues to work.





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



Re: Experiences with virtualenv + Django?

2011-05-24 Thread Andre Terra
Here's my go-to reference guide to using virtualenv and pip for django
development[1]. The same steps apply to deployment, to some extent.

Additionally, I recommend you checkout virtualenvwrapper[2]. It makes your
life incredibly easier and switching virtualenvs becomes as simple as typing
'workon my_virtualenv'. FWIW, I think this question is so often asked that
it would be reasonable to add a couple of links to these guides on
djangoproject.com (which I might preemptively add is not the same as
endorsing this or that solution).


Sincerely,
André Terra

[1]
http://saltycrane.com/blog/2009/05/notes-using-pip-and-virtualenv-django/
[2] http://www.doughellmann.com/projects/virtualenvwrapper/

On Tue, May 24, 2011 at 10:59 AM, Shawn Milochik  wrote:

> On 05/24/2011 09:53 AM, Brian Bouterse wrote:
>
>> Python is embedded so deeply into operating systems these days that not
>> using virtualenv is a bad idea.  Here is what happened to me once:
>>
>> 1.  I went to pip intall a python package without virtualenv
>> 2.  The installation failed leaving my python system raising an
>> interpreter error when going to run anything python
>> 3.  Everything on the system started breaking (yum, bash were the most
>> noticible).
>> 4.  I really tried to recover the box by repairing python  installing
>> a newer version of python  removing and reinstalling
>> 5.  Could not recover the linux system; it ended up being faster to
>> rebuild it.
>>
>> Don't be like me and break your system by not using virtualenv.
>>
>> Brian
>>
>
> To add to that, you can (and should) create each virtualenv with the
> --no-site-packages option. That way, each virtualenv is isolated from
> whatever stuff you have installed into the OS's default Python installation.
> Further, I never install anything in the base Python installation.
>
> Not only do you get standalone virtualenvs for whatever purpose you like,
> it also makes upgrading a lot easier.
>
> And an additional side note: If you are in a place (like a VPS) where you
> have root access, you should install Python2.7 with configure, make, sudo
> make altinstall. The altinstall will install Python2.7 on your system in an
> alternate location, leaving the default version alone so everything else in
> the OS continues to work.
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: hi

2011-05-24 Thread Andre Terra
You can define a value for the model's field by using the commit=False
"trick".

myform.save(commit=False) returns an instance of the model which hasn't yet
been saved to the database. So you can manually set the value for any
additional fields and then call save on the object to finally write it to
the db.

Please see the official docs[1] for futher reference.

In the future, try to pick a subject for your e-mail that explicitly states
the problem. Something like "hi" will get ignored most of the time!


Sincerely,
André Terra

[1]
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method


On Mon, May 23, 2011 at 11:01 AM, William Hudspeth
wrote:

> hi
>
> On Tue, 2011-05-10 at 09:08 -0700, wilbur wrote:
> > I am using Django 1.2.4 with a Postgresql 8.4 backend. Before creating
> > my models in Django, I began with a existing Postgresql database with
> > tables for which I had defined integer primary keys that used an
> > autoincrementing sequence on table inserts. When I created my Django
> > models, I defined the primary keys as IntegerFields with primaryKey
> > set to true using the same primary key field names as in the pre-
> > existing database tables.
> >
> > This autoincremented variable set in postgresql is
> > visible in the Django admin as "Sample_ID", with an empty form field.
> > Because the user can't possibly know what the next value in the
> > sequence
> > should be, I'm wondering how to deal with the field, as it is Not
> > NULL, and any attempt to submit without a value returns an error. Is
> > there perhaps a way to make the field not visible in admin, but have
> > the field automatically filled in once the rest of the form fields are
> > submitted?
> >
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: abstact model base class field override

2011-05-24 Thread Bill Freeman
In order to be a better metaphor in the common cases, python's
metaclass features are used to do special things with field type
elements.  You will have already noticed that the field attributes of
an *INSTANCE* of a model class are not field objects, or even
properties, but simple attributes.

Generally this is great stuff.  But it means that models are not
standard python classes.  An inheritance hierarchy is one of the
places where the distinction starts to show.  The things that don't
work as you would expect are surprising.  I once went down the rat
hole of the underlying mechanisms enough to be able to inherit
latitude and longitude fields for a group of models that all had a
"location", and thinking about it still makes my head swim.  The
resultant code wasn't particularly readable (maintainable), and I've
decided that in similar cases, it's better to RY (repeat yourself).
Or, depending on what you're doing, a one to one relationship may be a
better choice.

Good luck.

Form classes, by the way, have similar, though seemingly less severe, issues.

Bill

On Thu, May 19, 2011 at 7:21 PM, Valya Golev  wrote:
> Hi,
>
> Can anybody please tell me that's the problem with overriding a field from an 
> abstact base model class? It's somewhat against the whole "OOP" thingy and I 
> can't see any technical limitation. What am I missing?
>
> --
> Valya Golev
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Is there an HTML editor that's Django-aware

2011-05-24 Thread Тимур Зарипов
+1 for Aptana -- it's Eclipse-based IDE, so Eclipse plugins are also
available (Aptana + Mylyn in my case).

On Sat, May 21, 2011 at 2:19 AM, W Craig Trader wrote:

> On 05/20/2011 05:54 AM, BobX wrote:
>
>> Pretty obvious question, but is there any recommended HTML editor that
>> won't munch the Django template codes? I was using Amaya to form my
>> pages, but after a couple of what-the-heck moments, I discovered that
>> it sporadically "eats" the template codes - ones in table definitions
>> being particularly vulnerable.
>>
>> Notepad2 is very usable - but unfortunately that's just syntax
>> highlighting the raw HTML codes. So at the moment I'm generating the
>> templates with Amaya and then switching to Notepad2 once the template
>> codes are added.
>>
>> I've also got SeaMonkey but haven't had a chance to try it yet.
>> Platforms I've got available are Linux or Windows.
>>
>> Thanks. Bob.
>>
>
> The Aptana packaging of Eclipse for Python Development includes an HTML
> editor that is Django-aware.
>
> - Craig -
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Parsing an XML feed using ElementTree

2011-05-24 Thread Тимур Зарипов
I'd really reallly suggest you to use lxml library  for xml
parsing -- it has xpath in it.

On Tue, May 24, 2011 at 2:13 PM, Sithembewena Lloyd Dube
wrote:

> Hi Everyone,
>
> I am trying to parse an XML feed and display the text of each child node
> without any success. My code in the python shell is as follows:
>
> >>>import urllib
> >>>from xml.etree import ElementTree as ET
>
> >>>content = urllib.urlopen('
> http://xml.matchbook.com/xmlfeed/feed?sport-id=&vendor=TEST&sport-name=&short-name=Po
> ')
> >>>xml_content = ET.parse(content)
>
> I then check the xml_content object as follows:
>
> >>>xml_content
> 
>
> And now, to iterate through its child nodes and print out the text of each
> node:
>
> >>>for node in xml_content.getiterator('contest'):
> ...name = node.attrib.get('text')
> ...print name
> ...
> >>>
>
> Nothing is printed, even though the document does have 'contest' tags with
> text in them. If I try to count the contest tags and increment an integer
> (to see that the document is traversed) I get the same result - the int
> remains at 0.
>
> >>> i = 0
> >>> for node in xml_content.getiterator('contest'):
> ... i += 1
> ...
> >>> i
> 0
>
> What am I getting wrong? Any hints would be appreciated.
>
> --
> Regards,
> Sithembewena Lloyd Dube
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



json serialization question

2011-05-24 Thread Sells, Fred
I'm using AJAX, jquery and JSON for the first time, having used
templates to render XML for Flex/Flash in all my previous Django work.
My code looks like this

records = models.Residents.objects.extra( where=[], params=[...])
data = serializers.serialize('json', records, ensure_ascii=False,
fields=('fname','lname', 'pt'))
return HttpResponse(data)

After experimenting the "ensure_ascii=False" seems to get rid of the
Unicode prefix which is not used in my work.

which returns 
[
{"pk": "7", "model": "app.residents", "fields": {"lname": "Mouse ",
"pt": "0", "fname": "Minnie "}},
...]

I was surprised to see the subnode "fields" in the output.  Perhaps I'm
just old school having does basic cgi with json and pretty much forced
the format.  

1. However is the above the "best practice" or is there an option to
strip the meta data.

2. Does someone have a "best practice" jquery snippet to work with these
nested fields.

3. Would it be a cleaner solution to use a template to return some
"inner html" that ajax would use without any parsing logic.

I apologize for asking such basic questions, but I'm working solo and
this is my first serious HTML5 project after mostly using Flex and XML.

Thanks.

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



Logging SQL queries

2011-05-24 Thread candlerb
I have Django 1.3 installed, and would like the built-in 'runserver'
to show me the SQL queries it is executing.

I found this thread:
http://groups.google.com/group/django-users/browse_thread/thread/9ed3ea72afc02ee8/a5df8c062640d063?show_docid=a5df8c062640d063&fwc=1&pli=1

However, after reading the Django logging docs, I can't see how to
glue this together. I have the following in settings.py:

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %
(process)d %(thread)d %(message)s'
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
},
'console':{
'level':'DEBUG',
'class':'logging.StreamHandler',
'formatter': 'simple'
},
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
'django.db.backend': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': True,
},
}
}

This config is accepted, but runserver's console output still only
shows one line for each GET or POST, and does not include any SQL
queries.

It would be helpful if I could work out how the django.request logger
is plumbed into console output, but I can't see how it is at the
moment (notice that the config above only sends ERROR to mail_admins)

Anyway, I'm a bit stumped - does anyone have a working example of this
they can share?

Many thanks,

Brian.

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



Re: Logging SQL queries

2011-05-24 Thread Shawn Milochik

I recommend logging to a file.

Here's a handler:

'django_log_file': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': '/tmp/myproject_django.log',
'formatter': 'verbose',
'backupCount': 50,
'maxBytes': 2 ** 20,
},


Here's a logger:

'django':{
'handlers': ['django_log_file'],
'level': 'DEBUG',
'propagate': True,
},

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



Re: Is there an HTML editor that's Django-aware

2011-05-24 Thread Simon Connah

On 20 May 2011, at 21:18, Kevin Monceaux wrote:

> On Fri, May 20, 2011 at 07:51:06AM -0400, Brian Bouterse wrote:
> 
>> +1 for vim
> 
> I'll second that motion.  I've tried numerous other editors and keep
> sticking with vim for almost everything.  I do use emacs for my e-mail
> editor, with Mutt as my mail client.
> 

Yep, vim (and in particular MacVim) is awesome for Python / Django work. 
Especially when you install all the Python plugins and source code checkers 
that are available that highlight any mistakes you make in your work.

Couldn't live without it. I just wish it was as good for Objective-C, then I'd 
use it all the time.

Simon.

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



UK-based Django Host?

2011-05-24 Thread Nan
I know this question has been asked before, but the most recent thread
I can find in the archives is from 2007, and presumably the landscape
has changed since then.

I'm looking for a Webfaction-like host with servers in the UK.  It
needs to allow long-running processes, of course, and would ideally be
(like Webfaction) fully managed.  (We don't have the staff to keep a
server updated or tuned).  We need plenty of memory, shell access (of
course), and preferably mod_wsgi.

Does anyone have any recommendations of hosts they've worked with?

Thanks!
-Nan

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



User model with application code

2011-05-24 Thread lingrlongr
Hi All,

Django comes with its own authentication scheme, which includes the
User model.  So let's say I created my Django app, and I connect some
of my models to the User model using the ForeignKey field type.  If I
delete a User object, I now have objects that used to refer to a valid
User, but now return None as the User.  Is there a preferred method
for handling this?  A real world example could be a corporate
timesheet system.  A user enters their time for their duration at the
company, say 8 months.  But when the user is terminated, their account
in Django is removed as well.  Now all the time entries would refer to
"None" as the user.  So what if, for historical purposes, you need to
keep the users there so your data still makes sense.

Is there a recommended way to design your application to accommodate
this?  Looking at the "on_delete" kwarg for the ForeignKey field
mentions some options, but nothing usable, to me.
http://docs.djangoproject.com/en/1.3/ref/models/fields/#django.db.models.ForeignKey.on_delete

Perhaps, use a save signal on the User model that will create a
duplicate of that User object as an instance of a similar model
(perhaps inherited from User??), and that similar model is what I
connect all my other models to.  I could then delete my User objects
and still keep the SimilarUser objects intact so my app still works.

Thanks for any ideas...

Keith

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



save and restore session

2011-05-24 Thread CrabbyPete
I'm trying to access LinkedIn using Oauth. I don't want to log in with
it, just get user info from it. I'm using a call back which creates an
anonymous session on the callback. I want to save the session of the
user who initiated the callback. Is there a way to save a session and
then restore it back to the original user.

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



Re: Experiences with virtualenv + Django?

2011-05-24 Thread John Crawford
Thanks all, great answers. Sounds like virtualenv is better than I
thought. And Shawn cleared up one of the misconceptions I had, I
didn't realize it was possible to alt-install multiple versions of
Python - I was trying to install 2.6 *under* virtualenv, which is not
how it works. :)

Still not finished yet, but have gotten to a clean 'import django'
with Python 2.6, apparently without disturbing Python 2.4 at all. :)

John C>

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



Re: Experiences with virtualenv + Django?

2011-05-24 Thread John Crawford
(sigh) Naturally as soon as I hit the [send] button, another question
comes up :) I switched to my VPS, and was thinking about where to
create a project, when I was wondering:

How do people generally organize their virtualenv directories, and
Django projects?

I'm on as root on my machine, and under /root, created /root/mylib
(where Python 2.6) is, and /root/myenv for the env, but thinking about
it, those may not be the best locations. :) Should they be under my
root login? Or is that a bad idea for some reason? And if so, where?

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



Re: Is there an HTML editor that's Django-aware

2011-05-24 Thread AJ
Simon,

Can you please give details of plugins that you use for Python/Django in
MacVim?

Thanks,
AJ

On Tue, May 24, 2011 at 12:51 PM, Simon Connah wrote:

>
> On 20 May 2011, at 21:18, Kevin Monceaux wrote:
>
> > On Fri, May 20, 2011 at 07:51:06AM -0400, Brian Bouterse wrote:
> >
> >> +1 for vim
> >
> > I'll second that motion.  I've tried numerous other editors and keep
> > sticking with vim for almost everything.  I do use emacs for my e-mail
> > editor, with Mutt as my mail client.
> >
>
> Yep, vim (and in particular MacVim) is awesome for Python / Django work.
> Especially when you install all the Python plugins and source code checkers
> that are available that highlight any mistakes you make in your work.
>
> Couldn't live without it. I just wish it was as good for Objective-C, then
> I'd use it all the time.
>
> Simon.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
AJ

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



Dynamic Forms

2011-05-24 Thread Afshin Moshrefi
I want to write a form which can dynamically add fields.  I can simply
add additional fields that I need with JavaScript but am not sure if
that is the best way to handle this with Django?

What are the best ways to handle creating and processing such dynamic
form with Django?



AM

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



Re: Experiences with virtualenv + Django?

2011-05-24 Thread Shawn Milochik
I create a folder called 'pyenv' in the root of my 'home' directory and 
put all of my virtualenvs there.


I don't use the root user or the root home folder for anything, and you 
probably shouldn't either.


If you're going to have multiple projects running on the same server, 
here's what I do. I don't know if it's "recommended," but it works great 
for me (and my company).


Separate 'home' folder for each project.

Each 'home' folder has a 'pyenv' folder. You'll only be actively 
using one, but you can have multiple for testing updates to Python 
modules or Python versions.


Always install and use supervisor + gunicorn, and have the Django 
app run (via gunicorn) by supervisor. You'll need to tweak the 
supervisor config file so that the log and PID files don't conflict, but 
that's easy.


One nginx installation with separate config files for each project, 
each very simple and mainly just doing a proxy_pass to the appropriate port.



If you have more questions don't hesitate.

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



Re: Dynamic Forms

2011-05-24 Thread Shawn Milochik
You can add fields dynamically in the __init__ of your form by 
processing the info passed in as the 'data' kwarg.


Parse the info and just append fields to self.fields, something like this:

self.fields['dynamic_field_' + field_num] = 
forms.CharField(max_length = 10)



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



CRUD Tutorial

2011-05-24 Thread Mike Wisniewski
Hi!

Could somebody please post an example CRUD program with a tutorial?
It seems like this is a frequent request and I have yet find something
decent.  I've tried the django generator and it works, but it would be
nice if somebody could explain what things do and how to do it.

Thanks.

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



Re: CRUD Tutorial

2011-05-24 Thread Boštjan Mejak
What does CRUD stand for? Is it Create Read Update Delete?

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



Re: CRUD Tutorial

2011-05-24 Thread Mike Wisniewski
Yup, that is correct.

I'm starting to pull my hair out because I can't find a decent one.
Most of them that I've seen either use the generic view or don't
really go into explanation.  There are also lots of tutorials, many of
them use the admin interface, which isn't what I want to do.

Thanks!

On May 24, 1:20 pm, Boštjan Mejak  wrote:
> What does CRUD stand for? Is it Create Read Update Delete?

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



Re: Serving static file on Windows

2011-05-24 Thread shofty
I thought we were still on jquery 1.5.1?

Matt

On May 24, 9:22 am, Alagu Madhu  wrote:
> Hi,
>
> sample/
>           media/
>                     js/jquery.1.6.1.min.js
>                  css/
>            static/
>                     js/jquery.1.6.1.min.js
>                  css/
>
> settings.py
>
> import os
> PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))
> MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media/')
> MEDIA_URL = '/media/'
> STATIC_ROOT = os.path.join(PROJECT_DIR, 'static/')
> STATIC_URL = '/static/'
>
> urls.py
>
> urlpatterns = patterns('',
>     (r'^media/(?P.*)$', 'django.views.static.serve',
> {'document_root': settings.MEDIA_ROOT}),
>     (r'^static/(?P.*)$', 'django.views.static.serve',
> {'document_root': settings.STATIC_ROOT}),
>
> http://192.168.1.141:44/static/js/jquery.1.6.1.min.js
>
> Page not found (404)
> 'js\jquery.1.6.1.min.js' could not be found
>
> Thanks
>
> Madhu

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



Annotate with a filtered Count

2011-05-24 Thread Casey Greene


I am trying to figure out how to annotate with a count that is filtered. 
 Here is a quick example of the situation and what I'm looking for:


models.py:

class A(models.Model):
name = models.CharField(...)
...

class B(models.Model):
date = models.DateField(null=False)
...

---
views.py
(proper imports)

def myview(request):

#here I would like to filter based on a date field from the form
#let's call the form 'form' and the field 'date'
a_qset = A.objects.annotate(before_val=Count(
  'b__date__lte='+form.cleaned_data['date']))

---

Basically I want the number of B as of the date 
form.cleaned_data['date'] accessible in a queryset of As.


Now I know this code isn't correct (since I don't know the proper way to 
approach it) and is vastly simplified, but hopefully it gives an idea of 
what I want to do.  Any suggestions are greatly appreciated.


Thanks!
Casey

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



Re: Serving static file on Windows

2011-05-24 Thread shofty
ignore that last comment, im clearly behind a version!

not sure why you're needing to static.serve the static files, if
you're on django 1.3 it does that bit for you.


On May 24, 9:22 am, Alagu Madhu  wrote:
> Hi,
>
> sample/
>           media/
>                     js/jquery.1.6.1.min.js
>                  css/
>            static/
>                     js/jquery.1.6.1.min.js
>                  css/
>
> settings.py
>
> import os
> PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))
> MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media/')
> MEDIA_URL = '/media/'
> STATIC_ROOT = os.path.join(PROJECT_DIR, 'static/')
> STATIC_URL = '/static/'
>
> urls.py
>
> urlpatterns = patterns('',
>     (r'^media/(?P.*)$', 'django.views.static.serve',
> {'document_root': settings.MEDIA_ROOT}),
>     (r'^static/(?P.*)$', 'django.views.static.serve',
> {'document_root': settings.STATIC_ROOT}),
>
> http://192.168.1.141:44/static/js/jquery.1.6.1.min.js
>
> Page not found (404)
> 'js\jquery.1.6.1.min.js' could not be found
>
> Thanks
>
> Madhu

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



Re: UK-based Django Host?

2011-05-24 Thread shofty
just use webfaction, you dont know that they're US when you connect
from the UK, speed isnt an issue.
I moved to a VPS for cost reasons, but webfaction were fine for me.

Matt

On May 24, 6:03 pm, Nan  wrote:
> I know this question has been asked before, but the most recent thread
> I can find in the archives is from 2007, and presumably the landscape
> has changed since then.
>
> I'm looking for a Webfaction-like host with servers in the UK.  It
> needs to allow long-running processes, of course, and would ideally be
> (like Webfaction) fully managed.  (We don't have the staff to keep a
> server updated or tuned).  We need plenty of memory, shell access (of
> course), and preferably mod_wsgi.
>
> Does anyone have any recommendations of hosts they've worked with?
>
> Thanks!
> -Nan

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



Re: Is there an HTML editor that's Django-aware

2011-05-24 Thread shofty
why not use a python ide that is html aware?
pycharm by jetbrains is good.



On May 24, 6:49 pm, AJ  wrote:
> Simon,
>
> Can you please give details of plugins that you use for Python/Django in
> MacVim?
>
> Thanks,
> AJ
>
> On Tue, May 24, 2011 at 12:51 PM, Simon Connah 
> wrote:
>
>
>
>
>
>
>
> > On 20 May 2011, at 21:18, Kevin Monceaux wrote:
>
> > > On Fri, May 20, 2011 at 07:51:06AM -0400, Brian Bouterse wrote:
>
> > >> +1 for vim
>
> > > I'll second that motion.  I've tried numerous other editors and keep
> > > sticking with vim for almost everything.  I do use emacs for my e-mail
> > > editor, with Mutt as my mail client.
>
> > Yep, vim (and in particular MacVim) is awesome for Python / Django work.
> > Especially when you install all the Python plugins and source code checkers
> > that are available that highlight any mistakes you make in your work.
>
> > Couldn't live without it. I just wish it was as good for Objective-C, then
> > I'd use it all the time.
>
> > Simon.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> AJ

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



Re: UK-based Django Host?

2011-05-24 Thread Nan
Thanks, Matt.  Normally I'd agree with you, but this application isn't
just a website -- it's sensitive to latency issues and will be
integrating with a third-party service that's also UK-based, so we're
looking at minimizing cross-Atlantic round-trips.



On May 24, 2:46 pm, shofty  wrote:
> just use webfaction, you dont know that they're US when you connect
> from the UK, speed isnt an issue.
> I moved to a VPS for cost reasons, but webfaction were fine for me.
>
> Matt
>
> On May 24, 6:03 pm, Nan  wrote:
>
>
>
>
>
>
>
> > I know this question has been asked before, but the most recent thread
> > I can find in the archives is from 2007, and presumably the landscape
> > has changed since then.
>
> > I'm looking for a Webfaction-like host with servers in the UK.  It
> > needs to allow long-running processes, of course, and would ideally be
> > (like Webfaction) fully managed.  (We don't have the staff to keep a
> > server updated or tuned).  We need plenty of memory, shell access (of
> > course), and preferably mod_wsgi.
>
> > Does anyone have any recommendations of hosts they've worked with?
>
> > Thanks!
> > -Nan

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



Re: CRUD Tutorial

2011-05-24 Thread Shawn Milochik

On 05/24/2011 02:38 PM, Mike Wisniewski wrote:

Yup, that is correct.

I'm starting to pull my hair out because I can't find a decent one.
Most of them that I've seen either use the generic view or don't
really go into explanation.  There are also lots of tutorials, many of
them use the admin interface, which isn't what I want to do.

Thanks!



Actually, page one of the tutorial has a fairly thorough treatment of this:
http://docs.djangoproject.com/en/1.3/intro/tutorial01/#playing-with-the-api

Check out the two sections which take place in the interactive 
interpreter. They'll walk you through the commands you'll use in your 
own views to do your basic CRUD stuff.



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



Re: Logging SQL queries

2011-05-24 Thread candlerb
On May 24, 5:28 pm, Shawn Milochik  wrote:
> Here's a handler:
...
> Here's a logger:

Thank you. I tried this and it still didn't log my SQL queries. Then I
went through the documentation again, and found that I should have
configured "django.db.backends" instead of "django.db.backend".

It's working now. Sorry for the noise - it would have been nice if my
junk config had provoked a warning though :-)

Regards,

Brian.

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



Re: Logging SQL queries

2011-05-24 Thread Shawn Milochik

On 05/24/2011 03:25 PM, candlerb wrote:

Thank you. I tried this and it still didn't log my SQL queries. Then I
went through the documentation again, and found that I should have
configured "django.db.backends" instead of "django.db.backend".

It's working now. Sorry for the noise - it would have been nice if my
junk config had provoked a warning though :-)

Regards,

Brian.



There won't be any warnings for that because nothing's wrong. If you 
read up on how the logging module works it'll make sense. In short, you 
can give any names you like (a lot of people just use __file__ to use 
the current filename). The logging module then treats dotted names like 
a hierarchy. So what you entered was a completely legitimate name -- it 
just didn't happen to match the name the Django team used when they 
created their logger instance.



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



Re: Dynamic Forms

2011-05-24 Thread Ovnicraft
On Tue, May 24, 2011 at 12:47 PM, Afshin Moshrefi
wrote:

> I want to write a form which can dynamically add fields.  I can simply
> add additional fields that I need with JavaScript but am not sure if
> that is the best way to handle this with Django?
>
> What are the best ways to handle creating and processing such dynamic
> form with Django?
>
>
You need review how persist the changes about add/remove fields in __init__
method..

Regards,


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


-- 
Cristian Salamea
@ovnicraft

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



TabularInline - getting rid of 'original' row

2011-05-24 Thread candlerb
I've built the 'tutorial' poll application under Django 1.3.

One thing I notice is that when viewing the choices shown inline under
the poll, each choice has an extra heading piece of text. For example,
I could see

Choices

Not much
[Not much  ] [0]

The Sky
[The Sky   ] [0]

Just hacking again
[Just hacking again] [0]

The heading appears in the HTML as  element inside a table cell
with class="original" (see below), but is redundant in this case as
it's just showing the choice name.

Is there a way to get rid of it, short of overriding templates/admin/
edit_inline/tabular.html ? The template looks for
"inline_admin_form.original or inline_admin_form.show_url" but I can't
see how to set those via TabularInline

Thanks... Brian.



  
   Not much


  
  

  
  
  
  
  
  


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



Re: Parsing an XML feed using ElementTree

2011-05-24 Thread Brian Bouterse
+1 for xpath

I also like using
xml.dom.minidomsince
it is so simple and straightforward.

If you XML is poorly formed go with beautiful
soup
.

Brian


2011/5/24 Тимур Зарипов 

> I'd really reallly suggest you to use lxml library  for
> xml parsing -- it has xpath in it.
>
> On Tue, May 24, 2011 at 2:13 PM, Sithembewena Lloyd Dube <
> zebr...@gmail.com> wrote:
>
>> Hi Everyone,
>>
>> I am trying to parse an XML feed and display the text of each child node
>> without any success. My code in the python shell is as follows:
>>
>> >>>import urllib
>> >>>from xml.etree import ElementTree as ET
>>
>> >>>content = urllib.urlopen('
>> http://xml.matchbook.com/xmlfeed/feed?sport-id=&vendor=TEST&sport-name=&short-name=Po
>> ')
>> >>>xml_content = ET.parse(content)
>>
>> I then check the xml_content object as follows:
>>
>> >>>xml_content
>> 
>>
>> And now, to iterate through its child nodes and print out the text of each
>> node:
>>
>> >>>for node in xml_content.getiterator('contest'):
>> ...name = node.attrib.get('text')
>> ...print name
>> ...
>> >>>
>>
>> Nothing is printed, even though the document does have 'contest' tags with
>> text in them. If I try to count the contest tags and increment an integer
>> (to see that the document is traversed) I get the same result - the int
>> remains at 0.
>>
>> >>> i = 0
>> >>> for node in xml_content.getiterator('contest'):
>> ... i += 1
>> ...
>> >>> i
>> 0
>>
>> What am I getting wrong? Any hints would be appreciated.
>>
>> --
>> Regards,
>> Sithembewena Lloyd Dube
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Brian Bouterse
ITng Services

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



Re: Is there an HTML editor that's Django-aware

2011-05-24 Thread Simon Connah

On 24 May 2011, at 18:49, AJ wrote:

> Simon,
> 
> Can you please give details of plugins that you use for Python/Django in 
> MacVim?
> 
> Thanks,
> AJ

Sure.

I use this plugin collection:

https://github.com/carlhuda/janus

as well as this extra plugin:

http://www.vim.org/scripts/script.php?script_id=2441

I'm positive there are more out there and I have tried various code folding 
plugins but they just slowed me down. If anyone else has any more tips I'd like 
to know what the consensus is with vim users for Python / Django development. 
My .vimrc file is as follows if you want that as well (it has some stuff for 
Haskell in it as well which you can remove):

set nocompatible
set columns=80
if has("colorcolumn")
set colorcolumn=80
else
au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)
endif
set guifont=Monaco:h14
set guioptions=aAce
set shiftwidth=4
set tabstop=4
set softtabstop=4
set expandtab
set undolevels=1000
set history=1000
set hlsearch
set showmatch
set title
set visualbell
set noerrorbells
set wildignore=*.o,*.swp,*.pyc,*.pyo,*.hg,*.git,*.bak,*.class
filetype on
filetype plugin indent on
" enable omni completion for python
au FileType python set omnifunc=pythoncomplete#Complete
" pyflakes is an intellisense checker for python
let g:pyflakes_use_quickfix = 0
syntax on
au Bufenter *.hs compiler ghc
set confirm
set number
set nowrap
set nobackup
set nowritebackup
set noswapfile
set pastetoggle=
let g:haddock_browser = "open"
let g:haddock_browser_callformat = "%s %s"

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



Re: Parsing an XML feed using ElementTree

2011-05-24 Thread Masklinn
On 2011-05-24, at 21:57 , Brian Bouterse wrote:
> +1 for xpath
> 
> I also like using
> xml.dom.minidomsince
> it is so simple and straightforward.
> 
I'm sorry, but I whole-heartedly disagree with this. ElementTree is orders of 
magnitude simpler and more straightforward than the unending pain of working 
with the DOM interface.

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



Re: Parsing an XML feed using ElementTree

2011-05-24 Thread Brian Bouterse
We all have our opinions.  Either way this conversation is OT from Django.

On Tue, May 24, 2011 at 4:07 PM, Masklinn  wrote:

> On 2011-05-24, at 21:57 , Brian Bouterse wrote:
> > +1 for xpath
> >
> > I also like using
> > xml.dom.minidom >since
> > it is so simple and straightforward.
> >
> I'm sorry, but I whole-heartedly disagree with this. ElementTree is orders
> of magnitude simpler and more straightforward than the unending pain of
> working with the DOM interface.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Brian Bouterse
ITng Services

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



login with subdomains

2011-05-24 Thread tom
Hello,

I have a application, where I want that users log in to a special
subdomain. For example: The login screen is served at www.agileamp.com
and the user is member of the account with subdomain
test.agileamp.com.

When the user logs in at www.agileamp.com/login/ I want to make sure,
that he gets the session cookie set for his accounts subdomain.
test.agileamp.com.

Any ideas?

regards, Tom

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



Synchronize method or model field access

2011-05-24 Thread Etam
Hi,

how do you synchronize a method (or model field access) in Django?

It doesn't work:

from multiprocessing import Lock
change_status_lock = Lock()
def change_status(self, status):
self.change_status_lock.acquire()
...
self.change_status_lock.release()

Thanks in advance,
Etam.

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



Re: Dynamic Forms

2011-05-24 Thread Rafael Machado
Afshin, recently i came across the same problem.

This page helped me to figure out how to do dynamic forms:
http://jacobian.org/writing/dynamic-form-generation/



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



Re: CRUD Tutorial

2011-05-24 Thread Boštjan Mejak
I created a wiki in Django. I can send you the source if you're interested.

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



Django Newbie Question (Exception Type: TypeError, Value: argument of type 'NoneType' is not iterable)

2011-05-24 Thread Alexandra
Hi All,

I am somewhat new to Django, although I have been programming in
Python for a while. I installed Pinax and have been working on a site
from one of the starter templates, and have an error I can't seem to
wrap my head around.

Exception Type: TypeError at /models/add
Exception Value: argument of type 'NoneType' is not iterable
Exception Location: /Users/ab/Desktop/mysite/lib/python2.6/site-
packages/django/forms/models.py in construct_instance, line 40

Here is the traceback:
Traceback:
File "/Users/ab/Desktop/mysite/lib/python2.6/site-packages/django/core/
handlers/base.py" in get_response
  100. response = callback(request,
*callback_args, **callback_kwargs)
File "/Users/ab/Desktop/mysite/lib/python2.6/site-packages/django/
contrib/auth/decorators.py" in _wrapped_view
  25. return view_func(request, *args, **kwargs)
File "/Users/ab/Desktop/store/models/views.py" in add_model
  65.   if formtoaddmodel.is_valid():
File "/Users/ab/Desktop/mysite/lib/python2.6/site-packages/django/
forms/forms.py" in is_valid
  121. return self.is_bound and not bool(self.errors)
File "/Users/ab/Desktop/mysite/lib/python2.6/site-packages/django/
forms/forms.py" in _get_errors
  112. self.full_clean()
File "/Users/ab/Desktop/mysite/lib/python2.6/site-packages/django/
forms/forms.py" in full_clean
  269. self._post_clean()
File "/Users/ab/Desktop/mysite/lib/python2.6/site-packages/django/
forms/models.py" in _post_clean
  316. self.instance = construct_instance(self, self.instance,
opts.fields, opts.exclude)
File "/Users/ab/Desktop/mysite/lib/python2.6/site-packages/django/
forms/models.py" in construct_instance
  40. or not f.name in cleaned_data:

Any hints on why this is occurring? Or at least hints on where to
start?

Thanks!

-Alexandra

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



Limit admin login domain?

2011-05-24 Thread λq
Hi guys,

Can I limit only a certain domain can login into django admin?

Without running multiple django instances. Is it possible?

Thanks

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



Re: Django Newbie Question (Exception Type: TypeError, Value: argument of type 'NoneType' is not iterable)

2011-05-24 Thread Alexandra
Ok I actually just figured it out. My issue was that I was calling the
function instead of the actual instance of the form. I got confused
because the variables were named almost identically.

On May 24, 8:27 pm, Alexandra  wrote:
> Hi All,
>
> I am somewhat new to Django, although I have been programming in
> Python for a while. I installed Pinax and have been working on a site
> from one of the starter templates, and have an error I can't seem to
> wrap my head around.
>
> Exception Type: TypeError at /models/add
> Exception Value: argument of type 'NoneType' is not iterable
> Exception Location: /Users/ab/Desktop/mysite/lib/python2.6/site-
> packages/django/forms/models.py in construct_instance, line 40
>
> Here is the traceback:
> Traceback:
> File "/Users/ab/Desktop/mysite/lib/python2.6/site-packages/django/core/
> handlers/base.py" in get_response
>   100.                     response = callback(request,
> *callback_args, **callback_kwargs)
> File "/Users/ab/Desktop/mysite/lib/python2.6/site-packages/django/
> contrib/auth/decorators.py" in _wrapped_view
>   25.                 return view_func(request, *args, **kwargs)
> File "/Users/ab/Desktop/store/models/views.py" in add_model
>   65.           if formtoaddmodel.is_valid():
> File "/Users/ab/Desktop/mysite/lib/python2.6/site-packages/django/
> forms/forms.py" in is_valid
>   121.         return self.is_bound and not bool(self.errors)
> File "/Users/ab/Desktop/mysite/lib/python2.6/site-packages/django/
> forms/forms.py" in _get_errors
>   112.             self.full_clean()
> File "/Users/ab/Desktop/mysite/lib/python2.6/site-packages/django/
> forms/forms.py" in full_clean
>   269.         self._post_clean()
> File "/Users/ab/Desktop/mysite/lib/python2.6/site-packages/django/
> forms/models.py" in _post_clean
>   316.         self.instance = construct_instance(self, self.instance,
> opts.fields, opts.exclude)
> File "/Users/ab/Desktop/mysite/lib/python2.6/site-packages/django/
> forms/models.py" in construct_instance
>   40.                 or not f.name in cleaned_data:
>
> Any hints on why this is occurring? Or at least hints on where to
> start?
>
> Thanks!
>
> -Alexandra

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



Re: Weird problem with rendering a Variable in a custom tag

2011-05-24 Thread stevedegrace
Thanks for the advice. I'm actually using this tag on a private
moderation page to quickly satisfy my curiosity about which countries
generate the most spam in my comments (FYI: Russia is winning hands
down so far).

On May 23, 10:24 am, Brice Leroy  wrote:
> Be careful will computing location on rendering. IPs will change in time. The 
> pattern is not clear but expect the information to expire.
>
> As you only extract the country, it shouldn't be an issue, but if you drill 
> down to Zip code I would commend you to store it with the comment's author 
> (less expensive) or the comment.
>
> Brice Leroy
>
> On May 23, 2011, at 1:34 AM, bruno desthuilliers 
>  wrote:
>
> > On May 23, 5:37 am, stevedegrace  wrote:
> >> I developed a custom tag to look up the country of a certain IP
> >> address using an IP to country database. It's sort of rough and ready,
> >> but it should work. The idea is that you read the comment.ip_address,
> >> feed it to the {% country %} tag, which then spits out the two letter
> >> country code. The interesting thing is that the tag works once and
> >> only once per page load if it has to render a variable. All subsequent
> >> calls raise template.VariableDoesNotExist in the code below.
>
> >> The interesting thing is that if you strip out the ability to
> >> recognize an IP as a string and make it just render variables, and you
> >> bind self.ip as a Variable object in the __init__ method and then try
> >> to call its render method in the CountryNode's render method, it
> >> actually raises AttributeError and claims that Variable object has no
> >> attribute render. Weird! FYI, I'm using Django 1.2. Anyone have any
> >> thoughts about what the heck is going on?
>
> > Avoid rebinding self.ip in the render method and it should work just
> > fine.
>
> >> Here's the Python code:
> > (snip imports)
> >> class CountryNode(template.Node):
> >>     def __init__(self, ip):
> >>         self.ip = ip
>
> >>     def render(self, context):
> >>         if self.ip[0] in '\'"':
> >>             self.ip = self.ip.strip('\'"')
>
> > don't rebind self.ip here.
>
> >>         else:
> >>             try:
> >>                 self.ip = Variable(self.ip).resolve(context)
>
> > don't rebind it here neither
>
> > You want to work on local variable, definitly.
>
> > HTH
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Weird problem with rendering a Variable in a custom tag

2011-05-24 Thread stevedegrace
And you are absolutely correct, using a local variable in the render
method and not rebinding self,ip resolves the problem. Thank you very
much. Can you explain why this is?

On May 23, 5:34 am, bruno desthuilliers
 wrote:
> On May 23, 5:37 am, stevedegrace  wrote:
>
> > I developed a custom tag to look up the country of a certain IP
> > address using an IP to country database. It's sort of rough and ready,
> > but it should work. The idea is that you read the comment.ip_address,
> > feed it to the {% country %} tag, which then spits out the two letter
> > country code. The interesting thing is that the tag works once and
> > only once per page load if it has to render a variable. All subsequent
> > calls raise template.VariableDoesNotExist in the code below.
>
> > The interesting thing is that if you strip out the ability to
> > recognize an IP as a string and make it just render variables, and you
> > bind self.ip as a Variable object in the __init__ method and then try
> > to call its render method in the CountryNode's render method, it
> > actually raises AttributeError and claims that Variable object has no
> > attribute render. Weird! FYI, I'm using Django 1.2. Anyone have any
> > thoughts about what the heck is going on?
>
> Avoid rebinding self.ip in the render method and it should work just
> fine.
>
>
>
> > Here's the Python code:
> (snip imports)
> > class CountryNode(template.Node):
> >     def __init__(self, ip):
> >         self.ip = ip
>
> >     def render(self, context):
> >         if self.ip[0] in '\'"':
> >             self.ip = self.ip.strip('\'"')
>
> don't rebind self.ip here.
>
> >         else:
> >             try:
> >                 self.ip = Variable(self.ip).resolve(context)
>
> don't rebind it here neither
>
> You want to work on local variable, definitly.
>
> HTH

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



Form Validation - Redisplay With Error

2011-05-24 Thread Robin
I'm writing a basic login form using the Django built in
authentication system, but my own login form.  This may be a mistake,
but it can't hurt to learn how to get it to work? :)

I have this Django Form:

class SignInForm(forms.Form):
username = forms.CharField(label='User Name', max_length=30)
password = forms.CharField(label='Password', max_length=30,
widget=forms.PasswordInput(render_value=False))

One of the things I'm not sure how to handle is the idea of
redisplaying the form with an error if the login doesn't succeed.  The
fields will validate alright, but the authentication may fail.  Rather
than redirect to a failure page when I call authenticate(), I would
like to return the user to the sign in page and display an error
message.  Is this something I should treat as a custom validation
issue for this form?  If so, I've seen mention of a clean_message
function on djangobook.com for 1.0, but it's not in the documentation
for 1.3...is this an old idea I should avoid?

I've tried to track down this information (new to Django and web dev)
and I'm certainly not expecting a spoon-fed answer.  A nudge in the
right direction would be most appreciated. :)

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



Re: Form Validation - Redisplay With Error

2011-05-24 Thread Robin
Apologies...it seems I misunderstood clean_message().  It's not a
method, but clean_* is something for each field.  I'll continue my
research, but would still love to hear from you all about custom login
forms and how you handle them.

On May 24, 8:48 pm, Robin  wrote:
> I'm writing a basic login form using the Django built in
> authentication system, but my own login form.  This may be a mistake,
> but it can't hurt to learn how to get it to work? :)
>
> I have this Django Form:
>
> class SignInForm(forms.Form):
>     username = forms.CharField(label='User Name', max_length=30)
>     password = forms.CharField(label='Password', max_length=30,
>         widget=forms.PasswordInput(render_value=False))
>
> One of the things I'm not sure how to handle is the idea of
> redisplaying the form with an error if the login doesn't succeed.  The
> fields will validate alright, but the authentication may fail.  Rather
> than redirect to a failure page when I call authenticate(), I would
> like to return the user to the sign in page and display an error
> message.  Is this something I should treat as a custom validation
> issue for this form?  If so, I've seen mention of a clean_message
> function on djangobook.com for 1.0, but it's not in the documentation
> for 1.3...is this an old idea I should avoid?
>
> I've tried to track down this information (new to Django and web dev)
> and I'm certainly not expecting a spoon-fed answer.  A nudge in the
> right direction would be most appreciated. :)

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