Re: problem with compressed egg in mysqldb module

2011-01-26 Thread Adrian Bool


On 26 Jan 2011, at 23:24, Cindy wrote:

> 
> On Jan 26, 2:13 pm, Cindy  wrote:
>> Hi, all.  I'm getting this error, when trying to export my django site
>> to a new place:

Do you mean to a new server?

>> 
>> TemplateSyntaxError: Caught ImproperlyConfigured while rendering:
>> Error loading MySQLdb module: bad local file header in /usr/local/lib/
>> python2.6/site-packages/MySQL_python-1.2.3-py2.6-freebsd-8.1-RELEASE-
>> amd64.egg

If so; is the destination server running a 64bit OS? 

Regards,

aid

-- 
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 SOAP request

2011-01-26 Thread sami nathan
Hi
Now i tried to parse the incoming request and send my response i tried
in the following way by  just sending what request came as it as response
(ECHO server).and i am very newbie i dont know how to parse the request. I
used ZSI sucessfully but in that requset was handled by itself but ZSI
application is not accepting in django

My view looks like this :
def recive_ShortMessage(request):
if request.method == 'GET':
   ref= "Process  in progress"
   return HttpResponse(ref)
elif request.method == 'POST':
print request.POST.QueryDict
return HttpResponse (request.POST)

But the error is
org.apache.axis2.AxisFault:  in xml declaration
 at [row,col {unknown-source}]: [1,13]

(I am using java client)

-- 
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 SOAP request

2011-01-26 Thread Łukasz Rekucki
Hey,

On 27 January 2011 07:32, sami nathan  wrote:
> Hi
>    i am working web service i am getting SOAP(POST) request from client now
> i am trying to parse the request xml and sending the response my soap
> request is
>
>  encoding=\'UTF-8\'?> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/;> eiveShortMessageRequest
> xmlns:ns1="http://flypp.infy.com/sms/v2010r1_0;> D>12345343661t1 ctionID>p1p2 ge>DICT
> test Envelope>']}>
> response
>  now i want send response as change is denoted in colors
> ' xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/;> eiveShortMessageRequest
> xmlns:ns1="http://flypp.infy.com/sms/v2010r1_0;> D>12345343661t1 ctionID>p1p2 ge>TEXT
> HERE Envelope>']}>
>

Ok, so what problem are you encountering and what have you already tried ?

-- 
Łukasz Rekucki

-- 
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: Long admin emails

2011-01-26 Thread Torsten Bronger
Hallöchen!

Russell Keith-Magee writes:

> On Thu, Jan 27, 2011 at 1:19 PM, Torsten Bronger
>  wrote:
>
>> [...]
>>
>> I had looked at the raw mail message, and the text/plain part
>> looked exactly the same as I uploaded -- really.
>
> I don't know what's happening here, but I'm fairly certain it
> isn't Django's fault.
>
> It's clear that *something* is processing your mail

Thank you, you are probably right.  I invesitage this; I just sent
an email to our IT department.  It may be though that all I can do
is to patch my local Django branch because the IT department might
refuse to change their configuration.

If both MIME parts are so different, multipart/alternative may be a
problematic approach anyway.

Tschö,
Torsten.

-- 
Torsten BrongerJabber ID: torsten.bron...@jabber.rwth-aachen.de
  or http://bronger-jmp.appspot.com

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



parsing SOAP request

2011-01-26 Thread sami nathan
Hi
   i am working web service i am getting SOAP(POST) request from client now
i am trying to parse the request xml and sending the response my soap
request is

http://schemas.xmlsoap.org/soap/envelope/
">http://flypp.infy.com/sms/v2010r1_0
">12345343661t1p1p2DICT
test']}>
response
 now i want send response as change is denoted in colors
**'http://schemas.xmlsoap.org/soap/envelope/
">http://flypp.infy.com/sms/v2010r1_0
">12345343661t1p1p2TEXT HERE
']}>

-- 
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: Challenge with installing django on windows 7 64 bit

2011-01-26 Thread Chris Matthews
1) Generally "not a valid archive" means the file was corrupted during the 
download/copy or the download/copy did not complete. If you used ftp to copy 
the file and the file mode settings was ASCII (not binary) then you can have a 
corrupt file (because CR 0x0D gets converted to CRLF 0x0D0A). If that is the 
case then download it again. You can confirm it was corrupt if you keep the 1st 
version of your archive and compare it with the 2nd one (using DOS/Windows file 
compare command: comp file1 file2

2) You can see if Python's gzip likes your archive (from Python help):
import gzip
f = gzip.open('/home/joe/file.txt.gz', 'rb')
file_content = f.read()
f.close()

3) If it is a 64 bit/Windows 7 issue then:
Have you tried changing your 7z's compatibility settings to run it in an older 
mode? In explorer: Right-click on exe file -> properties -> compatibility -> 
"Run this program in compatibility mode for" and then choose Windows XP


-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Magge
Sent: 26 January 2011 19:24
To: Django users
Subject: Challenge with installing django on windows 7 64 bit

Hi,

I am trying to extract the installation files from the
Django-1.2.4.tar.gz file that I got from the django website. I tried
using winzip, 7z, cygwin and so forth. All these programs complain
that the file isnt a valid archive.

I used to work with django back in 2009 on Window. The installation
used to be off the extract of a zip file I remember. How do I get
going with the installation?

I appreciate any inputs on this

Thanks
Keshav Magge

-- 
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: Error filtering using bboverlaps

2011-01-26 Thread bheathr
Great.  I missed that part of the documentation.  I changed my
managers, and it worked.

On Jan 26, 1:58 am, Jani Tiainen  wrote:
> On Wednesday 26 January 2011 05:57:01 B. Heath Robinson wrote:
>
> > I am getting the following error when I try a complicated filter with a
> > join involving bboverlaps.
>
> > Join on field 'shape' not permitted. Did you misspell 'bboverlaps' for
> > the lookup type?
>
> > Here is the line that causes the problem.
>
> > saved_properties =
> > saved_properties.filter(property__parcel__shape__bboxoverlaps=mybbox)
>
> > Is this a legitimate way to use bboverlaps?
>
> You didn't posted your models, but does all of those, property and parcel have
> explicit definition GeoManager as their default manager?
>
> --
>
> Jani Tiainen

-- 
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: Long admin emails

2011-01-26 Thread Russell Keith-Magee
On Thu, Jan 27, 2011 at 1:19 PM, Torsten Bronger
 wrote:
> Hallöchen!
>
> Russell Keith-Magee writes:
>
>> [...]
>>
>> Although we now send HTML error mails, we still send the original
>> text mail, in exactly the same format as before. We do this by
>> sending two MIME enclosures in the message; a text/plain enclosure
>> with the raw-text version, and a text/html version with the full
>> markup. The first MIME enclosure is always the text/plain
>> enclosure.
>
> I had looked at the raw mail message, and the text/plain part looked
> exactly the same as I uploaded -- really.

I don't know what's happening here, but I'm fairly certain it isn't
Django's fault.

It's clear that *something* is processing your mail -- the text/plain
container you've provided has a footer providing contact details for
"Dr Ulrich Krafft, Prof Dr-Ing Harald Bolt, and Prof Dr. Sebastian M.
Schmidt. That content wasn't provided by Django.

You can check the exact output of Django using the File email backend
-- put the following two lines in your settings file:

EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
EMAIL_FILE_PATH = '/a/path/somewhere/mail'

(substituting an appropriate FILE_PATH), and you'll see the raw
content that is being sent by Django, one file per email.

Yours,
Russ Magee %-)

-- 
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: Long admin emails

2011-01-26 Thread Torsten Bronger
Hallöchen!

Torsten Bronger writes:

> Russell Keith-Magee writes:
>
>> [...]
>>
>> Although we now send HTML error mails, we still send the original
>> text mail, in exactly the same format as before. We do this by
>> sending two MIME enclosures in the message; a text/plain
>> enclosure with the raw-text version, and a text/html version with
>> the full markup. The first MIME enclosure is always the
>> text/plain enclosure.
>
> I had looked at the raw mail message, and the text/plain part
> looked exactly the same as I uploaded -- really.

I hope I didn't overlook any of our secrets but I posted the raw
mail at http://wilson.homeunix.com/6966

Tschö,
Torsten.

-- 
Torsten BrongerJabber ID: torsten.bron...@jabber.rwth-aachen.de
  or http://bronger-jmp.appspot.com

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



Re: Long admin emails

2011-01-26 Thread Torsten Bronger
Hallöchen!

Russell Keith-Magee writes:

> [...]
>
> Although we now send HTML error mails, we still send the original
> text mail, in exactly the same format as before. We do this by
> sending two MIME enclosures in the message; a text/plain enclosure
> with the raw-text version, and a text/html version with the full
> markup. The first MIME enclosure is always the text/plain
> enclosure.

I had looked at the raw mail message, and the text/plain part looked
exactly the same as I uploaded -- really.

Tschö,
Torsten.

-- 
Torsten BrongerJabber ID: torsten.bron...@jabber.rwth-aachen.de
  or http://bronger-jmp.appspot.com

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



Re: newbie help with console, can't run Django function

2011-01-26 Thread Russell Keith-Magee
On Thu, Jan 27, 2011 at 12:22 PM, Mike Dewhirst  wrote:
> On 27/01/2011 2:35pm, Casual Coder wrote:
>
> import django
> django.VERSION
>>
>> (0, 96.406, None)
>>
> django.get_version()
>>
>> Traceback (most recent call last):
>>   File "", line 1, in
>> AttributeError: 'module' object has no attribute 'get_version'
>>
>
> Maybe Django version 0.96 didn't use a get_version() function?

