Re: Using a template variable in the "include" template tag

2010-01-29 Thread Super McFly
I store the model name as a field in the "Content" class. I then added

def include_template(self):
return"content/" + self.content_type.lower() + "/include.html"

to the model. Then in the template I used

{% for content in content_list %}
{% include content.include_template %}
{% endfor %}


On Jan 30, 6:19 am, Eric Abrahamsen  wrote:
> On Jan 30, 2010, at 2:07 PM, Super McFly wrote:
>
> > Thanks for your suggestion, Eric. I actually tried that but for some
> > reason it didn't work so I assumed it was the same problem. It turns
> > out it does work so a big thank you to you and everyone else who tried
> > to help.
>
> Good!
>
> Since you've already got a Content superclass going you could probably  
> do some metaclass jiggery-pokery to make this automatic for subclasses  
> ¨C on reflection it wouldn't be as simple as I blithely suggested in my  
> last response, but I think it could be done.
>
> E
>
>
>
> > On Jan 30, 5:59 am, Eric Abrahamsen  wrote:
> >> I've done this by including a python-only attribute on the models
> >> themselves:
>
> >> include_template = "content/post/include.html"
>
> >> and in the template {% include content.include_template %}
>
> >> Provided that "content" is a model instance.
>
> >> You could even write a model mixin class that does this  
> >> automatically,
> >> populating the include_template attribute using string formatting and
> >> the class name.
>
> >> Eric
>
> >> On Jan 30, 2010, at 1:45 PM, Super McFly wrote:
>
> >>> I guess the only way to do this would be to use an if conditional,
> >>> which would be really ugly...
>
> >>> {% if content.model_type == 'post' %}
> >>>   {% include "content/post/include.html" %}
> >>> {% endif %}
>
> >>> {% if content.model_type == 'review' %}
> >>>   {% include "content/review/include.html" %}
> >>> {% endif %}
>
> >>> On Jan 30, 5:33 am, Super McFly  wrote:
>  Thank you for the reply. Do you have any suggestions on how to do  
>  it
>  my way?
>
>  On Jan 30, 5:23 am, pyleaf  wrote:
>
> > i think that will not work,because 'include' excutes before the
> > Variable.
>
> > On Sat, Jan 30, 2010 at 12:51 PM, Super McFly
> > wrote:
>
> >> Is it possible to use a template variable in the "include"  
> >> template
> >> tag. My actual problem is below...
>
> >> {% include "content/{{ content.model_type }}/include.html" %}
>
> >> {{ content.model_type }} by itself outputs "post" and the full
> >> string
> >> outputs "content/post/include.html" and if that string is hard-
> >> coded
> >> then the template is included.
>
> >> --
> >> You received this message because you are subscribed to the
> >> Google Groups
> >> "Django users" group.
> >> To post to this group, send email to django-users@googlegroups.com
> >> .
> >> To unsubscribe from this group, send email to
> >> django-users+unsubscr...@googlegroups.com
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/django-users?hl=en.
>
> > --
> > ÏàÐÅÄÇһƬÌì¿Õ»áÒòÄãµÄÖ´×ŶøÇçÀÊ
>
> >>> --
> >>> You received this message because you are subscribed to the Google
> >>> Groups "Django users" group.
> >>> To post to this group, send email to django-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
> >>> .
>
> > --
> > 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
> > .

-- 
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: Using a template variable in the "include" template tag

2010-01-29 Thread Eric Abrahamsen


On Jan 30, 2010, at 2:07 PM, Super McFly wrote:


Thanks for your suggestion, Eric. I actually tried that but for some
reason it didn't work so I assumed it was the same problem. It turns
out it does work so a big thank you to you and everyone else who tried
to help.


Good!

Since you've already got a Content superclass going you could probably  
do some metaclass jiggery-pokery to make this automatic for subclasses  
�C on reflection it wouldn't be as simple as I blithely suggested in my  
last response, but I think it could be done.


E



On Jan 30, 5:59 am, Eric Abrahamsen  wrote:

I've done this by including a python-only attribute on the models
themselves:

include_template = "content/post/include.html"

and in the template {% include content.include_template %}

Provided that "content" is a model instance.

You could even write a model mixin class that does this  
automatically,

populating the include_template attribute using string formatting and
the class name.

Eric

On Jan 30, 2010, at 1:45 PM, Super McFly wrote:


I guess the only way to do this would be to use an if conditional,
which would be really ugly...



{% if content.model_type == 'post' %}
  {% include "content/post/include.html" %}
{% endif %}



{% if content.model_type == 'review' %}
  {% include "content/review/include.html" %}
{% endif %}



On Jan 30, 5:33 am, Super McFly  wrote:
Thank you for the reply. Do you have any suggestions on how to do  
it

my way?



On Jan 30, 5:23 am, pyleaf  wrote:



i think that will not work,because 'include' excutes before the
Variable.



On Sat, Jan 30, 2010 at 12:51 PM, Super McFly
wrote:


Is it possible to use a template variable in the "include"  
template

tag. My actual problem is below...



{% include "content/{{ content.model_type }}/include.html" %}



{{ content.model_type }} by itself outputs "post" and the full
string
outputs "content/post/include.html" and if that string is hard-
coded
then the template is included.



--
You received this message because you are subscribed to the
Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com 
.

To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com

a hook where request is available

2010-01-29 Thread Eric Abrahamsen
I've got a "NewContent" model which is essentially a tumblelog – when  
instances of certain models are created or saved, a NewContent  
instance is created that keeps track of them, and NewContent querysets  
are used to populate the index page, RSS feed, etc.


Up until now I've been doing this in the admin, with a custom save  
button called "Save and Mark and New", and then a subclassed  
ModelAdmin with response_add and response_change overridden, to check  
for this particular save value in request.POST and create a NewContent  
instance if necessary.


