Re: looping over dictionaries

2010-02-14 Thread Javier Rivera

Karen Tracey wrote:

Now in a template I want to iterate over them as follows:
{% for project in projects %}
{{ project }}
 {% for chain in project.chains %}
 -- {{ chain }}
 {% endfor %}
{% endfor %}


I'm usually use the values() property to iteract dictionary values. I 
find it more readable than items(), and usually, as I need to sort the 
output, the fact that it returns a list is quite useful.


{% for project in projects %}
{{ project }}
{% for chain in project.chains.values %}
 -- {{ chain }}
{% endfor %}
{% endfor %}

The drawback is that it (likely, not sure) uses more memory, as it makes 
a copy of the dictionary values as a list.


It seems that most people prefer items(). Why?.

Javier.

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



Re: Django IDE

2010-02-14 Thread Mike Ramirez
On Sunday 14 February 2010 20:59:22 dj_vishal wrote:
> Hello
> 
>Hi to all am new to the Django Framework.am learning django
>Which IDE is suitable for Django ..plz help me in right way
> 
>Thanks in Advance
>vishal
>2009vis...@gmail.com
> 

eric4 has a nice django plugin that you might like...

http://eric-ide.python-projects.org/

It's mainly for pyqt but the django plugin works as expected.
-- 
Failure is not an option -- it comes bundled with Windows. 


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


Re: Django IDE

2010-02-14 Thread Skylar Saveland
This might be the wrong way to help you if you want something super-
gui-fabulous.  But, I have a dusty old project that is not gaining any
traction to make a nice IDE out of vim.  If you don't know/like vim
and have no desire to learn then I might just be wasting your time.

http://github.com/skyl/vim-config-python-ide

I use something pretty close to the supertab branch myself.  vim
config is kind of a personal thing though.  So is an IDE.  There  are
lots of answers on stack overflow that will tell you eclipse with
pydev.  Many people use textmate, emacs and even some prominent people
are using gedit?

To go farther than just an editor, I just use the gnu-linux command
line with git/hg and ipython for debugging and bpython as the shell.
I like small tools that do one thing well.

On Feb 14, 11:59 pm, dj_vishal <2009vis...@gmail.com> wrote:
> Hello
>
>    Hi to all am new to the Django Framework.am learning django
>    Which IDE is suitable for Django ..plz help me in right way
>
>    Thanks in Advance
>    vishal
>    2009vis...@gmail.com
> --
> View this message in 
> context:http://old.nabble.com/Django-IDE-tp27589650p27589650.html
> Sent from the django-users mailing list archive at Nabble.com.

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



Django IDE

2010-02-14 Thread dj_vishal

Hello

   Hi to all am new to the Django Framework.am learning django
   Which IDE is suitable for Django ..plz help me in right way

   Thanks in Advance
   vishal
   2009vis...@gmail.com
-- 
View this message in context: 
http://old.nabble.com/Django-IDE-tp27589650p27589650.html
Sent from the django-users mailing list archive at Nabble.com.

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



how to handle Winsock TCP\IP in Django

2010-02-14 Thread Keyan
Please let me know is it possible to handle Winsock TCP\IP concepts in
Django. & is there any tutorials to follow.

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



Re: Object data change approvals.

2010-02-14 Thread iliveinapark
Thanks very much, Bruno, this is a pretty simple way of doing what I
want.

Now I just have to figure out to apply it generically over multiple
levels of inheritance =/

Cheers mate.

On Feb 12, 10:00 pm, bruno desthuilliers
 wrote:
> On Feb 12, 11:24 am, bruno desthuilliers wrote:
>
> (snip)
>
> oops, forgot to actually use the custom manager:
>
> > class MyModelRevision(models.Model):
>
> (snip)
>       objects =  MyModelRevisionManager()
>
>
>
> >    class Meta:
> >        unique_together = (('MyModel', 'published'),)

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



Re: Django 1.2 and Python 3.X ?

2010-02-14 Thread Shawn Milochik
No:

http://docs.djangoproject.com/en/dev/faq/install/#can-i-use-django-with-python-3

A lot of third-party modules have to be updated first. And when it doest 
happen, it'll be big enough news that you'll probably hear about it.

When in doubt, check docs.djangoproject.com -- the answer is usually easy to 
find.