No, it didn't. get_version() was added in v1.0.

> Have a look inside /site-packages/django/__init__.py to see what is
> happening.
>
> If you are just beginning with django it would be better to start with a
> more up-to-date version. I recommend using the development version but if
> that worries you then at least the most recent production release.
>
> I don't know for sure but I wouldn't be surprised if 0.96 is no longer
> supported.

No, it isn't, and 0.96 hasn't been supported in *any* capacity for
almost a year. For a year prior to that, it only received critical
security updates.

There are quite a few very important differences between 0.96 and 1.0
-- if you're just starting out, you *definitely* want to be using a
recent release. Django 1.2 is the currently stable supported version;
a new stable version (1.3) is due out very soon (hopefully within a
couple of weeks).

Yours,
Russ Magee %-)

-- 
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: newbie help with console, can't run Django function

2011-01-26 Thread Mike Dewhirst

On 27/01/2011 2:35pm, Casual Coder wrote:

import django
django.VERSION

(0, 96.406, None)


django.get_version()

Traceback (most recent call last):
   File "", line 1, in
AttributeError: 'module' object has no attribute 'get_version'



Maybe Django version 0.96 didn't use a get_version() function?

Have a look inside /site-packages/django/__init__.py to see 
what is happening.


If you are just beginning with django it would be better to start with a 
more up-to-date version. I recommend using the development version but 
if that worries you then at least the most recent production release.


I don't know for sure but I wouldn't be surprised if 0.96 is no longer 
supported.


Mike

--
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: newbie help with console, can't run Django function

2011-01-26 Thread Casual Coder
>>> import django
>>> django.VERSION
(0, 96.406, None)

>>> django.get_version()
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'module' object has no attribute 'get_version'

-- 
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: newbie help with console, can't run Django function

2011-01-26 Thread Casual Coder
Mike I appreciate your answers and am trying them lots of ways.  Still
not getting that Django linkage in my console.

>>> import django
>>> django.get_version()
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'module' object has no attribute 'get_version'

Is there a way to see what all got imported from django?

I tried it the other way too

>>> from django import get_version
Traceback (most recent call last):
  File "", line 1, in 
ImportError: cannot import name get_version

-- 
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: newbie help with console, can't run Django function

2011-01-26 Thread Mike Dewhirst

On 27/01/2011 1:02pm, Casual Coder wrote:

Thanks Mike.

But Darn I'm not as powerful as I had hoped.   I expected DUMPDATA to
work the same way, but it doesn't.   How did VERSION work?


VERSION didn't actually "work". It is a constant which is an attribute 
of django. Bear in mind that django is just python code.


You can import anything from the django python package using dot 
notation. That includes constants in __init__.py.


I just had a look in there and see now why you were trying to call 
get_version(). The correct way to do that is ...


>>> import django
>>> django.get_version()
u'1.3 alpha 1 SVN-14914'
>>>

or

>>> from django import get_version
>>> get_version()
u'1.3 alpha 1 SVN-14914'
>>>



and why doesn't django-admin.py dumpdata work?


Because that isn't how python code works. Within the interpreter (and in 
your code) you need to import packages or modules without mentioning the 
.py file extension. Python relies on finding things via the python path 
and dot notation.


Try getting a shell command line or Windows DOS prompt and do ...

python django-admin.py dumpdata

hth

M






django-admin.py dumpdata

   File "", line 1
 django-admin.py dumpdata
^
SyntaxError: invalid syntax

print 'darn'

darn



--
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: Confusion about the new staticfiles contrib app

2011-01-26 Thread Brian Neal
I can answer one of my own questions now:

On Jan 25, 11:46 pm, Brian Neal  wrote:
...
> My second confusion point:
> I am running the dev server with -Wall and I am seeing warnings:
> PendingDeprecationWarning: The view at `django.views.static.serve` is
> deprecated; use the path `django.contrib.staticfiles.views.serve`
> instead.
>
> I don't understand why I'm getting these warnings.

This warning is being generated by the django debug toolbar calling
into the deprecated view function.

-BN

-- 
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: newbie help with console, can't run Django function

2011-01-26 Thread Casual Coder
Thanks Mike.

But Darn I'm not as powerful as I had hoped.   I expected DUMPDATA to
work the same way, but it doesn't.   How did VERSION work?

and why doesn't django-admin.py dumpdata work?

>>> django-admin.py dumpdata
  File "", line 1
django-admin.py dumpdata
   ^
SyntaxError: invalid syntax
>>> print 'darn'
darn

-- 
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 form(s) for intermediary models

2011-01-26 Thread aa56280
Wow, that is bananas, Ian. I'll give your solution a try and see what
happens.

-- 
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: newbie help with console, can't run Django function

2011-01-26 Thread Casual Coder
On Jan 26, 8:13 pm, Mike Dewhirst  wrote:
>  >>> from django import VERSION
>  >>> VERSION
> (1, 3, 0, 'alpha', 1)


Ah.  That works.   I have suddenly become quite powerful.   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: newbie help with console, can't run Django function

2011-01-26 Thread Mike Dewhirst

On 27/01/2011 12:02pm, Casual Coder wrote:

I'd like to get handy with using the console.   Do I have a setup
problem or a usage problem?



>>> from django import VERSION
>>> VERSION
(1, 3, 0, 'alpha', 1)
>>>




See following pydev console output.   Am I not able to run
get_version() like that?

Thanks...


import sys; print('%s %s' % (sys.executable or sys.platform, sys.version))

C:\Python25\python.exe 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC
v.1310 32 bit (Intel)]

sys.path

['C:\\Program Files\\eclipse\\plugins\
\org.python.pydev_1.5.7.2010050621\\PySrc', 'C:\\Program Files\\Google\
\google_appengine', 'C:\\Python25\\lib\\site-packages', 'C:\\Python25\
\lib\\site-packages\\PIL', 'C:\\ca1\\lib\\antlr3', 'C:\\Python25', 'C:\
\ca1\\lib\\webob', 'C:\\Python25\\lib\\plat-win', 'C:\\Python25\\lib',
'C:\\ca1\\lib\\ipaddr', 'C:\\ca1\\lib\\django', 'C:\\ca1\\lib\\django\
\django', 'C:\\ca1\\src', 'C:\\Python25\\DLLs', 'C:\\ca1\\lib\
\cacerts', 'C:\\ca1\\lib\\yaml\\lib', 'C:\\Python25\\lib\\lib-tk', 'C:\
\WINDOWS\\system32\\python25.zip']

from django import VERSION
get_version()

Traceback (most recent call last):
   File "", line 1, in
NameError: name 'get_version' is not defined

print 'darn'

darn






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



newbie help with console, can't run Django function

2011-01-26 Thread Casual Coder
I'd like to get handy with using the console.   Do I have a setup
problem or a usage problem?

See following pydev console output.   Am I not able to run
get_version() like that?

Thanks...

>>> import sys; print('%s %s' % (sys.executable or sys.platform, sys.version))
C:\Python25\python.exe 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC
v.1310 32 bit (Intel)]
>>> sys.path
['C:\\Program Files\\eclipse\\plugins\
\org.python.pydev_1.5.7.2010050621\\PySrc', 'C:\\Program Files\\Google\
\google_appengine', 'C:\\Python25\\lib\\site-packages', 'C:\\Python25\
\lib\\site-packages\\PIL', 'C:\\ca1\\lib\\antlr3', 'C:\\Python25', 'C:\
\ca1\\lib\\webob', 'C:\\Python25\\lib\\plat-win', 'C:\\Python25\\lib',
'C:\\ca1\\lib\\ipaddr', 'C:\\ca1\\lib\\django', 'C:\\ca1\\lib\\django\
\django', 'C:\\ca1\\src', 'C:\\Python25\\DLLs', 'C:\\ca1\\lib\
\cacerts', 'C:\\ca1\\lib\\yaml\\lib', 'C:\\Python25\\lib\\lib-tk', 'C:\
\WINDOWS\\system32\\python25.zip']
>>> from django import VERSION
>>> get_version()
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'get_version' is not defined
>>> print 'darn'
darn
>>>

-- 
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: Long admin emails

2011-01-26 Thread Russell Keith-Magee
On Thu, Jan 27, 2011 at 7:10 AM, Torsten Bronger
 wrote:
> Hallöchen!
>
> I just upgraded from Django 13xxx to the current SVN.  Before the
> upgrade, error emails from 500 errors to the admins lokked like
> .  I liked that very much, especially
> because the traceback was easily readable.
>
> Now, they look like .  It's the
> text/plain part of the email (my client can't display HTML).  Is
> there a possibility to get the old, for me clearer emails back, at
> least almost?

Sorry to be the bearer of bad news, but this means your mail client is
broken (or, at least, misconfigured).

Although we now send HTML error mails, we still send the original text
mail, in exactly the same format as before. We do this by sending two
MIME enclosures in the message; a text/plain enclosure with the
raw-text version, and a text/html version with the full markup. The
first MIME enclosure is always the text/plain enclosure.

So - I don't know what mail client you're using, but you need to
convince it to display the text/plain option, rather than the
text/html option.

Yours,
Russ Magee %-)

-- 
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 compressed egg in mysqldb module

2011-01-26 Thread Cindy
To be specific:
mysqldb version 1.2.3
django version 1.2.4
python 2.6
freebsd 8.1

