Re: Django Internals

2011-07-13 Thread Gath
There was a long talk by James Bannett called "Django In Depth" during
pycon 2010, it would be good to check it out

http://djangocon.blip.tv/file/3322277/

Gath


On Jul 13, 7:36 pm, Venkatraman S  wrote:
> Except for the code, is there any good place to start with to better
> understand the django structure.
> As in, i am trying to figure out a way by which django can be much leaner,
> so that the actual footprint
> is much smaller. Say, if i just want to have a simple website with a handful
> of models, with no complex
> queries, then having something like a 'django-lite' would be awsome.
>
> I started cleaning(/removing) up the code sometime back, but soon digressed.
>
> -V

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



creating a simple mailbox

2011-07-13 Thread bahare hoseini
hi there,
as my first project i'm going to create a simple mail box to recieve or
delete Emails,
i made my models in my application, could you please tell me the next steps?

thanks.

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



middleware

2011-07-13 Thread NISA BALAKRISHNAN
how to write a middleware that that stores all database requests.
How can i store all database requests?

pls help

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



can you use the Form Wizard with Model Forms?

2011-07-13 Thread sq1020
Hi everyone!

I have one model and I've created a form out of the model using
ModelForm.  Now, I want to spread the form across two pages.  For
example, the first three fields will appear on the first page then the
user clicks next and fills out the last three fields then he clicks
submit and the user submitted data is added to the database.

I took a look at the docs for the Form Wizard and it seems like it
would work for model forms as well?  Can someone confirm this?

And if it does, can someone explain the process of creating a
WizardView class.

This example is given in the docs and I don't understand what the
second two parameters are.  Is form_list just a list of form objects
that you've instantiated based on your form classes?  And what is
**kwargs?

class ContactWizard(SessionWizardView):
def done(self, form_list, **kwargs):
do_something_with_the_form_data(form_list)
return HttpResponseRedirect('/page-to-redirect-to-when-done/')

Thanks in advance for your help!

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



Re: Django form validation.. does anyone else find it awkward??

2011-07-13 Thread Matteius
"""
Devs: ALWAYS call model.full_clean() OR form.is_valid() to protect
Database from radical or duplicate DB entries!
* Calling model.full_clean() OR form.is_valid() calls 3 underlying
methods (clean, clean_fields, validate_unique)
"""

I haven't had to do much with form validation beyond what is default
and beyond what I have included in my model definitions.  Rendering
forms and displaying any error messages is standard fare included in
Django as far as I see it.

-Matteius

On Jul 12, 12:35 pm, Andre Terra  wrote:
> On Tue, Jul 12, 2011 at 2:25 PM, Venkatraman S  wrote:
>
> > On Tue, Jul 12, 2011 at 9:12 PM, Andre Terra  wrote:
>
> >> May I ask if you are managing to do this (and, if so, how) without
> >>> writing duplicate logic?
>
> >> This, to me, is a key area for improvement. Aside from the development
> >> challenge the idea imposes, an extra issue with writing DRY validation for
> >> django and javascript is that the project doesn't officially endorse any
> >> javascript library (there's been extensive discussion about this), but
> >> nobody says it's not okay to write an app that uses jQuery, for example.
>
> > A probable approach would be , probably, for the form renderer to
> > *automatically* clone the validation logic written in clean() to js? (!!)
>
> Cloning validation from clean() would be nearly impossible, as the developer
> is free to write any python code in that logic. A small, achievable step
> would be adding things like required fields to a on-the-fly generated js
> validator.
>
>
>
> >> My issue with uni-form and the like is that these apps get hard to extend
> >> once you find a fringe-case for your app. I tried using it once and soon
> >> enough I was writing so much custom code that I decided to drop uni-form
> >> altogether.
>
> > Can you educate us on the use-case; i am just curious.
>
> I don't remember correctly as it was a long time ago, but I think it had
> something to do with customizing how fieldsets were rendered, and how I
> needed different html markup. I can dig up the source later if you really
> want to know.
>
> History shows good ideas *do *get implemented, and Alex Gaynor is, imho, the
>
> >> developer to look at for examples on how to write quality django apps (for
> >> instance, take a look athttps://github.com/alex/django-filter/
> >> which is pretty small, but
> >> very django-like, even though he's not really proud of the API for that app
> >> in particular)
>
> > An awsum app that is! I was even more excited when i looked at its code. So
> > little, but so powerful!
>
> It's a great app indeed, I use it on every single project now.
>
> That's what he gets from knowing django's internals so well =)
>
> Cheers!

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



Re: something about django mysql database long connection

2011-07-13 Thread Jian Chang
Try DBUtils
http://www.webwareforpython.org/DBUtils/Docs/UsersGuide.html

2011/7/13 Kejun He 

> hi,
> I am sorry. My English is very bad.
>
> Yes, i want to make persistent databases connection on each session.
>
>
> and yesterday i try to modify the  code on
> "site-packages\django\db\__init__.py"
>
> 
> def close_connection(**kwargs):
> for conn in connections.all():
> conn.close()
> #signals.request_finished.connect(close_connection) <---
>
> 
>
> could it work?
>
> regards,
> he
>
>
>
>
> On Mon, Jul 11, 2011 at 7:31 PM, Cal Leeming [Simplicity Media Ltd] <
> cal.leem...@simplicitymedialtd.co.uk> wrote:
>
>>
>>
>> On Mon, Jul 11, 2011 at 4:49 AM, oops  wrote:
>>
>>> hi,
>>> Now, i am doing a django project, and use models to do all operation
>>> about data in mysql db.
>>>
>>> and i think that it would connect to database whenever  do some
>>> operation like 'XXX.objects.all()' , may be it would cast much of
>>> resource on database connection. So i need a connection never being
>>> desconnected.
>>>
>>
>> At as best guess (as the question is somewhat broken), are you asking how
>> to make persistent connections which are guaranteed to never time out in a
>> single session?
>>
>> Could you clarify a little more on your question please?
>>
>> Cal
>>
>>
>>>
>>> Does django has this function?  And how to do for it??
>>>
>>> thank you
>>> rgs,
>>> he
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Some more curious performance issues between MySQL and Django ORM

2011-07-13 Thread Andre Terra
PostgreSQL or bust.



On Wed, Jul 13, 2011 at 9:24 PM, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:

>
> On 14 Jul 2011 00:13, "bruno desthuilliers" 
> wrote:
> >
> > On 13 juil, 21:37, "Cal Leeming [Simplicity Media Ltd]"
> >  wrote:
> >
> > > _users = map(lambda x: x.get('memberid'),
> Members.objects.filter(
> > > username = self.username
> > > ).values('memberid'))
> >
> > What's wrong with values_list ?
> >
> > member_ids = Members.objects.filter(
> > username = self.username
> > ).values_list('memberid', flat=True)
>
> I didn't know about values_list(), thanks for this :)
>
> >
> >
> > And FWIW, did you try the obvious:
> >
> > return Session.objects.filter(
> >member__username=self.username,
> >is_fake = 0
> > ).order_by("-id")
>
> If you look at the original query i pasted, you'll see that this
> modification wouldn't have been any better (as they both would have
> generated the same query). The problem is that mysql does strange ass things
> when it comes to nested lookups or w/e its called. But tbh, ive come across
> so many times when its faster to perform operations outside of mysql, than
> it is inside.. the more i use mysql, the more i see how flawed it is :X
>
> >
> > (not that it might necessarily be faster - depending on your dataset,
> > indexes, hardware and whatnot).
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Some more curious performance issues between MySQL and Django ORM

2011-07-13 Thread Cal Leeming [Simplicity Media Ltd]
On 14 Jul 2011 00:13, "bruno desthuilliers" 
wrote:
>
> On 13 juil, 21:37, "Cal Leeming [Simplicity Media Ltd]"
>  wrote:
>
> > _users = map(lambda x: x.get('memberid'),
Members.objects.filter(
> > username = self.username
> > ).values('memberid'))
>
> What's wrong with values_list ?
>
> member_ids = Members.objects.filter(
> username = self.username
> ).values_list('memberid', flat=True)

I didn't know about values_list(), thanks for this :)

>
>
> And FWIW, did you try the obvious:
>
> return Session.objects.filter(
>member__username=self.username,
>is_fake = 0
> ).order_by("-id")

