Re: Newbee stumped again - admin pages doing exactly what they should, but not what I need

2010-03-05 Thread Atamert Ölçgen
On Saturday 06 March 2010 06:07:30 dogfuel wrote:
> most of you probably know this will not give the desired result - it
> shows the correct test, but not as a hyperlink.
Moving the method to ModelAdmin and setting `allow_tags` True on it should 
solve this problem:

  class Destination_admin(admin.ModelAdmin):
  list_display = ('name', 'location_nrd', 'link_to_other_site')

  def link_to_other_site(self, obj):
  return u"link" % (obj.location_nbr)
  link_to_other_site.allow_tags = True


-- 
Saygılarımla,
Atamert Ölçgen

 -+-
 --+
 +++

www.muhuk.com
mu...@jabber.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-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: Formset: 'ArticleForm' object does not support item assignment

2010-03-05 Thread coco
Getting out of the bed, I partly found why this new problem occurs.
This is because the following HTML line:


Becomes this after the first submit by the browser:


Then I loose "id_form-0" substring and the corrupted HTML cannot work
twice.

This seem encouraging, but now I need to sleep. I will post the
solution if I find it tomorrow.
Goodnight...

-- 
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: Formset: 'ArticleForm' object does not support item assignment

2010-03-05 Thread coco
I made some progress replacing the defective line with:
   formset.forms[i] = ArticleForm(cd[i])

Mysteriously: it work when the browser send the first submit. But the
form becomes empty if I submit twice.

Here is the template:



Test


Test

{% if form.errors %}

Please correct the error{{ form.errors|pluralize }} below.

{% endif %}


{{ formset.management_form }}


XYZ
{% for form in formset.forms %}

{% for field in form %}
{{ field }}
{% endfor %}
{{ form.errors }}

{% endfor %}







-- 
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: problem with objects.get(id=None)

2010-03-05 Thread Ilya Braude


Karen Tracey wrote:
I'm guessing you are using MySQL That's just how it behaves, by 
default. See:


http://dev.mysql.com/doc/refman/5.1/en/server-session-variables.html#sysvar_sql_auto_is_null


Wow, thanks.  I now see that this has been brought up a few times 
before.  This MySQL behavior should really be documented somewhere in 
Django.


The solution of putting the following line in settings.py works for me:

 DATABASE_OPTIONS = {'init_command': 'set sql_auto_is_null=0'}

from:

 http://www.mail-archive.com/django-users@googlegroups.com/msg74313.html


Ilya

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



Formset: 'ArticleForm' object does not support item assignment

2010-03-05 Thread coco
Good evening,

I stick with the above error message in the following example. I
looked at each
attributes of the object (Base_fields, etc.), but I can't find how I
to assign the new dataset back into the form.

def manage_articles(request):
ArticleFormSet = formset_factory(ArticleForm)
if request.method == 'POST':
formset = ArticleFormSet(request.POST, request.FILES)
if formset.is_valid():
# do something with the formset.cleaned_data
cd = formset.cleaned_data
for i in range(len(cd)):
cd[i]['answer'] = cd[i]['x'] + cd[i]['y']

# Here Is the problem (this line do not work)
formset.forms[i].base_fields = cd[i]
else:
formset = ArticleFormSet()
return render_to_response('manage_articles.html', {'formset':
formset})

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.



Newbee stumped again - admin pages doing exactly what they should, but not what I need

2010-03-05 Thread dogfuel
In a model, I have added a method that builds text for a html link
(based on model attributes) similar to:
-
from django.db import models

class Destination(models.Model)
name = models.CharField(max_length=25)
location_nbr = models.CharField(max_length=4)

def link_to_other_site(self):
return "link" % (self.location_nbr)


I hope to display a working link (for reference, not for any django
based use) in the admin list for this model by writing:


from django.contrib import admin
admin.autodiscover()

class Destination_admin(admin.ModelAdmin):
list_display = ('name', location_nrd, link_to_other_site)

admin.site.register(Destination, Destination_admin)
-

most of you probably know this will not give the desired result - it
shows the correct test, but not as a hyperlink.

Would you please enlighten a very humble newbee?

Also, can it e included in a fieldset of an admin change page?




-- 
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: problem with objects.get(id=None)

2010-03-05 Thread Karen Tracey
I'm guessing you are using MySQL That's just how it behaves, by default.
See:

http://dev.mysql.com/doc/refman/5.1/en/server-session-variables.html#sysvar_sql_auto_is_null

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: problem with objects.get(id=None)

2010-03-05 Thread Ilya Braude

Ilya Braude wrote:

Hello!