Another question: if django/python is somehow using the wrong method
to unzip the egg
(since I can "unzip" just fine in the listed directory) is there some
way I can configure the correct
one?

Again, thanks...

On Jan 26, 2:13 pm, Cindy  wrote:
> Hi, all.  I'm getting this error, when trying to export my django site
> to a new place:
>
> TemplateSyntaxError: Caught ImproperlyConfigured while rendering:
> Error loading MySQLdb module: bad local file header in /usr/local/lib/
> python2.6/site-packages/MySQL_python-1.2.3-py2.6-freebsd-8.1-RELEASE-
> amd64.egg
>
> When I install the module (I reinstalled it clean after finding the
> above problem), I get the above egg as a zip file (and it unzips
> without errors).  But I can't seem to use it.  I've been trying to
> figure out what to do next -- I've considered trying to make it use
> uncompressed eggs, but even though I've uncompressed it in that
> directory (site-packages) it's not helping.  Does django have some way
> of telling python to not use compressed eggs, but to look for
> uncompressed stuff instead?  Or are there other suggestions/
> solutions?  (I'm kinda hoping not to reinstall python itself esp. as I
> hate changing /usr/ports default setups as it always bites me later
> when i reinstall/upgrade things)
>
> When I reinstalled py-MySQLdb, it created the egg in /root/.python-
> eggs/MySQL_python-1.2.3-py2.6-freebsd-8.1-RELEASE-amd64.egg but after
> trying to run the django stuff, that egg disappears, leaving
> the .python-eggs dir empty, and giving me the above error message.
>
> Using the latest version of django, python & mysqldb, on freebsd 8.1
> (moving it from a freebsd 8.0 install, where it's working fine --
> django & python versions the same on both).
>
> Thanks for any and all help & suggestions!

-- 
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: Challenge with installing django on windows 7 64 bit

2011-01-26 Thread Mike Dewhirst

On 27/01/2011 9:22am, j_syk wrote:

Hello-
I only develop django on osx and lunix (ubuntu), but I've looked into
options for installing it on my windows desktop- even though I've
never gotten around to it...
I've found http://www.instantdjango.com/ which has all the common
files you need to develop in one package. According to the site, you
don't even need to install anything, just extract the .exe and work
there.
7-zip documentation says that it should be able to unzip tar.gz, but
maybe you somehow got a corrupted download. Have you tried downloading
it again?


On Jan 26, 11:23 am, Magge  wrote:

Hi,

I am trying to extract the installation files from the
Django-1.2.4.tar.gz file that I got from the django website. I tried
using winzip, 7z, cygwin and so forth. All these programs complain
that the file isnt a valid archive.


Maybe it got corrupted and another download may fix it.

Maybe Windows 7 thinks it knows better than you and is trying to protect 
you from yourself by stopping you from doing what you want until you 
adjust the properties of the tar.gz file to take all responsibility from 
Windows so it doesn't have to worry.


Maybe you don't have Win7 installation privileges.

Once you get it opened, drill down until you see a directory containing 
setup.py and drag that directory to a convenient temporary location. cd 
into that temp dir and open a command prompt. At the command line do ...


python setup.py install

... which ought to put django into your site-packages directory.

You should not need cygwin unless you intend to compile python from 
source. Django is python all the way down.


hth

Mike



I used to work with django back in 2009 on Window. The installation
used to be off the extract of a zip file I remember. How do I get
going with the installation?

I appreciate any inputs on this

Thanks
Keshav Magge




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



Long admin emails

2011-01-26 Thread Torsten Bronger
Hallöchen!

I just upgraded from Django 13xxx to the current SVN.  Before the
upgrade, error emails from 500 errors to the admins lokked like
.  I liked that very much, especially
because the traceback was easily readable.

Now, they look like .  It's the
text/plain part of the email (my client can't display HTML).  Is
there a possibility to get the old, for me clearer emails back, at
least almost?

Tschö,
Torsten.

-- 
Torsten BrongerJabber ID: torsten.bron...@jabber.rwth-aachen.de
  or http://bronger-jmp.appspot.com

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



Re: Custom validation in model

2011-01-26 Thread Shawn Milochik
Overriding the clean method of the modelform is the way to go.

If you're getting an error about not having 'cleaned_data,' it could be because 
your custom clean method doesn't return anything -- you're responsible for 
returning it if you override it that method.

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.



Custom validation in model

2011-01-26 Thread Mario8k
Hi,
Supose that I have a model with a from and to date:

class Foo (models.Model):
from_date = models.DateField()
to_date = models.DateField()

What is the correct way to ensure that from_date is always before
to_date?
For now, I'm using only the admin site.

One way, may be, is to use custom validation to the admin, like
suggest in 
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#adding-custom-validation-to-the-admin.

But i think that is better to have a method to validate, inside model
logic, as suggested in an old thread
http://groups.google.com/group/django-users/browse_thread/thread/58c20c72f8b8725a/ec2a26c6118183fd?lnk=gst=validation#ec2a26c6118183fd

The latter one, does not work for me i dont know what i'm doing
wrong, i got an error msg :
'Foo' object has no attribute 'cleaned_data'

Regards,
Mario.

-- 
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: Need some ideas for how to implement a two-part form

2011-01-26 Thread Shawn Milochik
Try using formsets or model formsets.

http://docs.djangoproject.com/en/dev/topics/forms/formsets/

As for remembering some information about the form without displaying it, in 
your case it sounds like the guest form could have a foreign key to the party 
they're attending. You could exclude that  key from the form that is displayed 
to the user (using 'exclude' in the class meta). You can access the guest 
instance from within the guest form by using self.instance, so the party can be 
accessed via self.instance.party in your custom clean() and save() code.

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: Challenge with installing django on windows 7 64 bit

2011-01-26 Thread j_syk
Hello-
I only develop django on osx and lunix (ubuntu), but I've looked into
options for installing it on my windows desktop- even though I've
never gotten around to it...
I've found http://www.instantdjango.com/ which has all the common
files you need to develop in one package. According to the site, you
don't even need to install anything, just extract the .exe and work
there.
7-zip documentation says that it should be able to unzip tar.gz, but
maybe you somehow got a corrupted download. Have you tried downloading
it again?


On Jan 26, 11:23 am, Magge  wrote:
> Hi,
>
> I am trying to extract the installation files from the
> Django-1.2.4.tar.gz file that I got from the django website. I tried
> using winzip, 7z, cygwin and so forth. All these programs complain
> that the file isnt a valid archive.
>
> I used to work with django back in 2009 on Window. The installation
> used to be off the extract of a zip file I remember. How do I get
> going with the installation?
>
> I appreciate any inputs on this
>
> Thanks
> Keshav Magge

-- 
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: Error when adding to many to Many table via Admin

2011-01-26 Thread ara
I fixed the problem; it appears I was using database settings for
Django 1.1; as soon as I included the full path for sqlite3, & added a
suffix of .db to my database name, all was well.

On Jan 26, 4:43 pm, ara  wrote:
> Hi,
>
> I am a newbie at Django, & have created my models as follows:
>
> rom django.db import models
> from django.contrib.auth.models import User
>
> # Create your models here.
>
> class Ingredient(models.Model):
>     #user=models.ForeignKey(User)
>     ingname = models.CharField(max_length=30)
>
>     def __unicode__(self):
>         return self.ingname
>
> class Product(models.Model):
>     pname = models.CharField(max_length=70)
>     manuf = models.CharField (max_length=70)
>     ingredient = models.ManyToManyField(Ingredient)
>
>     def __unicode__(self):
>         return self.pname
>
>     class Meta:
>         ordering = ('pname',)
>
> The Ingredients table works fine in admin; however, when I try to add
> a new product, Django throws a fit. Below is the error I am getting:
>
> DatabaseError at /admin/fs1/product/add/
>
> no such table: fs1_product_ingredient
>
> Request Method:         POST
> Request URL:    http://localhost:8000/admin/fs1/product/add/
> Django Version:         1.2.3
> Exception Type:         DatabaseError
> Exception Value:
>
> no such table: fs1_product_ingredient
>
> Exception Location:     /Library/Python/2.6/site-packages/django/db/
> backends/sqlite3/base.py in execute, line 200
> Python Executable:      /usr/bin/python
> Python Version:         2.6.1
> Python Path:    ['/Users/aa/Desktop/python/Django-1.2.3/django_fs', '/
> System/Library/Frameworks/Python.framework/Versions/2.6/lib/
> python26.zip', '/System/Library/Frameworks/Python.framework/Versions/
> 2.6/lib/python2.6', '/System/Library/Frameworks/Python.framework/
> Versions/2.6/lib/python2.6/plat-darwin', '/System/Library/Frameworks/
> Python.framework/Versions/2.6/lib/python2.6/plat-mac', '/System/
> Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-
> mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/
> Versions/2.6/Extras/lib/python', '/System/Library/Frameworks/
> Python.framework/Versions/2.6/lib/python2.6/lib-tk', '/System/Library/
> Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old', '/
> System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
> lib-dynload', '/Library/Python/2.6/site-packages', '/System/Library/
> Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC', '/
> System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/
> python/wx-2.8-mac-unicode']
> Server time:    Wed, 26 Jan 2011 15:31:02 -0600
>
> Would appreciate your help on this. Thanks.
> -ara

-- 
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: custom Middleware for Django

2011-01-26 Thread Piotr Kilczuk
Hi,

More a Python thing, than Django.

You should never put custom code in the django package.

Generally you can put SWFUploadMiddleware inside, say, middleware.py in the
same directory as your settings.py.

Then you'd have to put:
'yourprojectname.middleware.SWFUploadMiddleware'

Once you understand how namespaces work, you'll be fine. At least until you
try do deploy using mod_wsgi ;)


Regards,
Piotr

-- 
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 compressed egg in mysqldb module

2011-01-26 Thread Cindy
Hi, all.  I'm getting this error, when trying to export my django site
to a new place:

TemplateSyntaxError: Caught ImproperlyConfigured while rendering:
Error loading MySQLdb module: bad local file header in /usr/local/lib/
python2.6/site-packages/MySQL_python-1.2.3-py2.6-freebsd-8.1-RELEASE-
amd64.egg

When I install the module (I reinstalled it clean after finding the
above problem), I get the above egg as a zip file (and it unzips
without errors).  But I can't seem to use it.  I've been trying to
figure out what to do next -- I've considered trying to make it use
uncompressed eggs, but even though I've uncompressed it in that
directory (site-packages) it's not helping.  Does django have some way
of telling python to not use compressed eggs, but to look for
uncompressed stuff instead?  Or are there other suggestions/
solutions?  (I'm kinda hoping not to reinstall python itself esp. as I
hate changing /usr/ports default setups as it always bites me later
when i reinstall/upgrade things)

When I reinstalled py-MySQLdb, it created the egg in /root/.python-
eggs/MySQL_python-1.2.3-py2.6-freebsd-8.1-RELEASE-amd64.egg but after
trying to run the django stuff, that egg disappears, leaving
the .python-eggs dir empty, and giving me the above error message.

Using the latest version of django, python & mysqldb, on freebsd 8.1
(moving it from a freebsd 8.0 install, where it's working fine --
django & python versions the same on both).

Thanks for any and all help & suggestions!

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



Need some ideas for how to implement a two-part form

2011-01-26 Thread j_syk
I'm working on a project that requires a RSVP form for an event.

The first step of the form would ask first & last name, e-mail,
attending (yes/no/unsure), and total number of guests attending.
Currently I have this form correctly working and submitting to the
database.

The second step of the form would interact with a second table which
would be the guest list and it would only contain the first & last
name of each guest along with who registered them. It would give
enough forms to add the names of the guests from that party attending
(based on number submitted in the first step and only if the rsvp
response was Yes). The registered by column should be filled
automatically and be hidden on the client-side.
So far I have this working for just one name entry (pulls from POST
data).

So the real question is, what is the best way to go about adding a
secondary form which automatically provides enough name fields based
on the field filled in the first form? Also it should add the
registering guest's name to the first set of fields for convenience.

I'd be open to adding some sort of js/jquery/ajax/whatever to have the
form be all one page and dynamically add the number of name fields but
still save those to the second database table.

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



Error when adding to many to Many table via Admin

2011-01-26 Thread ara
Hi,

I am a newbie at Django, & have created my models as follows:

rom django.db import models
from django.contrib.auth.models import User

# Create your models here.

class Ingredient(models.Model):
#user=models.ForeignKey(User)
ingname = models.CharField(max_length=30)

def __unicode__(self):
return self.ingname

class Product(models.Model):
pname = models.CharField(max_length=70)
manuf = models.CharField (max_length=70)
ingredient = models.ManyToManyField(Ingredient)

def __unicode__(self):
return self.pname

class Meta:
ordering = ('pname',)

The Ingredients table works fine in admin; however, when I try to add
a new product, Django throws a fit. Below is the error I am getting:

DatabaseError at /admin/fs1/product/add/

no such table: fs1_product_ingredient

Request Method: POST
Request URL:http://localhost:8000/admin/fs1/product/add/
Django Version: 1.2.3
Exception Type: DatabaseError
Exception Value:

no such table: fs1_product_ingredient

Exception Location: /Library/Python/2.6/site-packages/django/db/
backends/sqlite3/base.py in execute, line 200
Python Executable:  /usr/bin/python
Python Version: 2.6.1
Python Path:['/Users/aa/Desktop/python/Django-1.2.3/django_fs', '/
System/Library/Frameworks/Python.framework/Versions/2.6/lib/
python26.zip', '/System/Library/Frameworks/Python.framework/Versions/
2.6/lib/python2.6', '/System/Library/Frameworks/Python.framework/
Versions/2.6/lib/python2.6/plat-darwin', '/System/Library/Frameworks/
Python.framework/Versions/2.6/lib/python2.6/plat-mac', '/System/
Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-
mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/
Versions/2.6/Extras/lib/python', '/System/Library/Frameworks/
Python.framework/Versions/2.6/lib/python2.6/lib-tk', '/System/Library/
Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old', '/
System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/
lib-dynload', '/Library/Python/2.6/site-packages', '/System/Library/
Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC', '/
System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/
python/wx-2.8-mac-unicode']
Server time:Wed, 26 Jan 2011 15:31:02 -0600

Would appreciate your help on this. Thanks.
-ara

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



custom Middleware for Django

2011-01-26 Thread Rich
I'm new to Django and trying to place a custom middleware file in the
Django path. I'm modifying the settings.py file in my project.  The
swfupload.py is located in django

/usr/lib/python2.4/site-packages/django/middleware

I had it in the project earlier but ti did not work and this does not
work either.


MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
# 'django.middleware.swfupload.SWFUploadMiddleware',
}

-- 
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: Object Oriented or Relational Database?

2011-01-26 Thread Adrian Bool


Hi Bruno,

On 26 Jan 2011, at 12:55, bruno desthuilliers wrote:
> Some will talk about "OO/relational impedance mismatch" (ok, I cheated
> - Daniel just did;)), but I don't see it that way as far as I'm
> concerned - I'm using a relational model wrapped into an OO
> representation, and that's just what I want for most apps.

