Re: Handle on request object from custom tag

2008-05-09 Thread Greg Fuller

That did it  -- thanks.

On May 9, 10:41 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Fri, May 9, 2008 at 10:11 PM, Greg Fuller <[EMAIL PROTECTED]> wrote:
> > How do I get a handle on the request object from within a custom
> > template tag?
>
> By making the request available to the template as a context variable,
> then accessing it the same as any other context variable.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: child edit causes duplication with model inheritance

2008-05-09 Thread Karen Tracey
On Sat, May 10, 2008 at 12:28 AM, Karen Tracey <[EMAIL PROTECTED]> wrote:

> On Fri, May 9, 2008 at 8:43 AM, Erwin Elling <[EMAIL PROTECTED]>
> wrote:
>
>>
>> On May 5, 1:47 pm, bobhaugen <[EMAIL PROTECTED]> wrote:
>> > Thanks.  If I read that last one correctly, queryset-factor was merged
>> > into trunk on 4-26, andnewforms-adminmerged trunk on 4-28 (and
>> > appears to do so regularly), so the answer to my question is "yes".
>>
>> That's the way I read it as well. Queryset refactoring branch has been
>> merged into trunk. After that, newforms-admin branch has been merged
>> with trunk.
>>
>
> No, newforms-admin has not been merged to trunk.  Rather, on 4/28, trunk
> updates were merged to newforms-admin, meaning newforms-admin got the
> queryset-refactor changes that had previously been merged to trunk.
>

Sorry, on closer reading you understood that.  I just misread and thought
you said  newforms-admin had been merged to trunk.

 Karen

>
> Anyone with experience with newforms admin and queryset refactoring,
>> yet? Does the admin in the newforms-admin branch indeed treat
>> inherited models right?
>> Looking for some people who have tried this out, before I dive into
>> it... It sounds so promising!
>>
>
> The ticket for the admin inheritance changes is:
>
> http://code.djangoproject.com/ticket/6755
>
> It's open, so no, inheritance handling in the admin isn't there yet.
>
> Karen
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: child edit causes duplication with model inheritance

2008-05-09 Thread Karen Tracey
On Fri, May 9, 2008 at 8:43 AM, Erwin Elling <[EMAIL PROTECTED]> wrote:

>
> On May 5, 1:47 pm, bobhaugen <[EMAIL PROTECTED]> wrote:
> > Thanks.  If I read that last one correctly, queryset-factor was merged
> > into trunk on 4-26, andnewforms-adminmerged trunk on 4-28 (and
> > appears to do so regularly), so the answer to my question is "yes".
>
> That's the way I read it as well. Queryset refactoring branch has been
> merged into trunk. After that, newforms-admin branch has been merged
> with trunk.
>

No, newforms-admin has not been merged to trunk.  Rather, on 4/28, trunk
updates were merged to newforms-admin, meaning newforms-admin got the
queryset-refactor changes that had previously been merged to trunk.

Anyone with experience with newforms admin and queryset refactoring,
> yet? Does the admin in the newforms-admin branch indeed treat
> inherited models right?
> Looking for some people who have tried this out, before I dive into
> it... It sounds so promising!
>

The ticket for the admin inheritance changes is:

http://code.djangoproject.com/ticket/6755

It's open, so no, inheritance handling in the admin isn't there yet.

Karen

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Handle on request object from custom tag

2008-05-09 Thread James Bennett

On Fri, May 9, 2008 at 10:11 PM, Greg Fuller <[EMAIL PROTECTED]> wrote:
> How do I get a handle on the request object from within a custom
> template tag?

By making the request available to the template as a context variable,
then accessing it the same as any other context variable.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Handle on request object from custom tag

2008-05-09 Thread Greg Fuller

I searched for solutions/examples with no luck, but this can't be that
hard.

How do I get a handle on the request object from within a custom
template tag?

Thanks --- Greg F
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Building filter strings dynamically

2008-05-09 Thread Greg Fuller

Thanks to both.  Got it working.

On May 9, 9:17 pm, Aaron Fay <[EMAIL PROTECTED]> wrote:
> Similarly, this will work also:field = 'sections' qry = 
> qry.filter(**{field+'__name__exact': 'shooting'})Cheers,
> Aaron
> John Lenton wrote:On Fri, May 9, 2008 at 6:19 PM, Greg Fuller<[EMAIL 
> PROTECTED]>wrote:Hello, I'm trying to build filter strings dynamically. The 
> normal way works: qry = qry.filter(sections__name__exact='printing') This 
> does not work: filter_str = "sections__name__exact='shooting'" qry = 
> qry.filter(filter_str) . The error is "too many values to unpack" at 
> django/db/models/sql/ query.py in add_filter, line 933 I realize something 
> outside normal name-spacing is probably happening, since 
> "sections__name__exact" doesn't have to be defined anywhere. But is there any 
> way to build the parameter to the filter dynamically?the usual python way of 
> building dynamic args: filter = {'sections__name__exact': 'shooting'} qry = 
> qry.filter(**filter)
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: File caching and pickling issue

2008-05-09 Thread Julien

Hi all,

I keep getting lots errors related to caching when pages are crawled
by bots like GoogleBot, Yahoo slurp, and Co (see tracebacks and code
above).
It works perfectly well when browsed by real users and real browsers.

Has anyone had an issue with crawlers and caching, or would have some
suggestions to track this down?

Thanks a lot!

Julien


On May 3, 8:48 am, Julien <[EMAIL PROTECTED]> wrote:
> > So we have same problem? Have you find solution?
>
> I don't know if we both have the same problem... the error messages
> seem to be a bit different.
>
> I have had other problems with caching that same function (all other
> parts of the site that are cached work perfectly). I've got
> "TypeError: object does not support item assignment" and also
> "UnicodeDecodeError: 'utf8' codec can't decode byte 0xae in position
> 5946: unexpected code byte".
>
> All those errors had the same traceback as above, and came in bulk of
> 20 within a very short time.
>
> One important remark, most of these errors seem to be caught by web
> crawlers:
>
> HTTP_USER_AGENT': 'msnbot/1.1 (+http://search.msn.com/msnbot.htm)
>  or
>  'HTTP_USER_AGENT': 'WebAltaCrawler/2.0 (http://www.webalta.net/ru/
> about_webmaster.html) (Windows; U; Windows NT 5.1; ru-RU)'
>  or
> 'HTTP_USER_AGENT': 'Mozilla/5.0 (compatible; Googlebot/2.1; 
> +http://www.google.com/bot.html)'
>  or
> 'HTTP_USER_AGENT': 'Mozilla/5.0 (compatible; Yahoo! 
> Slurp;http://help.yahoo.com/help/us/ysearch/slurp)',
>
> Any idea what's going on here?
>
> Many thanks,
>
> Julien
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Building filter strings dynamically

2008-05-09 Thread Aaron Fay





Similarly, this will work also:
field = 'sections'
qry = qry.filter(**{field+'__name__exact': 'shooting'})


Cheers,
Aaron


John Lenton wrote:

  On Fri, May 9, 2008 at 6:19 PM, Greg Fuller <[EMAIL PROTECTED]> wrote:
  
  
Hello,

I'm trying to build filter strings dynamically.

The normal way works:
   qry = qry.filter(sections__name__exact='printing')

This does not work:
   filter_str = "sections__name__exact='shooting'"
   qry = qry.filter(filter_str)
.
The error is "too many values to unpack" at django/db/models/sql/
query.py in add_filter, line 933

I realize something outside normal name-spacing is probably happening,
since "sections__name__exact"  doesn't have to be defined anywhere.

But is there any way to build the parameter to the filter dynamically?

  
  
the usual python way of building dynamic args:

filter = {'sections__name__exact': 'shooting'}
qry = qry.filter(**filter)

  


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/django-users?hl=en  -~--~~~~--~~--~--~---






Re: Group by for querysets

2008-05-09 Thread Eric Abrahamsen

> Awesome! Thanks much, Eric!

My pleasure... Just noticed there's a typo in the second part, should
be columns.setdefault..., not blocks.

Hooray for native group_by support in the ORM! I didn't realize that
was already in there.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: auto admin for production

2008-05-09 Thread Jeff Anderson

pihentagy wrote:

Hi all!

I come to here from a little symfony background (a framework, which
try to borrow good things from django), and would like to have an
overview how django stacks up.

I would like to ask, if the admin module can be used on a production
server by registered users.
  

The admin module can be used by registered users, yes.

What problems can occur?
(I assume every object references a user)
  
The admin interface was designed for admins. As long as you keep the 
access limited to trusted users, very few problems (security wise)

- editing/deleting objects not belonging to user
  
Currently the admin interface doesn't handle row-level permissions. A 
user can be granted to edit articles, but not restricted to only their 
own. I *believe* this is a feature that will be added in newforms-admin.



How these problems are solved in django?

  
These problems are solved by writing your own views for your models. Its 
really quite easy to do. We have an in-house ticket system done in 
django, and I've tinkered with "person x in group y can edit these 
tickets", "group z can edit tickets that are assigned to a certain 
category", etc... We simply disabled access to the admin interface for 
the less-privileged users, yet they can still edit certain objects at 
the row-level with our custom views.


It almost sounds like you are asking if the admin interface can just be 
your whole site. That's a bad idea.


Good Luck!


Jeff Anderson



signature.asc
Description: OpenPGP digital signature


auto admin for production

2008-05-09 Thread pihentagy

Hi all!

I come to here from a little symfony background (a framework, which
try to borrow good things from django), and would like to have an
overview how django stacks up.

I would like to ask, if the admin module can be used on a production
server by registered users.

What problems can occur?
(I assume every object references a user)

- editing/deleting objects not belonging to user
- id leak (the user will know how many object of any type is) - for
this to solve, one must use an unique index (not an autoincremented
number) to select specific objects. OR the primary keys should be
hidden from user (stored in session, and the request just references
to the index in the session)
- what else gotchas?