I've run into a problem when calling .get on a related field manager 
with id = None.
As far as I understand, doing an objects.get(id=None) should throw a 
DoesNotExist exception.


However, it seems that there is some caching going on, as demonstrated 
in this trivial example:

http://dpaste.com/168572/

The first call to
 blog.entry_set.get(id=None)
returns entry2, while the second call correctly throws the exception, 
which is incorrect! 


Oops. I meant that returning entry2 is incorrect; throwing the exception 
is the (correct) expected behavior.




I've been able to reproduce this with trunk as of today.

Am I doing something wrong, or is there a bug?

Thanks,
Ilya



--
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: Question!!!

2010-03-05 Thread summea
This is something I've been looking around for earlier.  Thanks for
posting it here as well!  I originally found it here: (http://
groups.google.com/group/django-users/browse_thread/thread/
1f97ae29f23f71d4)

But after using that type of method to list a ManyToManyField (in my
case, a field called "authors",) I realized that when viewing a table
that has various column names from the model I was working with (in my
case, a Book model,) I was seeing the name of the function listed in
the column heading.  And that is how it should be with the way I had
it set up initially.

But do you know if there is any way to set a ManyToManyField's column
heading to something besides the function name itself?  For example...
I tried setting verbose_name='authors' in the model... but it didn't
seem to work as expected.  (No error really, it just didn't change the
name of the column heading.)

Have you ever needed to change the column name in a view of a
ManyToManyField?  Anyway... if so, do I need to use something other
than verbose_name?

Thanks for any pointers...
Andy




On Mar 5, 2:55 pm, Kenny Meyer  wrote:
> Wilmer A. Delpratt (wdelprat...@gmail.com) wrote:
>
>
>
>
>
> > Hi everyone..i'm new in this group...my friends says this is one of
> > the best groups...
> > I'd like to know how i can use a ManyToManyField in a "list_display",
> > i've read the documentation, but there says this is not possible
> > (isn't supported),i wish to know if there is another way to solve
> > this problem (i really need to do that)well that's all...thanks a
> > lot
> > PD: Sorry my bad englishi'm from Cuba (official language
> > 'Spanish').
> > Once again thank you all...please help me.see you
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> Hey Wilmer :)
>
> First of all I must criticize your attempt to ask a simple question.
> Ever heard of using a meaningful subject [1]_, or how to ask *smart
> questions* [2]_? Your style honestly sucks and is painful to read.=20
> Period.
>
> Back to topic:
> Using a ManyToManyField in the Django's model class is not possible
> AFAIK, but by writing a little Python function you can easily handly
> this.
>
> Take the following example:
>
> class Book(models.Model):
>         ...
>         authors =3D models.ManyToManyField(Author)
>         ...
>
>         def get_authors(self):
>                 return self.authors.all()
>
>         class Admin:
>                 list_display =3D ('get_authors')
>
> This is pretty self-explanatory and not tested, but should work.
>
> > Hi everyone..i'm new in this group...my friends says this is one of
> > the best groups...
>
> They're certainly right your friends. ;)
>
> Hope I could help,
> Kenny
>
> .. [1]http://www.hoax-slayer.com/email-subject-lines.html
> .. [2]http://catb.org/~esr/faqs/smart-questions.html
> --
>   Kenny Meyer
>   Software Geek |http://kenny.alwaysdata.net
>
>   Shoot for the moon, even if you miss, you'll land amongst the stars..
>     - Les Brown

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



problem with objects.get(id=None)

2010-03-05 Thread Ilya Braude

Hello!

I've run into a problem when calling .get on a related field manager 
with id = None.
As far as I understand, doing an objects.get(id=None) should throw a 
DoesNotExist exception.


However, it seems that there is some caching going on, as demonstrated 
in this trivial example:

http://dpaste.com/168572/

The first call to
 blog.entry_set.get(id=None)
returns entry2, while the second call correctly throws the exception, 
which is incorrect!


I've been able to reproduce this with trunk as of today.

Am I doing something wrong, or is there a bug?

Thanks,
Ilya

--
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 to display PendingDeprecationWarning using dev. server?

2010-03-05 Thread Brian Neal
Any ideas? Can anyone else try this and report back? Just insert the
code below into a view function and start the dev. server with "python
-Wall manage.py runserver". Thanks.