Shawn

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



Re: Django 1.2 and Python 3.X ?

2010-02-14 Thread James Bennett
On Sun, Feb 14, 2010 at 7:06 PM, italiasky  wrote:
> Can we expect Django 1.2 to be used with Python 3.x ?

Django's documentation contains answers to many common questions,
including this one:

http://docs.djangoproject.com/en/dev/faq/install/#can-i-use-django-with-python-3

In the future, please consider searching the documentation for answers.


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



Django 1.2 and Python 3.X ?

2010-02-14 Thread italiasky
Hi!

Can we expect Django 1.2 to be used with Python 3.x ?

Thanks
Bye

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



Re: How do I manually set the "GROUP BY" for a django queryset?

2010-02-14 Thread Russell Keith-Magee
On Mon, Feb 15, 2010 at 6:30 AM, Greg  wrote:
> I have a large-ish query which is taking ~10 seconds to run, but I can
> get it down to less than a second by changing the group by part of the
> query from
>
>    GROUP BY `refunds_userprofile`.`ird_number` ,
> `auth_user`.`first_name` , `auth_user`.`last_name` ,
> `refunds_userprofile`.`user_id` , `auth_user`.`id` ,
> `auth_user`.`username` , `auth_user`.`first_name` ,
> `auth_user`.`last_name` , `auth_user`.`email` ,
> `auth_user`.`password` , `auth_user`.`is_staff` ,
> `auth_user`.`is_active` , `auth_user`.`is_superuser` ,
> `auth_user`.`last_login` , `auth_user`.`date_joined`
>
> to
>
>    GROUP BY `refunds_userprofile`.`ird_number`
>
> (note this doesn't change the query results)
>
> I figured I might have to use some undocumented methods to do this,
> but I couldn't figure it out - I've tried explicitly setting the
> query.group_by attribute with no success. Does anyone know how I could
> do this?

The short answer is  "you don't". Django doesn't expose any way to
manually control GROUP BY because that is a relational construct, and
Django is attempting to provide an Object-like wrapper.

As for why dropping GROUP BY clauses is faster - remember, t's always
possible to get the wrong answer in O(1) time :-) Daniel has asked the
more important question - what are you trying to do? Django is
generally pretty careful about adding GROUP BY clauses; arbitrarily
dropping them make me a little nervous. It's possible you're found a
bug, but it's impossible to confirm that without more details.

Yours
Russ Magee %-)

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



Re: Why is the post syncdb hook signal not called 'post' syncdb?

2010-02-14 Thread Russell Keith-Magee
On Mon, Feb 15, 2010 at 12:41 AM, monkut  wrote:
> Just curious, but I was looking at using the post-syncdb hook and
> found that it's actually called *before* the complete syncdb command
> finishes.  (Custom and indicies are run after the signal)
>
> http://docs.djangoproject.com/en/dev/ref/signals/#post-syncdb
>
> When I first used this my expectation was that the signal would be
> *after* the syncdb command finishes.
> It would be nice to have a 'real' post-syncdb signal.

The naming and timing of the post-syncdb signal is mostly a historical
artefact. The documentation for the post-syncdb signal could be
improved to highlight the exact ordering that takes place.

You're not the first to suggest a 'really post syncdb' signal, either.
"database done" was the last proposal I remember seeing. Personally,
I'm not morally opposed to such a signal, I'm just not particularly
motivated to work on it myself. The only use case I've seen is
deleting indexes that have been created automatically.

Yours,
Russ Magee %-)

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



Re: How do I manually set the "GROUP BY" for a django queryset?