If you look at the original query i pasted, you'll see that this
modification wouldn't have been any better (as they both would have
generated the same query). The problem is that mysql does strange ass things
when it comes to nested lookups or w/e its called. But tbh, ive come across
so many times when its faster to perform operations outside of mysql, than
it is inside.. the more i use mysql, the more i see how flawed it is :X

>
> (not that it might necessarily be faster - depending on your dataset,
> indexes, hardware and whatnot).
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
>

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



Django Cache - how to clear per-site cache?

2011-07-13 Thread galgal
I use per-site cache. In my admin actions I want to add some commnad to 
clear cache every time content is changed.
How can I clear per-site cache from admin?

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



Re: Digest for django-users@googlegroups.com - 25 Messages in 8 Topics

2011-07-13 Thread Alistair Cohen

Sent via BlackBerry® from Telstra

-Original Message-
From: django-users+nore...@googlegroups.com
Sender: django-users@googlegroups.com
Date: Wed, 13 Jul 2011 18:37:47 
To: Digest Recipients
Reply-To: django-users@googlegroups.com
Subject: Digest for django-users@googlegroups.com - 25 Messages in 8 Topics

=
Today's Topic Summary
=

Group: django-users@googlegroups.com
Url: http://groups.google.com/group/django-users/topics

  - Add attributes (css-class) to formfield [6 Updates]
http://groups.google.com/group/django-users/t/5e981b9e16ea2b4
  - Django piston [2 Updates]
http://groups.google.com/group/django-users/t/a01ffdf6094dd6e6
  - Django Internals [2 Updates]
http://groups.google.com/group/django-users/t/2484b11a33f4e030
  - AW: Trouble overriding registration templates [8 Updates]
http://groups.google.com/group/django-users/t/599a8f9e4644f6ce
  - exclude field from SQL insert [3 Updates]
http://groups.google.com/group/django-users/t/c3a3b585f671edf6
  - old app fails tests, runs ok [1 Update]
http://groups.google.com/group/django-users/t/319bda41ab57e75b
  - Duplicate Key Error in Cache [2 Updates]
http://groups.google.com/group/django-users/t/36f8d7797e874757
  - Efficiently querying db [1 Update]
http://groups.google.com/group/django-users/t/8f09718bb62d56f9


=
Topic: Add attributes (css-class) to formfield
Url: http://groups.google.com/group/django-users/t/5e981b9e16ea2b4
=

-- 1 of 6 --
From: Andreas Pfrengle 
Date: Jul 13 10:41AM -0700
Url: http://groups.google.com/group/django-users/msg/8176dff0b94dae11

Hello,

I know about assigning attributes to widgets, like shown here:

or here:


However, I want to assign an additional attribute to a formfield,
since we want a css class for a div that is wrapped around the
presentation of a field. I've tried to assign an attribute in the
form's__init__, like:

self.fields['my_field'].div_css = "test"

If I try to fetch it in the template however, it resolves to an empty
string (supposedly the attribute doesn't exist):
{% for field in form.visible_fields %}



{% endfor %}

Any help or explanation what goes on inside Django is appreciated.

Regards,
Andreas


-- 2 of 6 --
From: Shawn Milochik 
Date: Jul 13 01:47PM -0400
Url: http://groups.google.com/group/django-users/msg/448c3aea3807fb7

Following this as a sample (from the docs you linked to):
 widget=forms.TextInput(attrs={'class':'special'}))

You'd do this:
 widget=forms.TextInput(attrs={'div_css':'test'}))

Or, to not clobber other things set in the form, you could do it in the 
__init__:

 #working example I just did in one of my projects to prove it works
 self.fields['release_date'].widget.attrs["div_css"] = 'test'


-- 3 of 6 --
From: Andreas Pfrengle 
Date: Jul 13 11:00AM -0700
Url: http://groups.google.com/group/django-users/msg/5a31279b06a4129d

Hello Shawn,

thanks for your answer, however that's not exactly what I wanted. Now
the html renders to:
No. of properties


However, I would want:

No. of properties



Additionally, I can't access {{ field.widget.attrs.div_css }} to get
the class directly, I get an empty string instead.


-- 4 of 6 --
From: Andre Terra 
Date: Jul 13 03:05PM -0300
Url: http://groups.google.com/group/django-users/msg/be002e8f71acc736

Write a wrapper function and make it even shorter (ok, go ahead and call it
syntax sugar):

def css(field, **kwargs):
field.attrs.update(**kwargs)

use as:

css(self.fields['release_date'], div_css="test")

DISCLAIMER: not tested on a real Field, but I tested it on a simple class in
a python shell and it seemed to work

I'll leave it as homework for you to make this a class method and make the
syntax even shorter. Maybe even propose a patch!


Cheers,
André Terra / airstrike




-- 5 of 6 --
From: Shawn Milochik 
Date: Jul 13 02:25PM -0400
Url: http://groups.google.com/group/django-users/msg/c42a60a54f032847

On 07/13/2011 02:00 PM, Andreas Pfrengle wrote:
>  

> Additionally, I can't access {{ field.widget.attrs.div_css }} to get
> the class directly, I get an empty string instead.

Replace 'div_css' in my example with 'class' and you'll get 
'class="test"' in your output.


-- 6 of 6 --
From: Andre Terra 

Re: Some more curious performance issues between MySQL and Django ORM

2011-07-13 Thread bruno desthuilliers
On 13 juil, 21:37, "Cal Leeming [Simplicity Media Ltd]"
 wrote:

>         _users = map(lambda x: x.get('memberid'), Members.objects.filter(
>             username = self.username
>         ).values('memberid'))

What's wrong with values_list ?

member_ids = Members.objects.filter(
 username = self.username
 ).values_list('memberid', flat=True)


And FWIW, did you try the obvious:

return Session.objects.filter(
member__username=self.username,
is_fake = 0
 ).order_by("-id")

(not that it might necessarily be faster - depending on your dataset,
indexes, hardware and whatnot).

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



Re: Some more curious performance issues between MySQL and Django ORM

2011-07-13 Thread Cal Leeming [Simplicity Media Ltd]
Sorry, let me rephrase to avoid confusion.

The original query I showed took about 4 seconds in total.

The modified query underneath took around 0.2s in total.

Cal

On Wed, Jul 13, 2011 at 11:08 PM, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:

> The first query took around 4 seconds, the latter took around 0.2s. :)
> On 13 Jul 2011 21:15, "Andre Terra"  wrote:
> > On Wed, Jul 13, 2011 at 4:37 PM, Cal Leeming [Simplicity Media Ltd] <
> > cal.leem...@simplicitymedialtd.co.uk> wrote:
> >
> > (...)
> >
> >
> >> **
> >> *This original query took 4 seconds to complete:*
> >>
> >> # return sessions for all subscriptions under this username
> >> _users = Members.objects.filter(
> >> username = 'testuser'
> >> )
> >> return Session.objects.filter(
> >> member__in = _users,
> >> is_fake = 0
> >> ).order_by("-id")
> >>
> >> *SELECT* *COUNT*(*) *FROM* `ddcms_session` *WHERE*
> (`ddcms_session`.`is_fake`
> >> = 0 *AND* `ddcms_session`.`member_id` *IN* (*SELECT* U0.`memberid`<
> http://dev.cp.dukedollars.com/paytools/lookingglass/120186270#>
> >> *FROM* `members` U0 *WHERE*U0.`username` = testuser ))
>
> >>
> >> ID SELECT_TYPE TABLE TYPE POSSIBLE_KEYS KEY KEY_LEN REF ROWS EXTRA
> >> 1 PRIMARY ddcms_session index None member_id 281 None 397790 Using
> where;
> >> Using index
> >> 2 DEPENDENT SUBQUERY U0 unique_subquery PRIMARY,username PRIMARY 8 func
> 1 Using
> >> where
> >>
> >>
> >
> >> *To speed this up, I had to change it to the following:*
> >>
> >> _users = map(lambda x: x.get('memberid'), Members.objects.filter(
> >> username = self.username
> >> ).values('memberid'))
> >>
> >
> > # return sessions for all subscriptions under this username
> >> return Session.objects.filter(
> >> member__memberid__in = _users
> >> is_fake = 0
> >> ).order_by("-id")
> >> *SELECT* *COUNT*(*)<
> http://dev.cp.dukedollars.com/paytools/lookingglass/120186270#>
> >> *FROM* `ddcms_session` *WHERE* (`ddcms_session`.`is_fake` = 0 *AND*
>
> >> `ddcms_session`.`member_id` *IN* (120186270, 120235430, 120235431))
> >>
> >>
> >> ID SELECT_TYPE TABLE TYPE POSSIBLE_KEYS KEY KEY_LEN REF ROWS EXTRA
> >> 1 SIMPLE ddcms_session range member_id member_id 4 None 187 Using where;
> >> Using index
> >>
> >
> > So basically this means you'll write two different queries, whereas the
> > former example used one query + subquery? How long did these two queries
> > take combined? Less than the 4 seconds from the first code?
> >
> >
> > Cheers,
> > André
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> >
>

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