How these problems are solved in django?

thanks
Gergo
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Group by for querysets

2008-05-09 Thread James Bennett

On Fri, May 9, 2008 at 12:47 PM, Chris <[EMAIL PROTECTED]> wrote:
> Does django carry something similar to what I am looking for? If not,
> would a group_by feature be something worth adding to django?

If you're using a recent Django trunk checkout (after the
queryset-refactor merge), there is some basic support if you go look
at it. As of the qsrf merge, each QuerySet instance is backed by an
instance of django.db.models.sql.query.Query, which represents the
actual query to be executed, and that class offers a number of
features which are not yet exposed as high-level API methods. The one
you'll want to look at is the attribute 'group_by' of the Query class,
which should be a list or tuple of either column names or additional
Query objects; when the query is executed, the presence the 'group_by'
attribute will become a GROUP BY clause in the SQL.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



localisation issue

2008-05-09 Thread ginta

Hi,

after moving server and upgrading the application this strange error
happens to me. Strange because it is inside Django - means nothing to
do with the app - and there wasn't changed anything with Django.

The only thing changed is that
'django.contrib.auth.backends.ModelBackend', has been enabled as
authentication backend.

The exact Django version I'm not aware, it is some SVN from around
December 2007. There is memchaded running on the system and it throws
'unhandled exceptions to the lighttpd server used.

Here a fresh error message out of the error log.

Would be great if anybody has an idea.

thxs
g

2008-05-09 23:18:09: (mod_fastcgi.c.2502) FastCGI-stderr: Traceback
(most recent call last):

  File "/usr/lib/python2.5/site-packages/flup-1.0-py2.5.egg/flup/
server/fcgi_base.py", line 558, in run
protocolStatus, appStatus = self.server.handler(self)
  File "/usr/lib/python2.5/site-packages/flup-1.0-py2.5.egg/flup/
server/fcgi_base.py", line 1117, in handler
result = self.application(environ, start_response)
  File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
wsgi.py", line 205, in __call__
response = self.get_response(request)
  File "/usr/local/lib/python2.5/site-packages/django/core/handlers/
base.py", line 64, in get_response
response = middleware_method(request)
  File "/usr/local/lib/python2.5/site-packages/django/middleware/
locale.py", line 16, in process_request
language = translation.get_language_from_request(request)
  File "/usr/local/lib/python2.5/site-packages/django/utils/
translation/__init__.py", line 97, in get_language_from_request
return real_get_language_from_request(request)
  File "/usr/local/lib/python2.5/site-packages/django/utils/
translation/trans_real.py", line 351, in get_language_from_request
lang_code = request.session.get('django_language', None)
  File "/usr/local/lib/python2.5/site-packages/django/contrib/sessions/
backends/base.py", line 48, in get
return self._session.get(key, default)
  File "/usr/local/lib/python2.5/site-packages/django/contrib/sessions/
backends/base.py", line 126, in _get_session
self._session_cache = self.load()
  File "/usr/local/lib/python2.5/site-packages/django/contrib/sessions/
backends/db.py", line 18, in load
expire_date__gt=datetime.datetime.now()
  File "/usr/local/lib/python2.5/site-packages/django/db/models/
manager.py", line 69, in get
return self.get_query_set().get(*args, **kwargs)
  File "/usr/local/lib/python2.5/site-packages/django/db/models/
query.py", line 261, in get
obj_list = list(clone)
  File "/usr/local/lib/python2.5/site-packages/django/db/models/
query.py", line 114, in __iter__
return iter(self._get_data())
  File "/usr/local/lib/python2.5/site-packages/django/db/models/
query.py", line 483, in _get_data
self._result_cache = list(self.iterator())
  File "/usr/local/lib/python2.5/site-packages/django/db/models/
query.py", line 196, in iterator
rows = cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE)
ProgrammingError: no results to fetch

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Building filter strings dynamically

2008-05-09 Thread John Lenton

On Fri, May 9, 2008 at 6:19 PM, Greg Fuller <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> I'm trying to build filter strings dynamically.
>
> The normal way works:
>qry = qry.filter(sections__name__exact='printing')
>
> This does not work:
>filter_str = "sections__name__exact='shooting'"
>qry = qry.filter(filter_str)
> .
> The error is "too many values to unpack" at django/db/models/sql/
> query.py in add_filter, line 933
>
> I realize something outside normal name-spacing is probably happening,
> since "sections__name__exact"  doesn't have to be defined anywhere.
>
> But is there any way to build the parameter to the filter dynamically?

the usual python way of building dynamic args:

filter = {'sections__name__exact': 'shooting'}
qry = qry.filter(**filter)

-- 
John Lenton ([EMAIL PROTECTED]) -- Random fortune:
The trouble with a lot of self-made men is that they worship their creator.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Building filter strings dynamically

2008-05-09 Thread Greg Fuller

Hello,

I'm trying to build filter strings dynamically.

The normal way works:
qry = qry.filter(sections__name__exact='printing')

This does not work:
filter_str = "sections__name__exact='shooting'"
qry = qry.filter(filter_str)
.
The error is "too many values to unpack" at django/db/models/sql/
query.py in add_filter, line 933

I realize something outside normal name-spacing is probably happening,
since "sections__name__exact"  doesn't have to be defined anywhere.

But is there any way to build the parameter to the filter dynamically?

Thanks in advance,

Greg F.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Group by for querysets

2008-05-09 Thread gmacgregor