Many thanks for your comments; although it wasn't really what I wanted to hear 
- as I prefer the OO model over the relational.  I now feel that if I decide to 
use Django - not following a relational style will only cause me difficulties.

Kind regards,

aid

-- 
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 CMS 2.1 final was just released!

2011-01-26 Thread Jonas Obrist
We are very proud to announce that a few moments ago, the django CMS 
team released the final release for version 2.1.0. This new version adds 
new exciting features to our CMS and fixes many issues.


Whats new in 2.1?

- Frontend-editing. This is probably the most noticeable new feature, 
allowing you to edit your CMS pages directly on the page, rather than in 
the admin panel. This feature even works for non-CMS pages, if they use 
the newly introduced Placeholder Fields, see the next point.
- Placeholder Fields. A new model field allowing developers to use the 
full power of the CMS plugin system on their own models. This feature is 
already used in some third party extensions, such as the cmsplugin-blog, 
which even uses the full power of plugins and placeholders to provide 
multilingual content.
- Improved Menu. With the new menu, it is easy for developers to extend 
the menu tree with custom menu nodes, to link to non-CMS content on 
their websites.
- Better Apphooks. Apphooks are the CMS way to integrate third party 
Django applications into the CMS. Coupled with the new menu and possibly 
Placeholder Fields, it is as easy as never before to make your Django 
application integrate seamlessly into the django CMS. You can even make 
your application CMS-ready, without having the CMS as a dependency!
- Better tests. We've increased our test coverage a lot and have more 
robust continuous integration, building against Django 1.2 and Django 
trunk as well as Python 2.5 and 2.6. We also decreased the time required 
to run the test suite by a lot, making it easier for developers to test 
their code.
- Better documentation. We've listened to all the feedback we got on our 
documentation and carefully improved and extended it. It is also hosted 
on readthedocs.org now, allowing us to provide you with multiple 
versions of our documentation with ease.
- More core developers. We increased our bus factor by adding more core 
developers, so welcome Ųyvind Saltvik and Eric Robitaille to the django 
CMS team! Of course we're looking forward to welcome more developers in 
our team. So go ahead and fork us on github and start hacking!


At this point, we would like to thank the over 150 people who 
contributed to the django CMS, without you, there would be no 2.1 
release today! We're looking forward to your future contributions and to 
all the developers contributing to the CMS.


Together with this new release, we also release our new django-cms.org 
website. We've update the design and integrate with amazing services 
such as djangopackages.com and readthedocs.org. Also, we now have a 
proper demo set up, which allows you to play around on a fresh django 
CMS instance. The demos are generously hosted by ep.io.


In the name of the django CMS developer team,

Jonas Obrist

--
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: It is a good practice to use logging in the webs applications based on django ???

2011-01-26 Thread Shawn Milochik

On Jan 26, 2011, at 3:11 PM, Ariel wrote:

> I would want to know if it is a good practice to use the logging python 
> module in the web applications based on django ??? The performance is 
> severily affected ???
> 
> 
> Thanks for your attention.
> Regards
> Ariel

It's fantastic practice.  In fact, in 1.3 the logging has its own configuration 
settings right in settings.py.

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.



It is a good practice to use logging in the webs applications based on django ???

2011-01-26 Thread Ariel
I would want to know if it is a good practice to use the logging python
module in the web applications based on django ??? The performance is
severily affected ???


Thanks for your attention.
Regards
Ariel

-- 
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: Error when subclassing models.ForeignKey field

2011-01-26 Thread Roman Klesel
Hello again,

since no one responded untill now, I'd like to bring this back to attention.

If no one knows an answer to my question, maybe some one could give me
some hint what I could do?

Should I open a bug report?

Thanks in advance!

Roman

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



Challenge with installing django on windows 7 64 bit

2011-01-26 Thread Magge
Hi,