On Feb 28, 5:28 pm, Brian Neal  wrote:
> I'm having trouble seeing PendingDeprecationWarning's on stderr when
> using the dev server.
>
> To make sure I'm not crazy, I wrote a simple Python program that looks
> like this:
>
> print "** WARNING **"
> import warnings
> warnings.warn(
>     "Testing the warnings module!",
>     PendingDeprecationWarning
> )
>
> And here are some sample runs:
>
> $ python warning.py
> ** WARNING **
> $ python -Wall warning.py
> ** WARNING **
> warning.py:5: PendingDeprecationWarning: Testing the warnings module!
>   PendingDeprecationWarning
>
> Now when I put that code in some view function in my Django app, I
> always see the print statement output, but never the actual warning
> message. I've tried starting the dev. server various ways, but none of
> them seem to work:
>
> $python -Wall manage.py runserver
> $python -Wd manage.py runserver
>
> I only seem to have this trouble with PendingDeprecationWarning.
> UserWarning, for example, works as expected.
>
> What am I doing wrong? I am using Python 2.5.2 and Django SVN r12623.
> 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: Question!!!

2010-03-05 Thread Kenny Meyer
Russell Keith-Magee (freakboy3...@gmail.com) wrote:
> On Sat, Mar 6, 2010 at 6:55 AM, Kenny Meyer  wrote:
> > Wilmer A. Delpratt (wdelprat...@gmail.com) wrote:
> >> Hi everyone..i'm new in this group...my friends says this is one of
> >> the best groups...
> >> I'd like to know how i can use a ManyToManyField in a "list_display",
> >> i've read the documentation, but there says this is not possible
> >> (isn't supported),i wish to know if there is another way to solve
> >> this problem (i really need to do that)well that's all...thanks a
> >> lot
> >> PD: Sorry my bad englishi'm from Cuba (official language
> >> 'Spanish').
> >> Once again thank you all...please help me.see you
> >>
> >> --
> >> You received this message because you are subscribed to the Google Groups 
> >> "Django users" group.
> >> To post to this group, send email to django-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.
> >>
> >
> > Hey Wilmer :)
> >
> > First of all I must criticize your attempt to ask a simple question.
> > Ever heard of using a meaningful subject [1]_, or how to ask *smart
> > questions* [2]_? Your style honestly sucks and is painful to read.=20
> > Period
> 
> Can you see the irony in coming in like a rabid bulldog when the
> original author was commenting on how he heard Django-users was such a
> nice community? Bravo. It takes special skills to miss the point so
> successfully.
> 
> There is absolutely no excuse for treating other human beings like
> crap. If you can't find a civil way to suggest that someone might want
> to rephrase their question, keep your mouth shut. We can live without
> that sort of attitude.
> 
> We can also live without the references to ESR. As I've noted many
> times on this group, his 'smart questions' rant is correct in spirit,
> but in no way shares the tone we are trying to maintain in this group.
> 
> Wilmer - on behalf of the group, I apologize for Kenny's response.
> Please don't consider his attitude to be representative of the group
> as a whole -- we're usually quite nice.
> 
> 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.
> 

Russ, 

I give in, my comment was very out of place.

I did not mean to offend neither to treat you (Wilmer) like crap and I'm
sorry for causing unnecessary trouble; I will try being solely focused on
the topic itself next time.

Best regards,
Kenny

-- 
  Kenny Meyer
  Software Geek | http://kenny.alwaysdata.net

  Shoot for the moon, even if you miss, you'll land amongst the stars..
- Les Brown

-- 
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: Adding a new convenience filter 'contains_any'

2010-03-05 Thread Russell Keith-Magee
On Sat, Mar 6, 2010 at 9:09 AM, Phlip  wrote:
>> >>> (I also disagree with leaving out the spaces around =, but obviously
>> >>> obeying a team style guide supersedes improving it...)
>>
>> >> ... the goal of clarity/legibility
>>
>> > uh...
>>
>> ;)  I meant *having* a style guide was consistent with said goal.
>
> right - following an aesthetic style guide is more important than the
> validity of each of its line items, so the Nuremberg Defense applies
>
> (not so a _technical_ style guide!;)

In this case, it's not just a team style guide - it's PEP8, which clearly says:

 - Don't use spaces around the '=' sign when used to indicate a
  keyword argument or a default parameter value.

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: Adding a new convenience filter 'contains_any'

2010-03-05 Thread Phlip
> >>> (I also disagree with leaving out the spaces around =, but obviously
> >>> obeying a team style guide supersedes improving it...)
>
> >> ... the goal of clarity/legibility
>
> > uh...
>
> ;)  I meant *having* a style guide was consistent with said goal.

right - following an aesthetic style guide is more important than the
validity of each of its line items, so the Nuremberg Defense applies

(not so a _technical_ style guide!;)

-- 
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: Question!!!