Re: Django piston

2011-07-13 Thread Dipo Elegbede
Thanks.

On 13 Jul 2011 19:24, "Shawn Milochik"  wrote:
> Try going to github and doing a search for 'django-piston.' That will
> show you a list of open-source projects that have implemented
django-piston.
>
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
>

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



Re: Add attributes (css-class) to formfield

2011-07-13 Thread Andreas Pfrengle
Hello Andre,

it took me some time, but since I couldn't get insight in suggestion
1) and 2) really seemed too ugly, I've discovered an intermediate
solution.
I came around it when trying to make suggestion 2) a little less ugly,
and after all it's still quite easy ;-)

3) Write a template-filter that looks for a css-attribute in the
field, which I set dynamically during the form's __init__.
I also understand now why my first approach didn't work after
realising how BoundFields are created by Django.

I've put my solution here:


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



Re: Some more curious performance issues between MySQL and Django ORM

2011-07-13 Thread Cal Leeming [Simplicity Media Ltd]
The first query took around 4 seconds, the latter took around 0.2s. :)
On 13 Jul 2011 21:15, "Andre Terra"  wrote:
> On Wed, Jul 13, 2011 at 4:37 PM, Cal Leeming [Simplicity Media Ltd] <
> cal.leem...@simplicitymedialtd.co.uk> wrote:
>
> (...)
>
>
>> **
>> *This original query took 4 seconds to complete:*
>>
>> # return sessions for all subscriptions under this username
>> _users = Members.objects.filter(
>> username = 'testuser'
>> )
>> return Session.objects.filter(
>> member__in = _users,
>> is_fake = 0
>> ).order_by("-id")
>>
>> *SELECT* *COUNT*(*) *FROM* `ddcms_session` *WHERE*
(`ddcms_session`.`is_fake`
>> = 0 *AND* `ddcms_session`.`member_id` *IN* (*SELECT* U0.`memberid`<
http://dev.cp.dukedollars.com/paytools/lookingglass/120186270#>
>> *FROM* `members` U0 *WHERE*U0.`username` = testuser ))
>>
>> ID SELECT_TYPE TABLE TYPE POSSIBLE_KEYS KEY KEY_LEN REF ROWS EXTRA
>> 1 PRIMARY ddcms_session index None member_id 281 None 397790 Using where;
>> Using index
>> 2 DEPENDENT SUBQUERY U0 unique_subquery PRIMARY,username PRIMARY 8 func 1
Using
>> where
>>
>>
>
>> *To speed this up, I had to change it to the following:*
>>
>> _users = map(lambda x: x.get('memberid'), Members.objects.filter(
>> username = self.username
>> ).values('memberid'))
>>
>
> # return sessions for all subscriptions under this username
>> return Session.objects.filter(
>> member__memberid__in = _users
>> is_fake = 0
>> ).order_by("-id")
>> *SELECT* *COUNT*(*)<
http://dev.cp.dukedollars.com/paytools/lookingglass/120186270#>
>> *FROM* `ddcms_session` *WHERE* (`ddcms_session`.`is_fake` = 0 *AND*
>> `ddcms_session`.`member_id` *IN* (120186270, 120235430, 120235431))
>>
>>
>> ID SELECT_TYPE TABLE TYPE POSSIBLE_KEYS KEY KEY_LEN REF ROWS EXTRA
>> 1 SIMPLE ddcms_session range member_id member_id 4 None 187 Using where;
>> Using index
>>
>
> So basically this means you'll write two different queries, whereas the
> former example used one query + subquery? How long did these two queries
> take combined? Less than the 4 seconds from the first code?
>
>
> Cheers,
> André
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
>

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



Re: Model "created_by"

2011-07-13 Thread Nick Serra
That error just means you didn't add that field to the database and it
can't find it. Verify the user_id field is on that table.

On Jul 13, 2:40 pm, Petey  wrote:
> Hi!
>
> I've made a model in news application:http://pastebin.com/49VkFT14
>
> I want it to save user who created a message, however I get this message:
> OperationalError at /admin/news/news/add/(1054, "Unknown column 'user_id' in
> 'field list'")

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



Re: Some more curious performance issues between MySQL and Django ORM

2011-07-13 Thread Andre Terra
On Wed, Jul 13, 2011 at 4:37 PM, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:

(...)


> **
> *This original query took 4 seconds to complete:*
>
> # return sessions for all subscriptions under this username
> _users = Members.objects.filter(
> username = 'testuser'
> )
> return Session.objects.filter(
> member__in = _users,
> is_fake = 0
> ).order_by("-id")
>
> *SELECT* *COUNT*(*) *FROM* `ddcms_session` *WHERE* (`ddcms_session`.`is_fake`
> = 0 *AND* `ddcms_session`.`member_id` *IN* (*SELECT* 
> U0.`memberid`
>  *FROM* `members` U0 *WHERE*U0.`username` = testuser ))
>
> ID SELECT_TYPE TABLE TYPE POSSIBLE_KEYS KEY KEY_LEN REF ROWS EXTRA
> 1 PRIMARY ddcms_session index None member_id 281 None 397790 Using where;
> Using index
> 2 DEPENDENT SUBQUERY U0 unique_subquery PRIMARY,username PRIMARY 8 func 1 
> Using
> where
>
>

> *To speed this up, I had to change it to the following:*
>
> _users = map(lambda x: x.get('memberid'), Members.objects.filter(
> username = self.username
> ).values('memberid'))
>

# return sessions for all subscriptions under this username
> return Session.objects.filter(
> member__memberid__in = _users
> is_fake = 0
> ).order_by("-id")
>*SELECT* 
> *COUNT*(*)
>  *FROM* `ddcms_session` *WHERE* (`ddcms_session`.`is_fake` = 0 *AND*
>  `ddcms_session`.`member_id` *IN* (120186270, 120235430, 120235431))
>
>
>  ID SELECT_TYPE TABLE TYPE POSSIBLE_KEYS KEY KEY_LEN REF ROWS EXTRA
>  1 SIMPLE ddcms_session range member_id member_id 4 None 187 Using where;
> Using index
>

So basically this means you'll write two different queries, whereas the
former example used one query + subquery? How long did these two queries
take combined? Less than the 4 seconds from the first code?


Cheers,
André

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



Some more curious performance issues between MySQL and Django ORM

2011-07-13 Thread Cal Leeming [Simplicity Media Ltd]
Most of you will probably read this and say "duh", so this is aimed more at
people who haven't had experience with using large data sets in Django.

This isn't necessarily a bug or a problem with the ORM (although it would be
nice if it could try and utilize little gotcha's like this), it just shows
that sometimes adhering to the typical syntax / usage of the ORM, can be
detrimental to performance.

Cal
*
*
*This original query took 4 seconds to complete:*

# return sessions for all subscriptions under this username
_users = Members.objects.filter(
username = 'testuser'
)
return Session.objects.filter(
member__in = _users,
is_fake = 0
).order_by("-id")

*SELECT* *COUNT*(*) *FROM* `ddcms_session` *WHERE* (`ddcms_session`.`is_fake`
= 0 *AND* `ddcms_session`.`member_id` *IN* (*SELECT*
U0.`memberid`
 *FROM* `members` U0 *WHERE*U0.`username` = testuser ))

ID SELECT_TYPE TABLE TYPE POSSIBLE_KEYS KEY KEY_LEN REF ROWS EXTRA
1 PRIMARY ddcms_session index None member_id 281 None 397790 Using where;
Using index
2 DEPENDENT SUBQUERY U0 unique_subquery PRIMARY,username PRIMARY 8 func 1 Using
where

*To speed this up, I had to change it to the following:*

_users = map(lambda x: x.get('memberid'), Members.objects.filter(
username = self.username
).values('memberid'))

# return sessions for all subscriptions under this username
return Session.objects.filter(
member__memberid__in = _users
is_fake = 0
).order_by("-id")
*SELECT* 
*COUNT*(*)
 *FROM* `ddcms_session` *WHERE* (`ddcms_session`.`is_fake` = 0 *AND*
 `ddcms_session`.`member_id` *IN* (120186270, 120235430, 120235431))

ID SELECT_TYPE TABLE TYPE POSSIBLE_KEYS KEY KEY_LEN REF ROWS EXTRA
1 SIMPLE ddcms_session range member_id member_id 4 None 187 Using where;
Using index

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



Re: session and caching

2011-07-13 Thread het.oosten
As always afterwards everything is very logical :-)
Never used caching before.

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