I am trying to extract the installation files from the
Django-1.2.4.tar.gz file that I got from the django website. I tried
using winzip, 7z, cygwin and so forth. All these programs complain
that the file isnt a valid archive.

I used to work with django back in 2009 on Window. The installation
used to be off the extract of a zip file I remember. How do I get
going with the installation?

I appreciate any inputs on this

Thanks
Keshav Magge

-- 
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: MySQL behavior about Warning/Exception

2011-01-26 Thread Tom Evans
On Wed, Jan 26, 2011 at 4:57 PM, etienned  wrote:
> Thanks for your answer.
>
> I have compared the .cnf on both of my servers and they are identical?
>
> Then, in my settings.py file, I set my database options to
> 'sql_mode' : 'TRADITIONAL' and now I don't have the error anymore. So
> that fix my problem.
>
> But that doesn't explain the 2 different behaviors on 2 mostly
> identical servers?
>
> Etienne
>

I can't help you with your problem, I don't know why they are behaving
differently. However, it is a universal truth of computing that given
the same input and environment, the same software will produce the
same result.
Somewhere along the way therefore, you must not have the same input,
environment or software. Establishing where the two differ will help
you solve the issue, I am sure.

Cheers

Tom

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



Re: MySQL behavior about Warning/Exception

2011-01-26 Thread etienned
Thanks for your answer.

I have compared the .cnf on both of my servers and they are identical?

Then, in my settings.py file, I set my database options to
'sql_mode' : 'TRADITIONAL' and now I don't have the error anymore. So
that fix my problem.

But that doesn't explain the 2 different behaviors on 2 mostly
identical servers?

Etienne

On Jan 25, 6:34 pm, Dirk Eschler  wrote:
> Am Dienstag, 25. Januar 2011, 19:48:48 schrieb etienned:
>
>
>
> > I would like to understand how Warning/Exception are treated in the
> > MySQL backend because I have a weird bug.
>
> > When I run the test suite of django-reversion on my production server
> > (Ubuntu 10.04) one test fail because MySQL give a warning instead of
> > an exception. If I run the same test on my testing server (again
> > Ubuntu 10.04 but in VirtualBox, so it's mostly the same software)
> > MySQL give the exception so the test didn't fail. I tried on both
> > server with DEBUG = True and DEBUG = False with the same result.
>
> > For more info you could check here:
> >https://github.com/etianen/django-reversion/issues/closed#issue/18/co...
> > 566932
>
> > Anyone have an idea on this bug or, at least, explain how Warning/
> > Exception are treated in the MySQL backend?
>
> Hello,
>
> the behaviour depends on the "non-strict" setting of the MySQL server. If i
> remember correctly in non-strict mode an error will be raised. You should
> compare the server configs of both machines.
>
> Best Regards,
> Dirk Eschler
>
> --
> Dirk Eschler 

-- 
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 - Verfication of runserver vs browser

2011-01-26 Thread Kimberly Harvey
Thanks, I restarted the whole Django program. Will send feedbacks if any
problems this week.

On Tue, Jan 25, 2011 at 12:17 AM, raj  wrote:

> If none of above seems to work, You may be using a browser like google
> chrome, which by default ignores the localhost.
>
> --
>  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: Ajax and SSL

2011-01-26 Thread Tom Evans
On Sat, Jan 1, 2011 at 7:17 PM, Jakob H  wrote:
> Hi,
>
> I'm using Satchmo to build a store for a Django-powered webpage.
> Satchmo provides a convenient middleware
> ('satchmo_store.shop.SSLMiddleware.SSLRedirect') which allows me to
> add { 'SSL' : True } arguments to my view specifications (in urls.py).
> This forwards requests to using the HTTPS protocol when so specified.
> There are other middlewares that do roughly the same thing, so this is
> not necessarily Satchmo-specific.
>
> I have some views configured to be forwarded to using SSL (HTTPS
> protocol). However, I also have some general Ajax views configured.
> E.g. I have one that updates a progress bar on every page once that
> page has loaded.
>
> The problem is the following: consider me having the following
> (abstract) specification in urls.py:
>
> VIEW1[SSL=True]
> AJAX1[SSL=False]
>
> where a client-side call to AJAX1 is performed once the page has fully
> loaded as generated by VIEW1. The page generated by VIEW1 should call
> AJAX1 using the HTTPS protocol, but the convenient middleware will
> forward it to HTTP, as specified above, which will cause problems
> (i.e. it will not work). If I set AJAX1[SSL=True] I will get problems
> when I access views using the HTTP protocol.
>
> Is there a way to make use of the above-mentioned convenient
> declarative middleware (just adding { 'SSL' : True } in view-
> specifications), but get around these kinds of problems?
>
> What are some common design patterns for these kinds of problems?
>
> Thanks,
> Jakob
>

I don't use satchmo, but is there a third option for SSL, None? In my
SSL middleware, setting SSL to True implies that the view must be
loaded over SSL, setting it to False implies that it must not be, and
not setting it implies that the middleware should stay out of it.

If you can finagle that, then you should do so for your your AJAX
views, and refer to them in your templates/JS using URI references
rather than an absolute URI ('/foo/bar/' rather than
'http://wibble.com/foo/bar/'). This way, the browser will DTRT with
the protocol when making the ajax call - SSL when the view is loaded
over SSL, HTTP otherwise.


Cheers

Tom

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



Re: Confusion about the new staticfiles contrib app

2011-01-26 Thread Brian Neal
On Jan 26, 8:46 am, Jonas Geiregat  wrote:
>
> MEDIA_ROOT is the path to the directory where your files will live.
>
> MEDIA_URL is the URL the get to those files.
>
> So if MEDIA_ROOT='/home/you/media'
> and MEDIA_URL='site-media/'
>
> Then if you want to view a file located at /home/you/media/thisFile.jpg you 
> enterhttp://yoursite.com/site-media/thisFile.jpg.

I understand the settings just fine. Are you saying that the dev
server is serving your media files? Because it isn't for me. It is
only serving the static media.

> The same counts for STATIC_ROOT and STATIC_URL.

What do you have STATIC_URL set to? Is it different than your
MEDIA_URL?

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: Restrict access to the whole application

2011-01-26 Thread tobik
Well, by an application I meant the 'subfolder' in your django project
directory, which you create using manage.py startapp 'appname' (or
maybe django.admin.py). That confused me. So if in your case an
application is a model inside database, then I understand that you can
use standard permissions and singal 'post_save'. I checked your code
 and the line 44
made it all clear.

When I understand it finally I am not sure whether I will go this way.
You know, my project is going to have like 3-4 stable applications. I
don't actually need to dynamically add new ones and the whole layer
for working with applications (view.connect) is a little bit brutal
for my needs. While discussing with you I found out that there is such
things like Middleware in django, so I will probably use it instead
(see the link in second post).

Anyway, I feel much smarter thanks to you! So thanks again for your
time.


On 26 led, 15:45, Brian Bouterse  wrote:
> Maybe this will clear things up, but if not, write back.  In my example an
> "application" is a resource inside of a django project, not a django project
> itself.  Your description of 'use_appname' is correct.  An app for me is a
> model and so I have setup a post_save
> signalon
> that model so that when the model is created the post save signal
> ensures
> the permission is created.
>
> The permission is then checked when a user goes to use an application using
> standard django permission checking.  You could use this same scheme to
> limit access to installed django application I could imagine.
>
> Brian
>
>
>
> On Wed, Jan 26, 2011 at 9:39 AM, tobik  wrote:
> > Thank you for your answer. It is to much information for me and I am
> > not sure whether I understand it correctly :)
>
> > So basically you create for each application a corresponding
> > permission which looks something like 'use_appname'. If the user wants
> > to access 'appname' application, he has to have 'use_appname'
> > permission. And when these permissions are being created? When
> > starting a new application? (./manage.py startapp appname) And Django
> > just knows that permission named use_appname belongs to 'appname'?
> > It's a part of core? Sorry for my dumb question, I just don't know
> > much yet about how does Django work under the hood.
>
> > Btw I found also this  > login-required-middleware> which could also solve my problem. It
> > wouldn't be difficult to modify the code in order to add support for
> > groups.
>
> > On 26 led, 14:39, Brian Bouterse  wrote:
> > > I've used a post_save signal to create a per-object permission such as
> > 'use
> > > application X'  This permission is checked at application use time.
> > > Hereis the
> > > code I wrote to do, I think, exactly what you want.  It is part of a
> > > django
> > > based connection broker  that manages
> > cloud
> > > virtual machines to provide applications to users.
>
> > > Best,
> > > Brian
>
> > > On Wed, Jan 26, 2011 at 2:11 AM, tobik  wrote:
> > > > My first question is whether it is possible to restrict access to the
> > > > whole application from one place. I could write @login_required over
> > > > every function but is there a better way?
>
> > > > My second question is whether it is possible to use user groups for
> > > > restricting applications. I want for example that only users in group
> > > > 'teachers' could access the 'teaching' application. I know that groups
> > > > are meant for something else but it would spare me a lot of time.
>
> > > > I've just started with Django so be patient with 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.
>
> > > --
> > > 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.
>
> --
> Brian Bouterse
> ITng Services


Re: looking cheap Python/Django/mySQL hosting

2011-01-26 Thread James Abel
+1 on http://www.webfaction.com/ .  I'm using it and the automation 
and documentation are good.  Fast servers and reasonably priced.

-- 
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: Confusion about the new staticfiles contrib app

2011-01-26 Thread Jonas Geiregat
>> 
> 
> I don't understand this. One is a URL, the other is a file path. Why
> would I set STATIC_URL = MEDIA_ROOT? Or did you make a typo and mean
> MEDIA_URL? That might make more sense to me.