2010-03-05 Thread Russell Keith-Magee
On Sat, Mar 6, 2010 at 6:55 AM, Kenny Meyer  wrote:
> Wilmer A. Delpratt (wdelprat...@gmail.com) wrote:
>> Hi everyone..i'm new in this group...my friends says this is one of
>> the best groups...
>> I'd like to know how i can use a ManyToManyField in a "list_display",
>> i've read the documentation, but there says this is not possible
>> (isn't supported),i wish to know if there is another way to solve
>> this problem (i really need to do that)well that's all...thanks a
>> lot
>> PD: Sorry my bad englishi'm from Cuba (official language
>> 'Spanish').
>> Once again thank you all...please help me.see you
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-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.
>>
>
> Hey Wilmer :)
>
> First of all I must criticize your attempt to ask a simple question.
> Ever heard of using a meaningful subject [1]_, or how to ask *smart
> questions* [2]_? Your style honestly sucks and is painful to read.=20
> Period

Can you see the irony in coming in like a rabid bulldog when the
original author was commenting on how he heard Django-users was such a
nice community? Bravo. It takes special skills to miss the point so
successfully.

There is absolutely no excuse for treating other human beings like
crap. If you can't find a civil way to suggest that someone might want
to rephrase their question, keep your mouth shut. We can live without
that sort of attitude.

We can also live without the references to ESR. As I've noted many
times on this group, his 'smart questions' rant is correct in spirit,
but in no way shares the tone we are trying to maintain in this group.

Wilmer - on behalf of the group, I apologize for Kenny's response.
Please don't consider his attitude to be representative of the group
as a whole -- we're usually quite nice.

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: Question!!!

2010-03-05 Thread Kenny Meyer
Wilmer A. Delpratt (wdelprat...@gmail.com) wrote:
> Hi everyone..i'm new in this group...my friends says this is one of
> the best groups...
> I'd like to know how i can use a ManyToManyField in a "list_display",
> i've read the documentation, but there says this is not possible
> (isn't supported),i wish to know if there is another way to solve
> this problem (i really need to do that)well that's all...thanks a
> lot
> PD: Sorry my bad englishi'm from Cuba (official language
> 'Spanish').
> Once again thank you all...please help me.see you
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-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.
> 

Hey Wilmer :)

First of all I must criticize your attempt to ask a simple question.
Ever heard of using a meaningful subject [1]_, or how to ask *smart
questions* [2]_? Your style honestly sucks and is painful to read.=20
Period.

Back to topic:
Using a ManyToManyField in the Django's model class is not possible
AFAIK, but by writing a little Python function you can easily handly
this.

Take the following example:

class Book(models.Model):
...
authors =3D models.ManyToManyField(Author)
...

def get_authors(self):
return self.authors.all()

class Admin:
list_display =3D ('get_authors')

This is pretty self-explanatory and not tested, but should work.

> Hi everyone..i'm new in this group...my friends says this is one of
> the best groups...
They're certainly right your friends. ;)

Hope I could help,
Kenny

.. [1] http://www.hoax-slayer.com/email-subject-lines.html
.. [2] http://catb.org/~esr/faqs/smart-questions.html
-- 
  Kenny Meyer
  Software Geek | http://kenny.alwaysdata.net

  Shoot for the moon, even if you miss, you'll land amongst the stars..
- Les Brown

-- 
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: Question!!!

2010-03-05 Thread Wolf Halton
Hola Wilmer!
Is it not available in the newest Django?

-Wolf

sent from the research lab at http://networksecuritynews.net

On Mar 5, 2010 3:14 PM, "Wilmer A. Delpratt"  wrote:

Hi everyone..i'm new in this group...my friends says this is one of
the best groups...
I'd like to know how i can use a ManyToManyField in a "list_display",
i've read the documentation, but there says this is not possible
(isn't supported),i wish to know if there is another way to solve
this problem (i really need to do that)well that's all...thanks a
lot
PD: Sorry my bad englishi'm from Cuba (official language
'Spanish').
Once again thank you all...please help me.see you

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-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.

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



Question!!!

2010-03-05 Thread Wilmer A. Delpratt
Hi everyone..i'm new in this group...my friends says this is one of
the best groups...
I'd like to know how i can use a ManyToManyField in a "list_display",
i've read the documentation, but there says this is not possible
(isn't supported),i wish to know if there is another way to solve
this problem (i really need to do that)well that's all...thanks a
lot
PD: Sorry my bad englishi'm from Cuba (official language
'Spanish').
Once again thank you all...please help me.see you

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Adding a new convenience filter 'contains_any'

2010-03-05 Thread Peter Herndon

On Mar 5, 2010, at 1:03 PM, Phlip wrote:

> On Mar 5, 8:41 am, Peter Herndon  wrote:
> 
>> On Mar 4, 2010, at 7:37 PM, Phlip wrote:
> 
>>> (I also disagree with leaving out the spaces around =, but obviously
>>> obeying a team style guide supersedes improving it...)
>> 
>> ... the goal of clarity/legibility
> 
> uh...

;)  I meant *having* a style guide was consistent with said goal.

-- 
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: Adding a new convenience filter 'contains_any'

2010-03-05 Thread Phlip
On Mar 5, 8:41 am, Peter Herndon  wrote:

> On Mar 4, 2010, at 7:37 PM, Phlip wrote:

> > (I also disagree with leaving out the spaces around =, but obviously
> > obeying a team style guide supersedes improving it...)
>
> ... the goal of clarity/legibility

uh...

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



Seeking Django developer (Boston, MA)

2010-03-05 Thread Chris B
Senior Web Developer (Python/Django) - Joslin Diabetes Center, Boston
MA

Job Description: The Senior Web Developer position is responsible for
leading the design, development, support and management of internal
and external database driven web applications for the Research
community at the Joslin Diabetes Center.  This is a full time perm
position.

The Joslin Diabetes Center, an internationally recognized diabetes
care, research and education institution affiliated with Harvard
Medical School and headquartered in Boston, MA, seeks a highly
motivated and energetic individual to join a team supporting the
Joslin Research Division. The candidate will be primarily responsible
for a web based LIMS system that manages ordering, fulfillment and
reporting for various scientific applications and data used daily by
the Research division. Ideal candidate will be able to demonstrate
understanding of modern software design principles and be comfortable
developing an end to end application. Technically the candidate will
be fluent in Python and the Django framework used to develop dynamic
web applications and will be able to demonstrate expertise in SQL,
xHTML, Ajax, Javascript, and CSS

Ideal Qualifications Include:
• Bachelor's Degree in Computer Science or Liberal Arts or equivalent
experience
• 5-8 years of software development with a minimum of 5 years in web
application development
• Fluent in Python, with Django strongly desired
• Knowledge of web technologies including Apache, JavaScript, AJAX,
CSS, xHTML
• Programming skills building forms, layouts, charts, and graphing
required
• Understanding and experience with object-oriented design practices
• Familiar with LDAP/Active Directory/Open Directory authentication
schemas
• Experienced developing secure web application

The full job description is at: http://jobs-joslin.icims.com/jobs/1994/job

-- 
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: Form initial data is not dynamic

2010-03-05 Thread NaMaK
Ah. That does make sense! I cant believe I missed that in the docs.
Thanks for pointing it out!


On Mar 5, 7:08 am, David De La Harpe Golden
 wrote:
> On 05/03/10 01:30, NaMaK wrote:
>
>  class DateTest(forms.Form):
> > ...     in_date=forms.DateTimeField(initial=datetime.datetime.now())
> > ...
>
> Well, note that the now() was executed when python first saw it, which
> was just a bit after it first saw the class definition. Think about it -
> it does make sense.
>
> But django allows initial on a form field to be a callable that will be
> called for a value at display time, so if that's suitable, you can do:
>
> class DateTest(forms.Form):
>      in_date=forms.DateTimeField(initial=datetime.now )
>
> # note absence of () on 'now' as you want to pass in now itself,
> # not call it.
>
> This is covered in the docs, 
> btw.http://docs.djangoproject.com/en/1.1/ref/forms/fields/#initial
> (towards the end of that section)
>
> Note deferring to display time with a callable is slightly different to
> passing in a value at form construction time - another option is to pass
> an initial dict of whatever you want at form construction time, if you
> want it to be that (probably more relevant for cases other than
> now/now()...)
>
> f = DateTest(initial=dict(in_date=datetime.now()))
>
> (callables also work there 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: ImportError: Could not import settings 'mysite.settings'

2010-03-05 Thread roc bhakta
Thanks Karen for the tip on SELinux.  After researching,  I found i
needed to do:

setsebool -P httpd_enable_homedirs 1
chcon -R -t httpd_user_content_t  /home/mysite



On Thu, Mar 4, 2010 at 8:15 PM, Karen Tracey  wrote:
>
> Fedora 12 has the security-enhanced linux kernel. If this is active on your
> system then chown/chmod may not be doing what you expect. I only know enough
> about selinux to tell you that much; how to configure it to enable Apache to
> access /home directories is beyond me. But I do recall others on this list
> have run into this type of problem when setting up machines that use
> selinux.
>
> 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: Adding a new convenience filter 'contains_any'

2010-03-05 Thread Peter Herndon

On Mar 4, 2010, at 7:37 PM, Phlip wrote:
> 
> Sorry, I didn't say "operator overload" (which are either spot-on or
> sophomoric, when they work).