Model "created_by"

2011-07-13 Thread Petey
Hi!

I've made a model in news application:
http://pastebin.com/49VkFT14

I want it to save user who created a message, however I get this message: 
OperationalError at /admin/news/news/add/(1054, "Unknown column 'user_id' in 
'field list'")

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



Re: Add attributes (css-class) to formfield

2011-07-13 Thread Andre Terra
Shawn,

He wants the form attribute to be applied to the div, not the field.


Andreas,

You can't pass an attribute to a field and expect it to show up in a
different object altogether. I assume your div isn't handled by django, so
you need to fix that first in order to be able to pass extra attributes to
it.

A few solutions:
1) Use a fieldset (like the admin does) and then define how *that* gets
rendered - complex, flexible.
2) Pass a css attribute to the view (not sure where you're going to get that
css_class stuff from) and use it in your template's context, then add
classes on the fly during template compilation - easy, ugly.



Cheers,
André


On Wed, Jul 13, 2011 at 3:25 PM, Shawn Milochik  wrote:

> On 07/13/2011 02:00 PM, Andreas Pfrengle wrote:
>
>> Hello Shawn,
>>
>> thanks for your answer, however that's not exactly what I wanted. Now
>> the html renders to:
>> No. of properties
>> > id="id_n_properties" />
>>
>> However, I would want:
>> 
>> No. of properties
>> > id="id_n_properties" />
>> 
>>
>> Additionally, I can't access {{ field.widget.attrs.div_css }} to get
>> the class directly, I get an empty string instead.
>>
>>
> Replace 'div_css' in my example with 'class' and you'll get 'class="test"'
> in your output.
>
>
>
> --
> 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+unsubscribe@**
> googlegroups.com .
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en
> .
>
>

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



Re: Add attributes (css-class) to formfield

2011-07-13 Thread Shawn Milochik

On 07/13/2011 02:00 PM, Andreas Pfrengle wrote:

Hello Shawn,

thanks for your answer, however that's not exactly what I wanted. Now
the html renders to:
 No. of properties
 

However, I would want:
 
 No. of properties
 
 

Additionally, I can't access {{ field.widget.attrs.div_css }} to get
the class directly, I get an empty string instead.



Replace 'div_css' in my example with 'class' and you'll get 
'class="test"' in your output.



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



Re: Django piston

2011-07-13 Thread Shawn Milochik
Try going to github and doing a search for 'django-piston.' That will 
show you a list of open-source projects that have implemented django-piston.



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



Django piston

2011-07-13 Thread Dipo Elegbede
I'm about to start using django piston.
Can anyone please point me to any example?
I've looked through the documentation but can't get a hang of it.
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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django Internals

2011-07-13 Thread Daniel Roseman
On Wednesday, 13 July 2011 17:36:44 UTC+1, Venkatraman.S. wrote:
>
> Except for the code, is there any good place to start with to better 
> understand the django structure. 
> As in, i am trying to figure out a way by which django can be much leaner, 
> so that the actual footprint
> is much smaller. Say, if i just want to have a simple website with a 
> handful of models, with no complex 
> queries, then having something like a 'django-lite' would be awsome. 
>
> I started cleaning(/removing) up the code sometime back, but soon 
> digressed.
>
> -V
>

For understanding the code, the absolute best place to start is Marty 
Alchin's great book Pro Django.

But if you want a "Django-lite", you'll be better off dropping Django and 
looking at one of the micro-frameworks like Flask. They usually don't come 
with ORMs, but you can always use  something like SQLObject, which again is 
much more minimal than Django's or SQLAlchemy.
--
DR.

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



Re: Add attributes (css-class) to formfield

2011-07-13 Thread Andre Terra
Write a wrapper function and make it even shorter (ok, go ahead and call it
syntax sugar):

def css(field, **kwargs):
field.attrs.update(**kwargs)

use as:

css(self.fields['release_date'], div_css="test")

DISCLAIMER: not tested on a real Field, but I tested it on a simple class in
a python shell and it seemed to work

I'll leave it as homework for you to make this a class method and make the
syntax even shorter. Maybe even propose a patch!


Cheers,
André Terra / airstrike


On Wed, Jul 13, 2011 at 2:47 PM, Shawn Milochik  wrote:

>
>
> Following this as a sample (from the docs you linked to):
>widget=forms.TextInput(attrs={**'class':'special'}))
>
> You'd do this:
>widget=forms.TextInput(attrs={**'div_css':'test'}))
>
> Or, to not clobber other things set in the form, you could do it in the
> __init__:
>
>#working example I just did in one of my projects to prove it works
>self.fields['release_date'].**widget.attrs["div_css"] = 'test'
>
>
> --
> 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+unsubscribe@**
> googlegroups.com .
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en
> .
>
>

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



Re: Add attributes (css-class) to formfield

2011-07-13 Thread Andreas Pfrengle
Hello Shawn,

thanks for your answer, however that's not exactly what I wanted. Now
the html renders to:
No. of properties


However, I would want:

No. of properties



Additionally, I can't access {{ field.widget.attrs.div_css }} to get
the class directly, I get an empty string instead.

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



Re: Add attributes (css-class) to formfield

2011-07-13 Thread Shawn Milochik



Following this as a sample (from the docs you linked to):
widget=forms.TextInput(attrs={'class':'special'}))

You'd do this:
widget=forms.TextInput(attrs={'div_css':'test'}))

Or, to not clobber other things set in the form, you could do it in the 
__init__:


#working example I just did in one of my projects to prove it works
self.fields['release_date'].widget.attrs["div_css"] = 'test'

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



Re: Trouble overriding registration templates

2011-07-13 Thread Joshua Russo
Correct

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/K5yKllF_gPcJ.
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.



Add attributes (css-class) to formfield

2011-07-13 Thread Andreas Pfrengle
Hello,

I know about assigning attributes to widgets, like shown here:

or here:


However, I want to assign an additional attribute to a formfield,
since we want a css class for a div that is wrapped around the
presentation of a field. I've tried to assign an attribute in the
form's __init__, like:

self.fields['my_field'].div_css = "test"