I'm slowly moving to front-end admin functionality, using generic  
views, and so far as I can tell, there's no point during the create/ 
update cycle where I'll have access to both the request (for checking  
the custom save value), and the created/updated object itself (which  
gets passed to a NewContent creation manager). I've looked at signals,  
middleware, form save methods, object save methods, and wrapping the  
generic view functions (I guess that's the same as middleware).


The only things left I can think of is, using my own versions of  
create_object and create_object, which I'd rather not do, or else  
doing away with the custom save button, and having post_save_redirect  
point to a page that asks users if they want to add the newly saved  
object to the new content stream.


Option two wouldn't be terrible, but I'd rather do it in one step. Do  
I have any other options here?


Thanks!
Eric

--
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: Using a template variable in the "include" template tag

2010-01-29 Thread Super McFly
Thanks for your suggestion, Eric. I actually tried that but for some
reason it didn't work so I assumed it was the same problem. It turns
out it does work so a big thank you to you and everyone else who tried
to help.

On Jan 30, 5:59 am, Eric Abrahamsen  wrote:
> I've done this by including a python-only attribute on the models  
> themselves:
>
> include_template = "content/post/include.html"
>
> and in the template {% include content.include_template %}
>
> Provided that "content" is a model instance.
>
> You could even write a model mixin class that does this automatically,  
> populating the include_template attribute using string formatting and  
> the class name.
>
> Eric
>
> On Jan 30, 2010, at 1:45 PM, Super McFly wrote:
>
> > I guess the only way to do this would be to use an if conditional,
> > which would be really ugly...
>
> > {% if content.model_type == 'post' %}
> >{% include "content/post/include.html" %}
> > {% endif %}
>
> > {% if content.model_type == 'review' %}
> >{% include "content/review/include.html" %}
> > {% endif %}
>
> > On Jan 30, 5:33 am, Super McFly  wrote:
> >> Thank you for the reply. Do you have any suggestions on how to do it
> >> my way?
>
> >> On Jan 30, 5:23 am, pyleaf  wrote:
>
> >>> i think that will not work,because 'include' excutes before the  
> >>> Variable.
>
> >>> On Sat, Jan 30, 2010 at 12:51 PM, Super McFly  
> >>> wrote:
>
>  Is it possible to use a template variable in the "include" template
>  tag. My actual problem is below...
>
>  {% include "content/{{ content.model_type }}/include.html" %}
>
>  {{ content.model_type }} by itself outputs "post" and the full  
>  string
>  outputs "content/post/include.html" and if that string is hard-
>  coded
>  then the template is included.
>
>  --
>  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 
> > athttp://groups.google.com/group/django-users?hl=en
> > .

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Using a template variable in the "include" template tag

2010-01-29 Thread Super McFly
I had just responded to myself with that suggestion but I've deleted
it to avoid repetition.

I'll try to explain the bigger picture but it's a little tricky. There
is a "Content" base model from which "Post", "Review", "Feature",
e.t.c inherit. To get a list of the latest content for all types I
have a view which renders "content_list = get_list_or_404(Content)" to
a template. In that template I loop over "content_list" and want to
include a specific template for each content type (post, review,
feature).

*** view ***
...
def content_list(request):
content_list = get_list_or_404(Content)
return render_to_response('content/content/list.html',
{'content_list': content_list}, context_instance=RequestContext
(request))
...

*** content/content/list.html ***
...
{% for content in content_list %}
{% include "content/{{ content.model_type }}/include.html" %}
{% endfor %}
...

*** content/review/include.html ***
...
{{ content.introduction|linebreaks }}
{{ content.body|linebreaks }}
{{ content.verdict|linebreaks }}
{{ content.score }}
...


On Jan 30, 5:37 am, Sam Lai  wrote:
> You can always use if blocks, e.g.
>
> {% ifequal content.model_type "post" %}
> {% include "content/post/include.html" %}
> {% elseifequal ... %}
> ...
> {% endif %}
>
> What's the bigger picture for what you're trying to do?
>
> 2010/1/30 Super McFly :
>
> > Thank you for the reply. Do you have any suggestions on how to do it
> > my way?
>
> > On Jan 30, 5:23 am, pyleaf  wrote:
> >> i think that will not work,because 'include' excutes before the Variable.
>
> >> On Sat, Jan 30, 2010 at 12:51 PM, Super McFly 
> >> wrote:
>
> >> > Is it possible to use a template variable in the "include" template
> >> > tag. My actual problem is below...
>
> >> > {% include "content/{{ content.model_type }}/include.html" %}
>
> >> > {{ content.model_type }} by itself outputs "post" and the full string
> >> > outputs "content/post/include.html" and if that string is hard-coded
> >> > then the template is included.
>
> >> > --
> >> > 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 
> > athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Using a template variable in the "include" template tag

2010-01-29 Thread Eric Abrahamsen
I've done this by including a python-only attribute on the models  
themselves:


include_template = "content/post/include.html"

and in the template {% include content.include_template %}

Provided that "content" is a model instance.

You could even write a model mixin class that does this automatically,  
populating the include_template attribute using string formatting and  
the class name.


Eric

On Jan 30, 2010, at 1:45 PM, Super McFly wrote:


I guess the only way to do this would be to use an if conditional,
which would be really ugly...

{% if content.model_type == 'post' %}
   {% include "content/post/include.html" %}
{% endif %}

{% if content.model_type == 'review' %}
   {% include "content/review/include.html" %}
{% endif %}



On Jan 30, 5:33 am, Super McFly  wrote:

Thank you for the reply. Do you have any suggestions on how to do it
my way?

On Jan 30, 5:23 am, pyleaf  wrote:

i think that will not work,because 'include' excutes before the  
Variable.


On Sat, Jan 30, 2010 at 12:51 PM, Super McFly  
wrote:



Is it possible to use a template variable in the "include" template
tag. My actual problem is below...



{% include "content/{{ content.model_type }}/include.html" %}


{{ content.model_type }} by itself outputs "post" and the full  
string
outputs "content/post/include.html" and if that string is hard- 
coded

then the template is included.



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




--
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: Using a template variable in the "include" template tag

2010-01-29 Thread Super McFly
I guess the only way to do this would be to use an if conditional,
which would be really ugly...

{% if content.model_type == 'post' %}
{% include "content/post/include.html" %}
{% endif %}

{% if content.model_type == 'review' %}
{% include "content/review/include.html" %}
{% endif %}



On Jan 30, 5:33 am, Super McFly  wrote:
> Thank you for the reply. Do you have any suggestions on how to do it
> my way?
>
> On Jan 30, 5:23 am, pyleaf  wrote:
>
> > i think that will not work,because 'include' excutes before the Variable.
>
> > On Sat, Jan 30, 2010 at 12:51 PM, Super McFly wrote:
>
> > > Is it possible to use a template variable in the "include" template
> > > tag. My actual problem is below...
>
> > > {% include "content/{{ content.model_type }}/include.html" %}
>
> > > {{ content.model_type }} by itself outputs "post" and the full string
> > > outputs "content/post/include.html" and if that string is hard-coded
> > > then the template is included.
>
> > > --
> > > 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.



Re: Using a template variable in the "include" template tag

2010-01-29 Thread Sam Lai
You can always use if blocks, e.g.

{% ifequal content.model_type "post" %}
{% include "content/post/include.html" %}
{% elseifequal ... %}
...
{% endif %}

What's the bigger picture for what you're trying to do?

2010/1/30 Super McFly :
> Thank you for the reply. Do you have any suggestions on how to do it
> my way?
>
> On Jan 30, 5:23 am, pyleaf  wrote:
>> i think that will not work,because 'include' excutes before the Variable.
>>
>> On Sat, Jan 30, 2010 at 12:51 PM, Super McFly wrote:
>>
>>
>>
>> > Is it possible to use a template variable in the "include" template
>> > tag. My actual problem is below...
>>
>> > {% include "content/{{ content.model_type }}/include.html" %}
>>
>> > {{ content.model_type }} by itself outputs "post" and the full string
>> > outputs "content/post/include.html" and if that string is hard-coded
>> > then the template is included.
>>
>> > --
>> > 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.
>
>

-- 
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: Using a template variable in the "include" template tag

2010-01-29 Thread Super McFly
Thank you for the reply. Do you have any suggestions on how to do it
my way?

On Jan 30, 5:23 am, pyleaf  wrote:
> i think that will not work,because 'include' excutes before the Variable.
>
> On Sat, Jan 30, 2010 at 12:51 PM, Super McFly wrote:
>
>
>
> > Is it possible to use a template variable in the "include" template
> > tag. My actual problem is below...
>
> > {% include "content/{{ content.model_type }}/include.html" %}
>
> > {{ content.model_type }} by itself outputs "post" and the full string
> > outputs "content/post/include.html" and if that string is hard-coded
> > then the template is included.
>
> > --
> > 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.



Re: Using a template variable in the "include" template tag

2010-01-29 Thread pyleaf
i think that will not work,because 'include' excutes before the Variable.

On Sat, Jan 30, 2010 at 12:51 PM, Super McFly wrote:

> Is it possible to use a template variable in the "include" template
> tag. My actual problem is below...
>
> {% include "content/{{ content.model_type }}/include.html" %}
>
> {{ content.model_type }} by itself outputs "post" and the full string
> outputs "content/post/include.html" and if that string is hard-coded
> then the template is included.
>
> --
> 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.



Re: REST & Django

2010-01-29 Thread pyleaf
oh,thanks.

On Sat, Jan 30, 2010 at 12:44 AM, myfreeweb  wrote:

> REST is a web service architecture, not a program functionality.
> If you want to implement a RESTful API for your app, take a look at
> django-piston: http://bitbucket.org/jespern/django-piston/wiki/Home
>
> On 29 янв, 19:03, pyleaf  wrote:
> > how REST looks like in django?
> > does Django support REST defautly?
> > --
> > Believing is everythig!
>
> --
> 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.



Using a template variable in the "include" template tag

2010-01-29 Thread Super McFly
Is it possible to use a template variable in the "include" template
tag. My actual problem is below...

{% include "content/{{ content.model_type }}/include.html" %}

{{ content.model_type }} by itself outputs "post" and the full string
outputs "content/post/include.html" and if that string is hard-coded
then the template is included.

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



'Reverse' (??) InlineModelAdmin objects

2010-01-29 Thread Rishabh Manocha
Hey guys,
I've been trying to get InlineModelAdmin objects setup in my admin
app, but am unable to figure out how to do so correctly. Using the
same example as the one listed in the docs [1]:

class Author(models.Model):
   name = models.CharField(max_length=100)

class Book(models.Model):
   author = models.ForeignKey(Author)
   title = models.CharField(max_length=100)

What I would like to do is have the Author creation form show up in
with the Book creation form - so basically, my admin.py code would
look something like:

class AuthorInline(admin.TabularInline):
model = Author

class BookAdmin(admin.ModelAdmin):
...
inlines = [AuthorInline, ]

However, when I try this, I get an error:

Exception Value:  has no ForeignKey to
.

So, I was wondering if anyone knows how I could get an Author creation
form show up inline with on the 'Add Book' page.

Thanks.

--

Best,

R

[1] 
- http://docs.djangoproject.com/en/dev/ref/contrib/admin/#inlinemodeladmin-objects

-- 
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: svn checkout problems? (at around 2:50 pm GMT, 2010-01-29)

2010-01-29 Thread Kenneth Gonsalves
On Friday 29 Jan 2010 8:29:55 pm chefsmart wrote:
> For the last 1 hour I have been trying to checkout a fresh copy of
> django-trunk from svn. But the checkout is failing.  Unfortunately, I
> don't have the exact message I have been receiving, but just wondering
> if anybody else facing similar issues with checkout?
> 

this problem usually occurs when your internet connection is bad
-- 
regards
Kenneth Gonsalves
Senior Project Officer
NRC-FOSS
http://nrcfosshelpline.in/web/

-- 
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: Division with Python/Django

2010-01-29 Thread Mike Ramirez
On Friday 29 January 2010 12:28:37 Chris McComas wrote:
> Hey everyone, here's all of the information:
> 
> Here's the models:
> http://dpaste.com/152277/
> 
> Here's my view:
> http://dpaste.com/152061/
> 
> Here's the full error message:
> http://dpaste.com/152060/
> 

All your fields in the models are DecimalFields 

in your view you have:

cogability.pcatessay_conv = int(cogability.pcatessay_rawscore) / 5 
cogability.pcat_conv = int(cogability.pcat_rawscore) / 100

These are Type Int when saved, not Decimal, you should convert them somewhere 
along the lines or change the fields to be IntegerField

Mike


-- 
Let not the sands of time get in your lunch.


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


Content Transfer Encoding in Emails

2010-01-29 Thread Stephen Sundell
How would I get my content transfer encoding for emails sent through
the django emails system to be 7bit?

Stephen

-- 
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 admin login failure

2010-01-29 Thread toinbis
Hi folks,

logging into django admin fails when 'log in' button is pressed first
time, but pressing "back" and "log in' again - logs the user in
successfully.

I am deploying Django app with zc.buildout here, with a setup similar
to what is described here 
http://www.meppum.com/2009/jan/17/installing-django-ubuntu-intrepid/.
Nginx (listening on 127.0.0.1:8003) is running beyond Apache(listening
on 127.0.0.1:8001), configurations of both servers are provided at the
end of the post. I'm accessing my django app as 127.0.0.1:8003.

So, 127.0.0.1:8003/admin/ opens django admin login form.
1)Entering username/pass, pressing "log in" redirects to 127.0.0.1/
admin, therefore ends up with nothing, as there is no server listening
on 80 port.
Browser sends:
POST /admin/ HTTP/1.1

Cookie: Kapow_Graphs=SUM%2C1%3ATBL%2C1%3ATER%2C1%3ATHR%2C1%3ARCR%2C1%3A
%23MEM%2C1%3AQR%2C1%3AER%2C1%3ARPCS%2C1;
sessionid=9b1b072a02f9ff3297442285729d5010

(sessionid value, at the time of pressing 'log in' matches the one
which is present in django db, in the 'session_key' column of the
single row in django_session table.

Nginx returns :
HTTP/1.x 302 FOUND

<..>
Set-Cookie: sessionid=5d2af76b5ea0b6f19d81e71690515d20; expires=Fri,
12-Feb-2010 21:35:59 GMT; Max-Age=1209600; Path=/

<..>

The old row in django_session is replaced with the new one, containing
the session from the Nginx returned 302 response.

2)Pressing browser's back , and 'log in' button once again  (or
pressing browser's 'back' and 'refresh') logs in succesfully into
127.0.0.1:8003/admin/.

It looks like that's a cookie-related issue, but, i guess, the root of
the problem might lie in the apache and/or nginx config as well.

Any ideas how to make the admin log-in form work immediately?

Cheers!

to


P.S.configs:
=
apache vhost configuration
===



Order deny,allow
Allow from all


WSGIDaemonProcess tsd user=www-data group=www-data threads=25
WSGIProcessGroup tsd

WSGIScriptAlias / /home/toinbis/Desktop/programming/project/
runtime/htdocs/django_wsgi/djproject.wsgi