I'm using "operator overloading" in this case because "id=" already has a 
specific function, and you would have it do something in addition to that 
function.  I may be using the term incorrectly.

> Because, IIRC, no SQL database can store arrays ('list's) in fields,
> the =[] event is free to be "overloaded" by its type.

Entertainingly, Postgresql does have array types 
(http://www.postgresql.org/docs/8.4/interactive/arrays.html), though that's 
more of an exception than the general case.  Django's ORM doesn't support db 
arrays directly, though there is the CommaSeparatedIntegerField, which 
approximates a primitive version.

> So id=[] would resolve to id__in=[], id=Scalar to id__exact=Scalar,
> and the explicit versions are available if you suspect that
> overloading is fragile.

Interesting thought.  Might be worth doing, to see how practical it is.  You 
should start it as a third-party project, see how much traction it gets.
> 
> (I also disagree with leaving out the spaces around =, but obviously
> obeying a team style guide supersedes improving it...)

Interestingly, that particular style choice is part of the language-level style 
guide, PEP8 (http://www.python.org/dev/peps/pep-0008/), rather than 
Django-specific.  Needless to say, it's a guide, rather than a syntax error, so 
it could be (and occasionally is, in some projects) ignored at the project 
level.  In the case of Django, though, PEP8 is specified.  I personally think 
it's a good thing that there's a language-level style guide, which is entirely 
consistent with both the goal of clarity/legibility, and the philosophy that 
"there should be one --and preferably only one-- obvious way to do it".  It 
means I don't have to think about style, I can instead focus on solving the 
problem.  Which is, really, the entire point of any style guide.

---Peter

-- 
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: Sqlite3, saving many items simultaneosly

2010-03-05 Thread Atamert Ölçgen
On Friday 05 March 2010 18:09:22 gintare wrote:
> b = Blog(  [name, tagline] , ['Beatles Blog', 'All the latest Beatles
> news]  )
> 
> >>> b.save()
How many items are you saving at once? Have you measured the time required to 
execute these queries and the total time your view/management command takes? 
Do you really need to optimize here and now to do custom SQL?

 
> I do not want to call save(column_name, item_value) for every item
> separately, i.e.:
> b = Blog(name='Beatles Blog', tagline='All the latest Beatles news.')
> 
> >>> b.save()
You can use create() manager method to achieve this in one step.
 

-- 
Saygılarımla,
Atamert Ölçgen

 -+-
 --+
 +++

www.muhuk.com
mu...@jabber.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-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: Sqlite3, saving many items simultaneosly

2010-03-05 Thread Shawn Milochik
Yes. Look at the syntax for executemany() (as opposed to execute()).

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.



Sqlite3, saving many items simultaneosly

2010-03-05 Thread gintare
Hello,

Is it possible to pack name of the column and value before submitting
to the database.
I mean something to save( dictionary), where dictionaries key is the
name of column and dictionaries item is value to be saved) or
save(list_column_names, list_values)?

b = Blog(  [name, tagline] , ['Beatles Blog', 'All the latest Beatles
news]  )
>>> b.save()


I do not want to call save(column_name, item_value) for every item
separately, i.e.:
b = Blog(name='Beatles Blog', tagline='All the latest Beatles news.')
>>> b.save()

My database consist of 20 columns.
Now i am using Sqlite3 syntax, where i print all column and item
names  to one string.

regards,
gintare

-- 
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: converting strings to model names dynamically.

2010-03-05 Thread Atamert Ölçgen
On Friday 05 March 2010 11:10:29 Omer Barlas wrote:
> How can I use a unicode string as a model instance?
You can't. However you can get a reference to your model class like this:

> from django.db.models.loading import get_model
> model_class = get_model('myapp', 'mymodel')
> instance = model_class._default_manager.get(id=42)


-- 
Saygılarımla,
Atamert Ölçgen

 -+-
 --+
 +++

www.muhuk.com
mu...@jabber.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-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: converting strings to model names dynamically.

2010-03-05 Thread Alessandro Pasotti
2010/3/5 Omer Barlas 

> I have an ajax form which updates the status field of a table's status
> column dynamically. I send the table name, and the Id to be replaced to the
> ajax processor, but when I try to call
>
> what = model_name.objects.get(Id=id_number)
>
> django barks at me like this;
>
> Traceback:
> File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py" in
> get_response
>  92. response = callback(request, *callback_args,
> **callback_kwargs)
> File "/home/www/django/adm/ajax/views.py" in statusUpdate
>  15.   what = model_name.objects.get(Id=id_number)
>
> Exception Type: AttributeError at /adm/ajax/statusUpdate/
> Exception Value: 'unicode' object has no attribute 'objects'
>
> How can I use a unicode string as a model instance?
>
>

AFAIK you can't, but you can retrieve a model class object from the model
name using


from django.db.models import get_model

model_class = get_model('appname', model_name) # appname is the application
name
what = model_class.objects.get(Id=id_number)


Hope this helps.

-- 
Alessandro Pasotti
w3:   www.itopen.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-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.



converting strings to model names dynamically.

2010-03-05 Thread Omer Barlas
I have an ajax form which updates the status field of a table's status 
column dynamically. I send the table name, and the Id to be replaced to the 
ajax processor, but when I try to call


what = model_name.objects.get(Id=id_number)

django barks at me like this;

Traceback:
File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py" in get_response
  92. response = callback(request, *callback_args, 
**callback_kwargs)

File "/home/www/django/adm/ajax/views.py" in statusUpdate
  15.   what = model_name.objects.get(Id=id_number)

Exception Type: AttributeError at /adm/ajax/statusUpdate/
Exception Value: 'unicode' object has no attribute 'objects'

How can I use a unicode string as a model instance?

--
Omer Barlas
omer.bar...@gmail.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.



Re: Adding a new convenience filter 'contains_any'

2010-03-05 Thread Masklinn
On 5 Mar 2010, at 05:15 , aditya bhargava wrote:
> 
> Not quite, because 'in' does exact matching, and I'm looking for the inexact
> matching that 'contains' provides. Here's one way to simulate a
> 'contains_any' filter:
> 
>t = ["acrylic","watercolors"]   # my list of tags
> 
>q = Q(tags__name__contains=t[0])
>for i in range(1,len(t)):
>q = q | Q(tags__name__contains=t[i])
> 
>o = Image.objects.filter(q) # o is the result of the contains_any filter
> 
> 
> This works fine, but here is the ideal way I'm hoping to write the same
> thing:
> o = Image.objects.filter(tags__name__contains_any=t)
> 
> 
> But I'm not sure how to go about adding that new filter.

Are you using django-tagging? It probably provides convenience methods for that 
kind of "I want the boolean result of the interesection between these two sets" 
filter.

You might also want to check the googles using "intersect" or "intersection" as 
a keyword, to get stuff like 
http://stackoverflow.com/questions/108193/union-and-intersect-in-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-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: Cassandra back end for Django

2010-03-05 Thread Waldemar Kornewald
On Mar 3, 5:32 pm, Oshadha  wrote:
> Hia fellas,
>
> I'm kind of new to Django framework.as far as I know Django only
> supports four major database engines.I have a requirement to use
> Cassandra(http://incubator.apache.org(/cassandra/) as the database
> backend,but I couldn't find any good resources on the net that give a
> helping hand.So I need a help form you guys.If anyone know a good
> resources for implementing Cassandra with Django framwork please post
> it here and share your experience on these technologies if you have
> any.

You could write a backend for the Django nonrel branch:
http://bitbucket.org/wkornewald/django-nonrel

Currently we only support App Engine. MongoDB will hopefully come
soon. We'd be happy about other backends.

Bye,
Waldemar Kornewald

-- 
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 and database user column update privileges

2010-03-05 Thread Ken
Cheers Karen.

I just wanted to make sure that all aspects of my question were
answered, so I separated the second problem into this thread.  Thanks
for your help.  (See other thread.)

Ken

On 5 Mar, 02:17, Karen Tracey  wrote:
> I answered your question in the other thread you had asking the exact same
> thing.
> 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: Update a single column of a row in a Model

2010-03-05 Thread Ken
Many thanks Karen.  This worked perfectly (though the 'name' attribute
is just name without the quotes).

Cheers,

Ken


On 5 Mar, 01:42, Karen Tracey  wrote:
> On Thu, Mar 4, 2010 at 2:24 PM, Ken  wrote:
> > Thanks for your example, but whilst you're correct about Person.id not
> > getting updated, all the other columns do get changed (even if it is
> > to the same value).
>
> > Here's my code...
>
> > class TcsDetectionListsForm(forms.Form):
> >    name = forms.CharField()
>
> > def candidateWithForm(request, tcs_transient_objects_id):
> >    detectionListRow = TcsDetectionLists.objects.get(pk=0)
>
>    if request.method == 'POST':
>
>
>
>
>
> >        form = TcsDetectionListsForm(request.POST)
> >        if form.is_valid(): # All validation rules pass
> >            detectionListRow.name = form.cleaned_data['name']
> >            detectionListRow.save()
> >    else:
> >        form = TcsDetectionListsForm(initial={'name':
> > detectionListRow.name })
>
> > Here's what happened in the database (from the DB log):
>
> > 223592 Query    UPDATE `tcs_detection_lists` SET `name` = 'rubbish',
> > `description` = 'Bad Candidates' WHERE `tcs_detection_lists`.`id` = 0
>
> > We shouldn't be updating the 'description' column.  If my security
> > settings were in place, this query would fail, because my DB user only
> > has update access to the 'name' column.
>
> TcsDetectionLists.objects.filter(pk=0).update('name'=form.cleaned_data['nam 
> e'])
>
> will produce an SQL UPDATE that only touches the name column.
>
> 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: Form initial data is not dynamic

2010-03-05 Thread David De La Harpe Golden

On 05/03/10 01:30, NaMaK wrote:


class DateTest(forms.Form):

... in_date=forms.DateTimeField(initial=datetime.datetime.now())
...


Well, note that the now() was executed when python first saw it, which
was just a bit after it first saw the class definition. Think about it - 
it does make sense.


But django allows initial on a form field to be a callable that will be 
called for a value at display time, so if that's suitable, you can do:


class DateTest(forms.Form):
in_date=forms.DateTimeField(initial=datetime.now )

# note absence of () on 'now' as you want to pass in now itself,
# not call it.

This is covered in the docs, btw.
http://docs.djangoproject.com/en/1.1/ref/forms/fields/#initial
(towards the end of that section)

Note deferring to display time with a callable is slightly different to 
passing in a value at form construction time - another option is to pass 
an initial dict of whatever you want at form construction time, if you 
want it to be that (probably more relevant for cases other than 
now/now()...)


f = DateTest(initial=dict(in_date=datetime.now()))

(callables also work there 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: django static files css headache

2010-03-05 Thread Mihail Lukin
Instead of passing media_url to each view, I do the following:
1) in my urls.py I put:
...
  url(r'^media/(?P.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}, 'media'),
...

2) in my templates I put:
...

...

On Mar 4, 1:57 am, "mendes.rich...@gmail.com" 
wrote:
> Hello Justin,
>
> It's a bit hard to see what's wrong based on this info.
> The thing you should check is if you could access the css by
> navigating to it in the url bar.
>
> You could check if the following would work.
>
> 
>     �...@import {{media_url}}style.css;
> 
>
> another thing that is different from the alert.js is that you put a /
> behind the style.css not sure if that could cause it
> but try without.
>
> if this doesn't work could you post the html code with a link to a
> javascript file in the same dir that works and css that doesn't.
>
> regards,
>
> Richard
>
> On Mar 3, 10:58 pm, justin jools  wrote:
>
> > I have setup my static docs in root urls:
>
> >  (r'^media/(?P.*)$', 'django.views.static.serve',
> > {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
>
> > and am serving media_url in with my other data: views.py as follows.
>
> > media_url = settings.MEDIA_URL
>
> > def dblist(request):
> >     obj_list_menu = dbModel1.objects.all()
> >     obj_list_model = dbModel2.objects.all()
> >     return render_to_response('products/dblist.html',
> > {'make_list': obj_list_menu, 'model_list': obj_list_model,
> > 'media_url': media_url })
>
> > so in my template I can reference images, fine.
>
> > 
> >  > height="100">
>
> > but for the life of me I can't figure out why I can't reference the
> > style.css the same way. I tried this in base.html and it returns the
> > correct url but doesnt execute it.
>
> >   (returns media/style.css)
>
> > I tried the same thing with a linked alert.js and this works fine:
>
> > 
>
> > so why doesnt my style.css do anything: it is int the same media
> > directory as alert.js...
>
> > would greatly appreciate any help, 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: Changing template variables

2010-03-05 Thread Kevin Renskers
For those interested:

In my base template I've added this:

{% load custom_tags %}
{% if form %}
{% formerrors request form %}
{% endif %}

In my custom_tags template tags library:

@register.simple_tag
def formerrors(request, form):
for field, errors in form.errors.items():
for error in errors:
if field == '__all__':
messages.error(request, error)
else:
messages.error(request, field+': '+error)

return ''


Works perfectly for me: now all form errors are shown in exactly the
same way as all other messages in my application.

Cheers,
Kevin


On Mar 4, 4:33 pm, Kevin Renskers  wrote:
> I'll explain a bit more what precisely it is what I want to do: Django
> 1.2 comes with a new messages framework that allows for each message
> to have a different "level" (succes, error, warning, etc). I want to
> see if a form has errors, and if so, make a message for each error so
> all my notices and errors are displayed in the same way in my
> application.
>
> But I think I just came up with a solution: make a new template tag in
> my base template, always give it the form variable (whether it exists
> or not), and from there create the new messages.

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