MEDIA_ROOT is the path to the directory where your files will live.


MEDIA_URL is the URL the get to those files.

So if MEDIA_ROOT='/home/you/media'
and MEDIA_URL='site-media/' 

Attention never use MEDIA_URL='media/' because that url is already used by the 
admin interface.

Then if you want to view a file located at /home/you/media/thisFile.jpg you 
enter http://yoursite.com/site-media/thisFile.jpg.

The same counts for STATIC_ROOT and STATIC_URL.

I hope everything is clear now. I'm aware the docs are pretty much useless on 
these subjects. But then again that's about the only thing you can say bad 
about django's documentation.

Sorry if I wasn't that obvious this morning but I didn't sleep well and I had 
little time. But I could feel your frustration since I had the same problem 
going on some day's ago.

Good luck!

-- 
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: Restrict access to the whole application

2011-01-26 Thread Brian Bouterse
Maybe this will clear things up, but if not, write back.  In my example an
"application" is a resource inside of a django project, not a django project
itself.  Your description of 'use_appname' is correct.  An app for me is a
model and so I have setup a post_save
signalon
that model so that when the model is created the post save signal
ensures
the permission is created.

The permission is then checked when a user goes to use an application using
standard django permission checking.  You could use this same scheme to
limit access to installed django application I could imagine.

Brian

On Wed, Jan 26, 2011 at 9:39 AM, tobik  wrote:

> Thank you for your answer. It is to much information for me and I am
> not sure whether I understand it correctly :)
>
> So basically you create for each application a corresponding
> permission which looks something like 'use_appname'. If the user wants
> to access 'appname' application, he has to have 'use_appname'
> permission. And when these permissions are being created? When
> starting a new application? (./manage.py startapp appname) And Django
> just knows that permission named use_appname belongs to 'appname'?
> It's a part of core? Sorry for my dumb question, I just don't know
> much yet about how does Django work under the hood.
>
> Btw I found also this  login-required-middleware> which could also solve my problem. It
> wouldn't be difficult to modify the code in order to add support for
> groups.
>
> On 26 led, 14:39, Brian Bouterse  wrote:
> > I've used a post_save signal to create a per-object permission such as
> 'use
> > application X'  This permission is checked at application use time.
> > Hereis the
> > code I wrote to do, I think, exactly what you want.  It is part of a
> > django
> > based connection broker  that manages
> cloud
> > virtual machines to provide applications to users.
> >
> > Best,
> > Brian
> >
> >
> >
> > On Wed, Jan 26, 2011 at 2:11 AM, tobik  wrote:
> > > My first question is whether it is possible to restrict access to the
> > > whole application from one place. I could write @login_required over
> > > every function but is there a better way?
> >
> > > My second question is whether it is possible to use user groups for
> > > restricting applications. I want for example that only users in group
> > > 'teachers' could access the 'teaching' application. I know that groups
> > > are meant for something else but it would spare me a lot of time.
> >
> > > I've just started with Django so be patient with 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.
> >
> > --
> > 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.
>
>


-- 
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: Restrict access to the whole application

2011-01-26 Thread tobik
Thank you for your answer. It is to much information for me and I am
not sure whether I understand it correctly :)

So basically you create for each application a corresponding
permission which looks something like 'use_appname'. If the user wants
to access 'appname' application, he has to have 'use_appname'
permission. And when these permissions are being created? When
starting a new application? (./manage.py startapp appname) And Django
just knows that permission named use_appname belongs to 'appname'?
It's a part of core? Sorry for my dumb question, I just don't know
much yet about how does Django work under the hood.

Btw I found also this  which could also solve my problem. It
wouldn't be difficult to modify the code in order to add support for
groups.

On 26 led, 14:39, Brian Bouterse  wrote:
> I've used a post_save signal to create a per-object permission such as 'use
> application X'  This permission is checked at application use time.
> Hereis the
> code I wrote to do, I think, exactly what you want.  It is part of a
> django
> based connection broker  that manages cloud
> virtual machines to provide applications to users.
>
> Best,
> Brian
>
>
>
> On Wed, Jan 26, 2011 at 2:11 AM, tobik  wrote:
> > My first question is whether it is possible to restrict access to the
> > whole application from one place. I could write @login_required over
> > every function but is there a better way?
>
> > My second question is whether it is possible to use user groups for
> > restricting applications. I want for example that only users in group
> > 'teachers' could access the 'teaching' application. I know that groups
> > are meant for something else but it would spare me a lot of time.
>
> > I've just started with Django so be patient with 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.
>
> --
> 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: Confusion about the new staticfiles contrib app

2011-01-26 Thread Brian Neal
On Jan 26, 1:46 am, Jonas Geiregat  wrote:
> Op 26-jan-2011, om 06:46 heeft Brian Neal het volgende geschreven:
>
> > Hi -
> > I'm trying to cut over my project to use the new staticfiles
> > application. I'm using the dev server with DEBUG = True on a recent
> > SVN trunk checkout. My STATIC_URL is '/static/' and my MEDIA_URL is
> > 'http://localhost:8000/media/'in this environment.
>
> STATIC_URL and MEDIA_URL are two different things.

Agree.

>
> if you want to serve static files that are related to your 
> webdesign/development you should use STATIC.
> User related files such as uploaded files such be placed inside the MEDIA 
> path.

That is what I'm trying to do.

>
> so change STATIC_URL into MEDIA_ROOT='static/'.

I don't understand this. One is a URL, the other is a file path. Why
would I set STATIC_URL = MEDIA_ROOT? Or did you make a typo and mean
MEDIA_URL? That might make more sense to me.

My question is, if I want to serve my apps' static files at the URL /
static/ and user-uploaded media at /media/ (Is this an unusual
requirement? Maybe this is typically only done in production?) what is
the best way to do this with the dev server, and should the docs be
strengthened to support this? The dev server, with DEBUG=True, does a
good job of serving my apps' static files at the URL rooted at /
static/, but it (obviously) 404's when a request is made for /media/.
So here I think I need to configure the new static serving view with
the URL pattern /media/ (and point it at my MEDIA_ROOT as I showed in
my original post).

Or, do most people (in dev. mode) set MEDIA_URL = STATIC_URL, and then
add the MEDIA_ROOT path to the STATICFILES_DIRS setting? Or do
something else?

Could some people could post their full (STATIC|MEDIA)_(ROOT|URL) and
STATICFILES_* settings for their dev server environment? I guess I am
looking for some "best practice" examples; for some reason this is
really tripping me up. Thank you.

-- 
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: forbid clones

2011-01-26 Thread Jaroslav Dobrek


On 26 Jan., 13:29, Chris Matthews  wrote:
> Have a look at unique_together:
> Django | Model Meta options | Django 
> documentationhttp://docs.djangoproject.com/en/dev/ref/models/options/
>
> Jump to unique_togetherý: Options.unique_together¶. Sets of field names that, 
> ... For convenience, unique_together can be a single list when dealing ...

Great, thank you. That is exactly what I was looking for.

-- 
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: DB-Views or read-only tables in models

2011-01-26 Thread bvdb
On Jan 26, 3:22 am, Russell Keith-Magee 
wrote:
> Django doesn't have a built-in representation of a view. ..
>
> You can define a Django model as a wrapper around a view by marking it
> managed, but that doesn't make the model read-only -- it just prevents
> Django from trying to create the model during syncdb.

Ok, thanks for this clear answer.
I've noted the "managed" option that might avoid errors on a sync but
as django still thinks these tables are updateable it's not a real
solution - and it's not wise to recommend django for the situations
mentioned in my first post.

So the django ORM is in the same situation as the Ruby-on-Rails ORM.
But, as opposed to Ruby, a possible solution already exists in the
form of SQLalchemy.
This approach has already been followed:
http://code.google.com/p/django-sqlalchemy/

Progress in this project seems a bit low, but maybe one day some
enlighted ghosts will take up the torch ...

-- 
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: looking cheap Python/Django/mySQL hosting

2011-01-26 Thread CrabbyPete
http://www.asmallorange.com/

On Jan 26, 12:36 am, GSV  wrote:
> for small project.
>
> Thank you

-- 
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: looking cheap Python/Django/mySQL hosting

2011-01-26 Thread Praveen Krishna R
*webfaction.com is also good, you can go live with your app in minutes.*
*See http://djangofriendly.com for a list of django friendly web hosts...
*
On Wed, Jan 26, 2011 at 4:20 PM, Jonas Geiregat  wrote:

>
>
>
> > for small project.
> >
>
> I use djangoeurope.com. They have server in Paris and Zurich.
>
>
>
> --
> 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.
>
>


-- 
*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: Restrict access to the whole application

2011-01-26 Thread Brian Bouterse
I've used a post_save signal to create a per-object permission such as 'use
application X'  This permission is checked at application use time.
Hereis the
code I wrote to do, I think, exactly what you want.  It is part of a
django
based connection broker  that manages cloud
virtual machines to provide applications to users.

Best,
Brian

On Wed, Jan 26, 2011 at 2:11 AM, tobik  wrote:

> My first question is whether it is possible to restrict access to the
> whole application from one place. I could write @login_required over
> every function but is there a better way?
>
> My second question is whether it is possible to use user groups for
> restricting applications. I want for example that only users in group
> 'teachers' could access the 'teaching' application. I know that groups
> are meant for something else but it would spare me a lot of time.
>
> I've just started with Django so be patient with 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.
>
>