If I try to fetch it in the template however, it resolves to an empty
string (supposedly the attribute doesn't exist):
{% for field in form.visible_fields %}



{% endfor %}

Any help or explanation what goes on inside Django is appreciated.

Regards,
Andreas

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



Re: Trouble overriding registration templates

2011-07-13 Thread Joshua Russo
*light bulb* I forgot about my development vs production settings. I was 
only changing the TEMPLATE_DIRS in the main settings.py that represents my 
production settings. I'm not in a place where I can test this but I'm almost 
certain that's what the problem is.

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



Re: Trouble overriding registration templates

2011-07-13 Thread Shawn Milochik
To be clear, when you say registration/login, you mean
templates/registration/login, correct?

Your 'registration' directory should be in a 'templates' dir.

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



Re: Trouble overriding registration templates

2011-07-13 Thread Joshua Russo
Cool, thanks for the confirmation. 

I do have my template directories explicitly listed in TEMPLATE_DIRS. I even 
made sure that my app's templates came before the admin templates, but for 
some reason it's not picking up my /registration/logged_out.html and the 
others that show up in the admin's templates/registration directory. My 
/registration/login.html works just fine.

I'll try playing with the order of the installed apps and see if that makes 
any difference.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/GJZkPFObtAIJ.
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.



old app fails tests, runs ok

2011-07-13 Thread Javier Guerra Giraldez
Hi,

I'm having a very weird problem, hope somebody can shed some light.

some time ago, I developed an internal app at my officeIt using Django
1.1 (final), and it has been running with very few issues, on a small
virtual machine.

Now i have to do some non-trivial changes, so i set up a Virtualenv on
my desktop with Django 1.1 and Python 2.6.6 (the server uses 2.6.2).
if i try with `manage runserver`, it seems to work pretty well.

but it refuses to pass the tests.   to be precise, the test
client.login() returns True, but the first request to a
`@login_required` view responds with a 302 => login, as if it wasn't
logged in.  the user and password are ok, changing either makes
client.login() return False

i tried on the server itself, and all tests pass OK.   Thinking it
might be a different version of the mysql libraries, i changed the
settings.py to use sqlite3.  much faster, but fails in exactly the
same way.  Also, using Python 2.6.6 or 2.7 doesn't make any
difference.

what else can i try?  was there any dependency that i might be missing?

-- 
Javier

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



Re: Trouble overriding registration templates

2011-07-13 Thread Shawn Milochik

On 07/13/2011 12:46 PM, Joshua Russo wrote:
That's fine, but I was under the impression that the templates could 
be overridden just by creating the proper path in my template 
directories. Is that not true?





It's true. Check the order of your TEMPLATE_DIRS in settings.py. If you 
don't have them specified and are relying on the automatic detection of 
a 'templates' dir in your app folders then check the order of your 
INSTALLED_APPS.


If you're having an issue it's probably a good idea to explicitly 
populate TEMPLATE_DIRS.


Hopefully this will help:
https://docs.djangoproject.com/en/1.3/ref/templates/api/#the-template-dirs-setting


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



Re: Trouble overriding registration templates

2011-07-13 Thread Joshua Russo
That's fine, but I was under the impression that the templates could be 
overridden just by creating the proper path in my template directories. Is 
that not true?

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



Re: exclude field from SQL insert

2011-07-13 Thread Venkatraman S
On Wed, Jul 13, 2011 at 8:57 PM, Tom Evans  wrote:

> Models based on views are not explicitly supported, but should work
> well in practice (use managed=False in the meta class). Virtual
> computed 'fields' are definitely not supported for update/insert.
>

Nice, i didnt know this.

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



Django Internals

2011-07-13 Thread Venkatraman S
Except for the code, is there any good place to start with to better
understand the django structure.
As in, i am trying to figure out a way by which django can be much leaner,
so that the actual footprint
is much smaller. Say, if i just want to have a simple website with a handful
of models, with no complex
queries, then having something like a 'django-lite' would be awsome.

I started cleaning(/removing) up the code sometime back, but soon digressed.

-V

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



Re: Trouble overriding registration templates

2011-07-13 Thread Andre Terra
Or render() which is the recommended shortcut since 1.3.

https://docs.djangoproject.com/en/1.3/topics/http/shortcuts/#render


Cheers,
André


On Wed, Jul 13, 2011 at 3:28 AM, Szabo, Patrick (LNG-VIE) <
patrick.sz...@lexisnexis.at> wrote:

>  Did you write your own view for that purpose ?!
>
> In that view you could use render_to_response and pass you own template to
> that.
>
> ** **
>
> *Von:* django-users@googlegroups.com [mailto:django-users@googlegroups.com]
> *Im Auftrag von *Joshua Russo
> *Gesendet:* Mittwoch, 13. Juli 2011 04:24
> *An:* django-users@googlegroups.com
> *Betreff:* Trouble overriding registration templates
>
> ** **
>
> I want to use my own logout template but it doesn't want to pick it up. The
> login template worked just fine, but for anything that's already in the
> admin's template/registration folder, it only wants to use those. I tried
> putting my templates folder before the admin templates folder in the list of
> template folder in the settings file but that didn't do anything. Any
> suggestions? 
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/VcsTSOx1iSoJ.
> 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.
>
>  . . . . . . . . . . . . . . . . . . . . . . . . . .
>
>  **
>
> Patrick Szabo
> XSLT Developer
>
> LexisNexis
> Marxergasse 25, 1030 Wien
>
> patrick.sz...@lexisnexis.at
>
> Tel.: 00431 534521573
>
> Fax: +43 (1) 534 52 - 146
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: AW: Trouble overriding registration templates

2011-07-13 Thread Joshua Russo
Am I wrong about how templates work?

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



Re: exclude field from SQL insert

2011-07-13 Thread Tom Evans
On Wed, Jul 13, 2011 at 4:05 PM, Slafs  wrote:
> Hello.
>
> I have a model in Django that is based on database view. One of the fields
> is "virtual" (computed in the view) .
> I would like to exclude this field in my model from being used in SQL Insert
> and Update statements.
>
> Do You know maybe how can I do that ?
>
> Regards

Models based on views are not explicitly supported, but should work
well in practice (use managed=False in the meta class). Virtual
computed 'fields' are definitely not supported for update/insert.

Cheers

Tom

Cheers

Tom

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



exclude field from SQL insert

2011-07-13 Thread Slafs
Hello. 

I have a model in Django that is based on database view. One of the fields 
is "virtual" (computed in the view) . 
I would like to exclude this field in my model from being used in SQL Insert 
and Update statements.

Do You know maybe how can I do that ?

Regards

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



Re: Duplicate Key Error in Cache

2011-07-13 Thread gamingdroid
I'm memory constrained and therefore memcache is not an option. The
pages makes a lot of independent SQL queries that is better handled
through one sql call via the db cache backend.

I suppose I could roll my own, but find it odd that somebody hasn't
fixed it. I would fix it myself, if I knew what was going on in there,
but I'm pretty new to Django.

On Jul 13, 9:55 am, "Cal Leeming [Simplicity Media Ltd]"
 wrote:
> May I ask why you are using a database cache, rather than something like
> memcache??
>
> Cal
>
>
>
>
>
>
>
> On Tue, Jul 12, 2011 at 5:09 PM, gamingdroid  wrote:
> > I ran into this problem using django core's database cache:
>
> > ERROR:  duplicate key value violates unique constraint "cache_pkey"
> > STATEMENT:  INSERT INTO "cache" (cache_key, value, expires) VALUES (E':
> > 1:cms-menu_nodes_en-us_1', E'gAJdcQEoY21lbnVzLmJhc2UKTmF2aW
> > LOG:  server process (PID 8453) was terminated by signal 9: Killed
> > LOG:  terminating any other active server processes
> > LOG:  all server processes terminated; reinitializing
> > FATAL:  could not create shared memory segment: Cannot allocate memory
> > DETAIL:  Failed system call was shmget(key=5432001, size=29278208,
> > 03600).
>
> > I looked in the table and sure enough, there is an entry for the key ':
> > 1:cms-menu_nodes_en-us_1'. I found a similar issue here (http://
> > stackoverflow.com/questions/1189541/django-cache-set-causing-duplicate-
> > key-error), but was unable to exactly understand what the issue is.
>
> > Sounds like a bug in django core, since if a key exist, it should
> > update the record. It looks as if somebody posted a ticket here
> > (https://code.djangoproject.com/ticket/11569), but not entireloy sure
> > if it is related. This problem sort of renders the database backend
> > useless. I would fix it if I knew how and contribute back, but really
> > don't know how.
>
> > Anyone have any ideas or suggestions?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: Efficiently querying db

2011-07-13 Thread Cal Leeming [Simplicity Media Ltd]
On Wed, Jul 13, 2011 at 9:36 AM, Amit Sethi wrote:

> I have a db that looks something like  this .
>
> { message : xyz
>  parent : 23
>  id : 25
> }
>  or
> { message : abc
> parent : None
> id : 25
> }
>
> { message : cde
> parent : 28
> id : 32
> }
>
> { message : lbq
> parent : 23
> id : 35
> }
>
> I want to make seperate the lists such that messages in same thread(
> The parent message and its child messages } come together . What is
> the best way to query the db or a efficient algorithm to do this.
>

How about you tell us what you have thought of so far, and we'll give you
some feedback on whether or not it can be improved upon.


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

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



Re: Duplicate Key Error in Cache

2011-07-13 Thread Cal Leeming [Simplicity Media Ltd]
May I ask why you are using a database cache, rather than something like
memcache??

Cal

On Tue, Jul 12, 2011 at 5:09 PM, gamingdroid  wrote:

> I ran into this problem using django core's database cache:
>
> ERROR:  duplicate key value violates unique constraint "cache_pkey"
> STATEMENT:  INSERT INTO "cache" (cache_key, value, expires) VALUES (E':
> 1:cms-menu_nodes_en-us_1', E'gAJdcQEoY21lbnVzLmJhc2UKTmF2aW
> LOG:  server process (PID 8453) was terminated by signal 9: Killed
> LOG:  terminating any other active server processes
> LOG:  all server processes terminated; reinitializing
> FATAL:  could not create shared memory segment: Cannot allocate memory
> DETAIL:  Failed system call was shmget(key=5432001, size=29278208,
> 03600).
>
> I looked in the table and sure enough, there is an entry for the key ':
> 1:cms-menu_nodes_en-us_1'. I found a similar issue here (http://
> stackoverflow.com/questions/1189541/django-cache-set-causing-duplicate-
> key-error), but was unable to exactly understand what the issue is.
>
> Sounds like a bug in django core, since if a key exist, it should
> update the record. It looks as if somebody posted a ticket here
> (https://code.djangoproject.com/ticket/11569), but not entireloy sure
> if it is related. This problem sort of renders the database backend
> useless. I would fix it if I knew how and contribute back, but really
> don't know how.
>
> Anyone have any ideas or suggestions?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: session and caching

2011-07-13 Thread Cal Leeming [Simplicity Media Ltd]
Nice, i didnt' even realise there was built in support for having sessions
in cache. :)

On Wed, Jul 13, 2011 at 2:36 PM, het.oosten  wrote:

> I want indeed cache all users using the same lay-out. I haven't
> considered writing my own middleware for this yet. I will look into
> it.
>
> Thanks!
>
> Rob
>
> On 13 jul, 15:24, "Henrik Genssen"  wrote:
> > you can inherit the cache system (UpdateCacheMiddleware,
> FetchFromCacheMiddleware) with your own get_Cache_Key function
> > that you extend by layout (as you hopefully do not want to cache every
> single user, but all user using the same layout)
> > Then create a new middleware, that uses your both new created
> CacheMiddlewares. See django.middleware.cache.py
> >
> >
> >
> >
> >
> >
> >
> > >reply to message:
> > >date: 13.07.2011 08:08:31
> > >from: "het.oosten" 
> > >to: "Django users" 
> > >subject: [] Re: session and caching
> >
> > >> Are you sure because in the docs I find the opposite.
> >
> > >When I read it correct this is about caching the session. I was
> > >referring to (or trying to) caching the entire webpage using a custom
> > >session key for the lay-out (I use memcached)
> >
> > >When I look at the request headers my custom session key, doesn't show
> > >up, therefore I doubt now if @vary_on_headers is the right option for
> > >me.
> >
> > >--
> > >You received this message because you are subscribed to the Google
> Groups "Django users" group.
> > >To post to this group, send email to django-users@googlegroups.com.
> > >To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> > >For more options, visit this group 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-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: session and caching

2011-07-13 Thread het.oosten
I want indeed cache all users using the same lay-out. I haven't
considered writing my own middleware for this yet. I will look into
it.

Thanks!

Rob

On 13 jul, 15:24, "Henrik Genssen"  wrote:
> you can inherit the cache system (UpdateCacheMiddleware, 
> FetchFromCacheMiddleware) with your own get_Cache_Key function
> that you extend by layout (as you hopefully do not want to cache every single 
> user, but all user using the same layout)
> Then create a new middleware, that uses your both new created 
> CacheMiddlewares. See django.middleware.cache.py
>
>
>
>
>
>
>
> >reply to message:
> >date: 13.07.2011 08:08:31
> >from: "het.oosten" 
> >to: "Django users" 
> >subject: [] Re: session and caching
>
> >> Are you sure because in the docs I find the opposite.
>
> >When I read it correct this is about caching the session. I was
> >referring to (or trying to) caching the entire webpage using a custom
> >session key for the lay-out (I use memcached)
>
> >When I look at the request headers my custom session key, doesn't show
> >up, therefore I doubt now if @vary_on_headers is the right option for
> >me.
>
> >--
> >You received this message because you are subscribed to the Google Groups 
> >"Django users" group.
> >To post to this group, send email to django-users@googlegroups.com.
> >To unsubscribe from this group, send email to 
> >django-users+unsubscr...@googlegroups.com.
> >For more options, visit this group 
> >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-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: [] Re: session and caching

2011-07-13 Thread Henrik Genssen
you can inherit the cache system (UpdateCacheMiddleware, 
FetchFromCacheMiddleware) with your own get_Cache_Key function
that you extend by layout (as you hopefully do not want to cache every single 
user, but all user using the same layout)
Then create a new middleware, that uses your both new created CacheMiddlewares. 
See django.middleware.cache.py


>reply to message:
>date: 13.07.2011 08:08:31
>from: "het.oosten" 
>to: "Django users" 
>subject: [] Re: session and caching
>
>
>
>
>> Are you sure because in the docs I find the opposite.
>>
>When I read it correct this is about caching the session. I was
>referring to (or trying to) caching the entire webpage using a custom
>session key for the lay-out (I use memcached)
>
>When I look at the request headers my custom session key, doesn't show
>up, therefore I doubt now if @vary_on_headers is the right option for
>me.
>
>-- 
>You received this message because you are subscribed to the Google Groups 
>"Django users" group.
>To post to this group, send email to django-users@googlegroups.com.
>To unsubscribe from this group, send email to 
>django-users+unsubscr...@googlegroups.com.
>For more options, visit this group at 
>http://groups.google.com/group/django-users?hl=en.
>

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



Re: VirtualServer definition

2011-07-13 Thread Shawn Milochik
It sounds like that part of the tutorial you're following is regarding
configuring Apache. You don't need to worry about that yet.

If you start with the Django tutorial it'll show you how to get
started using the development server. The tutorial doesn't take too
long to do.
https://docs.djangoproject.com/en/1.3/

Once you understand that it'll be a lot easier to see the distinction
between what's Django and what's server-admin stuff in the tutorial
you're working with.

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



Re: VirtualServer definition

2011-07-13 Thread Sergiy Khohlov
Could you please provide some detail about your target ?
If you are novice then  django is started at 127.0.0.1:8080
What do you what to do ?

 Thsnks,
Serge

2011/7/13 kyosa :
> Hi,
> I'm new to Ubuntu, Python and Django. To learn Python and Django I
> following a case in Pro Python System Administration book.
>
> I have done all what the book say, but I cant find out how to change
> config for "The VirtualServer definition for the Django web
> application"
>
> The book say that I need to change ip (192.168.0.1:80) but I cant find
> out how/where to modified this config.
>
> My system are:
> Ubuntu (latest version)
> Python 2.7
> Django 1.3
> For this case I'm using sqlite
>
> Kind Regards
> Kyosa
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: session and caching

2011-07-13 Thread het.oosten



> Are you sure because in the docs I find the opposite.
>
When I read it correct this is about caching the session. I was
referring to (or trying to) caching the entire webpage using a custom
session key for the lay-out (I use memcached)

When I look at the request headers my custom session key, doesn't show
up, therefore I doubt now if @vary_on_headers is the right option for
me.

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



VirtualServer definition

2011-07-13 Thread kyosa
Hi,
I'm new to Ubuntu, Python and Django. To learn Python and Django I
following a case in Pro Python System Administration book.

I have done all what the book say, but I cant find out how to change
config for "The VirtualServer definition for the Django web
application"

The book say that I need to change ip (192.168.0.1:80) but I cant find
out how/where to modified this config.

My system are:
Ubuntu (latest version)
Python 2.7
Django 1.3
For this case I'm using sqlite

Kind Regards
Kyosa

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



Re: session and caching

2011-07-13 Thread Jonas Geiregat


> I have site with with a lay-out depending on a session, set in my
> view. I first tried site-wide caching, and this obviously didn't work.
> The caching is not session aware, and the lay-out changes almost
> randomly.

Are you sure because in the docs I find the opposite.

https://docs.djangoproject.com/en/dev/topics/http/sessions/#using-cached-sessions



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



Re: failed to run PROJ/manage.py in zip file

2011-07-13 Thread Cal Leeming [Simplicity Media Ltd]
Hi Robert,

You might be interested to know that some of us are currently working on
something similar.

See following:
http://groups.google.com/group/django-users/browse_thread/thread/38525319cd44263c?hl=en#

Cal

On Wed, Jul 13, 2011 at 10:41 AM, Robert Nie  wrote:

> Hi,
>
> I would like to compress my DJANGO project into one zip file (all
> *.pyo files) and then do basic testing and deploy. Now I found PROJ/
> manage.py in zip file can not be invoked.
>
> It seems it is caused by imp.find_module() failed to find the
> 'settings' module. The code looks like this,
>
> >>> import sys
> >>> sys.path.insert(0, 'bin/proj.zip')
> >>> import imp
> >>> imp.find_module('proj.settings')
> Traceback (most recent call last):
>  File "", line 1, in 
> ImportError: No module named proj.settings
> >>> imp.find_module('settings')
> Traceback (most recent call last):
>  File "", line 1, in 
> ImportError: No module named settings
>
> By comment out the lines about sanity checking on 'settings' file,
> everything works fine. I can invoke 'runserver', 'shell' parameters
> after adding proj.zip to sys.path.
>
>
> Thanks,
> Robert
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



session and caching

2011-07-13 Thread het.oosten
I have site with with a lay-out depending on a session, set in my
view. I first tried site-wide caching, and this obviously didn't work.
The caching is not session aware, and the lay-out changes almost
randomly.

Therefore I tried my luck with the @vary_on_headers decorator, using
my session variable. This didn't make any change. Looking at the http
request I did found out that the session variable isn't send with the
http header (Confirmed by the docs).

Is there a way to make caching session aware?

One way perhaps is setting a cookie. But what happens with users who
don't use cookies (like search engine spiders)

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



Re: Inspecting objects

2011-07-13 Thread Cal Leeming [Simplicity Media Ltd]
You know, I think that this subject deserves it own page on the wiki. I'll
get something started later :)

On Wed, Jul 13, 2011 at 7:33 AM, Jonas Geiregat  wrote:

>
> Op 13-jul-2011, om 08:25 heeft Jirka Vejrazka het volgende geschreven:
>
> >> Thank you all for your help!!!
> >
> > I know I'm a bit late to the party (blame timezones :), but thought
> > I'd put my 2 cents worth in :)
> >
> > For inspecting models from command lines (usually when working with
> > models from legacy databases) I often use model_to_dict which is
> > "hidden" in django.forms.models.
>
>
>
> This is new for me. I've noticed before that django's API docs doesn't all
> function available. There's probably a good reason for it.
>
> What's the advantage of using model_to_dict against dict(some_queryset) ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: AW: Trouble overriding registration templates

2011-07-13 Thread Joshua Russo
Sorry, auto correct strikes again. I was trying to reply quickly from my 
phone. I meant auth, not author views. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/CoqBYvTqp8UJ.
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.



AW: Trouble overriding registration templates

2011-07-13 Thread Joshua Russo
I do have a views that are basically just proxies for the author views, but I 
was under the impression that if I just wanted to replace the registration 
templates then all I needed was a registration directory in my templates 
directory with the right file names. From there it should just take the first 
template it finds in the list of template directories in settings.

Where is the default login.html template? 

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



Re: Handling Efficiency issues

2011-07-13 Thread Lucian Nicolescu
Did you try updating multiple rows at once? see
https://docs.djangoproject.com/en/dev/topics/db/queries/#updating-multiple-objects-at-once
It is possible that in time the database will become slower depending
on your Message count but it will take some time.

Lucian

On Wed, Jul 13, 2011 at 1:11 PM, Amit Sethi  wrote:
> Hi all for some reason i am doing something like this
>  for i in Message.objects.all():
>        i.read_at = datetime.now()
>        i.save()
>
> now the number of Message instances are likely to increase by a lot
> with time . My question is is it likely that this code piece will
> become very slow over time. If yes how can handle this more
> efficiently
>
> --
> A-M-I-T S|S
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Duplicate Key Error in Cache

2011-07-13 Thread Andre Terra
And memcached isn't hard to setup at all!

Cheers,
André

On Tue, Jul 12, 2011 at 10:29 PM, Issac Kelly  wrote:

> I would guess your quickest way forward is to change backends, as it
> appears that this is a larger issue with database transactions between
> threads, which is a couple of years old.
>
> I've been tinkering with LocalMemCache for a really small site, and
> django-redis-cache as a toy, I know that some have used it in
> production, but I haven't, and adding another piece to your deployment
> isn't always a good idea.
>
> It's also possible that memcached is a good fit for what you're doing.
>
> On Jul 12, 12:09 pm, gamingdroid  wrote:
> > I ran into this problem using django core's database cache:
> >
> > ERROR:  duplicate key value violates unique constraint "cache_pkey"
> > STATEMENT:  INSERT INTO "cache" (cache_key, value, expires) VALUES (E':
> > 1:cms-menu_nodes_en-us_1', E'gAJdcQEoY21lbnVzLmJhc2UKTmF2aW
> > LOG:  server process (PID 8453) was terminated by signal 9: Killed
> > LOG:  terminating any other active server processes
> > LOG:  all server processes terminated; reinitializing
> > FATAL:  could not create shared memory segment: Cannot allocate memory
> > DETAIL:  Failed system call was shmget(key=5432001, size=29278208,
> > 03600).
> >
> > I looked in the table and sure enough, there is an entry for the key ':
> > 1:cms-menu_nodes_en-us_1'. I found a similar issue here (http://
> > stackoverflow.com/questions/1189541/django-cache-set-causing-duplicate-
> > key-error), but was unable to exactly understand what the issue is.
> >
> > Sounds like a bug in django core, since if a key exist, it should
> > update the record. It looks as if somebody posted a ticket here
> > (https://code.djangoproject.com/ticket/11569), but not entireloy sure
> > if it is related. This problem sort of renders the database backend
> > useless. I would fix it if I knew how and contribute back, but really
> > don't know how.
> >
> > Anyone have any ideas or suggestions?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Possible interest in a webcast/presentation about Django site with 40mil+ rows of data??

2011-07-13 Thread Andre Terra
Unfortunately, I'm on GMT-0300 and none of those timezones work for me.
Looking forward to the recorded version, though!

Cheers,
André

On Tue, Jul 12, 2011 at 10:48 AM, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:

> Hi all,
>
> Great response to this, 45 registered votes in total.
>
> The webcast will take place on Monday 29th August 2011 - (Minimum
> resolution 1920x1080)
>
> However, because the time zone results are almost split 50/50, I'm going to
> allow users to select from two time slots, if the results are still split
> 50/50, then I'll do both an afternoon and evening session.
>
> Please use this form to register your place.
>
> https://spreadsheets.google.com/a/foxwhisper.co.uk/spreadsheet/viewform?formkey=dENPX3BMUUFMbi1CbElwV3BvOEdkNmc6MQ
>
> Cal
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Handling Efficiency issues

2011-07-13 Thread Amit Sethi
Hi all for some reason i am doing something like this
 for i in Message.objects.all():
i.read_at = datetime.now()
i.save()

now the number of Message instances are likely to increase by a lot
with time . My question is is it likely that this code piece will
become very slow over time. If yes how can handle this more
efficiently

-- 
A-M-I-T S|S

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



Re: Possible interest in a webcast/presentation about Django site with 40mil+ rows of data??

2011-07-13 Thread AlexH
> If you're interested, please reply on-list so others can see.

Would be very interested in attending. Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/UMHxfgnxxkMJ.
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.



failed to run PROJ/manage.py in zip file

2011-07-13 Thread Robert Nie
Hi,

I would like to compress my DJANGO project into one zip file (all
*.pyo files) and then do basic testing and deploy. Now I found PROJ/
manage.py in zip file can not be invoked.

It seems it is caused by imp.find_module() failed to find the
'settings' module. The code looks like this,

>>> import sys
>>> sys.path.insert(0, 'bin/proj.zip')
>>> import imp
>>> imp.find_module('proj.settings')
Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named proj.settings
>>> imp.find_module('settings')
Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named settings

By comment out the lines about sanity checking on 'settings' file,
everything works fine. I can invoke 'runserver', 'shell' parameters
after adding proj.zip to sys.path.


Thanks,
Robert

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



Re: Simple example of custom user profile fields?

2011-07-13 Thread i...@webbricks.co.uk
read the paragraph on the AUTH_PROFILE_MODULE in james blog.
especially understand you're pointing it at a modelname, but that it
knows its a model

caught me out once upon a time and might be your issue.

Matt

On Jul 13, 3:57 am, Brent  wrote:
> Unfortunately, no matter what kind of path I put for
> AUTH_PROFILE_MODULE, the same error appears.
>
> On Jul 12, 5:51 pm, Andre Terra  wrote:
>
>
>
>
>
>
>
> > As the traceback helpfully states,
>
> > Exception Type: SiteProfileNotAvailable at /profile/Exception Value:
> > Unable to load the profile model, check AUTH_PROFILE_MODULE in your
> > project settings
>
> >http://www.google.com/search?=django+Unable+to+load+the+profile+mod...
>
> > check out the first result.
>
> > Cheers,
> > André
>
> > On Tue, Jul 12, 2011 at 8:09 PM, Brent  wrote:
> > > Good idea. Unfortunately, I tried that, but it results in a
> > > SiteProfileNotAvailable error:
>
> > >http://dpaste.com/567421/
>
> > > On Jul 12, 3:15 pm, Andre Terra  wrote:
> > > > Instead of using get or create, why not setting up a post_save signal
> > > > for the User model so that users always have a profile associated with
> > > > them?
>
> > > > Cheers,
> > > > Andre
>
> > > > On 7/12/11, Brent  wrote:
>
> > > > > Thanks for the help guys.
>
> > > > > Micky, that tutorial looks very good. I think I almost have it
> > > > > working. Just one more error:
>
> > > > >http://dpaste.com/567361/
>
> > > > > Andre, thanks for mentioning Pinax. I'll give it a shot if this
> > > > > doesn't work out. I have a year of python experience, but I haven't
> > > > > written anything web/database related.
>
> > > > > On Jul 12, 11:34 am, Micky Hulse  wrote:
> > > > >> This tutorial helped me:
>
> > > > >>http://www.turnkeylinux.org/blog/django-profile
>
> > > > >> Note: The above tutorial uses an FK to User model... The Django docs
> > > > >> suggest a OneToOne field.
>
> > > > >> Hope that helps.
>
> > > > >> Micky
>
> > > > > --
> > > > > 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.
>
> > > > --
> > > > Sent from my mobile device
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Django users" group.
> > > To post to this group, send email to django-users@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.

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



Re: Simple example of custom user profile fields?

2011-07-13 Thread i...@webbricks.co.uk
if i can extend the user model, anybody should be able to.
i followed james bennett example.
in fact most of the clever stuff i do came from his tuts

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

at this point, i'd suggest a clean virtualenv, with a single app,
single page no nonsense approach to just drop the django-registtration
and django-profiles apps in and get it working.

then go back and integrate it into your project once you know how it
works.

Matt

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



Efficiently querying db

2011-07-13 Thread Amit Sethi
I have a db that looks something like  this .

{ message : xyz
 parent : 23
 id : 25
}
 or
{ message : abc
parent : None
id : 25
}

{ message : cde
parent : 28
id : 32
}

{ message : lbq
parent : 23
id : 35
}

I want to make seperate the lists such that messages in same thread(
The parent message and its child messages } come together . What is
the best way to query the db or a efficient algorithm to do this.


-- 
A-M-I-T S|S

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



Re: Inspecting objects

2011-07-13 Thread Jonas Geiregat

Op 13-jul-2011, om 08:25 heeft Jirka Vejrazka het volgende geschreven:

>> Thank you all for your help!!!
> 
> I know I'm a bit late to the party (blame timezones :), but thought
> I'd put my 2 cents worth in :)
> 
> For inspecting models from command lines (usually when working with
> models from legacy databases) I often use model_to_dict which is
> "hidden" in django.forms.models.



This is new for me. I've noticed before that django's API docs doesn't all 
function available. There's probably a good reason for it.

What's the advantage of using model_to_dict against dict(some_queryset) ?

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



Re: Inspecting objects

2011-07-13 Thread Jonas Geiregat
I like to add:

import pdb; pdb.set_trace();

To my code.

Reload the page.

Go to the development server instance. You'll see that the page hangs forever 
,since we started the python debugger. 
Now you can easily inspect all variables, classes and functions from PDB. 
Of course you're not limited to using set_trace().

Good luck !


>> Thank you all for your help!!!
> 
> I know I'm a bit late to the party (blame timezones :), but thought
> I'd put my 2 cents worth in :)
> 
> For inspecting models from command lines (usually when working with
> models from legacy databases) I often use model_to_dict which is
> "hidden" in django.forms.models.
> 
 from django.forms.models import model_to_dict
 print model_to_dict(some_model)
> 
>  HTH
> 
> Jirka
> 
> -- 
> 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.
> 


Jonas Geiregat
jo...@geiregat.org





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



AW: Trouble overriding registration templates

2011-07-13 Thread Szabo, Patrick (LNG-VIE)
Did you write your own view for that purpose ?!

In that view you could use render_to_response and pass you own template
to that.

 

Von: django-users@googlegroups.com
[mailto:django-users@googlegroups.com] Im Auftrag von Joshua Russo
Gesendet: Mittwoch, 13. Juli 2011 04:24
An: django-users@googlegroups.com
Betreff: Trouble overriding registration templates

 

I want to use my own logout template but it doesn't want to pick it up.
The login template worked just fine, but for anything that's already in
the admin's template/registration folder, it only wants to use those. I
tried putting my templates folder before the admin templates folder in
the list of template folder in the settings file but that didn't do
anything. Any suggestions? 

-- 
You received this message because you are subscribed to the Google
Groups "Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/VcsTSOx1iSoJ.
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.


. . . . . . . . . . . . . . . . . . . . . . . . . .
Patrick Szabo
 XSLT Developer 
LexisNexis
Marxergasse 25, 1030 Wien

mailto:patrick.sz...@lexisnexis.at
Tel.: 00431 534521573 
Fax: +43 (1) 534 52 - 146 





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



Re: get all objects that are related to current, reverse look up

2011-07-13 Thread Jonas Geiregat

Op 12-jul-2011, om 09:18 heeft bruno desthuilliers het volgende geschreven:

> On Jul 12, 4:32 am, garagefan  wrote:
>> simply put, here's my code
>> 
>> class ContentBlock(Orderable, Displayable):
>>   location = models.ManyToManyField(ContentBlockLocation, blank=True,
>> null=True, help_text="list of locations to display content block")
>>   page = models.ManyToManyField(Page, blank=True, null=True,
>> help_text="list of pages to display content block")
>>   height = models.IntegerField(blank=True, null=True)
>>   width = models.IntegerField(blank=True, null=True)
>> 
>>   def __unicode__(self):
>> return self.title
>> 
>> class StaticContent(Displayable, RichText):
>>  content_block =  models.ForeignKey(ContentBlock, blank=True,
>> null=True)
>> 
>> class StaticContent2(Displayable, RichText):
>>  content_block =  models.ForeignKey(ContentBlock, blank=True,
>> null=True)
>> 
>> putting together a template tag that will return all the items
>> associated with a given ContentBlock, but i would like to do so
>> without knowing upfront all of the classes that have a foreign key to
>> ContentBlock as i'll want to be able to add more content types at any
>> time
> 
> 
> Are you sure your data model is right ?
> 

Displayable and RichText are probably classes that inherit from 
django.db.models.Model.




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



Re: Inspecting objects

2011-07-13 Thread Jirka Vejrazka
> Thank you all for your help!!!

I know I'm a bit late to the party (blame timezones :), but thought
I'd put my 2 cents worth in :)

For inspecting models from command lines (usually when working with
models from legacy databases) I often use model_to_dict which is
"hidden" in django.forms.models.

>>> from django.forms.models import model_to_dict
>>> print model_to_dict(some_model)

  HTH

 Jirka

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