On May 9, 4:57 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> (Don't forget to reply to the list...)

Apologies... didn't realize I hit "Reply to author"

> The documentation for the groupby function is notoriously obscure, but
> it's actually simple to use. It generates pairs where the first item
> .

Awesome! Thanks much, Eric!

Greg
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Need some help, file corrupt

2008-05-09 Thread Rajesh Dhawan



On May 8, 11:14 pm, meppum <[EMAIL PROTECTED]> wrote:
> Hey guys, I need some help. I realized today that one of my source
> files is corrupt. When I open it in NotePad++ all I get is "null"
> characters. I've tried everything. Even software recovery programs to
> see if I have a non-corrupt deleted version. The odd thing is though
> the models still validate even though the file is unreadable.
> I
> deleted the .pyc file to make sure, and everything still runs well.
> This leads me to believe that a copy of my source is being stored
> somewhere in a temp file.
>
> Any idea where django might put this sort of thing. It's a lot of work
> and it seems I didn't notice this file has been corrupt for quite a
> while. I'm out of ideas.

What happens if you rename this file and restart your Django app? If
your application still finds the models defined in this file, you may
have placed a copy of this file/Django app somewhere else in your
PYTHONPATH that python is still able to locate. So, check the
directories listed in your PYTHONPATH including the implicit "site-
packages" sub-directory in /python_install_location/lib/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: importing problem

2008-05-09 Thread Rajesh Dhawan



On May 9, 1:30 pm, Dennis Schmidt <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I've got an importing problem with my django projects. I'm trying to
> build some kind of a framework which basically consists of 4 bigger
> modules. So I thought this django modularity perfectly fits my needs.
> I created 4 projects with different apps in them. Now some of the
> models from one projects application need to access models from
> another projects app.

It's important to realize that Django applications do not have to live
inside Django projects. A Django project is essentially a place to
hold your settings file. It's the INSTALLED_APPS inside the project's
settings file that brings those applications together to form a
project. The very same apps could be brought into another project.

In other words, you should consider, moving your common/reusable
Django applications outside any of your project directories and into a
separate location called, say, 'django-apps'. Then, make sure 'django-
apps' is in your PYTHONPATH.

See, James Bennett's excellent article on all this:

http://www.b-list.org/weblog/2006/sep/10/django-tips-laying-out-application/

>
> So in my file vg_commons/csv_import/views.py i tried this to include
> some models from another projects app:
>
> from vg_customer.calls.models import *
>
> This only results in an "Error was: No module named
> vg_customer.calls.models" error message. So how do i have to write
> these includes? (the vg_customer project and the calls app especially
> are working correctly of course)

At a minimum, you will need to make sure the "parent" directory of the
vg_customer directory is in your PYTHONPATH.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Group by for querysets

2008-05-09 Thread Eric Abrahamsen

> This sounds like it might do what I need... Care to share a code
> example?
>
>
> Greg


(Don't forget to reply to the list...)

The documentation for the groupby function is notoriously obscure, but  
it's actually simple to use. It generates pairs where the first item  
is the common key for a group, and the second item is another iterable  
containing the list of members belonging to that group. So here,  
queryset is a list of objects, being grouped by their  
get_FOO_display() method. Note that queryset is already sorted by  
'kind': groupby only groups, you have to sort beforehand. Also, the  
second item returned is a custom iterable, if you want it as a list  
you have to cast it explicitly.

groups = {}
for k, lst in itertools.groupby(queryset,key=lambda x:  
x.get_kind_display()):
 groups[k] = list(lst)

Itertools is lots of fun. Once I've got the dictionary, I use  
itertools.cycle to split it into three roughly equal chunks for use as  
three columns in the template:

columns = {}
for x in itertools.cycle(('left','center','right')):
 try:
 blocks.setdefault(x,[]).append(groups.popitem())
 except KeyError:
 break

This is probably going overboard, but it's fun...

Eric

On May 10, 2008, at 2:41 AM, gmacgregor wrote:

>
>
> On May 9, 2:37 pm, gmacgregor <[EMAIL PROTECTED]> wrote:
>> Something like it is being "considered" but nothing for 
>> sure:http://code.djangoproject.com/ticket/3566
>
> Whoops, I lied: check out the (currently) last comment made by Russ M
> on the ticket page:
>
> "For the benefit of those that haven't heard - ORM aggregation support
> has been accepted as a 2008 Google Summer of Code project. Nicolas
> Lara will be doing the heavy lifting, I (Russell Keith-Magee) will be
> mentoring."
>
> Nice!
> >


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: GeoDjangoFriendly?

2008-05-09 Thread Alex Ezell

On Thu, May 8, 2008 at 7:38 PM, Tyler Erickson <[EMAIL PROTECTED]> wrote:
> I would be interested in hearing if your remaining issues with the
> GeoDjango install get resolved.

Tyler,
I am still working with the folks there and they are working on some
rock solid instructions for the whole process of building GEOS, Proj,
and PostGIS on their servers. I got a message yesterday that they
aren't quite there, though.

> Following the WebFaction forum post, it looks like there is another
> user with a successful GeoDjango install (overcoming a GEOS config
> problem).
> http://forum.webfaction.com/viewtopic.php?id=957

This did not solve my problems. From what I can tell, the problems may
be related specifically to the server on which my account lives.

I'll update you when I hear more.

/alex

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: A twist on cross importing models

2008-05-09 Thread [EMAIL PROTECTED]

If you have the ContentTypes app installed, you can do the following
to avoid circular imports (assume you need the model called "Author"):
# at top with other imports
from django.contrib.contenttypes.models import ContentType

#in function where model is needed
Author=ContentType.objects.get(model='author').model_class()
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Forward model references

2008-05-09 Thread Chris Farley

Is it ever. I don't know why I did not see that. 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with Postgres 8.2

2008-05-09 Thread Adi Jörg Sieker
Hi Marcin,

the syndb command doesn't change your tables it only creates them, so  
any changes you make to the models after the first sync will have to  
be created manually via pgadmin or whatever is your preferred tool.  
Alternatively if you are still in development and don't need the data  
in your tables. you can drop all your apps ables and then run ./ 
manage.py syncdb again.

adi

On 09.05.2008, at 18:48, Marcin Gorczyński wrote:

>
> The manage.py sql app shows
>
> CREATE TABLE "groups_groupdata" (
>"id" serial NOT NULL PRIMARY KEY,
>"group_id" integer NOT NULL REFERENCES "auth_group" ("id")
> DEFERRABLE INITIALLY DEFERRED,
>"division_id" integer NOT NULL REFERENCES "groups_division" ("id")
> DEFERRABLE INITIALLY DEFERRED,
>"name" varchar(40) NOT NULL,
>"user_number" integer NOT NULL,
>"group_image" varchar(100) NOT NULL,
>"date_created" date NOT NULL,
>"accepted" boolean NOT NULL
> )
>
> But still I get errors when trying to write to it and pgAdmin show
> that there are only 3 columns
> 
--
Adi J. Sieker mobile: +49 - 178 - 88 5 88 13
Freelance developer   skype:  adijsieker
SAP-Consultantweb:http://www.sieker.info/profile
   openbc: https://www.openbc.com/hp/ 
AdiJoerg_Sieker/




--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination: how to find out on what page a give object will end up

2008-05-09 Thread Juanjo Conti

VidJa Hunter escribió:
> 
> paginator.is_on_page(object) would return page 6 if object is element 31 of
> the given queryset.
> 

I am leaving right now, but, what about something like this?

for page in paginator.page_range:
if object in paginator.page(page).object_list:
return page

Greets!

Juanjo
-- 
mi blog: http://www.juanjoconti.com.ar

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Group by for querysets

2008-05-09 Thread Eric Abrahamsen

In the meantime, you can use the groupby template tag for simple  
grouping operations in the template, or else I've had success using  
the itertools.groupby function in the view, and then passing your  
queryset as a dictionary or list of tuples to the template. It will be  
nice to have native support in the ORM, though...

On May 10, 2008, at 2:41 AM, gmacgregor wrote:

>
>
> On May 9, 2:37 pm, gmacgregor <[EMAIL PROTECTED]> wrote:
>> Something like it is being "considered" but nothing for 
>> sure:http://code.djangoproject.com/ticket/3566
>
> Whoops, I lied: check out the (currently) last comment made by Russ M
> on the ticket page:
>
> "For the benefit of those that haven't heard - ORM aggregation support
> has been accepted as a 2008 Google Summer of Code project. Nicolas
> Lara will be doing the heavy lifting, I (Russell Keith-Magee) will be
> mentoring."
>
> Nice!
> >


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: file upload - race condition?

2008-05-09 Thread Alex Morega


On May 9, 2008, at 21:17 , Marty Alchin wrote:

>
> On Fri, May 9, 2008 at 2:00 PM, Alex Morega <[EMAIL PROTECTED]> wrote:
>> There seems to be a race condition in Django's model code for file
>> uploads. Here's the relevant code snippet (django/db/models/base.py
>> line 458 in the latest SVN version - #7520):
>>
>>while os.path.exists(os.path.join(settings.MEDIA_ROOT,
>> filename)):
>>try:
>>dot_index = filename.rindex('.')
>>except ValueError: # filename has no dot
>>filename += '_'
>>else:
>>filename = filename[:dot_index] + '_' +
>> filename[dot_index:]
>>
>> So the problem is that, if two instances of Django are trying to save
>> a file with the same name (even plus/minus a few trailing
>> underscores), one could end up overwriting the other one's file. The
>> event is highly unlikely, but that doesn't mean it's safe, imho. Or
>> I'm missing something obvious, maybe related to database transactions
>> providing some kind of locking?
>
> This has been reported in ticket #4948.[1] The solution proposed in
> that ticket has some cross-platform concerns, however, so it's not
> clear if there's a fool-proof way to tackle it. My file storage
> refactor[2] will allow you to manually provide the behavior described
> in #4948 if your platform supports it, so I think it'll end up just
> being a snippet you can use if your application actually runs into the
> problem.
>
> Until #5361 lands, however, the only way to do it is to patch Django
> itself, since #4948 is unlikely to get committed without
> cross-platform compatibility.
>
> -Gul
>
> [1] http://code.djangoproject.com/ticket/4948
> [2] http://code.djangoproject.com/ticket/5361

Thanks for the quick reply.

#5361 looks like a good solution, I'll look into it.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Group by for querysets

2008-05-09 Thread [EMAIL PROTECTED]

Their is a thread here regarding the GSOC student's work:
http://groups.google.com/group/django-developers/browse_thread/thread/f83457fc3cdb235d

On May 9, 1:41 pm, gmacgregor <[EMAIL PROTECTED]> wrote:
> On May 9, 2:37 pm, gmacgregor <[EMAIL PROTECTED]> wrote:
>
> > Something like it is being "considered" but nothing for 
> > sure:http://code.djangoproject.com/ticket/3566
>
> Whoops, I lied: check out the (currently) last comment made by Russ M
> on the ticket page:
>
> "For the benefit of those that haven't heard - ORM aggregation support
> has been accepted as a 2008 Google Summer of Code project. Nicolas
> Lara will be doing the heavy lifting, I (Russell Keith-Magee) will be
> mentoring."
>
> Nice!
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Group by for querysets

2008-05-09 Thread gmacgregor


On May 9, 2:37 pm, gmacgregor <[EMAIL PROTECTED]> wrote:
> Something like it is being "considered" but nothing for 
> sure:http://code.djangoproject.com/ticket/3566

Whoops, I lied: check out the (currently) last comment made by Russ M
on the ticket page:

"For the benefit of those that haven't heard - ORM aggregation support
has been accepted as a 2008 Google Summer of Code project. Nicolas
Lara will be doing the heavy lifting, I (Russell Keith-Magee) will be
mentoring."

Nice!
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Group by for querysets

2008-05-09 Thread gmacgregor


On May 9, 1:47 pm, Chris <[EMAIL PROTECTED]> wrote:
> Is there a group_by method when getting querysets?

Nope... nothing of the sort. You'll have to write raw SQL for that.
I'm struggling with the same thing right now.

> Check out the following example.
> ...
> events_by_group =
> SportsEvent.objects.group_by("sport_type").order_by("event_date")
>
> and hopefully get something like this:
>
> [, , ,]
>
> and each  would contain SportsEvents objects.
> [, ,  ]
>
> so...
>
> Basketball
> -
> January 2
> March 8
> May 10

I'd like that, too.

> Does django carry something similar to what I am looking for? If not,
> would a group_by feature be something worth adding to django?

Something like it is being "considered" but nothing for sure:
http://code.djangoproject.com/ticket/3566


Greg
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Forward model references

2008-05-09 Thread Matthias Kestenholz

Hi,

On Fri, 2008-05-09 at 10:47 -0700, Chris Farley wrote:
> I'm trying to model our customers in a Django application, but I'm
> encountering a problem:
> 
> Customers can have many CustAddresses
> One CustAddress is the Customer's primary billing address
> One CustAddress is the Customer's primary shipping address
> 
> It's a classic 'chicken and egg' problem. Customers have a CustAddress
> foreign key, and CustAddress has a Customers foreign key. When running
> syncdb, I get this error:
> 
> NameError: name 'Customer' is not defined
> 
> What's the way around this?
> 
> Here's my models.py:
> 
> class CustAddress(models.Model):
>customer = models.ForeignKey(Customer)
>name = models.CharField(max_length=50)
>address1 = models.CharField(max_length=50)
>address2 = models.CharField(max_length=50, blank=True)
>city = models.CharField(max_length=50)
>region = models.CharField(max_length=50)
>postal_code = models.CharField(max_length=50)
>country_code = models.CharField(max_length=2)
>residential = models.BooleanField(default=True)
> 
> class Customer(models.Model):
>number = models.CharField(max_length=15, unique=True)
>first_name = models.CharField(max_length=35)
>last_name = models.CharField(max_length=35)
>phone_no1 = models.CharField(max_length=20, blank=True)
>phone_no2 = models.CharField(max_length=20, blank=True)
>user = models.ForeignKey(User, unique=True)
>created_at = models.DateTimeField(editable=False)
>updated_at = models.DateTimeField(editable=False)
>primary_bill_address = models.ForeignKey(CustAddress)
>primary_ship_address = models.ForeignKey(CustAddress)

The solution for this problem is well documented here:
http://www.djangoproject.com/documentation/model-api/#many-to-one-relationships




-- 
http://spinlock.ch/blog/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to modify contrib.auth models etc

2008-05-09 Thread Mike H

http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/

You can create a profile model that holds all the information you  
need, then in your settings specify APP_PROFILE_MODULE which will  
define a OneToOne relationship from the auth user to your profile  
model. It will then be accessible through user.get_profile()

Hope that helps,

Mike

On 9 May 2008, at 15:14, Marcin Gorczyński wrote:

>
> Well basicly I want the groups to have more data associeted with them
> - like a image filename, extracting the numer of users, one-to-one
> relations with a model in a news app and forum app, adding models like
> category like this category->groups, group and category moderators.
> Probarly I can get what I want from the user model by the profile
> model, personal messages to users (maybe that shuld be another app)
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: file upload - race condition?

2008-05-09 Thread Marty Alchin

On Fri, May 9, 2008 at 2:00 PM, Alex Morega <[EMAIL PROTECTED]> wrote:
> There seems to be a race condition in Django's model code for file
> uploads. Here's the relevant code snippet (django/db/models/base.py
> line 458 in the latest SVN version - #7520):
>
> while os.path.exists(os.path.join(settings.MEDIA_ROOT,
> filename)):
> try:
> dot_index = filename.rindex('.')
> except ValueError: # filename has no dot
> filename += '_'
> else:
> filename = filename[:dot_index] + '_' +
> filename[dot_index:]
>
> So the problem is that, if two instances of Django are trying to save
> a file with the same name (even plus/minus a few trailing
> underscores), one could end up overwriting the other one's file. The
> event is highly unlikely, but that doesn't mean it's safe, imho. Or
> I'm missing something obvious, maybe related to database transactions
> providing some kind of locking?

This has been reported in ticket #4948.[1] The solution proposed in
that ticket has some cross-platform concerns, however, so it's not
clear if there's a fool-proof way to tackle it. My file storage
refactor[2] will allow you to manually provide the behavior described
in #4948 if your platform supports it, so I think it'll end up just
being a snippet you can use if your application actually runs into the
problem.

Until #5361 lands, however, the only way to do it is to patch Django
itself, since #4948 is unlikely to get committed without
cross-platform compatibility.

-Gul

[1] http://code.djangoproject.com/ticket/4948
[2] http://code.djangoproject.com/ticket/5361

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



file upload - race condition?

2008-05-09 Thread Alex Morega

Hi,

There seems to be a race condition in Django's model code for file  
uploads. Here's the relevant code snippet (django/db/models/base.py  
line 458 in the latest SVN version - #7520):

 while os.path.exists(os.path.join(settings.MEDIA_ROOT,  
filename)):
 try:
 dot_index = filename.rindex('.')
 except ValueError: # filename has no dot
 filename += '_'
 else:
 filename = filename[:dot_index] + '_' +  
filename[dot_index:]

So the problem is that, if two instances of Django are trying to save  
a file with the same name (even plus/minus a few trailing  
underscores), one could end up overwriting the other one's file. The  
event is highly unlikely, but that doesn't mean it's safe, imho. Or  
I'm missing something obvious, maybe related to database transactions  
providing some kind of locking?

Cheers,
-- Alex


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django with Ajax

2008-05-09 Thread Monica Leko

On 5/9/08, Richard Dahl <[EMAIL PROTECTED]> wrote:
>
>  I am not sure what the dom1.toxml() does, are you seeing:
>
>
>  
>  
>
>  left="Necklace"/>
>  

Yes, I am seeing this text.  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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Forward model references

2008-05-09 Thread Chris Farley

I'm trying to model our customers in a Django application, but I'm
encountering a problem:

Customers can have many CustAddresses
One CustAddress is the Customer's primary billing address
One CustAddress is the Customer's primary shipping address

It's a classic 'chicken and egg' problem. Customers have a CustAddress
foreign key, and CustAddress has a Customers foreign key. When running
syncdb, I get this error:

NameError: name 'Customer' is not defined

What's the way around this?

Here's my models.py:

class CustAddress(models.Model):
   customer = models.ForeignKey(Customer)
   name = models.CharField(max_length=50)
   address1 = models.CharField(max_length=50)
   address2 = models.CharField(max_length=50, blank=True)
   city = models.CharField(max_length=50)
   region = models.CharField(max_length=50)
   postal_code = models.CharField(max_length=50)
   country_code = models.CharField(max_length=2)
   residential = models.BooleanField(default=True)

class Customer(models.Model):
   number = models.CharField(max_length=15, unique=True)
   first_name = models.CharField(max_length=35)
   last_name = models.CharField(max_length=35)
   phone_no1 = models.CharField(max_length=20, blank=True)
   phone_no2 = models.CharField(max_length=20, blank=True)
   user = models.ForeignKey(User, unique=True)
   created_at = models.DateTimeField(editable=False)
   updated_at = models.DateTimeField(editable=False)
   primary_bill_address = models.ForeignKey(CustAddress)
   primary_ship_address = models.ForeignKey(CustAddress)
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Group by for querysets

2008-05-09 Thread Chris

Is there a group_by method when getting querysets?  Check out the
following example.

class SportsEvent(models.Model):
"""Sports"""
name = models.CharField(max_length=255)
sport_type = models.ForeignKey(Sport)
event_date = models.DateTimeField()

class Sport(models.Modle):
"""sports"""
sport_name = models.CharField(max_length=255)

so I would like to be able to do something like this:

events_by_group =
SportsEvent.objects.group_by("sport_type").order_by("event_date")

and hopefully get something like this:

[, , ,]

and each  would contain SportsEvents objects.
[, ,  ]

so...

Basketball
-
January 2
March 8
May 10

Football

January 10
February 16
June 21

and so on...

Does django carry something similar to what I am looking for? If not,
would a group_by feature be something worth adding to django?


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



CPOSC 2008 is looking for Django presentations

2008-05-09 Thread John

Hi,

I'm with the Central PA Linux User Group (CPLUG) and a few of us are
organizing a small, open source conference to be held this fall in
Harrisburg, PA (USA).

It would be cool to have a Django presentation (or two), so I wanted
to extend an invite to those on the django-discuss list. If you or
someone you know would like to speak at the conference, please see the
details below. Don't be shy!  :)

Thanks,
John

*** Call for Participation ***

CPOSC, the Central PA Open Source Conference, is a one-day, multi-
track, low-cost conference about all things open source: software,
programming, operating systems, community and more. It will take place
on Sunday, October 19th at the ITT Tech campus in Harrisburg, PA.

You can read more about the conference at http://cposc.org

We are looking for interesting speakers and talks. Instructions on how
to submit abstracts can be found here:

  http://www.cposc.org/speakers/call-for-participation

The submission deadline is July 11, 2008.  Accepted speakers will be
notified no later than July 25, 2008.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django with Ajax

2008-05-09 Thread Richard Dahl

I am not sure what the dom1.toxml() does, are you seeing:



   
   


in firebug, to be sure that it is correctly returning the xml?  If so
then the problem is most likely within the javascript and you may have
better luck at the googlemaps api group.
-richard


On 5/9/08, Monica Leko <[EMAIL PROTECTED]> wrote:
>
> On 5/9/08, Richard Dahl <[EMAIL PROTECTED]> wrote:
> >
> >  I am not sure what javascript library you are using based on the code
>
> Google maps.  GXmlHttp is just like XmlHttpRequest
>
> Now I have this in my view:
>
> return HttpResponse(dom1.toxml(), mimetype="text/xml")
>
> And still my  var xmlDoc = request.responseXML;
> alert(xmlDoc) is null.
>
> Server sends back this file:
>
> 
> 
>
> left="Necklace"/>
> 
>
> i don't get it
>
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



importing problem

2008-05-09 Thread Dennis Schmidt

Hello,

I've got an importing problem with my django projects. I'm trying to
build some kind of a framework which basically consists of 4 bigger
modules. So I thought this django modularity perfectly fits my needs.
I created 4 projects with different apps in them. Now some of the
models from one projects application need to access models from
another projects app.

So in my file vg_commons/csv_import/views.py i tried this to include
some models from another projects app:

from vg_customer.calls.models import *

This only results in an "Error was: No module named
vg_customer.calls.models" error message. So how do i have to write
these includes? (the vg_customer project and the calls app especially
are working correctly of course)

thnaks in advance, Dennis
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: one-to-many design question

2008-05-09 Thread Scott Moonen
Slight correction.  In your first example:

class Chapter(models.Model):
>book = models.ForeignKey(Chapter)
>

The parameter to ForeignKey should be book:

class Chapter(models.Model):
   book = models.ForeignKey(Book)

As mentioned earlier, you can locate a chapter's book as chapter.book, and
you can locate a book's chapters using book.chapter_set.all().

  -- Scott Moonen

On Fri, May 9, 2008 at 12:08 PM, Mike Chambers <[EMAIL PROTECTED]>
wrote:

>
> I am working on an app to host some books online. I cant figure out the
> best way to represent a one to many relationship.
>
> Basically, a Book has multiple Chapters, but a Chapter can only be in
> one book.
>
> Looking at the docs, this seems to be the way to represent this:
>
>
> --
> class Book(models.Model):
>
>
> class Chapter(models.Model):
>book = models.ForeignKey(Chapter)
> --
>
> Is that right? This seems a little counterintuitive to me, and something
> like this seems to make more sense:
>
>
> --
> class Book(models.Model):
>chapters = models.ManyToManyField(Chapter)
>
> class Chapter(models.Model):
> --
>
> Of course, that means that a chapter can be placed on multiple books.
>
> The second example, also seems to make it a little easier to work with
> Books, as I can do:
>
> Book.objects.all()
>
> and get the Chapters associated with each book.
>
> So, what is the "correct" way to model this relationship?
>
> Thanks for any input...
>
> mike
>
>
> >
>


-- 
http://scott.andstuff.org/  |  http://truthadorned.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django with Ajax

2008-05-09 Thread Monica Leko

On 5/9/08, Richard Dahl <[EMAIL PROTECTED]> wrote:
>
>  I am not sure what javascript library you are using based on the code

Google maps.  GXmlHttp is just like XmlHttpRequest

Now I have this in my view:

return HttpResponse(dom1.toxml(), mimetype="text/xml")

And still my  var xmlDoc = request.responseXML;
alert(xmlDoc) is null.

Server sends back this file:







i don't get it

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: one-to-many design question

2008-05-09 Thread Mike Chambers

Thanks for confirming.

Book.chapter_set.all()

gets all of the chapters for the book. Thanks!

mike

[EMAIL PROTECTED] wrote:
> The first way is the correct way, to get all the chapters for a given
> book you would do book_obj.chapter_set.all() , you can set what this
> attribute is named by doing ForeignKey(Chapter,
> related_name='this_thing').
> 
> On May 9, 11:08 am, Mike Chambers <[EMAIL PROTECTED]> wrote:
>> I am working on an app to host some books online. I cant figure out the
>> best way to represent a one to many relationship.
>>
>> Basically, a Book has multiple Chapters, but a Chapter can only be in
>> one book.
>>
>> Looking at the docs, this seems to be the way to represent this:
>>
>> --
>> class Book(models.Model):
>>
>> class Chapter(models.Model):
>> book = models.ForeignKey(Chapter)
>> --
>>
>> Is that right? This seems a little counterintuitive to me, and something
>> like this seems to make more sense:
>>
>> --
>> class Book(models.Model):
>> chapters = models.ManyToManyField(Chapter)
>>
>> class Chapter(models.Model):
>> --
>>
>> Of course, that means that a chapter can be placed on multiple books.
>>
>> The second example, also seems to make it a little easier to work with
>> Books, as I can do:
>>
>> Book.objects.all()
>>
>> and get the Chapters associated with each book.
>>
>> So, what is the "correct" way to model this relationship?
>>
>> Thanks for any input...
>>
>> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with Postgres 8.2

2008-05-09 Thread Marcin Gorczyński

The manage.py sql app shows

CREATE TABLE "groups_groupdata" (
"id" serial NOT NULL PRIMARY KEY,
"group_id" integer NOT NULL REFERENCES "auth_group" ("id")
DEFERRABLE INITIALLY DEFERRED,
"division_id" integer NOT NULL REFERENCES "groups_division" ("id")
DEFERRABLE INITIALLY DEFERRED,
"name" varchar(40) NOT NULL,
"user_number" integer NOT NULL,
"group_image" varchar(100) NOT NULL,
"date_created" date NOT NULL,
"accepted" boolean NOT NULL
)

But still I get errors when trying to write to it and pgAdmin show
that there are only 3 columns
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with Postgres 8.2

2008-05-09 Thread Marcin Gorczyński



On May 9, 6:34 pm, Marc Fargas <[EMAIL PROTECTED]> wrote:
> El vie, 09-05-2008 a las 09:30 -0700, Marcin Gorczyński escribió:
>
> > Hello
>
> > I have a problem with syncing with my PostgresDB - I type manage.py
> > syncdb, but it doesn`t create all the columns like in this model:
> > It creates only 3 columns - id, group_id, name
>
> Did you add columns after running syncdb *for the very first time* ? I
> mean, did you run syncdb with only the group and name fields defined and
> then run it again after adding columns? This is not supported.
>
> ./manage.py sql 
>
> Does this show the correct CREATE TABLE statements?
>
> --http://www.marcfargas.com-- will be finished some day.
>
>  signature.asc
> 1KDownload

Yes, now as I recall I added the fields after the first syncd. Didn`t
know I couldn`t do that, how can add them after the syncdb (I created
a second db 'test', changed the name to 'test' in settings and synced,
didn`t change anything, don`t know if this info changes anything)
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: IntegrityError on newforms-admin

2008-05-09 Thread Nuno Mariz

Thanks Brian,
One more question, there is another way to write a custom validator
without override the field type?

Nuno

On May 9, 5:30 pm, Brian Rosner <[EMAIL PROTECTED]> wrote:
> On May 9, 4:31 am, Nuno Mariz <[EMAIL PROTECTED]> wrote:
>
> > I'm using newforms-admin and I've got a "duplicate key violates unique
> > constraint" when I'm added new record(with the same value on field
> > that already exists in the db) in admin interface.
> > I've an "unique=True" in the field, shouldn't admin interface shows a
> > error message in the form and not raise a IntegrityError exception?
>
> Not yet. Similar to a ModelForm it does not do any model level
> validation. This functionality is on its way. This has become aparent
> because the newforms-admin branch now uses newforms to deal with forms
> which brings any problems newforms has. This can be avoided by writing
> your own custom validation in your own ModelForm and use it in the
> ModelAdmin, but nothing will be default until model aware validation
> lands.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Who has the better support for Sql Server?

2008-05-09 Thread Marc Fargas
Hi,
http://code.google.com/p/django-mssql/ holds the MSSQL backend as a
separate project as was the recommended action by mtredinnick in ticket
#5947.

Hope this helps.

El vie, 09-05-2008 a las 09:33 -0700, mamcxyz escribió:
> I submit this patch some time ago:
> 
> http://code.djangoproject.com/ticket/5062 (latter turn to
> http://code.djangoproject.com/ticket/5246)
> 
> However, after get invalidad and the decision to support it elsewhere,
> I wonder which have the better support of the external sql backend to
> help to improve it?
> 
> I need support for the recent trunk of django
> --~--~-~--~~~---~--~~
> 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 [EMAIL PROTECTED]
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en
> -~--~~~~--~~--~--~---
> 
-- 
http://www.marcfargas.com -- will be finished some day.


signature.asc
Description: Esta parte del mensaje está firmada	digitalmente


Re: Problem with Postgres 8.2

2008-05-09 Thread Marc Fargas
El vie, 09-05-2008 a las 09:30 -0700, Marcin Gorczyński escribió:
> Hello
> 
> I have a problem with syncing with my PostgresDB - I type manage.py
> syncdb, but it doesn`t create all the columns like in this model:

> It creates only 3 columns - id, group_id, name

Did you add columns after running syncdb *for the very first time* ? I
mean, did you run syncdb with only the group and name fields defined and
then run it again after adding columns? This is not supported.

./manage.py sql 

Does this show the correct CREATE TABLE statements?

-- 
http://www.marcfargas.com -- will be finished some day.


signature.asc
Description: Esta parte del mensaje está firmada	digitalmente


Who has the better support for Sql Server?

2008-05-09 Thread mamcxyz

I submit this patch some time ago:

http://code.djangoproject.com/ticket/5062 (latter turn to
http://code.djangoproject.com/ticket/5246)

However, after get invalidad and the decision to support it elsewhere,
I wonder which have the better support of the external sql backend to
help to improve it?

I need support for the recent trunk of django
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: IntegrityError on newforms-admin

2008-05-09 Thread Brian Rosner



On May 9, 4:31 am, Nuno Mariz <[EMAIL PROTECTED]> wrote:
> I'm using newforms-admin and I've got a "duplicate key violates unique
> constraint" when I'm added new record(with the same value on field
> that already exists in the db) in admin interface.
> I've an "unique=True" in the field, shouldn't admin interface shows a
> error message in the form and not raise a IntegrityError exception?

Not yet. Similar to a ModelForm it does not do any model level
validation. This functionality is on its way. This has become aparent
because the newforms-admin branch now uses newforms to deal with forms
which brings any problems newforms has. This can be avoided by writing
your own custom validation in your own ModelForm and use it in the
ModelAdmin, but nothing will be default until model aware validation
lands.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Problem with Postgres 8.2

2008-05-09 Thread Marcin Gorczyński

Hello

I have a problem with syncing with my PostgresDB - I type manage.py
syncdb, but it doesn`t create all the columns like in this model:

class GroupData(models.Model):
group = models.ForeignKey(Group)
division   = models.ForeignKey(Division)
name  = models.CharField(max_length=40)
user_number  = models.IntegerField(blank=True)
group_image  = models.ImageField(upload_to='images/%s' % name,
blank=True)
date_created = models.DateField('date created')
accepted = models.BooleanField()

def __str__(self):
return self.name

class Meta:
ordering = ["name"]

class Admin:
list_display = ('name', 'user_number')

It creates only 3 columns - id, group_id, name

I`m new to Django and maybe I`m syncing in a bad way or is it a
problem with the DB? (it reads and wrties data to it with no problems,
just the columns)

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: one-to-many design question

2008-05-09 Thread [EMAIL PROTECTED]

The first way is the correct way, to get all the chapters for a given
book you would do book_obj.chapter_set.all() , you can set what this
attribute is named by doing ForeignKey(Chapter,
related_name='this_thing').

On May 9, 11:08 am, Mike Chambers <[EMAIL PROTECTED]> wrote:
> I am working on an app to host some books online. I cant figure out the
> best way to represent a one to many relationship.
>
> Basically, a Book has multiple Chapters, but a Chapter can only be in
> one book.
>
> Looking at the docs, this seems to be the way to represent this:
>
> --
> class Book(models.Model):
>
> class Chapter(models.Model):
>         book = models.ForeignKey(Chapter)
> --
>
> Is that right? This seems a little counterintuitive to me, and something
> like this seems to make more sense:
>
> --
> class Book(models.Model):
>         chapters = models.ManyToManyField(Chapter)
>
> class Chapter(models.Model):
> --
>
> Of course, that means that a chapter can be placed on multiple books.
>
> The second example, also seems to make it a little easier to work with
> Books, as I can do:
>
> Book.objects.all()
>
> and get the Chapters associated with each book.
>
> So, what is the "correct" way to model this relationship?
>
> Thanks for any input...
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



one-to-many design question

2008-05-09 Thread Mike Chambers

I am working on an app to host some books online. I cant figure out the 
best way to represent a one to many relationship.

Basically, a Book has multiple Chapters, but a Chapter can only be in 
one book.

Looking at the docs, this seems to be the way to represent this:


--
class Book(models.Model):


class Chapter(models.Model):
book = models.ForeignKey(Chapter)
--

Is that right? This seems a little counterintuitive to me, and something 
like this seems to make more sense:


--
class Book(models.Model):
chapters = models.ManyToManyField(Chapter)

class Chapter(models.Model):
--

Of course, that means that a chapter can be placed on multiple books.

The second example, also seems to make it a little easier to work with 
Books, as I can do:

Book.objects.all()

and get the Chapters associated with each book.

So, what is the "correct" way to model this relationship?

Thanks for any input...

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Job opening: Malaria Atlas Project, Oxford University

2008-05-09 Thread John Handelaar

On Fri, May 9, 2008 at 4:50 PM, anand <[EMAIL PROTECTED]> wrote:
>
> Further particulars can be downloaded from http://www.zoo.ox.ac.uk/jobs/

That's not true.

jh

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Job opening: Malaria Atlas Project, Oxford University

2008-05-09 Thread anand

DEPARTMENT OF ZOOLOGY

Web developer
Grade 7: Salary range:£26,666 - £32,796
Three year post

A web developer is required to join the Malaria Atlas Project (MAP,
http://www.map.ox.ac.uk). The job will be to lead in the improvement
of the on-line presence and thus public engagement activities of MAP.
Specific responsibilities will be to implement an online database of
epidemiological information for MAP members and ultimately the wider
malaria public health community. The successful candidate will also be
required to develop the website functionality to display MAP products
through Google Maps and Google Earth. It will be necessary to
demonstrate a portfolio of skills and existing project experience in
these areas.

Further particulars can be downloaded from http://www.zoo.ox.ac.uk/jobs/
current vacancies or are available from the Personnel Office,
Department of Zoology, Tinbergen Building, South Parks Road, Oxford
OX1 3PS. E-mail; [EMAIL PROTECTED] Applications, including
curriculum vitae, giving contact details of three referees should be
sent to the above address, quoting reference AT08016. The closing date
for applications is 06 June 2008.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Debug tag not showing context from custom tags

2008-05-09 Thread Greg Fuller

Hi,

I would like to see the context from a custom tag using the {% debug
%} tag, but it's not displaying.

I'm rendering a template with the following view code:

   return render_to_response("index.html", {
"who": {'name': 'Greg', 'city':'Smallville'}

In the template, I have a custom tag to get entries, and then a for
tag to display entries:

{% get_entries as entries %}

{% for entry in entries %}
{{ entry.title }}
{{ entry.body_html }}
{% endfor %}

{% debug %}

The template properly loops through the entries and displays the title
and body, so I know that the custom tag is working.

The debug tag shows values for the  "who" context, but only shows an
empty list for the entries:

 'entries': [, ], 'who': {'city': 'Smallville', 'name':
'Greg'}} {'BaseHTTPServer': , 'Cookie': , ' etc, etc

Any idea why the entries context  is empty?

Thanks - Greg F.




--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: "None of the above" in a form?

2008-05-09 Thread Scott SA

On 5/9/08, Kirk Strauser ([EMAIL PROTECTED]) wrote:

>On Tuesday 06 May 2008, Scott SA wrote:
>
>> These are M2M relationship records handled transparently for you. In
>> reality, they are in a table in between your two 'Role' tables. If you
>> want to delete them, then you can select and delete them programatically
>> (i.e. from a button on your form)
>
>I think I expressed myself poorly.  What I meant was that when a visitor is 
>editing a form, and they accidentally click in a MultipleChoiceField widget 
>and select one of the options, there's no way (that I've found) for them to 
>un-select that option before clicking "Submit".
>
>Imagine a field in a job application like "Which crimes have you been 
>convicted of?  [Armed robbery] [Arson] [Kidnapping]".  You bump "Arson" by 
>mistake.  Don't you wish there was a "none of the above" option to select 
>instead?

I wonder what Freud would have said about that... LOL

For the admin interface, anyway:

help_text="Use shift-click to add more than one. Ctl-click 
(Cmd-click for Mac) to de-select your Freudian slip"

The select box works the same in custom forms, but I don't recall if the 
help-text shows.

Otherwise, it is a smidge of JavaScript unless you want to reload the form. A 
quick google for "javascript clear | empty select list" seemed to have a few 
options like the discussion for this one:



HTH

Scott

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why are my parameters gettings mangled?

2008-05-09 Thread John M

Randy, thanks for the follow-up,  and you're on the right track, turns
out it's an encoding 'problem' by default in django.  I just have to
change the encoding language and then ask it for a different code.

I got it working for what I need.

John

On May 8, 9:16 pm, Peter Rowell <[EMAIL PROTECTED]> wrote:
> Well, I'm not quite sure exactly what is being done to it, but it
> appears to happen at:
>
> =
> django/http/__init__.py:
> ...
> class QueryDict(MultiValueDict):
> ...
>  def appendlist(self, key, value):
> self._assert_mutable()
> key = str_to_unicode(key, self.encoding)
> value = str_to_unicode(value, self.encoding)
> MultiValueDict.appendlist(self, key, value)
> <<<
> =
>
> Before the call to appendlist value looks reasonable, afterwards it's
> been converted to ...? unicode or something.
>
> That and $3.50 will get you a latte, but there it is.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django with Ajax

2008-05-09 Thread Richard Dahl

I am not sure what javascript library you are using based on the code
snippet, but you seem to be looking for a javascript object to be
returned that contains XML.  What you are returning is simply the text
'hello world' as a plain vanilla http response.  You need to return
the type of object that the javascript call is expecting, usually a
JSON object, XML document, or perhaps a snippet of html.  If you are
already comfortable with xml use it, but if not, I believe that JSON
is a bit easier to work with, but that is simply my personal
preference.

look at the django documentation or search this groups archives for
"serializers" for examples of how to write the view.

I would also recommend that you look at a the Yahoo User Interface or
jQuery to do the ajax-based stuff in the browser, as those libraries
make it very simple.

You also should also use firebug to look at the ajax responses in the
browser, I do not know how ajax development is practical without
something like it.

hth,
-richard


On 5/9/08, Monica Leko <[EMAIL PROTECTED]> wrote:
>
> Hi
>
> I am trying to use some simple AJAX call, and can't get right result.
> I am using this Javascript function:
>
> function filterMarkers(){
>var request = GXmlHttp.create();
>request.open('GET', '/lbs/' + "?q=placeholder, true);
>request.onreadystatechange = function() {
>if (request.readyState == 4) {
>//  var xmlDoc = request.responseXML;
>alert("ok");
>}
>}
>request.send(null);
>return false;
> }
>
> GXmlHttp is just XmlHttpRequest.
>
> When I click submit on my form, alert box popup, and everything is ok,
> django view process normally, but after that I get response from
> server, instead of doing nothing, not refreshing, I get hello world
> response.  How can I catch response i order to have unmodified page
> from which I call for request?
>
> My view is something like this:
> def map(request):
>q = request.GET.get("q", "")
>if q:
>return HttpResponse("Hello world")
>
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



RE: Multiplechoicefield 1 value

2008-05-09 Thread Ben Eliott

Thanks Matthias, your crystal ball worked just fine, getlist clocked it.

-Original Message-
From: django-users@googlegroups.com
[mailto:[EMAIL PROTECTED] On Behalf Of Matthias Kestenholz
Sent: 09 May 2008 15:36
To: django-users@googlegroups.com
Subject: Re: Multiplechoicefield 1 value



On Fri, 2008-05-09 at 15:26 +0100, Ben Eliott wrote:
> Hi, Can anyone please advise on why a multiplechoicefield might be 
> returning only 1 value (the last value)? Or maybe i'm not accessing it

> correctly...? Many Thanks!
> Ben

How are you accessing the value? Are you using request.POST.get()
instead of request.POST.getlist()?

It's quite hard to find out what the cause of your problem might be
without code, a testcase or without a crystal ball.

-- 
http://spinlock.ch/blog/




-- 
No virus found in this incoming message.
Checked by AVG. 
Version: 7.5.524 / Virus Database: 269.23.11/1422 - Release Date:
08/05/2008 17:24



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: No request.FILES, but file is still uploaded?

2008-05-09 Thread Beals

> Does your model have a FileField?

Thanks, Karen.  Yes, my model has a FileField.  The doc never says
explicitly that it the save will happen, which was the source of my
confusion.  It appears that it does when you have a FileField (I dove
into the newforms code a bit and am partially convinced this is taking
place).

-Aaron

On May 8, 7:03 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Thu, May 8, 2008 at 3:51 PM, Beals <[EMAIL PROTECTED]> wrote:
> > Correction: request.FILES does exist -- it just wasn't getting printed
> > out with "print request".  An explicit "print request.FILES" did the
> > trick.
>
> > However, my question still stands: is form.save(commit=False) supposed
> > to be writing the file out to disk?  Is this the newforms way of
> > handling uploads, and therefore is checking for request.FILES and
> > writing the file out ourselves passé?
>
> Does your model have a FileField?  If so, then yes, I'd expect save of a
> ModelForm for that model to save the file to disk.  Haven't checked the doc
> to see if it explicitly says that will happen, that is just how I would
> expect it to behave.
>
> Not sure if/how this is different from oldforms, since I never used them.
> But checking request.FILES etc is not necessarily passé, it just depends on
> your model setup.  In my own app, I do upload files, but I don't use
> FileField (nor ModelForms), so I have to handle writing the uploaded file to
> the appropriate place myself.
>
> Karen
>
>
>
> > On May 8, 3:43 pm, Beals <[EMAIL PROTECTED]> wrote:
> > > A while back, I looked for code snippets for uploading files.  Almost
> > > every site I found contained something like the following:
>
> > > if 'file' in request.FILES:
> > >     file = request.FILES['file']
> > >     filename = file['filename']
> > >     fd = open('%s/%s' % (MEDIA_ROOT, filename), 'wb')
> > >     fd.write(file['content'])
> > >     fd.close
> > > else:
> > >     print "No file attached."
>
> > > This seemed to work -- files were uploaded and the pointers from the
> > > model worked fine, so I never thought to look at the logs... until
> > > today, and I noticed that even though the uploads were working
> > > properly, the "No file attached" message kept showing up.  Drilling
> > > in, I found that FILES wasn't even in the request object!  Yet the
> > > file was still written to disk... weird.
>
> > > So I started putting breakpoints in to figure out where in my view the
> > > file was getting written out.  The fourth line is the culprit:
>
> > > if request.method == 'POST':
> > >     form = FooForm(request.POST, request.FILES)
> > >     if form.is_valid():
> > >         new_artifact = form.save(commit=False)
> > >         *BREAKPOINT*
>
> > > So how/why is form.save(commit=False) writing the file out to disk??
> > > Is this expected behavior for ModelForms?  (NOTE: in case it matters,
> > > I'm using the built-in Django webserver.)
>
> > > -Aaron
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multiplechoicefield 1 value

2008-05-09 Thread Matthias Kestenholz

On Fri, 2008-05-09 at 15:26 +0100, Ben Eliott wrote:
> Hi, Can anyone please advise on why a multiplechoicefield might be
> returning only 1 value (the last value)? Or maybe i'm not accessing it
> correctly...?
> Many Thanks!
> Ben

How are you accessing the value? Are you using request.POST.get()
instead of request.POST.getlist()?

It's quite hard to find out what the cause of your problem might be
without code, a testcase or without a crystal ball.

-- 
http://spinlock.ch/blog/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Multiplechoicefield 1 value

2008-05-09 Thread Ben Eliott
Hi, Can anyone please advise on why a multiplechoicefield might be
returning only 1 value (the last value)? Or maybe i'm not accessing it
correctly...?
Many Thanks!
Ben

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django_sessions table getting out of hand

2008-05-09 Thread Scott Moonen
See
http://www.djangoproject.com/documentation/sessions/#clearing-the-session-table

  -- Scott

On Fri, May 9, 2008 at 10:24 AM, Matt Davies <[EMAIL PROTECTED]> wrote:

> I got you Scott
>
> cron job it is
>
> I seem to remember Adrian putting a nippet up somewhere with the code
> in(laxz I know), anyone remember where it was?
>
>
> >
>


-- 
http://scott.andstuff.org/  |  http://truthadorned.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django with Ajax

2008-05-09 Thread Monica Leko

Hi

I am trying to use some simple AJAX call, and can't get right result.
I am using this Javascript function:

function filterMarkers(){
var request = GXmlHttp.create();
request.open('GET', '/lbs/' + "?q=placeholder, true);
request.onreadystatechange = function() {
if (request.readyState == 4) {
//  var xmlDoc = request.responseXML;
alert("ok");
}
}
request.send(null);
return false;
}

GXmlHttp is just XmlHttpRequest.

When I click submit on my form, alert box popup, and everything is ok,
django view process normally, but after that I get response from
server, instead of doing nothing, not refreshing, I get hello world
response.  How can I catch response i order to have unmodified page
from which I call for request?

My view is something like this:
def map(request):
q = request.GET.get("q", "")
if q:
return HttpResponse("Hello world")

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django_sessions table getting out of hand

2008-05-09 Thread Matt Davies
I got you Scott

cron job it is

I seem to remember Adrian putting a nippet up somewhere with the code
in(laxz I know), anyone remember where it was?

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to modify contrib.auth models etc

2008-05-09 Thread Scott Moonen
Ok.  Sounds like you can probably get by with creating your own ancillary
GroupData model (for example) and associating it one-to-one with the Group
model.  I've done this in the past with User, creating my own UserData model
to hold some additional attributes, and it worked well for me.

  -- Scott

On Fri, May 9, 2008 at 10:14 AM, Marcin Gorczyński <[EMAIL PROTECTED]>
wrote:

>
> Well basicly I want the groups to have more data associeted with them
> - like a image filename, extracting the numer of users, one-to-one
> relations with a model in a news app and forum app, adding models like
> category like this category->groups, group and category moderators.
> Probarly I can get what I want from the user model by the profile
> model, personal messages to users (maybe that shuld be another app)
>
> Thanks
> >
>


-- 
http://scott.andstuff.org/  |  http://truthadorned.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to modify contrib.auth models etc

2008-05-09 Thread Marcin Gorczyński

Well basicly I want the groups to have more data associeted with them
- like a image filename, extracting the numer of users, one-to-one
relations with a model in a news app and forum app, adding models like
category like this category->groups, group and category moderators.
Probarly I can get what I want from the user model by the profile
model, personal messages to users (maybe that shuld be another app)

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Good to join your group – A thought : work hard, pay your taxes and smile

2008-05-09 Thread Riter
Hi All.

This is my first post here – just want to say Hi – Will make other posts
soon.

Peace

Riter



Did you know that your Govt. can make 100% profits through Taxes in 6 hours?
– read the story yourself.. http://talefunnytail.blogspot.com/  after that
laugh, think, growl or just pay up, but do it with a smile (smiles are not
taxable)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to modify contrib.auth models etc

2008-05-09 Thread Scott Moonen

Hi Marcin.  Can you give some more detail on what specific additional
functionality you need?

It is possible that you can augment the existing models by creating
your own ancillary "UserData" and "GroupData" models, each with a
OneToOneField that relates directly to the auth.models.User and
auth.models.Group models, and each containing any additional data and
relations that you need.  With the appropriate edit_inline setting on
the OneToOneField you can even edit this data on the User/Group page
in the admin interface.  However, if you are looking to extend some of
the behavior of the existing models; e.g., stretching permissions to
do something new, then you might be better off creating your own
models.

  -- Scott Moonen

On May 9, 9:48 am, Marcin Gorczyński <[EMAIL PROTECTED]> wrote:
> Hello
>
> I have a problem to tackle - in my site I want to have groups that
> have assigned forums, news etc. The Django contrib.auth just aren`t
> enough (also I need a more custom user model). Anyone can please tell
> me a good way to come around those limits? I thought about coding my
> own user, group app but that would take some time and I`m searching
> for a easier way.
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: "None of the above" in a form?

2008-05-09 Thread Kirk Strauser
On Tuesday 06 May 2008, Scott SA wrote:

> These are M2M relationship records handled transparently for you. In
> reality, they are in a table in between your two 'Role' tables. If you
> want to delete them, then you can select and delete them programatically
> (i.e. from a button on your form)

I think I expressed myself poorly.  What I meant was that when a visitor is 
editing a form, and they accidentally click in a MultipleChoiceField widget 
and select one of the options, there's no way (that I've found) for them to 
un-select that option before clicking "Submit".

Imagine a field in a job application like "Which crimes have you been 
convicted of?  [Armed robbery] [Arson] [Kidnapping]".  You bump "Arson" by 
mistake.  Don't you wish there was a "none of the above" option to select 
instead?
-- 
Kirk Strauser


signature.asc
Description: This is a digitally signed message part.


How to modify contrib.auth models etc

2008-05-09 Thread Marcin Gorczyński

Hello

I have a problem to tackle - in my site I want to have groups that
have assigned forums, news etc. The Django contrib.auth just aren`t
enough (also I need a more custom user model). Anyone can please tell
me a good way to come around those limits? I thought about coding my
own user, group app but that would take some time and I`m searching
for a easier way.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to Create a TextField and read data from it

2008-05-09 Thread João Rodrigues
Hello all. I'm new to Django, and to web development, so feel free to point
me to the manual if you need to :)

I am having a small problem developing a web interface for an application
(100% written in Python) I built. At first, I tried to use Ruby on Rails, as
advised by a friend, but since I was using Python, it felt weird (much like
treason actually:) to use a non-pythonic framework when there were some
available. However, I gave it a (tiny) try and got to a draft webpage of
what I wanted. In Django, I haven't been able to reproduce that webpage.

What I'm trying to do, is a simple text form where the user can type a few
lines of text, numbers, whatever. Then, I want to capture what he/she wrote,
parse it and pass it on to my python application. I am having trouble in the
very first part of the process: building the text form.

So, all in all, I'm asking, if that's not too much, for you to point me to a
readable solution (I read the new forms tutorial and to be honest, I got
confused :\ ) or examples.

Thanks in advance

-- 
João Rodrigues

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django_sessions table getting out of hand

2008-05-09 Thread Scott Moonen

Hi Matt.  The reason folks don't prefer to do it within the
application code is because it introduces a delay into rendering pages
while the DELETE is executed -- even in cases where there is nothing
to delete.  By running the DELETE in a cron job you improve the
performance of your page loads.

  -- Scott Moonen

On May 9, 8:54 am, "Matt Davies" <[EMAIL PROTECTED]> wrote:
> Thanks for getting back to me Arien
>
> If that's what people are doing to sort it out then that's fine by me, I can
> write a cron job to run a script and everyone is happy.
>
> If anyone has a more elegant solution I'm all ears.
>
> I suppose I could overwrite sections of the middleware so that whenever a
> session is created it checks the table and bins the expired records then,
> but I don't want to edit the source code if I can help it, for obvious
> upgrading reasons.
>
> I could pull that middleware into my app to avoid the problem I've just
> mentioned, but see how messy it is getting already?
>
> Is there a reason for keeping records in the django_sessions table once
> they've expired?  There may be one that I don't know of.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django_sessions table getting out of hand

2008-05-09 Thread Matt Davies
Thanks for getting back to me Arien

If that's what people are doing to sort it out then that's fine by me, I can
write a cron job to run a script and everyone is happy.

If anyone has a more elegant solution I'm all ears.

I suppose I could overwrite sections of the middleware so that whenever a
session is created it checks the table and bins the expired records then,
but I don't want to edit the source code if I can help it, for obvious
upgrading reasons.

I could pull that middleware into my app to avoid the problem I've just
mentioned, but see how messy it is getting already?

Is there a reason for keeping records in the django_sessions table once
they've expired?  There may be one that I don't know of.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django_sessions table getting out of hand

2008-05-09 Thread Matt Davies
Just a bit more information about how we're using the contrib.sessions

The only mention of it I have in my site is in the settings file, we don't
do anything else with it

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
)


Django source version is

Schedule: normal
Last Changed Author: gwilson
Last Changed Rev: 6635
Last Changed Date: 2007-10-31 04:04:07 + (Wed, 31 Oct 2007)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: child edit causes duplication with model inheritance

2008-05-09 Thread Erwin Elling

On May 5, 1:47 pm, bobhaugen <[EMAIL PROTECTED]> wrote:
> Thanks.  If I read that last one correctly, queryset-factor was merged
> into trunk on 4-26, andnewforms-adminmerged trunk on 4-28 (and
> appears to do so regularly), so the answer to my question is "yes".

That's the way I read it as well. Queryset refactoring branch has been
merged into trunk. After that, newforms-admin branch has been merged
with trunk.

Anyone with experience with newforms admin and queryset refactoring,
yet? Does the admin in the newforms-admin branch indeed treat
inherited models right?
Looking for some people who have tried this out, before I dive into
it... It sounds so promising!

Cheers,
Erwin
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django_sessions table getting out of hand

2008-05-09 Thread Arien

On Fri, May 9, 2008 at 7:28 AM, Matt Davies <[EMAIL PROTECTED]> wrote:
> What's the best method of keeping the django_sessions table from growing so
> large?

Well, there's django/bin/daily_cleanup.py ;-)


Arien

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



django_sessions table getting out of hand

2008-05-09 Thread Matt Davies
Hello everyone

I know one of the uber genii who use this list will have a very easy
solution to this one.

What's the best method of keeping the django_sessions table from growing so
large?

I've just ran a delete from django_sessions where expire_date <= $yesterday
to clear it out a little, clunky and temporary though.

Is there a way from within the django code to tell django to delete the
django_session record when the expire_date has passed?

Cheers for any advice.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Serializing custom fields

2008-05-09 Thread Luper Rouch

I have a db.models.Field subclass that needs a special representation in 
the database. This is achieved by implementing get_db_prep_save() and 
using SubfieldBase as the metaclass, and works fine.

The problem comes when serializing, the custom field is serialized using 
the python's form string representation of the data. I tried to 
implement flatten_data() in the custom field, as it seems [1] to be the 
serialization counterpart of get_db_prep_save(), but the method is not 
called.

Strangely if I don't use SubfieldBase as the metaclass, flatten_data() 
is called and the data is correctly serialized, but then the database 
part is broken ...

Am I doing something wrong ?

[1] 
http://www.djangoproject.com/documentation/custom_model_fields/#flatten-data-self-follow-obj-none

--Luper

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Pagination: how to find out on what page a give object will end up

2008-05-09 Thread VidJa Hunter
This is my 'problem',

I have a paginator object created like this: (example with 40 objects, but
in practice we are talking about several hundred objects)

paginator = Paginator(queryset,5)
paginator.page_range
[1, 2, 3, 4, 5, 6, 7, 8]

Some objects on page 1 link to objects on page 6. When a user jumps from
page X to Y I would like to keep the pagination structure intact such that
the user may paginate back and forth between page 1 and 6 to see what is in
between. Basically this boils down to the following question:

how to find out what the page number would be of specific object that is
part of the given queryset. Something like

paginator.is_on_page(object) would return page 6 if object is element 31 of
the given queryset.

Any suggestions how to implement this?

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



Re: Weird session problem

2008-05-09 Thread [EMAIL PROTECTED]

Look at the thing I posted.  The sessionid= tag is there but it seems
to confuse django when there's more than just that in that header.  I
don't know exactly what causes it though.

On May 7, 4:28 pm, finnam <[EMAIL PROTECTED]> wrote:
> Isn't it just a matter of session id cookie name? You should have
> different session id cookies for java app server and django.
>
> On May 7, 12:23 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > Ahh, I figured it out.  There was a java app server running on this
> > machine before and I for some reason that caused django to choke.  I
> > removed all of them and now it works.
>
> > Does this seem like a bug?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



IntegrityError on newforms-admin

2008-05-09 Thread Nuno Mariz

I'm using newforms-admin and I've got a "duplicate key violates unique
constraint" when I'm added new record(with the same value on field
that already exists in the db) in admin interface.
I've an "unique=True" in the field, shouldn't admin interface shows a
error message in the form and not raise a IntegrityError exception?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: No request.FILES, but file is still uploaded?

2008-05-09 Thread [EMAIL PROTECTED]

I don't think this matters here, but you're overriding the 'file'
builtin.

On May 8, 7:03 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Thu, May 8, 2008 at 3:51 PM, Beals <[EMAIL PROTECTED]> wrote:
> > Correction: request.FILES does exist -- it just wasn't getting printed
> > out with "print request".  An explicit "print request.FILES" did the
> > trick.
>
> > However, my question still stands: is form.save(commit=False) supposed
> > to be writing the file out to disk?  Is this the newforms way of
> > handling uploads, and therefore is checking for request.FILES and
> > writing the file out ourselves passé?
>
> Does your model have a FileField?  If so, then yes, I'd expect save of a
> ModelForm for that model to save the file to disk.  Haven't checked the doc
> to see if it explicitly says that will happen, that is just how I would
> expect it to behave.
>
> Not sure if/how this is different from oldforms, since I never used them.
> But checking request.FILES etc is not necessarily passé, it just depends on
> your model setup.  In my own app, I do upload files, but I don't use
> FileField (nor ModelForms), so I have to handle writing the uploaded file to
> the appropriate place myself.
>
> Karen
>
>
>
> > On May 8, 3:43 pm, Beals <[EMAIL PROTECTED]> wrote:
> > > A while back, I looked for code snippets for uploading files.  Almost
> > > every site I found contained something like the following:
>
> > > if 'file' in request.FILES:
> > >     file = request.FILES['file']
> > >     filename = file['filename']
> > >     fd = open('%s/%s' % (MEDIA_ROOT, filename), 'wb')
> > >     fd.write(file['content'])
> > >     fd.close
> > > else:
> > >     print "No file attached."
>
> > > This seemed to work -- files were uploaded and the pointers from the
> > > model worked fine, so I never thought to look at the logs... until
> > > today, and I noticed that even though the uploads were working
> > > properly, the "No file attached" message kept showing up.  Drilling
> > > in, I found that FILES wasn't even in the request object!  Yet the
> > > file was still written to disk... weird.
>
> > > So I started putting breakpoints in to figure out where in my view the
> > > file was getting written out.  The fourth line is the culprit:
>
> > > if request.method == 'POST':
> > >     form = FooForm(request.POST, request.FILES)
> > >     if form.is_valid():
> > >         new_artifact = form.save(commit=False)
> > >         *BREAKPOINT*
>
> > > So how/why is form.save(commit=False) writing the file out to disk??
> > > Is this expected behavior for ModelForms?  (NOTE: in case it matters,
> > > I'm using the built-in Django webserver.)
>
> > > -Aaron
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: very odd MySQL 'ascii' code error in MySQLdb/connections.py

2008-05-09 Thread oliver

Hi Julien,

that looks interesting, last time I looked at the django email it was
very basic and I needed to send HTML email with attachments, so that
snippet seemed the best way. By the looks you can now do that via
django as well!
thanks again.


On May 7, 10:48 pm, Julien <[EMAIL PROTECTED]> wrote:
> I also recommend you to use Django's EmailMessage class and its
> derivatives [1], as they handle unicode perfectly; they also reduce
> your code for sending emails to a couple of lines, which is always
> good.
>
> [1]http://www.djangoproject.com/documentation/email/#e-mail-messages
>
> On May 8, 3:26 am, oliver <[EMAIL PROTECTED]> wrote:
>
> > we use thishttp://www.djangosnippets.org/snippets/285/asa base and
> > made it work for us. templates are stored in the database so our users
> > can "edit" the html email and text email templates with a list of
> > "variables" they can use.
> > Works quite well .. and now even with out acii/unicode errors by the
> > looks of it. you can see most of the code for this in the dpast link
> > in my 1st message
>
> > On 7 May, 13:23, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
>
> > > On 07-May-08, at 12:49 PM, oliver wrote:
>
> > > > Now this all works fine till I get a non English PC using this (the
> > > > error below is from our very basic contact form!)
>
> > > > Exception Type: UnicodeEncodeError at /contact-opal-students/
> > > > Exception Value: 'ascii' codec can't encode character u'\xb4' in
> > > > position 88: ordinal not in range(128)
>
> > > how do you compose your email? I had this problem even using
> > > postgresql when I tried to compose the email within the view by
> > > concatenating strings. I then set up a text template and passed
> > > variables to that - and the problem went away
>
> > > --
>
> > > regards
> > > kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/code/
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---