-- 
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: looking cheap Python/Django/mySQL hosting

2011-01-26 Thread Jonas Geiregat



> for small project.
> 

I use djangoeurope.com. They have server in Paris and Zurich.



-- 
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: copying sqlite database file between projects

2011-01-26 Thread Ion Ray Studios
Yup. That did it.  The errors were a result of setttings.py pointing to 
the wrong database.


Too much mucking about with too many things at the same time...


On 25/01/11 16:36, Michael wrote:

I believe table names are all lower-case, so try 'sample_app_person'


--
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: Object Oriented or Relational Database?

2011-01-26 Thread bruno desthuilliers
On 26 jan, 12:41, Adrian Bool  wrote:
>
> I'm defining the DB in Python; using objects and inheritance.  As such, when 
> I'm doing this I'm thinking in an object orientated (OO) manner - a service 
> uses a number of resources so I create a Service object with with either 
> foreign key or many-to-many (as appropriate) relationship to the Resource 
> objects.  This gives me nice referential integrity and I can be sure that the 
> Service has valid connections to the Resources it requires.
>
> It seems, however, that Django expects the models not to be defined in an OO 
> manner.  For example; should I wish resources to be listed as Inlines on the 
> Service's page  I can only do this if the foreign key is with the Resource - 
> pointing 'up' the stack to the services - as possible to being pointed to by 
> the Service.  Django seems to be defining stricture using an OO language; but 
> expecting that structure in a more traditional, relational database, style 
> where entries point up to their owners rather than the owners pointing down 
> to their children.

That's indeed how a relational DB works, and Django's ORM doesn't try
to pretend the relational DB doesn't exists or is just a dumb 'bit
bucket'. So, while models ares defined as classes, these are mostly -
from this POV at least - "technical" objects wrapping the relational
model, and not "pure" OO domain objects (whatever a "pure" OO domain
object might be). This doesn't mean you have to go for an "anemic
domain model" neither - your relational schema is part of the "domain
space", and models (as well as managers) are also here to support
additional responsabilitie.

Some will talk about "OO/relational impedance mismatch" (ok, I cheated
- Daniel just did;)), but I don't see it that way as far as I'm
concerned - I'm using a relational model wrapped into an OO
representation, and that's just what I want for most apps.

-- 
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: forbid clones

2011-01-26 Thread Adrian Bool

Please ignore this dumn-ass p
On 26 Jan 2011, at 12:34, Adrian Bool wrote:

> 
> On 26 Jan 2011, at 12:26, Jaroslav Dobrek wrote:
> 
>>> 
>>> http://docs.djangoproject.com/en/1.2/ref/models/fields/#unique
>> Example:
>> 
>> This should be allowed:
>> 
>> car1: manufacturer = "foo", name = "bar"
>> car2: manufacturer = "foo", name = "baz"
>> 
>> This should not be allowed:
>> 
>> car1: manufacturer = "foo", name = "bar"
>> car2: manufacturer = "foo", name = "bar"
> 
> Doesn't look to be directly possible from the Django's API; but I guess you 
> could,
> 
> class Car(models.Model):
>   manufacturer = models.CharField(max_length=127)
>   name = models.CharField(max_length=127)
>   manufacturer_name = models.CharField(max_length=256, unique=True)
> 
>def save(self, *args, **kwargs):
>manufacturer_name = "%s_%s" % (self.manufacturer, self.name)
>super(Charge, self).save(*args, **kwargs)
> 


Urgh.  Please ignore this dis-information.  Hat off to Chris for knowing what 
he types.

aid


-- 
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: forbid clones

2011-01-26 Thread Adrian Bool

On 26 Jan 2011, at 12:26, Jaroslav Dobrek wrote:

>> 
>> http://docs.djangoproject.com/en/1.2/ref/models/fields/#unique
> Example:
> 
> This should be allowed:
> 
> car1: manufacturer = "foo", name = "bar"
> car2: manufacturer = "foo", name = "baz"
> 
> This should not be allowed:
> 
> car1: manufacturer = "foo", name = "bar"
> car2: manufacturer = "foo", name = "bar"

Doesn't look to be directly possible from the Django's API; but I guess you 
could,

class Car(models.Model):
manufacturer = models.CharField(max_length=127)
name = models.CharField(max_length=127)
manufacturer_name = models.CharField(max_length=256, unique=True)

def save(self, *args, **kwargs):
manufacturer_name = "%s_%s" % (self.manufacturer, self.name)
super(Charge, self).save(*args, **kwargs)

aid

-- 
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: forbid clones

2011-01-26 Thread Chris Matthews
Have a look at unique_together:
Django | Model Meta options | Django documentation
http://docs.djangoproject.com/en/dev/ref/models/options/

Jump to unique_together‎: Options.unique_together¶. Sets of field names that, 
... For convenience, unique_together can be a single list when dealing ...
docs.djangoproject.com/en/dev/ref/models/options/
Labeled Latest docs  1.0 docs  All docs


-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Jaroslav Dobrek
Sent: 26 January 2011 14:26
To: Django users
Subject: Re: forbid clones

>
> http://docs.djangoproject.com/en/1.2/ref/models/fields/#unique

Although this does help, it leaves one question open:

How can we forbid only such pairs of objects that have the same value
in all of their attributes.

Example:

This should be allowed:

car1: manufacturer = "foo", name = "bar"
car2: manufacturer = "foo", name = "baz"

This should not be allowed:

car1: manufacturer = "foo", name = "bar"
car2: manufacturer = "foo", name = "bar"


-- 
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: forbid clones

2011-01-26 Thread Jaroslav Dobrek
>
> http://docs.djangoproject.com/en/1.2/ref/models/fields/#unique

Although this does help, it leaves one question open:

How can we forbid only such pairs of objects that have the same value
in all of their attributes.

Example:

This should be allowed:

car1: manufacturer = "foo", name = "bar"
car2: manufacturer = "foo", name = "baz"

This should not be allowed:

car1: manufacturer = "foo", name = "bar"
car2: manufacturer = "foo", name = "bar"


-- 
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: Customising the Admin Save Models in DJango 1.1

2011-01-26 Thread Adrian Bool

Hu,

On 26 Jan 2011, at 07:22, Prof Falken wrote:
> I have two models, the first is a 'change request ticket' and the
> second reflects the status of that ticket.  They are linked by a
> ForeignKeyField on the first table.

You may find it best to collapse them into a single object; using the 'choice' 
option to allow the user to set the ticket's state.

> The two problems that I have are:
> 
> 1) Some of the 'states' should mark the ticket as closed, so when the
> ticket is saved with the state of 'closed', it should be marked as
> 'completed' with the date and time the action was carried out.

You can jump in and change the model's data before the model is saved by 
over-riding the 'save' method in your model.

Below is one of my models.  My frequency attribute could be quite similar to 
what you need for your state field.  Below you can see where I'm setting a 
number of my attributes (based upon the parent object when the Charge object is 
created as an Inline) before this Charge is saved,

class Charge (models.Model):
CHARGE_FREQUENCY_CHOICES = (
(u'NRC', u'Non-Recurring'),
(u'MRC', u'Monthly'),
(u'QRC', u'Quaterly'),
(u'ARC', u'Annual')
)

frequency = models.CharField(max_length=15, 
choices=CHARGE_FREQUENCY_CHOICES)
   

def save(self, *args, **kwargs):
self.description = self.service
self.customer = self.service.customer
self.legacy_charge_id = None
self.prorata = False
self.created_date = datetime.date.today()
self.started_date = self.service.completed_date
self.expiry_date = self.service.expiry_date
self.terminated_date = self.service.terminated_date
super(Charge, self).save(*args, **kwargs)

In order that the user does not set (or need to set) the above fields, set the 
fields attribute of the Admin object so only the values you want the user to 
control are visible.  Here's mine,

class ChargeInlineAdmin(admin.TabularInline):
fields = ('frequency','amount', 'currency', 'vat_chargeable')
model = Charge
extra = 0


Regards,

aid

Adrian Bool
a...@logic.org.uk



-- 
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: Object Oriented or Relational Database?

2011-01-26 Thread Adrian Bool

On 26 Jan 2011, at 11:55, Daniel Roseman wrote:
> 
> This is what's known as the object-relational impedance mismatch [1]. 
> Unfortunately, as you've noticed, OO concepts don't map completely cleanly 
> onto the relational model, and this is an issue with all systems that attempt 
> to do it. Django does what it can to smooth over the gaps, but can't always 
> do everything.

Thanks for the link; interesting reading.

> However, you should not be getting circular dependencies. Can you provide 
> some examples? One place where I often see them is when two models in 
> separate applications are related via ForeignKey, and the developer has 
> imported each model into the other's models.py. But it isn't necessary to 
> import them at all, as you can refer to models via strings: 
> 
> myfkfield = models.ForeignKey('otherapp.OtherModel')
> 
> so no circular dependency is declared. Does that solve your problem? If not, 
> some examples will be helpful.


I've used the string form for forward references of models; but I still seem to 
get problems when performing the initial migration (using South) of the 
database as the table to which the forward reference points does not exist at 
the time of creating the initial table.

I've just tried using a basic syncdb and that works fine.  I presume I'm seeing 
problems as South's migrations work one app at a time; in contrast to syncdb 
that seems to install the whole project - only worrying about dependencies at 
the end.

Still; I feel circular dependencies are bad; even work arounds are possible.

Is there a recommended path to take with Django?

Kind regards,

aid



-- 
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: forbid clones