LogLevel warn
ErrorLog  /home/toinbis/Desktop/programming/project/runtime/logs/
apache_tsd_error.log
CustomLog /home/toinbis/Desktop/programming/project/runtime/logs/
apache_tsd_access.log combined

ServerName localhost



===
nginx configuration
===

daemon off;
#user www-data;
worker_processes  2;

error_log  /home/toinbis/Desktop/programming/project/runtime/logs/
nginx_general_error.log;
pid/home/toinbis/Desktop/programming/project/runtime/var/pids/
nginx.pid;

events {
worker_connections  1024;
#server_names_hash_bucket_size: 128;
}

http {
include   /home/toinbis/Desktop/programming/project/runtime/
etc/nginx_conf/mime.types;
default_type  application/octet-stream;

access_log  /home/toinbis/Desktop/programming/project/runtime/logs/
nginx_access.log;
error_log   /home/toinbis/Desktop/programming/project/runtime/logs/
nginx_error.log;

sendfileon;
tcp_nopush on;

#keepalive_timeout  0;
keepalive_timeout  2;
tcp_nodelayon;

server_names_hash_bucket_size 128;
#server_name_hashes 128;
gzip  on;
gzip_comp_level 2;
gzip_proxied any;
gzip_disable "MSIE [1-6]\.(?!.*SV1)"; #iš ubuntu
gzip_types text/plain text/css application/x-javascript text/xml
application/xml application/xml+rss text/javascript;


upstream backend {
  server 127.0.0.1:8001;
}

server {
listen   8003;
server_name localhost;

error_log /home/toinbis/Desktop/programming/project/
runtime/logs/project_nginx_error.log;
access_log /home/toinbis/Desktop/programming/project/
runtime/logs/project_nginx_access.log;


location / {
proxy_pass  http://backend/;
include /home/toinbis/Desktop/programming/
project/runtime/etc/nginx_conf/nginx_proxy_1.conf;
}

location  /media/ {
root /home/toinbis/Desktop/programming/project/
src/tsd/core/;
}
}

}


cheers,
to

-- 
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: False negatives on model validation of CharField with choices

2010-01-29 Thread Thomas B. Higgins
Ramiro, great work on this! With your second patch I'm back in
business - with optgroups!

On a related matter, I don't often want a "blank" option when I use
choices/selects. I've been setting default selections and eliminating
the "blank" line as described on 11/07/07 by semenov in #4653 using a
combination of an explicit blank=False and a declared default value.
Under 1.1.1, this worked even when the field was disabled by
JavaScript (disabled because it was only conditionally required). I
had assumed that the default value was sent along to the database, but
don't really care. There was a big debate over what the convention for
"no blank choice" should be in #4653.

Now, using the development version, I can say blank=True, define a
default and get no blank option for some fields, while with other
fields with the same, identical model attribute structure yields a
select with the blank option. The only difference being that the
former group have "choices=something, required=False" in the model
form. Is the new convention that required=False in the model form
means no blank choice? This is wholly illogical to me.

Do you think this is an oversight? Is this new state of affairs
documented somewhere? Do you think it warrants a ticket?

Thanks for all your help.

Tom

On Jan 29, 5:13 am, Ramiro Morales  wrote:
> On Thu, Jan 28, 2010 at 2:46 PM, Thomas B.Higgins
>
>  wrote:
> > I've done some further checking, and see that this issue has two
> > parts. The first part is certainly a bug. Basically, selects with
> > optgroups are broken. Here's the 
> > ticket:http://code.djangoproject.com/ticket/12722.
>
> Sorry I didn't reply before, I had been offline.
>
> This has been already reported in ticket [1]12667. Please test the
> patch attached to
> it and report back your experiences.
>
> Regards,
>
> 1.http://code.djangoproject.com/ticket/12667
>
> --
> Ramiro Morales  |  http://rmorales.net

-- 
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: False negatives on model validation of CharField with choices

2010-01-29 Thread Thomas B. Higgins
Ramiro, great work on this! With your second patch I'm back in
business - with optgroups!

On a related matter, I don't often want a "blank" option when I use
choices/selects. I've been setting default selections and eliminating
the "blank" line as described on 11/07/07 by semenov in #4653 using a
combination of an explicit blank=False and a declared default value.
Under 1.1.1, this worked even when the field was disabled by
JavaScript (disabled because it was only conditionally required). I
had assumed that the default value was sent along to the database, but
don't really care. There was a big debate over what the convention for
"no blank choice" should be in #4653.

Now, using the development version, I can say blank=True, define a
default and get no blank option for some fields, while with other
fields with the same, identical model attribute structure yields a
select with the blank option. The only difference being that the
former group have "choices=something, required=False" in the model
form. Is the new convention that required=False in the model form
means no blank choice? This is wholly illogical to me.

Do you think this is an oversight? Is this new state of affairs
documented somewhere? Do you think it warrants a ticket?

Thanks for all your help.

Tom

On Jan 29, 5:13 am, Ramiro Morales  wrote:
> On Thu, Jan 28, 2010 at 2:46 PM, Thomas B.Higgins
>
>  wrote:
> > I've done some further checking, and see that this issue has two
> > parts. The first part is certainly a bug. Basically, selects with
> > optgroups are broken. Here's the 
> > ticket:http://code.djangoproject.com/ticket/12722.
>
> Sorry I didn't reply before, I had been offline.
>
> This has been already reported in ticket [1]12667. Please test the
> patch attached to
> it and report back your experiences.
>
> Regards,
>
> 1.http://code.djangoproject.com/ticket/12667
>
> --
> Ramiro Morales  |  http://rmorales.net

-- 
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: froms: extended labels

2010-01-29 Thread tom
to be specific. the view renders this form in the template
Members*: 


 test1
 test2
 test3
 test4
 test5
 test6
 test7
 test8
 test9


and I would like to have the option to get more information into
 so that there is not the text "test1" but
the full name of the user, for example.

On 29 Jan., 18:01, tom  wrote:
> Hi,
>
> I have a Model Form defined like that:
>
> class ProjectMemberForm(forms.ModelForm):
>     """
>     Renders a form where users can be assigned to a project.
>     The ``members`` are overidden and need to be populated in the view
>     with:
>         form = ProjectMemberForm()
>         form.base_fields['members'].queryset = ``SiteUser``
>     """
>     members = forms.ModelMultipleChoiceField(widget =
> forms.CheckboxSelectMultiple,
>                                              # TODO: shall never be
> displayed, only used for testing. find a better solution
>                                              queryset = None)
>
>     class Meta:
>         model = Project
>         fields = ('members',)
>
> and I add the members to the form in a view:
> ProjectMemberForm.base_fields['members'].queryset = users
>
> the "users" are a queryset of django.contrib.auth.models.User objects
>
> this works fine and renders a form with the username, but I would like
> to display the full name of the user and other information out of the
> profile. Does anyone know how I can get to that information?
>
> cheers, Tom

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

2010-01-29 Thread Adrian Maier
Shawn, Ondrey,

Thanks for your answers.   I ended up using to ModelForm and ModelFormSet.


Cheers,
Adrian


On Tue, Jan 19, 2010 at 16:12, ondrey  wrote:

> Hi,
>
> if the form is bound (i.e. form.is_bound is true) then you can access
> its data attribute, which contains the data entered into the form.
> If the form is valid (i.e. form.is_valid() is true), then you can
> access the cleaned_data attributes as well.
>
> So for example if you have form like this:
> f = MyForm({ "last_name": "some_value"})
>
> you can access the value in template in this way
> {{ f.data.last_name }}
>
> or alternatively, if your form is valid you can use:
> {{ f.cleaned_data.last_name }}
>
> Just bear in mind, that the two values can be different since
> cleaned_data the result of some processing in the validation methods.
>
>
> hope it helps,
>
> -Ondrej Bohm
>
> On Jan 17, 7:35 pm, adrian_m  wrote:
> > Hello people,
> >
> > How can I access the value of a form field in the template ? I'm
> > having
> > two different use cases :
> > - display a field value as simple text (the field is not meant to be
> > edited
> > by the user, therefore i don't want to use a input field)
> > - use the field value for generating a link
> >   ( something like this: Details )
> >
> > It would have been nice to have an attribute
> > {{form.field_name.value}}
> > which would return the value instead of a widget.Unfortunately there
> > seems
> > to be no such attribute available.
> >
> > I have looked at the Field attributes and also at the list of
> > available widgets,
> > but none seems to do what I need :  simply display the value as raw
> > text
> > instead of generating input field / textarea / etc.  I guess that my
> > use cases
> > are frequent enough, so there must be some simple way to do it ...
> >
> > (if it makes any difference: i am actually trying to use a forms set,
> > and
> > in each of the forms i want to create "details" and "delete" links
> > using
> > the id of the current record).
> >
> > Thanks in advance for any tips,
> > Adrian
>
> --
> 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.
>
>
>
>


-- 
Adrian Maier

-- 
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: Division with Python/Django

2010-01-29 Thread Chris McComas
Hey everyone, here's all of the information:

Here's the models:
http://dpaste.com/152277/

Here's my view:
http://dpaste.com/152061/

Here's the full error message:
http://dpaste.com/152060/


On Jan 29, 9:13 am, Chris McComas  wrote:
> The form is a ModelForm, where the fields involved, all of them are
> DecimalField()
>
> On Jan 29, 9:03 am, Chris McComas  wrote:
>
>
>
> > Changed my view to this:
>
> >http://dpaste.com/152061/
>
> > This is the full error message:
>
> >http://dpaste.com/152060/
>
> > The first three numbers, math_rawscore, science_rawscore, and
> > socsci_rawscore are GPAs, like 4.0, 3.47, etc. The second two numbers
> > pcat_rawscore and pcatessay_rawscore are whole numbers like 40 or 4
>
> > On Jan 29, 8:43 am, rebus_  wrote:
>
> > > On 29 January 2010 14:40, Chris McComas  wrote:> 
> > > I have this view with my form:http://dpaste.com/152046/whenItry to
> > > > submit the form I'm getting this error: unsupported operand type(s)
> > > > for //: 'unicode' and 'int' what did I do wrong?
>
> > > > --
> > > > 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.
>
> > > Are you sure cogability.* attributes are integers?
>
> > > Full error message would also be helpfull.

-- 
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: Models, forms and inlineformset

2010-01-29 Thread Stefan Nitsche
On Thu, Jan 28, 2010 at 10:15, andreas schmid  wrote:

> and your form works on edit too?
> i really cant understand why mine isnt...
>
> its giving me this MultiValueDictKeyError which i dont understand.
>
> Stefan Nitsche wrote:
> > On Wed, Jan 27, 2010 at 14:04, andreas schmid  > > wrote:
> >
> > is this an add or an edit form? or both?
> >
> > i have a similar inlineformset and i need to loop over the inline
> > objects to set the foreignkey to the parent object like:
> >
> >if form.is_valid() and formset.is_valid(): # All validation
> > rules pass
> >new_idea = form.save(commit=False)
> >new_idea.author = request.user
> >new_idea = form.save()
> >formset_models = formset.save(commit=False)
> >for f in formset_models:
> >f.idea = new_idea
> >f.save()
> >return
> > HttpResponseRedirect(new_idea.get_absolute_url())
> >
> >
> > im actually experiencing problems with the edit form where i can
> > get the
> > values displayed in the form if i want to edit but i get a
> >
> >Exception Type: MultiValueDictKeyError
> >Exception Value:
> >
> >Key 'activity_set-0-id' not found in  > {u'activity_set-0-name': [u'a\xf6lskjdf\xf6sa'],
> > u'activity_set-0-type': [u'research']
> >
> > on save... any hints?
> >
> >
> > Stefan Nitsche wrote:
> > > On Mon, Jan 4, 2010 at 23:27, Stefan Nitsche  > 
> > > >> wrote:
> > >
> > > Hi,
> > >
> > > to begin with I would like to declare that I'm still on the
> > > beginner end of the scale when it comes to Python and Django.
> > >
> > > I have an app which has two models:
> > >
> > > class Item(models.Model):
> > > title = models.CharField()
> > > description_markdown = models.TextField()
> > >
> > > class ItemImage(models.Model):
> > > item = models.ForeignKey(Item)
> > > image = models.ImageField(upload_to='tmp')
> > >
> > > What I want to do now is to create a page where users can
> submit
> > > an item and upload an image (or images) at the same time. I can
> > > create a form using ModelForm for the Item-model and I can
> > create
> > > a form for the ItemImage-model using inlineformset_factory, if
> I
> > > do this the submit page looks like it should. However it
> doesn't
> > > behave the way I want it to when saving, but to be honest I
> have
> > > no real idea of what I'm doing when it comes to the related
> > > model/form.
> > >
> > > If I understand it correctly when using inlineformset_factory I
> > > must give it an instance so that it can map the foreignkey,
> > > correct? So how do one go about and create a form where
> > people can
> > > add "item" and "itemimages" at the same time? I'm feeling
> totaly
> > > lost any pointers would be greatly appreciated.
> > >
> > > --
> > > Stefan Nitsche
> > > ste...@nitsche.se 
> > >
> > >
> > >
> > >
> > > Ok I'm totally lost here. I've created an edit function which works
> > > splendidly except for the inline-part, it displays alright but it
> > > isn't saved at all.
> > >
> > > My models look like this:
> > > ==
> > >
> > > class Recipe(models.Model):
> > > author = models.ForeignKey(User)
> > > name = models.CharField(max_length=255, verbose_name='Namn
> > på rätten')
> > > category = models.ForeignKey('Category',
> > verbose_name='Kategori')
> > > create_date = models.DateTimeField(auto_now_add=True)
> > > servings = models.CharField(max_length=10,
> > verbose_name='Portioner')
> > > cooking_time = models.CharField(max_length=10,
> > > verbose_name='Tillagningstid')
> > > ingredients = models.TextField(verbose_name='Ingridienser')
> > > instructions = models.TextField(verbose_name='Instruktioner')
> > > oven_heat = models.CharField(max_length=10, null=True,
> > blank=True,
> > > verbose_name='Ugnsvärme')
> > > serving_tips = models.TextField(null=True, blank=True,
> > > verbose_name='Serveringsförslag')
> > > tags = TagField(verbose_name='Taggar')
> > > slug = models.SlugField()
> > > published = models.NullBooleanField(default=1)
> > >
> > > class Image(models.Model):
> > > recipe = models.ForeignKey(Recipe)
> > > file = 

Re: Django Model Audit Log

2010-01-29 Thread Shawn Milochik
Awesome! Thanks, that does exactly what I need.

Shawn


On Jan 29, 2010, at 12:08 PM, tom wrote:

> maybe that middleware can help you out with getting the username
> http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser

-- 
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: REST & Django

2010-01-29 Thread myfreeweb
REST is a web service architecture, not a program functionality.
If you want to implement a RESTful API for your app, take a look at
django-piston: http://bitbucket.org/jespern/django-piston/wiki/Home

On 29 янв, 19:03, pyleaf  wrote:
> how REST looks like in django?
> does Django support REST defautly?
> --
> Believing is everythig!

-- 
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 Model Audit Log

2010-01-29 Thread Bill Freeman
This is much better than my ramblings.

On Fri, Jan 29, 2010 at 12:08 PM, tom  wrote:
> maybe that middleware can help you out with getting the username
> http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser
>
> On 29 Jan., 18:05, Shawn Milochik  wrote:
>> I need to implement auditing for my models. The current plan is to listen 
>> for the post_save() signal and dump the current values of the instance to an 
>> external database.
>>
>> The only problem is that I need to store the request.user with this data, 
>> and I don't see any way to capture that, since it appears to be completely 
>> out of scope. Is there any clean way to get that?
>>
>> Thanks,
>> 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.
>
>

-- 
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 Model Audit Log

2010-01-29 Thread Bill Freeman
If worse comes to worst, you could always patch the url dispatcher to
store the user in a global variable before it calls the view.  It
should be sure to set that variable to None when the view returns, so
that the global doesn't keep a reference on the user object between
requests (a try finally around the call to the view will work fine.
If you're running in a multi-threaded interpreter you need to think a
little harder, but it should still be doable.

And alternative is to look up the call stack for a function whose
first argument is a request object, assume that it is *the* request
object, and extract the user from there.

Both these assume that you're using the standard auth middleware that
puts a user attribute on the request object.

Hopefully someone else will have better solutions.

On Fri, Jan 29, 2010 at 12:05 PM, Shawn Milochik  wrote:
> I need to implement auditing for my models. The current plan is to listen for 
> the post_save() signal and dump the current values of the instance to an 
> external database.
>
> The only problem is that I need to store the request.user with this data, and 
> I don't see any way to capture that, since it appears to be completely out of 
> scope. Is there any clean way to get that?
>
> Thanks,
> 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.
>
>

-- 
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 Model Audit Log

2010-01-29 Thread tom
maybe that middleware can help you out with getting the username
http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser

On 29 Jan., 18:05, Shawn Milochik  wrote:
> I need to implement auditing for my models. The current plan is to listen for 
> the post_save() signal and dump the current values of the instance to an 
> external database.
>
> The only problem is that I need to store the request.user with this data, and 
> I don't see any way to capture that, since it appears to be completely out of 
> scope. Is there any clean way to get that?
>
> Thanks,
> 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.1 features covered in book.

2010-01-29 Thread Shawn Milochik
"The Definitive Guide to Django," Second Edition by Adrian Holovaty and Jacob 
Kaplan-Moss covers Django 1.1.

I have a copy sitting on my desk right now. 

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.



Django Model Audit Log

2010-01-29 Thread Shawn Milochik
I need to implement auditing for my models. The current plan is to listen for 
the post_save() signal and dump the current values of the instance to an 
external database. 

The only problem is that I need to store the request.user with this data, and I 
don't see any way to capture that, since it appears to be completely out of 
scope. Is there any clean way to get that?

Thanks,
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.1 features covered in book.

2010-01-29 Thread Bill Freeman
Yes, but you can only read it on line.  It's the 1.1 documentation and
release notes at
djangoproject.com .

On Fri, Jan 29, 2010 at 9:49 AM, Sebastian Pawlus
 wrote:
> Hi
> Do you know any Django books which cover functionalities introduced by
> version 1.1?
> 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.
>

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



froms: extended labels

2010-01-29 Thread tom
Hi,

I have a Model Form defined like that:

class ProjectMemberForm(forms.ModelForm):
"""
Renders a form where users can be assigned to a project.
The ``members`` are overidden and need to be populated in the view
with:
form = ProjectMemberForm()
form.base_fields['members'].queryset = ``SiteUser``
"""
members = forms.ModelMultipleChoiceField(widget =
forms.CheckboxSelectMultiple,
 # TODO: shall never be
displayed, only used for testing. find a better solution
 queryset = None)

class Meta:
model = Project
fields = ('members',)

and I add the members to the form in a view:
ProjectMemberForm.base_fields['members'].queryset = users

the "users" are a queryset of django.contrib.auth.models.User objects

this works fine and renders a form with the username, but I would like
to display the full name of the user and other information out of the
profile. Does anyone know how I can get to that information?

cheers, Tom

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

2010-01-29 Thread Malcolm Box
On Fri, Jan 29, 2010 at 4:03 PM, pyleaf  wrote:

> how REST looks like in django?
> does Django support REST defautly?
>
>
Django can be used to develop a REST API, it implements all the HTTP methods
needed and Django views can easily generate JSON, XML or whatever you
require.

There's not much built-in infrastructure for REST, but add-ons like
django-rest-interface (http://code.google.com/p/django-rest-interface/) do
provide a lot of the boilerplate code.

Malcolm

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



REST & Django

2010-01-29 Thread pyleaf
how REST looks like in django?
does Django support REST defautly?
-- 
Believing is everythig!

-- 
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: read only django admin

2010-01-29 Thread aledr
On Fri, Jan 29, 2010 at 12:55 AM, zweb  wrote:
> Is it possible to have a read only django admin, ie user cannot add,
> delete or update. User can only view data.
>
> or may be one user can be view only and other user has add/delete /
> update as well in Django admin.
>
> How to do that?

http://www.alextreme.org/drupal/?q=django-view-permissions-patch

Just read at bottom:

"Feel free to use the patch, but be warned: if users logging in to
your site really want to change something, they'll probably find a way
through."

--
[ ]'s
Aledr - Alexandre
"OpenSource Solutions for SmallBusiness Problems"

-- 
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: viewsite button takes me to example.com

2010-01-29 Thread Mario
You need to login to your admin and scroll down the Sites and change
the example.com to your domain name or IP address.

Cheers.



On Jan 29, 10:50 am, harryos  wrote:
> hi
> I was trying out the weblog app in bennet's book.I created some
> categories and entries and can list them properly 
> usinghttp://127.0.0.1:8000/myblog/
> andhttp://127.0.0.1:8000/myblog/categories
>
> The admin interface also lists the categories properly when I 
> tryhttp://127.0.0.1:8000/admin/myblog/category/
>
> But when I go to the Change Category page for a category and try the
> view site button ,it takes me tohttp://example.com/categories/someslug/
> instead of my localhost.I couldn't figure out why this is
> happening.Can someone help?
> thanks
> harry
>
> p.s:
> I have set the get_absolute_url to return
>  "/categories/%s/"%self.slug in Category and
> "/harryblog/%s/%s/"% (self.pub_date.strftime("%Y/%b/%d").lower
> () ,self.slug) in Entry.
>
> In the project urls file I have set these patterns:
> (r'^admin/', include(admin.site.urls)),
> (r'^harryblog/categories/',include('myblog.urls.categories')),
> (r'^harryblog/',include('myblog.urls.entries')),
>
> http://example.com/categories/meditation/

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



viewsite button takes me to example.com

2010-01-29 Thread harryos
hi
I was trying out the weblog app in bennet's book.I created some
categories and entries and can list them properly using
http://127.0.0.1:8000/myblog/
and
http://127.0.0.1:8000/myblog/categories


The admin interface also lists the categories properly when I try
http://127.0.0.1:8000/admin/myblog/category/

But when I go to the Change Category page for a category and try the
view site button ,it takes me to http://example.com/categories/someslug/
instead of my localhost.I couldn't figure out why this is
happening.Can someone help?
thanks
harry


p.s:
I have set the get_absolute_url to return
 "/categories/%s/"%self.slug in Category and
"/harryblog/%s/%s/"% (self.pub_date.strftime("%Y/%b/%d").lower
() ,self.slug) in Entry.

In the project urls file I have set these patterns:
(r'^admin/', include(admin.site.urls)),
(r'^harryblog/categories/',include('myblog.urls.categories')),
(r'^harryblog/',include('myblog.urls.entries')),






http://example.com/categories/meditation/

-- 
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: svn checkout problems? (at around 2:50 pm GMT, 2010-01-29)

2010-01-29 Thread chefsmart
No my svn checkout command was ok, as was the url in that command. To
elaborate, svn would continue with checkout then abruptly stop at a
random file. I tried it about 3 or 4 times with the same result.

Regards.

On Jan 29, 8:27 pm, Daniel Hilton  wrote:
> On 29 January 2010 14:59, chefsmart  wrote:
>
> > For the last 1 hour I have been trying to checkout a fresh copy of
> > django-trunk from svn. But the checkout is failing.  Unfortunately, I
> > don't have the exact message I have been receiving, but just wondering
> > if anybody else facing similar issues with checkout?
>
> > Regards.
>
> I had an issue about half an hour ago but it was because I was being foolish.
>
> I had 'browser' rather than 'svn' in the url.
>
> Check the svn url perhaps?
>
> HTH
> Dan
>
>
>
> > --
> > 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.
>
> --
> Dan Hilton
> www.twitter.com/danhiltonwww.DanHilton.co.uk
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: svn checkout problems? (at around 2:50 pm GMT, 2010-01-29)

2010-01-29 Thread Daniel Hilton
On 29 January 2010 14:59, chefsmart  wrote:
> For the last 1 hour I have been trying to checkout a fresh copy of
> django-trunk from svn. But the checkout is failing.  Unfortunately, I
> don't have the exact message I have been receiving, but just wondering
> if anybody else facing similar issues with checkout?
>
> Regards.

I had an issue about half an hour ago but it was because I was being foolish.

I had 'browser' rather than 'svn' in the url.

Check the svn url perhaps?

HTH
Dan

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



-- 
Dan Hilton

www.twitter.com/danhilton
www.DanHilton.co.uk


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

2010-01-29 Thread Olivier Guilyardi
On 01/28/2010 11:12 AM, Matthias Kestenholz wrote:
> Hi
> 
> On Wed, Jan 27, 2010 at 11:29 PM, Olivier Guilyardi  wrote:
>> Hi,
>>
>> I'm working with a polyhierarchical thesaurus, and trying to handle that in
>> Django. By polyhierarchical, I mean : nodes can have both multiple parents 
>> and
>> children.
>>
>> Actually, this is a geographical thesaurus, and yes a location can have 
>> multiple
>> parents (being across countries, etc..).
>>
>> I have read about the Nested set paradigm [1], and would love to use that, 
>> maybe
>> through django-mptt or django-treebeard. But unless someone shows me how, 
>> nested
>> sets aren't suitable for polyhierarchical data.
>>
>> Currently I have a simple recursive many-to-many mapping. This allows to
>> establish the poly-relations, but is completely unusable for real use cases.
>>
>> For instance, I have a table of "items", with a "location" field which 
>> points to
>> a location in the thesaurus.
>>
>> Now I need to list all items which are located in a given country.
>>
>> I just can't filter by country, there's no such field in the items table. 
>> And a
>> location can be of any level of precision, such as country, region, city,
>> village, etc..
>>
>> The nested set would be perfect for this, but apparently can't handle 
>> multiple
>> parents.
>>
>> Do you see a fast and elegant way to handle this ?
>>
>> [1] http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
>>
> 
> Maybe you could take a look at this project?
> http://bitbucket.org/cmutel/django-directed-acyclic-graph/

It's quite interesting indeed. However, it uses database stored functions and
triggers, which isn't very portable.

What's great about the Nested set solution is that it can be achieved through
standard Django model api calls. Unfortunately it doesn't fit the job.

I'm still looking for an elegant solution, that I'll hopefully find soon...

Thanks

--
  Olivier

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



svn checkout problems? (at around 2:50 pm GMT, 2010-01-29)

2010-01-29 Thread chefsmart
For the last 1 hour I have been trying to checkout a fresh copy of
django-trunk from svn. But the checkout is failing.  Unfortunately, I
don't have the exact message I have been receiving, but just wondering
if anybody else facing similar issues with checkout?

Regards.

-- 
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: What's the going rate for a Django developer?

2010-01-29 Thread thanos
In new York I know a few consultants at $1100/day - and that rate is
confirmed.

On Jan 29, 9:16 am, Dougal Matthews  wrote:
> I think the answer to that is probably "it depends".
>
>    1. Permanent or contractor?
>    2. What country?
>    3. Often it even matters what city?
>    4. How much experience do they have?
>
> It's probably best for you to look at job adverts and see what they are
> offering. Some listings onhttp://djangogigs.cominclude the salary/budget.
>
> Cheers,
> Dougal
>
> On 29 January 2010 12:00, Astley Le Jasper wrote:
>
>
>
> > Any ideas?
>
> > --
> > 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.



Django 1.1 features covered in book.

2010-01-29 Thread Sebastian Pawlus
Hi

Do you know any Django books which cover functionalities introduced by
version 1.1?

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: read only django admin

2010-01-29 Thread Alex Robbins
It sounds like the databrowse[1] contrib app may be what you are
looking for. It is basically a read-only admin. You'll have to
register classes with it the same way you register with the admin, but
it might be nicer than trying to force the admin to be read-only.

Hope that helps,
Alex

[1] http://docs.djangoproject.com/en/dev/ref/contrib/databrowse/

On Jan 28, 8:55 pm, zweb  wrote:
> Is it possible to have a read only django admin, ie user cannot add,
> delete or update. User can only view data.
>
> or may be one user can be view only and other user has add/delete /
> update as well in Django admin.
>
> How to do that?

-- 
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: Database performance during test execution

2010-01-29 Thread Russell Keith-Magee
On Fri, Jan 29, 2010 at 10:38 PM, Sebastian Pawlus
 wrote:
> Thanks Russell, your answer was more than helpful. It really worked for me.
> There were some problems on Django 1.0 but after that (1.1 and up) every
> thing looks good. Performance of database looks much better right now.
> I'm also wandering if that issue is well enough explained in Django docs?

It's currently explained in the testing docs [1]. I'll leave it up to
others to judge if that explanation is sufficient.

[1] http://docs.djangoproject.com/en/dev/topics/testing/#testcase

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: Database performance during test execution

2010-01-29 Thread Sebastian Pawlus
Thanks Russell, your answer was more than helpful. It really worked for me.
There were some problems on Django 1.0 but after that (1.1 and up) every
thing looks good. Performance of database looks much better right now.

I'm also wandering if that issue is well enough explained in Django docs?

On Fri, Jan 29, 2010 at 12:15 PM, Russell Keith-Magee <
freakboy3...@gmail.com> wrote:

> On Fri, Jan 29, 2010 at 6:51 PM, Sebastian Pawlus
>  wrote:
> > Hi everyone
> > I've very confusing issue related whit databases performance. I've took
> two
> > database engines and compared their performance during typical run for
> > project test suite.
> > results:
> > MySQL: Ran 241 tests in 533.822s
> > PostgreSQL: Ran 241 tests in 34.468s
> > Results are more than strange. I don't even start to think that MySQL is
> 9
> > times slower, but what is going on?
>
> It depends on your MySQL configuration. If you're using MyISAM tables,
> this is probably the cause of the slowdown you are seeing.
>
> To ensure that a clean test environment is available at the start of
> every test, Django clears out the database before each test starts. To
> make this a fast process, Django uses transactions where possible -
> rather than deleting and reloading test data, Django will commence a
> transaction at the start of the test, and roll back to the start of a
> transaction at the end of the test. There are some exceptions where
> this speedup isn't possible - most notably, if you're actually testing
> transactional behaviour - but this optimization is used by a lot of
> Django's test suite.
>
> Postgres makes full use of this transaction support, and as a result,
> tests are quite fast. However, not every MySQL configuration supports
> transactions. If your MySQL database doesn't support transactions (and
> MyISAM generally falls into this category), tests will run a *lot*
> slower. 10x slower would not be at all surprising.
>
> This doesn't mean that MySQL/MyISAM will be slow in general - just
> that the test suite will be slow. The test suite is doing something
> pathological: loading and deleting hundreds of data, over and over
> again. This isn't something most actual running applications will ever
> need to do, so it isn't a cause for concern for production.
>
> Unfortunately, there isn't much we can do about it. Without access to
> transactions, there isn't any way to speed up test cases.
>
> 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.
>
>

-- 
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: What's the going rate for a Django developer?

2010-01-29 Thread Dougal Matthews
I think the answer to that is probably "it depends".

   1. Permanent or contractor?
   2. What country?
   3. Often it even matters what city?
   4. How much experience do they have?

It's probably best for you to look at job adverts and see what they are
offering. Some listings on http://djangogigs.com include the salary/budget.

Cheers,
Dougal


On 29 January 2010 12:00, Astley Le Jasper wrote:

> Any ideas?
>
> --
> 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.



Re: Division with Python/Django

2010-01-29 Thread Chris McComas
The form is a ModelForm, where the fields involved, all of them are
DecimalField()


On Jan 29, 9:03 am, Chris McComas  wrote:
> Changed my view to this:
>
> http://dpaste.com/152061/
>
> This is the full error message:
>
> http://dpaste.com/152060/
>
> The first three numbers, math_rawscore, science_rawscore, and
> socsci_rawscore are GPAs, like 4.0, 3.47, etc. The second two numbers
> pcat_rawscore and pcatessay_rawscore are whole numbers like 40 or 4
>
> On Jan 29, 8:43 am, rebus_  wrote:
>
>
>
> > On 29 January 2010 14:40, Chris McComas  wrote:> I 
> > have this view with my form:http://dpaste.com/152046/whenI try to
> > > submit the form I'm getting this error: unsupported operand type(s)
> > > for //: 'unicode' and 'int' what did I do wrong?
>
> > > --
> > > 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.
>
> > Are you sure cogability.* attributes are integers?
>
> > Full error message would also be helpfull.

-- 
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: Division with Python/Django

2010-01-29 Thread Chris McComas
Changed my view to this:

http://dpaste.com/152061/

This is the full error message:

http://dpaste.com/152060/

The first three numbers, math_rawscore, science_rawscore, and
socsci_rawscore are GPAs, like 4.0, 3.47, etc. The second two numbers
pcat_rawscore and pcatessay_rawscore are whole numbers like 40 or 4



On Jan 29, 8:43 am, rebus_  wrote:
> On 29 January 2010 14:40, Chris McComas  wrote:> I 
> have this view with my form:http://dpaste.com/152046/when I try to
> > submit the form I'm getting this error: unsupported operand type(s)
> > for //: 'unicode' and 'int' what did I do wrong?
>
> > --
> > 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.
>
> Are you sure cogability.* attributes are integers?
>
> Full error message would also be helpfull.

-- 
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: Division with Python/Django

2010-01-29 Thread Mike Ramirez
On Friday 29 January 2010 05:40:19 Chris McComas wrote:
> I have this view with my form: http://dpaste.com/152046/ when I try to
> submit the form I'm getting this error: unsupported operand type(s)
> for //: 'unicode' and 'int' what did I do wrong?
> 

A full traceback would be helpful, along with your form code.

I suspect that your form isreturning unicode strings (which it gets from the 
POST of your form). If that's the case, you might want to try int(), float(), 
long(), (which ever floats your boat [pun intended]) and convert them from 
unicode strings to int's. -- if your strings aren't integers and you try to 
convert it, it will throw a ValueError at you

In [6]: x = u'123'

In [7]: int(x)/4
Out[7]: 30  

In [8]: x/4
---
TypeError Traceback (most recent call last)

/home/gufymike/Projects/goproject/ego_examples/src/ in 
()

TypeError: unsupported operand type(s) for /: 'unicode' and 'int'

In [9]: int(u"1x")
---
ValueErrorTraceback (most recent call last)

/home/gufymike/Projects/goproject/ego_examples/src/ in 
()

ValueError: invalid literal for int() with base 10: '1x'

  

Mike




-- 
We are MicroSoft.  You will be assimilated.  Resistance is futile.
-- Attributed to B.G., Gill Bates


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


Re: manytomany relations

2010-01-29 Thread CCC
I mean the users who have the number of group is the lagest ten.
and the relation is manytomany.thanks

On 1月29日, 下午8时05分, Stodge  wrote:
> I think he needs to read the tutorial:
>
> http://docs.djangoproject.com/en/1.1/intro/tutorial03/#write-views-th...
>
> And I quote:
>
> "Here's one stab at the index() view, which displays the latest 5 poll
> questions in the system"
>
> On Jan 29, 4:57 am, Wayne Koorts  wrote:
>
> > What do you mean by "top ten"?
>
> > On 29/01/2010, at 20:53, CCC  wrote:
>
> > > hi,
> > > I have two  models:user,group,and they are manytomany,
> > > class User(model.Model):
> > > name = models.CharField(max_length=20)
>
> > > class Group(models.Model):
> > > name = models.CharField(max_length=20)
> > > users = models.ManytoManyField(User)
>
> > > now i want to get the  top ten users who have the groups
> > > ,thanks for 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 
> > > athttp://groups.google.com/group/django-users?hl=en
> > > .

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

2010-01-29 Thread CCC
I mean the users who have the number of group is the largest ten
and you see  the relation is manytomany.
On 1月29日, 下午8时05分, Stodge  wrote:
> I think he needs to read the tutorial:
>
> http://docs.djangoproject.com/en/1.1/intro/tutorial03/#write-views-th...
>
> And I quote:
>
> "Here's one stab at the index() view, which displays the latest 5 poll
> questions in the system"
>
> On Jan 29, 4:57 am, Wayne Koorts  wrote:
>
> > What do you mean by "top ten"?
>
> > On 29/01/2010, at 20:53, CCC  wrote:
>
> > > hi,
> > > I have two  models:user,group,and they are manytomany,
> > > class User(model.Model):
> > > name = models.CharField(max_length=20)
>
> > > class Group(models.Model):
> > > name = models.CharField(max_length=20)
> > > users = models.ManytoManyField(User)
>
> > > now i want to get the  top ten users who have the groups
> > > ,thanks for 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 
> > > athttp://groups.google.com/group/django-users?hl=en
> > > .

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

2010-01-29 Thread rebus_
On 29 January 2010 14:40, Chris McComas  wrote:
> I have this view with my form: http://dpaste.com/152046/ when I try to
> submit the form I'm getting this error: unsupported operand type(s)
> for //: 'unicode' and 'int' what did I do wrong?
>
> --
> 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.
>
>
Are you sure cogability.* attributes are integers?

Full error message would also be helpfull.

-- 
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: ForeignKey query

2010-01-29 Thread mates fila
Hi,

try this:

**
resultList =
 list(
 set(modelList) &
 set(Model1.objects.filter(model2__pk__isnull = False).distinct
())
 )
**

or this:

**
resultList =
 list(
 set(modelList) &
 set([m.model1 for m in Model2.objects.all()])
 )
**

Both solutions are equivalent, I think, and are exactly what you need
- I hope :-)

Matus


On Jan 29, 10:29 am, Odd  wrote:
> Hmm...
>
> After a little testing, this is not what I wanted, some of the model1
> objects in the return_list was not in the provided modelList, and I
> dont't quite understand why they are returned. As stated before, I
> want to get  a distinct list of all model1 objects that is in a
> provided list and is used as a foreignkey in any model2 object. Is
> this doable?
>
> 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: Load template tags if installed?

2010-01-29 Thread trójkąt
On 18 Sty, 02:48, "Aaron C. de Bruyn"  wrote:
> I dove into django/template/defaulttags.py to figure out how the 'if'
> tag works, and I came up with this solution.

And do you have any solution for something like this:

{% ifloaded my_app %}
{% tag_from_my_app %}
{% endifloaded %}

?

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



What's the going rate for a Django developer?

2010-01-29 Thread Astley Le Jasper
Any ideas?

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



Division with Python/Django

2010-01-29 Thread Chris McComas
I have this view with my form: http://dpaste.com/152046/ when I try to
submit the form I'm getting this error: unsupported operand type(s)
for //: 'unicode' and 'int' what did I do wrong?

-- 
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: False negatives on model validation of CharField with choices

2010-01-29 Thread Ramiro Morales
On Thu, Jan 28, 2010 at 2:46 PM, Thomas B. Higgins
 wrote:
> I've done some further checking, and see that this issue has two
> parts. The first part is certainly a bug. Basically, selects with
> optgroups are broken. Here's the ticket: 
> http://code.djangoproject.com/ticket/12722.

Sorry I didn't reply before, I had been offline.

This has been already reported in ticket [1]12667. Please test the
patch attached to
it and report back your experiences.

Regards,

1. http://code.djangoproject.com/ticket/12667

-- 
Ramiro Morales  |  http://rmorales.net

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

2010-01-29 Thread Rick Caudill
Hi everyone,

I have been working on a Django reporting tool for the company I work for
and wonder if anyone thinks a reporting tool like attached would be valuable
to the community???  I should say that it doesn't handle m2m yet but I am
working on that.  I would also want to clean the code up some and put it on
google code but I want to pull the audience first to see if something like
it would be welcomed.  This is all the code that is needed in order to
create the screenshot attached:

class StudentFieldForm(FieldForm):
class Meta:
model = Student
inline_models = [Demographics,Medical,Emergency]
inline_excludes = {'Medical':['student'],'Demographics':['student']}

exclude=('school','address','student','studentclass.student','access_restrictions','photo')
extra_fields={'Student':{'age':CALLABLE}}

class StudentReportSearchForm(SearchForm):
class Meta:
model = Student
inline_models = [Demographics,Medical,Emergency]
inline_excludes = {'Medical':['student'],'Demographics':['student']}

exclude=('school','address','student','studentclass.student','access_restrictions','photo')

extra_fields={'Student':{'age':CALLABLE},'Father':{'father_fname':CALLABLE}}
class StudentOrderSearchForm(OrderingForm):
class Meta:
model = Student
inline_models = [Demographics,Medical,Emergency]
inline_excludes = {'Medical':['student'],'Demographics':['student']}

exclude=('school','address','student','studentclass.student','access_restrictions','photo')
extra_fields={'Student':{'age':CALLABLE}}

StudentFieldsFormset =
formset_factory(StudentFieldForm,formset=FieldFormSet)
StudentReportFormset =
formset_factory(StudentReportSearchForm,formset=SearchBaseFormSet)
StudentOrderFormset = formset_factory(StudentOrderSearchForm)

-- 
Rick Caudill

-- 
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: customize form in template according to field attribute

2010-01-29 Thread jul
I meant: "to be able to separate those having different type in my
CSS. "

On Jan 29, 12:56 pm, jul  wrote:
> hi,
>
> I've got the Category model and SearchForm form shown below. In my
> template I'd like to get all Category instances having a given type to
> be able to separate those having different style in my CSS.
> How can I do this?
> thanks
> Jul
>
> **Category model***
>
> CATEGORY_TYPE = [
>     (1, 'region'),
>     (2, 'type'),
> ]
>
> class Category(models.Model):
>
>     parent = models.ManyToManyField('self', symmetrical=False,
> null=True, blank=True)
>
>     type = models.PositiveSmallIntegerField(choices=CATEGORY_TYPE)
>
>     class Translation(multilingual.Translation):
>         name = models.CharField(max_length=100, unique=True)
>
>     class Meta:
>         verbose_name_plural = 'Categories'
>
>     def __unicode__(self):
>         return "%s" %(self.name)
>
> **SearchForm class***
>
> class SearchForm(forms.Form):
>
>     query = forms.CharField(max_length=100, required=False)
>     price_range = forms.IntegerField(widget=forms.Select(choices =
> PRICE_RANGES_AND_EMPTY), required=False)
>
>     def __init__(self, *args, **kwargs):
>         super(SearchForm, self).__init__(*args, **kwargs)
>         self.fields['country'] = forms.ModelChoiceField
> (queryset=Country.objects.all().order_by('name'), empty_label='All',
> required=False)
>         self.fields['category'] = forms.ModelMultipleChoiceField
> (queryset=Category.objects.all().order_by('name'),
> widget=forms.CheckboxSelectMultiple(), required=False)

-- 
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: popup forms

2010-01-29 Thread Bhaskar Gara
That where I stuck.. I am new to Django so I confuse where to add
what? what name i need to give to the widget,form etc.,

Can you please help me.

Thank you
Bhaskar

On Jan 29, 1:45 am, andreas schmid  wrote:
> hi, yes it works perfectly :)
>
> follow the steps on the turorial here
>
> http://www.hoboes.com/Mimsy/hacks/replicating-djangos-admin/
>
> sometimes its not so clear where to put the code... if you have questions ill 
> try to help you.
>
> ill make a "more complete" tutorial on my blog soon.
>
>
>
> Bhaskar Gara wrote:
> > Hi Andrew,  Do you have any luck on this. I need same functionality.
>
> > On Nov 30 2009, 5:40 am, andreas schmid  wrote:
>
> >> Emily Rodgers wrote:
>
> >>> On Oct 13, 1:20 pm, andreas schmid  wrote:
>
>  thank you very much for pointing me to the right path!!
>  ill try to understand the behaviour and report about my progress...
>
>  Andrew Ingram wrote:
>
> > I'm assuming you are doing this somewhere other than the admin, or in
> > custom views, so I'll explain how the admin stuff works.
>
> > Basically, when you create thepopupwindowyou give it a name which
> > can be used the uniquely identify the field that is using thepopup
> > (some variant on the field id would be ideal). Your main page (not the
> > popup) should also have a javascript function to be called after the
> > new author is saved (in the case of django admin, this function is
> > called dismissAddAnotherPopup and is in RelatedObjectLookup.js).
>
> > Now the clever part (which I had to hunt around for when I needed this
> > functionality, you can find it around line 608 in
> > django.contrib.admin.options.py), is that when you successfully save
> > the new author, you return an HttpResponse that consists of nothing
> > but a script tag that executes
> > owner.yourFunctionName(window_name,new_object_id (in the case of the
> > django admin this would be owner.dismissAddAnotherPopup), window_name
> > is the unique identifier you passed in originally.
>
> > This causes the browser to execute the function in the ownerwindow
> > (the one that created thepopup) with the parameters you specified -
> > which includes the ID of the new object. Django's code also provides
> > the representation string of the object so it can be added to the
> > select box.
>
> > Then you just make your JS function close thepopupwith 
> > window_name.close().
>
> > I may not have explained it that well, but the key parts are in
> > RelatedObjectLookup.js and options.py (near line 608).
>
> > I hope this helps.
>
> > - Andrew Ingram
>
> > 2009/10/13 nabucosound :
>
> >> This is the default behaviour in Django Admin, dude...
>
> >> On Oct 13, 9:43 am, andreas schmid  wrote:
>
> >>> hi,
>
> >>> how can i achieve a behaviour like in the admin backend where i can 
> >>> add
> >>> a related object through apopupwindowand have it selectable after i
> >>> saved the related form?
>
> >>> for example:
> >>> im copleting the form book and i have to select the author but it 
> >>> doesnt
> >>> exist yet... so i click on the + (add) button and apopupwindowappears
> >>> where i create the editor object, and i can select it in the book form
> >>> right after i saved and closed thispopupwindow.
>
> >>> can somebody point me to the code?
>
> >>> thank you in advance...
>
> >>> You might find this 
> >>> helpful:http://www.hoboes.com/Mimsy/hacks/replicating-djangos-admin/
>
> >>> Em
>
> >> the tutorial is nice but i cant get it really working. the problem is
> >> that thepopupopens but i get a:
>
> >>     TypeError at /popadd/topics/
>
> >>     'str' object is not callable
>
> >>     Request Method:     GET
> >>     Request URL:    http://127.0.0.1:8000/de/popadd/topics/?_popup=1
> >>     Exception Type:     TypeError
> >>     Exception Value:    
>
> >>     'str' object is not callable
>
> >>     Exception Location:    
> >>     /home/pepe/DEV/FSlabs/parts/django/django/core/handlers/base.py in
> >>     get_response, line 92
>
> >> my views.projects ProjectForm:
>
> >>     class ProjectForm(ModelForm):
> >>         topics       = ModelMultipleChoiceField(Topic.objects,
> >>     required=False, widget=MultipleSelectWithPop)
> >>         technologies = ModelMultipleChoiceField(Technology.objects,
> >>     required=False, widget=MultipleSelectWithPop)
> >>         class Meta:
> >>             model = Project
> >>             exclude = ['author']
>
> >> my views.handlePopAdd.py :
>
> >>     from django.utils.html import escape
> >>     from django.contrib.auth.decorators import login_required
>
> >>     from myapp.views.technologies import TechnologyForm
> >>     from myapp.views.topics import TopicForm
>
> >>     def handlePopAdd(request, addForm, field):
> >>         

Re: manytomany relations

2010-01-29 Thread Stodge
I think he needs to read the tutorial:

http://docs.djangoproject.com/en/1.1/intro/tutorial03/#write-views-that-actually-do-something

And I quote:

"Here's one stab at the index() view, which displays the latest 5 poll
questions in the system"

On Jan 29, 4:57 am, Wayne Koorts  wrote:
> What do you mean by "top ten"?
>
> On 29/01/2010, at 20:53, CCC  wrote:
>
>
>
> > hi,
> > I have two  models:user,group,and they are manytomany,
> > class User(model.Model):
> >     name = models.CharField(max_length=20)
>
> > class Group(models.Model):
> >     name = models.CharField(max_length=20)
> >     users = models.ManytoManyField(User)
>
> > now i want to get the  top ten users who have the groups
> > ,thanks for 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 
> > athttp://groups.google.com/group/django-users?hl=en
> > .

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

2010-01-29 Thread bastir
Sry. Just found it out. If it is in the view it must be :
app_name.view.function_name as you said. I tried it with
prog_name.app_name which does not work.
Thank you very much
bastir
On 29 Jan., 11:27, bastir  wrote:
> Hello Atamert,
>
> thanks for your quick reply. It seems that it now finds the function
> but still does not work:
>
> Reverse for '' with arguments '()' and
> keyword arguments '{'s_id': 1}' not found.
>
> Greetings
> bastir
>
> On 29 Jan., 11:19, Atamert Ölçgen  wrote:
>
> > Hi Bastir,
>
> > On Friday 29 January 2010 11:32:02 bastir wrote:> edirect but it cannot 
> > find my view function.
> > > Here is the relevant code that I tried. The error I get is:
> > > Reverse for 'show_id' with arguments '()' and keyword arguments
> > > '{'s_id': 1}' not found.
> > > Plz help me..
>
> > You need to give reverse() the full path of the view, such as
> > `reverse('myapp.views.show_id`)` or use a named URL.
>
> > --
> > 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.



customize form in template according to field attribute

2010-01-29 Thread jul
hi,

I've got the Category model and SearchForm form shown below. In my
template I'd like to get all Category instances having a given type to
be able to separate those having different style in my CSS.
How can I do this?
thanks
Jul

**Category model***

CATEGORY_TYPE = [
(1, 'region'),
(2, 'type'),
]

class Category(models.Model):

parent = models.ManyToManyField('self', symmetrical=False,
null=True, blank=True)

type = models.PositiveSmallIntegerField(choices=CATEGORY_TYPE)

class Translation(multilingual.Translation):
name = models.CharField(max_length=100, unique=True)

class Meta:
verbose_name_plural = 'Categories'

def __unicode__(self):
return "%s" %(self.name)


**SearchForm class***

class SearchForm(forms.Form):

query = forms.CharField(max_length=100, required=False)
price_range = forms.IntegerField(widget=forms.Select(choices =
PRICE_RANGES_AND_EMPTY), required=False)

def __init__(self, *args, **kwargs):
super(SearchForm, self).__init__(*args, **kwargs)
self.fields['country'] = forms.ModelChoiceField
(queryset=Country.objects.all().order_by('name'), empty_label='All',
required=False)
self.fields['category'] = forms.ModelMultipleChoiceField
(queryset=Category.objects.all().order_by('name'),
widget=forms.CheckboxSelectMultiple(), required=False)

-- 
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: redirect question

2010-01-29 Thread bastir
Hello Atamert,

thanks for your quick reply. It seems that it now finds the function
but still does not work:

Reverse for '' with arguments '()' and
keyword arguments '{'s_id': 1}' not found.

Greetings
bastir

On 29 Jan., 11:19, Atamert Ölçgen  wrote:
> Hi Bastir,
>
> On Friday 29 January 2010 11:32:02 bastir wrote:> edirect but it cannot find 
> my view function.
> > Here is the relevant code that I tried. The error I get is:
> > Reverse for 'show_id' with arguments '()' and keyword arguments
> > '{'s_id': 1}' not found.
> > Plz help me..
>
> You need to give reverse() the full path of the view, such as
> `reverse('myapp.views.show_id`)` or use a named URL.
>
> --
> 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: passing text formatting with sqlite3

2010-01-29 Thread Namibnat
Thanks, I was starting to try stupid things because I just wasn't
getting it right.

I could simply pass in the article with: {{ data|safe }}

Thanks for the help.

Vernon


On Jan 29, 11:59 am, Daniel Roseman  wrote:
> On Jan 29, 8:40 am, Namibnat  wrote:
>
> > If I have a "km2" within a Sqlite3 database, how do I
> > format the superscript to show right once it is displayed in the
> > template.  I have tried python  "\xb2" mark-up, the normal HTML "sup"
> > tags and I have tried to figure out a way to pass it with the normal
> > Django variable mechanism.  I am still new to Django and I don't have
> > much database experience..which is why I want to use Sqlite3 for now.
>
> > Would I be best off to rather save it to a file and simply save a url
> > to the Sqlite database?  Wouldn't that make it slower?  This isn't a
> > blog post, but what is the normal way that those writing a blog post
> > would deal with this kind of thing?
>
> > I want to automate it if I can, because it is going to be used in a
> > number of articles that get pulled up at random to the home page of
> > the website.
>
> This question has nothing whatever to do with sqlite3, or any database
> at all for that matter.
>
> Read this:http://docs.djangoproject.com/en/1.1/topics/templates/#id2
> --
> 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.



Re: Database performance during test execution

2010-01-29 Thread Russell Keith-Magee
On Fri, Jan 29, 2010 at 6:51 PM, Sebastian Pawlus
 wrote:
> Hi everyone
> I've very confusing issue related whit databases performance. I've took two
> database engines and compared their performance during typical run for
> project test suite.
> results:
> MySQL: Ran 241 tests in 533.822s
> PostgreSQL: Ran 241 tests in 34.468s
> Results are more than strange. I don't even start to think that MySQL is 9
> times slower, but what is going on?

It depends on your MySQL configuration. If you're using MyISAM tables,
this is probably the cause of the slowdown you are seeing.

To ensure that a clean test environment is available at the start of
every test, Django clears out the database before each test starts. To
make this a fast process, Django uses transactions where possible -
rather than deleting and reloading test data, Django will commence a
transaction at the start of the test, and roll back to the start of a
transaction at the end of the test. There are some exceptions where
this speedup isn't possible - most notably, if you're actually testing
transactional behaviour - but this optimization is used by a lot of
Django's test suite.

Postgres makes full use of this transaction support, and as a result,
tests are quite fast. However, not every MySQL configuration supports
transactions. If your MySQL database doesn't support transactions (and
MyISAM generally falls into this category), tests will run a *lot*
slower. 10x slower would not be at all surprising.

This doesn't mean that MySQL/MyISAM will be slow in general - just
that the test suite will be slow. The test suite is doing something
pathological: loading and deleting hundreds of data, over and over
again. This isn't something most actual running applications will ever
need to do, so it isn't a cause for concern for production.

Unfortunately, there isn't much we can do about it. Without access to
transactions, there isn't any way to speed up test cases.

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.



Database performance during test execution

2010-01-29 Thread Sebastian Pawlus
Hi everyone

I've very confusing issue related whit databases performance. I've took two
database engines and compared their performance during typical run for
project test suite.

results:
MySQL: Ran 241 tests in *533.822s*
PostgreSQL: Ran 241 tests in *34.468s*
*
*
Results are more than strange. I don't even start to think that MySQL is 9
times slower, but what is going on?

Databases are from ubuntu packages:

Mysql:
mysql> select version();
+-+
| 5.1.37-1ubuntu5 |
+-+

Postgres:
user=# select version();
  version

---
 PostgreSQL 8.4.2 on i486-pc-linux-gnu, compiled by GCC gcc-4.4.real (Ubuntu
4.4.1-4ubuntu8) 4.4.1, 32-bit
(1 row)


Any ideas where I've made a mistake?

x_O

-- 
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: redirect question

2010-01-29 Thread Atamert Ölçgen
Hi Bastir,

On Friday 29 January 2010 11:32:02 bastir wrote:
> edirect but it cannot find my view function.
> Here is the relevant code that I tried. The error I get is:
> Reverse for 'show_id' with arguments '()' and keyword arguments
> '{'s_id': 1}' not found.
> Plz help me..
> 
You need to give reverse() the full path of the view, such as 
`reverse('myapp.views.show_id`)` or use a named URL.


-- 
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: passing text formatting with sqlite3

2010-01-29 Thread Daniel Roseman
On Jan 29, 8:40 am, Namibnat  wrote:
> If I have a "km2" within a Sqlite3 database, how do I
> format the superscript to show right once it is displayed in the
> template.  I have tried python  "\xb2" mark-up, the normal HTML "sup"
> tags and I have tried to figure out a way to pass it with the normal
> Django variable mechanism.  I am still new to Django and I don't have
> much database experience..which is why I want to use Sqlite3 for now.
>
> Would I be best off to rather save it to a file and simply save a url
> to the Sqlite database?  Wouldn't that make it slower?  This isn't a
> blog post, but what is the normal way that those writing a blog post
> would deal with this kind of thing?
>
> I want to automate it if I can, because it is going to be used in a
> number of articles that get pulled up at random to the home page of
> the website.

This question has nothing whatever to do with sqlite3, or any database
at all for that matter.

Read this:
http://docs.djangoproject.com/en/1.1/topics/templates/#id2
--
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.



Re: manytomany relations

2010-01-29 Thread Wayne Koorts

What do you mean by "top ten"?

On 29/01/2010, at 20:53, CCC  wrote:


hi,
I have two  models:user,group,and they are manytomany,
class User(model.Model):
name = models.CharField(max_length=20)

class Group(models.Model):
name = models.CharField(max_length=20)
users = models.ManytoManyField(User)

now i want to get the  top ten users who have the groups
,thanks for 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 
.




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



i18n - duplicates/conflicts in applications

2010-01-29 Thread viz
We have a rather large project consisting of many apps. Each is being
developed rather independently. Therefore each app has its own
locale/.  Naturally, sometimes more apps happen to define the same
msgid.  When the server is started, the locales from all the
installed_apps are loaded in some order (= cached in a dict) .  Here
we go - we have confilcts. Some msgs get  translated using other apps
locale. These conflicts are difficult to detect and and almost always
causes problems later.

Could you advise some best practice?

Putting everything to a global project locale (what would eliminate
those hidden confilcts) has also some drawbacks. Additionally it would
require (yet another) django patch as running makemessages on the
entire project takes way too much time.

viz

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



passing text formatting with sqlite3

2010-01-29 Thread Namibnat
If I have a "km2" within a Sqlite3 database, how do I
format the superscript to show right once it is displayed in the
template.  I have tried python  "\xb2" mark-up, the normal HTML "sup"
tags and I have tried to figure out a way to pass it with the normal
Django variable mechanism.  I am still new to Django and I don't have
much database experience..which is why I want to use Sqlite3 for now.

Would I be best off to rather save it to a file and simply save a url
to the Sqlite database?  Wouldn't that make it slower?  This isn't a
blog post, but what is the normal way that those writing a blog post
would deal with this kind of thing?

I want to automate it if I can, because it is going to be used in a
number of articles that get pulled up at random to the home page of
the website.

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



redirect question

2010-01-29 Thread bastir
Hi,

i tried to construct a redirect but it cannot find my view function.
Here is the relevant code that I tried. The error I get is:
Reverse for 'show_id' with arguments '()' and keyword arguments
'{'s_id': 1}' not found.
Plz help me..
Thx
Sebastian

in views.py
def nametoid(request,name)
   ---get_id
  return HttpResponseRedirect(reverse('show_id', kwargs=
{'s_id':id}))


def show_id(request,s_id):
 #Do stuff based on id

the urls.py
 urlpatterns = patterns('tests.views',
 (r'^show/(?P\d+)/$', 'show_id'),
 (r'^show/(\w+)/$', 'nametoid'),
)

-- 
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: ForeignKey query

2010-01-29 Thread Odd
On 29 Jan, 09:52, Odd  wrote:
> On 29 Jan, 09:08, Odd  wrote:
>
> > >You originally say the model1
> > > has a foreign key to model2 - I interpret that to mean that the
> > > ForeignKey is defined on model1. However, your code references
> > > model1.model2_set - which would imply that the FK is defined on
> > > model2, pointing to model1. So, do you want the objects that are
> > > pointed to by FKs from objects in the initial list, or the ones that
> > > FKs in the initial list point to?
>
> > > return_list = Model1.objects.filter(model2__in=model2_list)
>
> > Sorry, the ForeignKey is defined on model2. I need to get all the
> > model1 objects that is in the given modelList and is used as a
> > foreignkey in a model2 object. Your suggestion assumes that the input
> > is a model2_list, but the modelList is model1 objects.
>
> Figured it out. This seems to be the solution:
>
> return_list=Model1.objects.filter(model2__in modelList).distinct()
>

Hmm...

After a little testing, this is not what I wanted, some of the model1
objects in the return_list was not in the provided modelList, and I
dont't quite understand why they are returned. As stated before, I
want to get  a distinct list of all model1 objects that is in a
provided list and is used as a foreignkey in any model2 object. Is
this doable?

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: ForeignKey query

2010-01-29 Thread Odd
On 29 Jan, 09:08, Odd  wrote:
> >You originally say the model1
> > has a foreign key to model2 - I interpret that to mean that the
> > ForeignKey is defined on model1. However, your code references
> > model1.model2_set - which would imply that the FK is defined on
> > model2, pointing to model1. So, do you want the objects that are
> > pointed to by FKs from objects in the initial list, or the ones that
> > FKs in the initial list point to?
>
> > return_list = Model1.objects.filter(model2__in=model2_list)
>
> Sorry, the ForeignKey is defined on model2. I need to get all the
> model1 objects that is in the given modelList and is used as a
> foreignkey in a model2 object. Your suggestion assumes that the input
> is a model2_list, but the modelList is model1 objects.

Figured it out. This seems to be the solution:

return_list=Model1.objects.filter(model2__in modelList).distinct()

Thanks for the pointer!

-- 
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: ForeignKey query

2010-01-29 Thread Odd
>You originally say the model1
> has a foreign key to model2 - I interpret that to mean that the
> ForeignKey is defined on model1. However, your code references
> model1.model2_set - which would imply that the FK is defined on
> model2, pointing to model1. So, do you want the objects that are
> pointed to by FKs from objects in the initial list, or the ones that
> FKs in the initial list point to?
>
>
> return_list = Model1.objects.filter(model2__in=model2_list)

Sorry, the ForeignKey is defined on model2. I need to get all the
model1 objects that is in the given modelList and is used as a
foreignkey in a model2 object. Your suggestion assumes that the input
is a model2_list, but the modelList is model1 objects.

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