2010-02-14 Thread Daniel Roseman
On Feb 14, 10:30 pm, Greg  wrote:
> I have a large-ish query which is taking ~10 seconds to run, but I can
> get it down to less than a second by changing the group by part of the
> query from
>
>     GROUP BY `refunds_userprofile`.`ird_number` ,
> `auth_user`.`first_name` , `auth_user`.`last_name` ,
> `refunds_userprofile`.`user_id` , `auth_user`.`id` ,
> `auth_user`.`username` , `auth_user`.`first_name` ,
> `auth_user`.`last_name` , `auth_user`.`email` ,
> `auth_user`.`password` , `auth_user`.`is_staff` ,
> `auth_user`.`is_active` , `auth_user`.`is_superuser` ,
> `auth_user`.`last_login` , `auth_user`.`date_joined`
>
> to
>
>     GROUP BY `refunds_userprofile`.`ird_number`
>
> (note this doesn't change the query results)
>
> I figured I might have to use some undocumented methods to do this,
> but I couldn't figure it out - I've tried explicitly setting the
> query.group_by attribute with no success. Does anyone know how I could
> do this?

What ORM query are you running to get the above generated SQL? Looks
like it could be a bug.
--
DR.

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



Running multiple FCGI processes out of the same directory

2010-02-14 Thread Peter Bengtsson
I'm running Nginx in front of Django using FCGI. I start it something
like this in my bash sysadmin scripts:

  python /foo/manage.py runfcgi host=127.0.0.1 port=9000 pidfile=/var/
foo.pid \
   errlog=err.log outfile=out.log

What I'm contemplating is running multiples of this so that I use the
same manage.py file but with different pid files and different port
numbers. The objective is running more processes as opposed to running
many threads. And most importantly if a fcgi process dies another can
take over and this is taken care of by the load balancer.

Is this a good idea? Are there any risks with this approach?

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



How do I manually set the "GROUP BY" for a django queryset?

2010-02-14 Thread Greg
I have a large-ish query which is taking ~10 seconds to run, but I can
get it down to less than a second by changing the group by part of the
query from

GROUP BY `refunds_userprofile`.`ird_number` ,
`auth_user`.`first_name` , `auth_user`.`last_name` ,
`refunds_userprofile`.`user_id` , `auth_user`.`id` ,
`auth_user`.`username` , `auth_user`.`first_name` ,
`auth_user`.`last_name` , `auth_user`.`email` ,
`auth_user`.`password` , `auth_user`.`is_staff` ,
`auth_user`.`is_active` , `auth_user`.`is_superuser` ,
`auth_user`.`last_login` , `auth_user`.`date_joined`

to

GROUP BY `refunds_userprofile`.`ird_number`

(note this doesn't change the query results)

I figured I might have to use some undocumented methods to do this,
but I couldn't figure it out - I've tried explicitly setting the
query.group_by attribute with no success. Does anyone know how I could
do 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Delete a data row that is inherit by another one.

2010-02-14 Thread Kev Dwyer
On Sun, 14 Feb 2010 10:24:08 -0800, manixor wrote:

> Hy, how can I check if a field is inherit by another one. If I delete
> that field, it delete cascade, the foreign data too.

Hello,

It's not clear what you mean by "field".  If you're talking about 
cascades in the database the documentation is at
http://docs.djangoproject.com/en/1.1/topics/db/queries/#deleting-objects

Cheers,

Kev

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



Re: ANN: django-admin-tools 0.1.0 released

2010-02-14 Thread David Jean Louis

Le 10/02/2010 09:56, David Jean Louis a écrit :

Hello,

I'm happy to announce the availability of the first public release of 
django-admin-tools.




For those interested in the project, I've setup a mailing list to share 
ideas on django-admin-tools future development:

http://groups.google.com/group/django-admin-tools/

Greetings,

--
David

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



Re: looping over dictionaries

2010-02-14 Thread Karen Tracey
On Sun, Feb 14, 2010 at 1:58 PM, Madis  wrote:

> Why will this not work or how should i write it to work:
>
> I have the following dictionary:
> projects = {u'NetMinutes': {'chains': [u'Arendus', u'Uuslahendus']},
> u'Veel': {'chains': []}}
>
> Now in a template I want to iterate over them as follows:
> {% for project in projects %}
> {{ project }}
>  {% for chain in project.chains %}
>  -- {{ chain }}
>  {% endfor %}
> {% endfor %}
>
> It iterates over the projects and prints out the project names but
> will not iterate over the project.chains.
> Maybe someone can give me some clues?
>


Iterating over projects just gives you the keys in the dictionary, as
strings. If you also want to work with the values assigned to the keys in
the dictionary you need to iterate over the key,value pairs returned by the
dictionary items() method. Then the value you have in your loop will have a
chains attribute you can access.  For example:

{% for project, chains_dict in projects.items %}
{{ project }}
 {% for chain in chains_dict.chains %}
 -- {{ chain }}
 {% endfor %}
{% endfor %}

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



Re: RequestContext and user.is_authenticated confusion

2010-02-14 Thread Kev Dwyer
On Sun, 14 Feb 2010 08:30:05 -0800, Achim Domma wrote:

> Hi Kev,
> 
> thanks for the hint. Trying different solutions I introduced indeed a
> typo. Now I can see the username and is_authenticated works as expected.
> But still curious: Is there a good reason, why I have to pass
> RequestContext each time? Whenever I'm using Django and having the
> feeling to violate DRY, there's usually a better solution. I'm quite
> surprised that it's not the case this time!?
> 
> cheers,
> Achim

Hello Achim,

I'm glad it's working for you now.

I don't know the original reason for having to use RequestContext; there 
is a hint in bug #650 that authentication wasn't thought to be a
common enough use case to justify the processing overhead of making
RequestContext available by default.

The idea of adding RequestContext to render_to_request by default was 
considered for 1.1 but special-cased, apparently because consensus could
not be reached.  Search the Django Developers list if you want the details.

All the best,

Kev


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



Re: looping over dictionaries

2010-02-14 Thread Skylar Saveland
{% for k, v in d.items %}
{{k}} {{v}}
{% endfor %}

On Feb 14, 1:58 pm, Madis  wrote:
> Why will this not work or how should i write it to work:
>
> I have the following dictionary:
> projects = {u'NetMinutes': {'chains': [u'Arendus', u'Uuslahendus']},
> u'Veel': {'chains': []}}
>
> Now in a template I want to iterate over them as follows:
> {% for project in projects %}
> {{ project }}
>   {% for chain in project.chains %}
>   -- {{ chain }}
>   {% endfor %}
> {% endfor %}
>
> It iterates over the projects and prints out the project names but
> will not iterate over the project.chains.
> Maybe someone can give me some clues?
>
> Regards,
> Madis

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



looping over dictionaries

2010-02-14 Thread Madis
Why will this not work or how should i write it to work:

I have the following dictionary:
projects = {u'NetMinutes': {'chains': [u'Arendus', u'Uuslahendus']},
u'Veel': {'chains': []}}

Now in a template I want to iterate over them as follows:
{% for project in projects %}
{{ project }}
  {% for chain in project.chains %}
  -- {{ chain }}
  {% endfor %}
{% endfor %}

It iterates over the projects and prints out the project names but
will not iterate over the project.chains.
Maybe someone can give me some clues?

Regards,
Madis

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



Re: InlineModelAdmin related items on two levels

2010-02-14 Thread Ogi Vranesic
>>On Feb 14, 6:19 am, Ogi Vranesic  wrote:
>> Hi all
>>
>> I read the very good tutorial 
onhttp://docs.djangoproject.com/en/dev/ref/contrib/admin/
>> and understood that the admin interface has the ability to edit models on 
the
>> same page as a parent model and these are called inlines. For two related
>> models is this easy:
>>
>> class A (models.Model):
>>name =...
>>
>> class B(models.Model):
>>a = models.ForeignKey(A)
>>title = ...
>>
>> in admin.py:
>>
>> class B(admin.TabularInline):
> >model = B
>>
>> class AAdmin(admin.ModelAdmin):
>> inlines = [
>> B,
>> ]
>>
>> and the result ist, that in add/change of A we can also add/change its 
child
>> models B
>>
>> My Problem is   that I however by B model have also child models:
>> class C
> >  b = models.ForeignKey(B)
>>   name = ...
>>
>> My Question is :
>> Is it possible than one can add/edit models of A on the one page together 
with
>> child models B and C as child models of B.
>>
>> Any hint or idee would be very appreciated

>Sounds like you want nested inlines. There is no built-in way to do
>this with django. I did some work (and got a solution working), but it
>required significant change to the installed django. I was planning on
>trying to make it into an installable app, but didn't get far.

>I do have a diff: I've just put it at http://pastie.org/823968 - this
>is with a fairly old trunk though, so it may not merge back in that
>well right now.

>It was based on another nested-inline diff I had come across, but I
>don't seem to have the link any more.

>Oh, and it is not flawless, there were still some issues I didn't get
>sorted out. I had some validation errors of some sort, I think, when
>updating data under certain circumstances, but I never quite
>completely tracked it down.

> Matt.

Hi Matt

Thank you very much for Your reply and effort to manage this issue.
It's pitty, that nested lists are not implemented in django.
I'll look Your diffs on http://pastie.org/823968 and try to do something.

Best regards
Ogi

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



Delete a data row that is inherit by another one.

2010-02-14 Thread manixor
Hy, how can I check if a field is inherit by another one. If I delete
that field, it delete cascade, the foreign data too.

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



Re: Returning array of integers as part of json dump, how to access in Javascript

2010-02-14 Thread robinne
Yea, that was it. I guess I wasn't quite clear on what was getting
passed back from the ajax call. I didn't realize obj.PythonList was
already a javascript array.

Thanks for your response, sorry my code wasn't very clear.

On Feb 13, 3:10 pm, Daniel Roseman  wrote:
> Unfortunately your question is not clear, and this "clarification"
> does not really help matters. As far as I can tell, obj.PythonList is
> already an array. If you do:
>    jArray = [obj.PythonList]
> then yes, jArray[0] is indeed the whole contents of obj.PythonList.
> But I don't understand why you want to do this - why not just
> obj.PythonList[0] which should be 3?
> --
> DR.
>
> On Feb 13, 7:04 pm, robinne  wrote:
>
> > I put in wrong variable name:
>
> > > var PIDS = obj.PackageIDS; //this brings back 3,2 for example, an
> > > array of integers.
>
> > should be...
>
> > var PIDS = obj.PythonList;
>
> > On Feb 13, 10:10 am, robinne  wrote:
>
> > > I am trying to pass an array of integers from a view to javascript in
> > > an ajax call.
>
> > > I know how to return json dump from a View so that javascript can
> > > access it as an object like this:
>
> > > VIEW
> > > response_dict = {"PythonList": MyList, "EditType": edittype}
> > > return HttpResponse(simplejson.dumps(response_dict), mimetype='text/
> > > javascript')
>
> > > where MyList is a... python list created by:
> > > MyList = []
> > >             for p in packages:
> > >                 MyList.append(p.id)
>
> > > in javascript, I can access the json by:
> > > var obj = YAHOO.lang.JSON.parse(o.responseText);
> > > var PIDS = obj.PackageIDS; //this brings back 3,2 for example, an
> > > array of integers.
>
> > > I cannot get at PIDS as an array in javascript. When I try to convert
> > > to an array, the first item in the array is always all values (3,2)
> > > instead of just the first one (3). The most simplistic attempt at this
> > > was:
>
> > > var jArray = [obj.PythonList]
>
> > > Any suggestions?

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



Why is the post syncdb hook signal not called 'post' syncdb?

2010-02-14 Thread monkut
Just curious, but I was looking at using the post-syncdb hook and
found that it's actually called *before* the complete syncdb command
finishes.  (Custom and indicies are run after the signal)

http://docs.djangoproject.com/en/dev/ref/signals/#post-syncdb

When I first used this my expectation was that the signal would be
*after* the syncdb command finishes.
It would be nice to have a 'real' post-syncdb signal.

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



Re: RequestContext and user.is_authenticated confusion

2010-02-14 Thread Achim Domma
Hi Kev,

thanks for the hint. Trying different solutions I introduced indeed a
typo. Now I can see the username and is_authenticated works as
expected. But still curious: Is there a good reason, why I have to
pass RequestContext each time? Whenever I'm using Django and having
the feeling to violate DRY, there's usually a better solution. I'm
quite surprised that it's not the case this time!?

cheers,
Achim

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



Before Christus date specification

2010-02-14 Thread dedalus
Is there an opportunity to work in Django with a before Christus date
specification?  I put a  value like „-0133-01-01“ in admin view, it
caused a failure: „Please fill in a correct date“.

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



Django docs - how to build json docs with sphinx

2010-02-14 Thread A Melé
I'm trying to use djangodocs: 
http://code.djangoproject.com/browser/djangoproject.com/djangodocs
. I see it requires documentation to be in .fjson format. So I have
tried to build the django docs with sphinx:

sphinx-build -b json . _build/json

But I get this error:
File "/usr/lib/python2.5/site-packages/Sphinx-0.6.4-py2.5.egg/sphinx/
builders/html.py", line 789, in handle_page
self.implementation.dump(ctx, f, 2)
AttributeError: 'module' object has no attribute 'dump'

I can convert the docs to HTML or .pickle files without errors, but
not to fjson. How can I do it?

Thanks!

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



Re: Session errors with mod_wsgi

2010-02-14 Thread birkin
David,

A while ago I had a serialization error that may be relevant to your
situation. Parts of the request object related to mod_wsgi were not
serializable. Below is how I handled it (this is a views.py def).

-Birkin

[start]
def variables( request, SSL=None ):
  from django.utils import simplejson
  import copy
  # get rid of dictionary items not serializable
  new_dict = copy.copy(request.META)
  new_dict.pop('wsgi.errors')
  new_dict.pop('wsgi.file_wrapper')
  new_dict.pop('wsgi.input')
  # now go ahead and serialize
  data = simplejson.dumps( new_dict, sort_keys=True, indent=2 )
  return HttpResponse( data, mimetype='text/javascript' )
  # end def variables()
[end]


On Feb 13, 10:04 pm, DavidMck  wrote:
> I've given up. There seems to be an issue with pickling some objects
> when you're using mod_wsgi - rather than using xlrd, I just attempted
> to add the uploaded file (small file held in memory) to the session
> data. The error log was essentially the same, but complaining about an
> attempt to pickle a CStringIO object or something instead...
>
> So instead, I'm writing the file to a known disk location and then
> loading it back again on the view page, instead of holding it in
> session memory. It's dirty and it isn't scalable, but it works for
> me :D
>
> Very strange how this all 'just works' when you use the built in dev
> server...
>
> David
>
> On Feb 14, 12:50 pm, DavidMck  wrote:
>
> > Hmm:
>
> > My relevant codes seems to be:
>
> > @login_required
> > def upload(request):
> >     if request.method == "POST":
> >         form = ExcelUploadForm(request.POST, request.FILES)
> >         if form.is_valid():
> >             request.session['sheet'] = form.cleaned_data["excelfile"]
>
> > If I put something boring into the session (like a string, instead of
> > the form.cleaned_data item), the problem goes away. If I leave that
> > last line as it is, it comes back...
>
> > David

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



A dark color scheme for the admin site

2010-02-14 Thread cool-RR
Hello,

Does anyone have a ready-made template with a dark color scheme for
the admin site? Ideally I'd want something where the text is light
grey and the background is dark grey, but I'd settle for anything
light-on-dark.

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



Re: Getting uploaded images to show

2010-02-14 Thread holger
Hi

I added the url-pattern and altered the admin_media_prefix and it
worked.

Thanks a lot for your help!

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



Re: RequestContext and user.is_authenticated confusion

2010-02-14 Thread andreas schmid
Kev Dwyer wrote:
> On Sun, 14 Feb 2010 01:19:41 -0800, Achim Domma wrote:
>
>   
>> Hi,
>>
>> depending on if a user is logged in or not, I want to display a "login"
>> form or a "logout" button. I tried to use this code snippet:
>>
>> http://docs.djangoproject.com/en/1.1/topics/auth/#id6
>>
>> If I render my view using render_to_response("myTemplate.html") the user
>> variable is empty. If I use
>> render_to_response("myTemplate.html",context_instance=RequestContext(request))
>> I get the correct user and can display the username. But
>> is_authenticated still always returns false!? Any hint what I might be
>> doing wrong?
>>
>> According to the documentation
>> "context_instance=RequestContext(request)" should only be required when
>> passing a additional data dictionary to render_to_response. As passing
>> data to a view and checking if the user is logged in should be something
>> quite common, this sounds strange to me!?
>>
>> I want to display the user information / status in my master template,
>> so having to pass a RequestContext into the template from each view
>> would be very tedious. Feels like I'm on a complete wrong way!?
>>
>> Any hint would be very appreciated!
>>
>> cheers,
>> Achim
>> 
>
> Hello Achim,
>
> It's difficult to tell why is_authenticated returns false for you, but
> assuming there aren't any typos in your template then you need to check 
> that your views are working correctly, particularly that authentication
> are not "lost" by forgetting to pass them to one of your views.
>
> Passing a RequestContext to your templates is the correct way to give your 
> templates access to authentication information.  It seems cumbersome
> while your changing all your render_to_response calls but it doesn't
> need any maintenance after that.
>
> Cheers,
>
> Kev
>
>   
did you put 'django.core.context_processors.request' into your
TEMPLATE_CONTEXT_PROCESSORS in your settings.py?

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



Re: RequestContext and user.is_authenticated confusion

2010-02-14 Thread Kev Dwyer
On Sun, 14 Feb 2010 01:19:41 -0800, Achim Domma wrote:

> Hi,
> 
> depending on if a user is logged in or not, I want to display a "login"
> form or a "logout" button. I tried to use this code snippet:
> 
> http://docs.djangoproject.com/en/1.1/topics/auth/#id6
> 
> If I render my view using render_to_response("myTemplate.html") the user
> variable is empty. If I use
> render_to_response("myTemplate.html",context_instance=RequestContext(request))
> I get the correct user and can display the username. But
> is_authenticated still always returns false!? Any hint what I might be
> doing wrong?
> 
> According to the documentation
> "context_instance=RequestContext(request)" should only be required when
> passing a additional data dictionary to render_to_response. As passing
> data to a view and checking if the user is logged in should be something
> quite common, this sounds strange to me!?
> 
> I want to display the user information / status in my master template,
> so having to pass a RequestContext into the template from each view
> would be very tedious. Feels like I'm on a complete wrong way!?
> 
> Any hint would be very appreciated!
> 
> cheers,
> Achim

Hello Achim,

It's difficult to tell why is_authenticated returns false for you, but
assuming there aren't any typos in your template then you need to check 
that your views are working correctly, particularly that authentication
are not "lost" by forgetting to pass them to one of your views.

Passing a RequestContext to your templates is the correct way to give your 
templates access to authentication information.  It seems cumbersome
while your changing all your render_to_response calls but it doesn't
need any maintenance after that.

Cheers,

Kev

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



Re: Session errors with mod_wsgi

2010-02-14 Thread Graham Dumpleton
You are somehow trying to pickle the WSGI environ dictionary, possibly
due to trying to pickle the Django request object. You cannot do that.

Graham

On Feb 14, 2:04 pm, DavidMck  wrote:
> I've given up. There seems to be an issue with pickling some objects
> when you're using mod_wsgi - rather than using xlrd, I just attempted
> to add the uploaded file (small file held in memory) to the session
> data. The error log was essentially the same, but complaining about an
> attempt to pickle a CStringIO object or something instead...
>
> So instead, I'm writing the file to a known disk location and then
> loading it back again on the view page, instead of holding it in
> session memory. It's dirty and it isn't scalable, but it works for
> me :D
>
> Very strange how this all 'just works' when you use the built in dev
> server...
>
> David
>
> On Feb 14, 12:50 pm, DavidMck  wrote:
>
>
>
> > Hmm:
>
> > My relevant codes seems to be:
>
> > @login_required
> > def upload(request):
> >     if request.method == "POST":
> >         form = ExcelUploadForm(request.POST, request.FILES)
> >         if form.is_valid():
> >             request.session['sheet'] = form.cleaned_data["excelfile"]
>
> > If I put something boring into the session (like a string, instead of
> > the form.cleaned_data item), the problem goes away. If I leave that
> > last line as it is, it comes back...
>
> > David

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



RequestContext and user.is_authenticated confusion

2010-02-14 Thread Achim Domma
Hi,

depending on if a user is logged in or not, I want to display a
"login" form or a "logout" button. I tried to use this code snippet:

http://docs.djangoproject.com/en/1.1/topics/auth/#id6

If I render my view using render_to_response("myTemplate.html") the
user variable is empty. If I use
render_to_response("myTemplate.html",context_instance=RequestContext(request))
I get the correct user and can display the username. But
is_authenticated still always returns false!? Any hint what I might be
doing wrong?

According to the documentation
"context_instance=RequestContext(request)" should only be required
when passing a additional data dictionary to render_to_response. As
passing data to a view and checking if the user is logged in should be
something quite common, this sounds strange to me!?

I want to display the user information / status in my master template,
so having to pass a RequestContext into the template from each view
would be very tedious. Feels like I'm on a complete wrong way!?

Any hint would be very appreciated!

cheers,
Achim

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