2011-01-26 Thread Jaroslav Dobrek
> http://docs.djangoproject.com/en/1.2/ref/models/fields/#unique
>

Wow, thanks. In this group answers almost come before one is able to
submit the posting.

-- 
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: forbid clones

2011-01-26 Thread Tom Evans
On Wed, Jan 26, 2011 at 11:57 AM, Jaroslav Dobrek
 wrote:
> Hi,
>
> how can I forbid that clones of a certain type are stored by an admin?
>
> Example: Suppose there are cars in the database and cars have as only
> attribute a name. How can I prevent that two cars that have the same
> name are stored?
>
> Jaroslav
>

http://docs.djangoproject.com/en/1.2/ref/models/fields/#unique

HTH

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.



forbid clones

2011-01-26 Thread Jaroslav Dobrek
Hi,

how can I forbid that clones of a certain type are stored by an admin?

Example: Suppose there are cars in the database and cars have as only
attribute a name. How can I prevent that two cars that have the same
name are stored?

Jaroslav

-- 
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: method of method

2011-01-26 Thread Jaroslav Dobrek
Thanks to all of you.

Now I understand this better.

Jaroslav

-- 
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: Object Oriented or Relational Database?

2011-01-26 Thread Daniel Roseman
On Wednesday, January 26, 2011 11:41:10 AM UTC, aid wrote:
>
>
> Hi,
>
> I'm creating a DB using Django for managing our companies data - customers, 
> services, orders, billing etc.  I'm using the Django admin interface to 
> manage the data.
>
> I seem to be consistently at odds with myself and would be good to hear the 
> community's point of view on this.
>
> I'm defining the DB in Python; using objects and inheritance.  As such, 
> when I'm doing this I'm thinking in an object orientated (OO) manner - a 
> service uses a number of resources so I create a Service object with with 
> either foreign key or many-to-many (as appropriate) relationship to the 
> Resource objects.  This gives me nice referential integrity and I can be 
> sure that the Service has valid connections to the Resources it requires.
>
> It seems, however, that Django expects the models not to be defined in an 
> OO manner.  For example; should I wish resources to be listed as Inlines on 
> the Service's page  I can only do this if the foreign key is with the 
> Resource - pointing 'up' the stack to the services - as possible to being 
> pointed to by the Service.  Django seems to be defining stricture using an 
> OO language; but expecting that structure in a more traditional, relational 
> database, style where entries point up to their owners rather than the 
> owners pointing down to their children.
>
> In order to try to fit in with Django Admin I've ended up using both 
> styles.  Unsurprisingly this mixture of styles is now causing me problems 
> with circular dependencies.  I know I need to jump one way or the other; but 
> would be great to get some comments from experienced Django coders before I 
> decide which way...
>
> Any comments/advice welcome...
>
> Cheers,
>
> aid
>

This is what's known as the object-relational impedance mismatch [1]. 
Unfortunately, as you've noticed, OO concepts don't map completely cleanly 
onto the relational model, and this is an issue with all systems that 
attempt to do it. Django does what it can to smooth over the gaps, but can't 
always do everything.

However, you should not be getting circular dependencies. Can you provide 
some examples? One place where I often see them is when two models in 
separate applications are related via ForeignKey, and the developer has 
imported each model into the other's models.py. But it isn't necessary to 
import them at all, as you can refer to models via strings: 

myfkfield = models.ForeignKey('otherapp.OtherModel')

so no circular dependency is declared. Does that solve your problem? If not, 
some examples will be helpful.
--
DR.

[1] wikipedia has a good 
write-up: http://en.wikipedia.org/wiki/Object-relational_impedance_mismatch

-- 
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: looking cheap Python/Django/mySQL hosting

2011-01-26 Thread Praveen Krishna R
Free hosting @  *http://www.alwaysdata.com/*

On Wed, Jan 26, 2011 at 8:36 AM, GSV  wrote:

> for small project.
>
> Thank you
>
> --
> 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.
>
>


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



Customising the Admin Save Models in DJango 1.1

2011-01-26 Thread Prof Falken
Hi all,

I'm relatively new to DJango (I've been using it for about three
months) and so far I'm loving it - makes a really nice change from
PHP... ;)

I've run into an issue which my Google foo skills just can't find an
answer to - how to I edit the Admin models and the way that they are
saved?

I have two models, the first is a 'change request ticket' and the
second reflects the status of that ticket.  They are linked by a
ForeignKeyField on the first table.

The two problems that I have are:

1) Some of the 'states' should mark the ticket as closed, so when the
ticket is saved with the state of 'closed', it should be marked as
'completed' with the date and time the action was carried out.

2) Each ticket is created by a user, each additional piece of
information is created by a user.  Both sections should take this
information from the current session, not a drop down list, otherwise
I cannot guarantee that the reporting engine I am also writing will
return accurate data about who opened/edited/closed each ticket.

I don't particularly want to write my own forms for this, but it's not
something that I can find a way of doing.  I'm sure I'm not the first
to do this, however if I do get a solution through this group, I
promise to put up a blog post about it! :)

To answer a few questions I'm sure some of you will have:

Q) Why DJango 1.1, why not upgrade?
A) Because 1.1 is what ships with CentOS and that's what we use at
work.  Company policy is not to install from "source".

Q) Where is the code?
A) The code is part of the Edison project and the exact model can be
found at
https://github.com/proffalken/edison/blob/master/changemanagement/models.py

Kind regards,

Matt

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



Restrict access to the whole application

2011-01-26 Thread tobik
My first question is whether it is possible to restrict access to the
whole application from one place. I could write @login_required over
every function but is there a better way?

My second question is whether it is possible to use user groups for
restricting applications. I want for example that only users in group
'teachers' could access the 'teaching' application. I know that groups
are meant for something else but it would spare me a lot of time.

I've just started with Django so be patient with 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.



looking cheap Python/Django/mySQL hosting

2011-01-26 Thread GSV
for small project.

Thank you

-- 
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: Object Oriented or Relational Database?

2011-01-26 Thread Adrian Bool

Hi,

I'm creating a DB using Django for managing our companies data - customers, 
services, orders, billing etc.  I'm using the Django admin interface to manage 
the data.

I seem to be consistently at odds with myself and would be good to hear the 
community's point of view on this.

I'm defining the DB in Python; using objects and inheritance.  As such, when 
I'm doing this I'm thinking in an object orientated (OO) manner - a service 
uses a number of resources so I create a Service object with with either 
foreign key or many-to-many (as appropriate) relationship to the Resource 
objects.  This gives me nice referential integrity and I can be sure that the 
Service has valid connections to the Resources it requires.

It seems, however, that Django expects the models not to be defined in an OO 
manner.  For example; should I wish resources to be listed as Inlines on the 
Service's page  I can only do this if the foreign key is with the Resource - 
pointing 'up' the stack to the services - as possible to being pointed to by 
the Service.  Django seems to be defining stricture using an OO language; but 
expecting that structure in a more traditional, relational database, style 
where entries point up to their owners rather than the owners pointing down to 
their children.

In order to try to fit in with Django Admin I've ended up using both styles.  
Unsurprisingly this mixture of styles is now causing me problems with circular 
dependencies.  I know I need to jump one way or the other; but would be great 
to get some comments from experienced Django coders before I decide which way...

Any comments/advice welcome...

Cheers,

aid

-- 
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 form(s) for intermediary models

2011-01-26 Thread Ian Lewis
Hi,

What you want to do here is use a Django "Formset" which contains your
ModelForms. Since you want to show one form per person
regardless of whether they are a member or not we can't use the
modelformset_factory() and will have to do some manipulation of the
initial data using the formset_factory() function instead. I haven't
actually run and tested the code below (user beware) but you'll need
to do something similar in order to do what you're describing.

See:
http://docs.djangoproject.com/en/dev/topics/forms/formsets/
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#model-formsets

Using the Membership form (I called it MembershipForm) from the previous poster:

from django.forms.models import formset_factory

def myview(request, group_id):
group = Group.objects.get(pk=group_id)

MembershipFormset = formset_factory(form=MembershipForm, extra=0)
if request.method == 'POST':
formset = MembershipFormset(request.POST)
if formset.is_valid():
# since the formset itself isn't a ModelFormset
# we need to loop over the individual ModelForms
# and save() them.
for form in formset.forms:
form.save()
# Do something
else:

# Make a person_id to membership mapping.
memberships = dict(map(lambda m: (m.person_id, m),
groups.membership_set.all()))
initial = {}
We need to order by pk (or some other field) here so that the
form indexes match.
for i,person in enumerate(Person.objects.all().order_by("pk")):
prefix = form.get_default_prefix()
membership = memberships.get(person.pk, None)

# Here we create the initial data.
# Add data for the each initialized form here.
# initial data is needed for every person in order
# to set the number of forms.
initial.update({
'%s-%s-person' % (prefix, i): person if membership else None,
'%s-%s-date_joined' % (prefix, i):
membership.date_joined if membership else None,
})
formset = MembershipFormset(initial=initial)

# do something


On Wed, Jan 26, 2011 at 8:46 AM, aa56280  wrote:
>> In your case it would become something like:
>>
>> class Membership(ModelForm):
>>         class Meta:
>>                 model = Membership
>>                 fields = ('person', 'date_joined')
>>                 widgets = {
>>                         'person' : CheckBox(),
>>                         'date_joined': TextInput(),
>>                 }
>
> I need a form for each person though because a Group could have many
> members.
>
> --
> 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.
>
>



-- 
Ian

http://www.ianlewis.org/

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