Updating parent record, when child record changes

2011-12-06 Thread zobbo
I asked a similar question last week but got no responses - here's a
related but hopefully simpler question.

What is the recommended way to update a field on a parent record when
one or more of it's child records (held in inlines) are modified? I
could hook on post_save on the inlines, but if you have 50 inline you
only really want to do the processing at the end of the last inline
record to be saved.

I want to update a status field on the parent record, whose value will
vary depending on the child records.

Ian

-- 
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: slow function

2011-12-06 Thread Derek
On Dec 5, 12:18 pm, Håkon Erichsen  wrote:
> 2011/12/5 kenneth gonsalves 
>
>
> That seems to be the biggest problem you have. Some other comments:
>
> - Holy mother of god, that's a huge view file! I would advice to slice
> it into logically separated files, and put this in a directory called
> "views", everything doesn't have to be in views.py!
>
> - Put your forms in another file, like forms.py
>
> - If you're just checking if someone is logged in with
> @user_passes_test, why not just use @login_required?
>
> - Check out 
> render:https://docs.djangoproject.com/en/dev/topics/http/shortcuts/#render
>
> Best regards,
>
> Håkon Erichsen

Another side comment would be a suggestion to avoid "old skl vrbl nms"
- in other words, use "player" for "ply", "month" for "mnth", "scores"
for "scrs", "form" for "fm" and so on.  It may seem obvious right now
what those mean, but you (or someone else?) comes back in six months
or a year's time...  (I must admit to some small curiosity as to what
"dick" is an abbreviation for... I assume its "dictionary", in which
case a name more descriptive of the contents could be useful.)

-- 
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: slow function

2011-12-06 Thread kenneth gonsalves
On Tue, 2011-12-06 at 02:15 -0800, Derek wrote:
> Another side comment would be a suggestion to avoid "old skl vrbl nms"
> - in other words, use "player" for "ply", "month" for "mnth", "scores"
> for "scrs", "form" for "fm" and so on.  It may seem obvious right now
> what those mean, but you (or someone else?) comes back in six months
> or a year's time... 

'player', 'score' etc are names used in my models/fields, I was under
the impression that instances should bear the same name as the models so
I make similar names - although frankly I do not know where I got the
impression from and whether it is correct or not.

>  (I must admit to some small curiosity as to what
> "dick" is an abbreviation for... I assume its "dictionary", in which
> case a name more descriptive of the contents could be useful.) 

dictionary is right.
-- 
regards
Kenneth Gonsalves

-- 
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: New design for class-based views

2011-12-06 Thread Tobia Conforto
On Dec 5, 12:56 am, Russell Keith-Magee 
wrote:
> On Sun, Dec 4, 2011 at 12:43 PM, akaariai  wrote:
> > I don't know much about class based views, but I do know that their
> > design thread at django-developers was _very_ long. So, there might be
> > reason why things are done as they are.
>
> Indeed there were good reasons. The design decisions are documented here:
>
> https://code.djangoproject.com/wiki/ClassBasedViews

Thank you, I missed that overview.

I will go back to studying the arguments there and resurface when I
have a more solid proposal.

Tobia

-- 
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: slow function

2011-12-06 Thread kenneth gonsalves
On Mon, 2011-12-05 at 11:18 +0100, Håkon Erichsen wrote:
> One thing you should look into is
> QuerySet.select_related(): 
> https://docs.djangoproject.com/en/dev/ref/models/querysets/#select-related 
> 
> Without it, every time you run scr.hole on a new scr, Django will run
> a new query, fetching that 'hole' object. If you have 10 000 scores,
> that means 10 000 queries, which is an insane number for queries like
> this. If you use select_related, Django will fetch the corrosponding
> hole for you, in the same query... meaning 1 query, instead of 10
> 000 :) 
> 
> In other words, change this: 
> 
> scrs = Score.objects.all()
> 
> 
> pscrs = Pscore.objects.filter(hole__tee__course = club)
> 
> 
> To this: 
> 
> 
> 
> scrs = Score.objects.all().select_related('hole')
> 
> 
> pscrs = Pscore.objects.filter(hole__tee__course = club).select_related('hole')

I first did select_related() and the laptop nearly caught fire! timed
out after an hour or so. I then did select_related(depth=1) and it took
less than a minute.
> 
> 
> 
> 
> 
> That seems to be the biggest problem you have. Some other comments:
> 
> - Holy mother of god, that's a huge view file! I would advice to slice it 
> into logically separated files, and put this in a directory called "views", 
> everything doesn't have to be in views.py!
> 

there is a lot of duplicated code - a huge clean up is needed, but every
time I sit to do it, a new feature is needed, so it does not get done! 
> - Put your forms in another file, like forms.py

that is on the todo list.
> 
> - If you're just checking if someone is logged in with @user_passes_test, why 
> not just use @login_required?

this is legacy code - at the time it was written, login_required did not
do what I wanted, I need to review that.
> 
> - Check out render: 
> https://docs.djangoproject.com/en/dev/topics/http/shortcuts/#render
> 
> 

will do - thanks to all for taking the trouble of reading the code and
making suggestions.
-- 
regards
Kenneth Gonsalves

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



Internationalization and localization

2011-12-06 Thread rentgeeen
I have a question about internationalization -
https://docs.djangoproject.com/en/dev/topics/i18n/internationalization/

What I want to how to translate stuff from DB, all at django official
say is about static content, what I have only found is this:

http://packages.python.org/django-easymode/i18n/index.html

Easymode

I think there is more official way from Django no?

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.



Management commands inside namespaced packages not found

2011-12-06 Thread cberner
I've run into an issue with namespaced packages that are installed in
development mode.

I have two packages that are installed with pip in development mode
(pip install develop):
A.B.management.commands (code in ~/A.B/A/B/management/commands/) and
A.C.management.commands (~/A.C/A/C/management/commands)

A.B and A.C can be distributed separately via pip, and A is just a
namespace package (our company name, in my case).

The problem is that management commands in A.C aren't detected,
because manage.py relies on imp.find_module, and when installed in
development mode, setuptools uses egg-links (symlinks), which means
that find_module('A') returns the path to A.B (because it comes first
alphabetically), but not the path to A.C.

When the packages are installed (not in development mode) everything
works fine, because the packages are merged into the same directory
hierarchy in site-packages. Anyone have suggestions for fixing 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 E-Commerce Framework

2011-12-06 Thread Md,Mehedi Hasan Kabir(Tanim)
Hi

Can anyone give me some suggestion/link for Django E-Commerce Framework?

Regards
Tanim

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



filtering on a model method

2011-12-06 Thread kenneth gonsalves
hi,

say I have a model method like get_age(self), can I filter on this?

Mymodel.objects.filter(get_age() = 5) (this does not work, but any ideas
would be appreciated)
-- 
regards
Kenneth Gonsalves

-- 
regards
Kenneth Gonsalves

-- 
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: New design for class-based views

2011-12-06 Thread Tobia Conforto
On Dec 5, 6:37 pm, Reinout van Rees  wrote:> That
link will expire in a month, so that's not really suited to posting>
on a mailinglist that people might still read a month from now.
You're right. Here is another link: http://pastebin.com/w7u74AJ7
On Dec 5, 4:07 pm, sebastien piquemal  wrote:
> Could you post a link to a place where class-based views are being
> criticized ? And also in what sense are they convoluted ?

I chanced on many places, on the list, in the issues, and over the
web, where people expressed confusion over the current design of class-
based views. Here is one such place: https://code.djangoproject.com/ticket/13879
This ticket documents a missing feature (the issue of decorators with
arguments I outlined in my first post) but the current state is so
convoluted that it was left marked as Design decision needed, for lack
of a clear way out of the mess.

The complexity is inherent in the design decision that was made about
class-based views. I won't go into detail here, because I still need
to read up the references on the link posted by Russell. But it seems
the design that was chosen violates at least one of the original
requirements, "Ease of decoration."

I believe my design (which is basically this
https://code.djangoproject.com/wiki/ClassBasedViews#__new__ ) is the
correct solution, but I'll make sure to review past discussions and
post a better argument when I'm ready, including an implementation
passing the current test case. The devil must be in the details.

Tobia

-- 
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: Query with no-correspondence results

2011-12-06 Thread Reinout van Rees

On 06-12-11 06:43, wgis wrote:

But then I would have something like
(Carrots, Flavor,2.0)
as the result

instead of the desired

(Carrots, Flavour, 2.0)
(Carrots, Smell, 0.0)
(Carrots, Usability, 0.0)
(Carrots, Size, 0.0)


That's the same, right? At least,

Vote.objects.filter(thing=carrot).values_list('thing', 'context', 'vote)

should return a list of those lists.


What do you get with a plain Vote.objects.filter(thing=carrot) ?



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: Template filter with multiple non-string arguments?

2011-12-06 Thread Reinout van Rees

On 06-12-11 02:05, Nan wrote:

So, yes, I know one can combine template filter arguments by quoting
them into a single concatenated string...  But what if one needs to do
something that amounts to the following?

{% for object in object_list %}
 {{ some_other_var|custom_filter(constant_string, object.field)|
some_other_filter|etc }}
{% endfor %}

Obviously one can't within the loop convert the argument list into a
string.  Is there any workaround for this that isn't horribly ugly?


Sounds like your best bet is to try and do it in your Python view code 
instead of in your template.



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: Management commands inside namespaced packages not found

2011-12-06 Thread Reinout van Rees

On 06-12-11 06:34, cberner wrote:

I've run into an issue with namespaced packages that are installed in
development mode.

I have two packages that are installed with pip in development mode
(pip install develop):
A.B.management.commands (code in ~/A.B/A/B/management/commands/) and
A.C.management.commands (~/A.C/A/C/management/commands)

A.B and A.C can be distributed separately via pip, and A is just a
namespace package (our company name, in my case).

The problem is that management commands in A.C aren't detected,
because manage.py relies on imp.find_module, and when installed in
development mode, setuptools uses egg-links (symlinks), which means
that find_module('A') returns the path to A.B (because it comes first
alphabetically), but not the path to A.C.

When the packages are installed (not in development mode) everything
works fine, because the packages are merged into the same directory
hierarchy in site-packages. Anyone have suggestions for fixing this?


Django doesn't really like namespace packages. The problem is with the 
applications in the INSTALLED_APPS list. Did you add 'A' in there? Then 
it is logical that it only finds one of the two.


You ought to add both 'B' and 'C' in the INSTALLED_APPS list.


For my, this defeats the purpose of namespace packages a bit. I was used 
myself to companyname.product packages, but in Django I've switched to 
packages named companyname-product (with a dash) and modules named 
companyname_product (with an underscore).


- You still have the companyname prefix.

- You get the full "companyname_product" in INSTALLED_APPS.

- You visually see the difference between the package dir and the python 
module dir.




Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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 E-Commerce Framework

2011-12-06 Thread Reinout van Rees

On 06-12-11 06:40, Md,Mehedi Hasan Kabir(Tanim) wrote:


Can anyone give me some suggestion/link for Django E-Commerce Framework?


No personal experience, but the one I see mentioned most often: django 
lightning fast shop. http://www.getlfs.com/



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: filtering on a model method

2011-12-06 Thread Tom Evans
On Tue, Dec 6, 2011 at 7:09 AM, kenneth gonsalves
 wrote:
> hi,
>
> say I have a model method like get_age(self), can I filter on this?
>
> Mymodel.objects.filter(get_age() = 5) (this does not work, but any ideas
> would be appreciated)

You can't do this. Querysets are interfaces to the database, so all
filtering must be on attributes present or computable in the database.
Presumably age is calculated from something in the database?

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.



Re: Django E-Commerce Framework

2011-12-06 Thread Daniel Cure V.
Hello people.

You can try with Satchmo .Its a very robust
framework.



Daniel Cure Velasquez

-- 
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 E-Commerce Framework

2011-12-06 Thread Andre Terra
I haven't worked with either one of them, but satchmo[1] is also often
mentioned.

Django packages also has a list of e-commerce tools for django [2].

Hope that helps!


Cheers,
AT


[1] http://www.satchmoproject.com/
[2] http://djangopackages.com/grids/g/ecommerce/



On Tue, Dec 6, 2011 at 10:55 AM, Reinout van Rees wrote:

> On 06-12-11 06:40, Md,Mehedi Hasan Kabir(Tanim) wrote:
>
>>
>> Can anyone give me some suggestion/link for Django E-Commerce Framework?
>>
>
> No personal experience, but the one I see mentioned most often: django
> lightning fast shop. http://www.getlfs.com/
>
>
> Reinout
>
> --
> Reinout van Reeshttp://reinout.vanrees.org/
> rein...@vanrees.org 
> http://www.nelen-schuurmans.**nl/
> "If you're not sure what to do, make something. -- Paul Graham"
>
>
> --
> 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: slow function

2011-12-06 Thread Håkon Erichsen
2011/12/6 kenneth gonsalves 

>
> I first did select_related() and the laptop nearly caught fire! timed
> out after an hour or so. I then did select_related(depth=1) and it took
> less than a minute.
>

Indeed, select_related() will follow every foreignkey it gets to, which can
be a lot, so you either have to specify a field like I did ('hole'), or a
depth. Glad it worked!


> there is a lot of duplicated code - a huge clean up is needed, but every
> time I sit to do it, a new feature is needed, so it does not get done!
>

Ah, the usual plague. Nothing is as permanent as a hack that works ;)

will do - thanks to all for taking the trouble of reading the code and
> making suggestions.


It was just some thoughts after a quick scan, not really any trouble.
Actually, I should be sorry for the unsolicited advice, I'm glad you took
it the right way! ;)

Best regards
Håkon Erichsen

-- 
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: Performance

2011-12-06 Thread Felipe Morales
No, when you use the select_related method, the query that generated is:

SELECT * FROM tablename
 INNER JOIN tablename2 ON (tablename.field = tablename2.field)
 
 WHERE 

The problem is when you have a null value in a field that is foreing key.

You'll can try to fix this or you'll can set foreing key fields name
manually as a list:

queryset = Model.objects.filter().select_related(fields=['field', 'field2'])

the main idea is exclude fields that contains null values. Probably this
will produce more than one query.

apologies, my english is quite bad


2011/12/6 Szabo, Patrick (LNG-VIE) 

>  Okay it seems that specifying which Foreign-Keys it should follow solves
> the problem. 
>
> Is this a known issue and can I be sure that this won’t cause any further
> trouble !?
>
> ** **
>
>  . . . . . . . . . . . . . . . . . . . . . . . . . .
>
>  **
>
> Ing. Patrick Szabo
> XSLT Developer
>
> LexisNexis
> Marxergasse 25, 1030 Wien
>
> patrick.sz...@lexisnexis.at
>
> Tel.: 00431 534521573
>
> Fax: +43 (1) 534 52 - 146
>
>
> *Von:* django-users@googlegroups.com [mailto:django-users@googlegroups.com]
> *Im Auftrag von *Szabo, Patrick (LNG-VIE)
> *Gesendet:* Dienstag, 06. Dezember 2011 08:29
> *An:* django-users@googlegroups.com
> *Betreff:* AW: AW: Performance
>
> ** **
>
> Thank you, i could cut my queries in half which brings almost a second J**
> **
>
> Unfortunately the function seems to effect the results.
>
> ** **
>
> If I run the query with select_related() I get 151 objects. 
>
> Without select_related() I get 199. 
>
> ** **
>
> Is there something I can to to overcome this ?!
>
> ** **
>
> *Von:* django-users@googlegroups.com [mailto:django-users@googlegroups.com]
> *Im Auftrag von *Felipe Morales
> *Gesendet:* Montag, 05. Dezember 2011 17:50
> *An:* django-users@googlegroups.com
> *Betreff:* Re: AW: Performance
>
> ** **
>
> Patrick, 
>
> ** **
>
> try to use select_related() method instead of only filter() when you get a
> list of elements, e.g. :
>
> ** **
>
> queryset = Model.objects.filter().select_related()
>
> ** **
>
> by this way you'll get only one query instead 800
>
> ** **
>
> good luck!
>
> ** **
>
> Felipe
>
> 2011/12/5 Nikolas Stevenson-Molnar 
>
> It would help to know a little more about your code here. Could you give
> some examples?
>
> ** **
>
> _NIk
>
> ** **
>
> On Dec 5, 2011, at 3:18 AM, Szabo, Patrick (LNG-VIE) wrote:
>
> ** **
>
> Okay that toolbar is really useful and also looks kind of nice J…Thanks
> for that.
>
> I’ve already found the problem….somehow my app triggers 800 queries just
> for a simple page.
>
> Can I somehow find out which part of my code is causing those queries ?!**
> **
>
>  
>
> patrick
>
>  
>
> ** **
>
> . . . . . . . . . . . . . . . . . . . . . . . . . .
>
> Ing. Patrick Szabo
> XSLT Developer
>
> LexisNexis
> Marxergasse 25, 1030 Wien
>
> patrick.sz...@lexisnexis.at
>
> Tel.: 00431 534521573
>
> Fax: +43 (1) 534 52 - 146
>
> ** **
>
> *Von:* django-users@googlegroups.com [mailto:django-users@googlegroups.com
> ] *Im Auftrag von *Nikolas Stevenson-Molnar
> *Gesendet:* Montag, 05. Dezember 2011 08:14
> *An:* Nikolas Stevenson-Molnar
> *Cc:* django-users@googlegroups.com
> *Betreff:* Re: Performance
>
>  
>
> A bit more searching turned up something even better... looks like the
> Django folks address this directly:
> https://code.djangoproject.com/wiki/ProfilingDjango
>
>  
>
> _Nik
>
>  
>
> On Dec 4, 2011, at 11:03 PM, Nikolas Stevenson-Molnar wrote:
>
> ** **
>
> I haven't done this myself, but I would assume you could use the Python
> profiler. Here's one project that facilitates profiling a WSGI app
> (assuming you're using Django via WSGI): http://repoze.org/
>
>  
>
> Others here may have more experience with profiling web apps.
>
>  
>
> _Nik
>
>  
>
> On Dec 4, 2011, at 10:55 PM, Szabo, Patrick (LNG-VIE) wrote:
>
> ** **
>
> Hi,
>
>  
>
> In the last couple of weeks my app has become quite slowly and I’m
> wondering why that is.
>
> Are there any debugging tools where I can see what takes how much time ?**
> **
>
>  
>
> cheers
>
>  
>
> . . . . . . . . . . . . . . . . . . . . . . . . . .
>
> Ing. 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 sub

Re: Internationalization and localization

2011-12-06 Thread Andres Reyes
At the moment i don't know of any official support for that kind of
internationalization from Django, there are a number of different Packages
that try to address the problem with some level of success. In one project
of mine i used the approach described in
http://snippets.dzone.com/posts/show/2979 . You must remember however that
in the end Django Models are only a representation of the data in your
database, you can design you database to handle multiple languages just as
you would wth PHP or any other framework.



2011/12/5 rentgeeen 

> I have a question about internationalization -
> https://docs.djangoproject.com/en/dev/topics/i18n/internationalization/
>
> What I want to how to translate stuff from DB, all at django official
> say is about static content, what I have only found is this:
>
> http://packages.python.org/django-easymode/i18n/index.html
>
> Easymode
>
> I think there is more official way from Django no?
>
> 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.
>
>


-- 
Andrés Reyes Monge
armo...@gmail.com
+(505)-8873-7217

-- 
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: Conditional choice fields for model specification...

2011-12-06 Thread Derek
On Dec 5, 11:06 pm, Marc Edwards  wrote:
> I would like to create my choice fields in my models according to a
> hierarchy of conditions, but I can't think of how to specify this in
> Python.

Marc

You'd need to do this using Javascript/AJAX, in the browser.  Your
model definition would contain all the possible choices and you'd
filter these to the user accordingly.  There have been many many posts
to this list (as well as many blog entries) all detailing possible
routes you can take.

HTH
Derek

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



help optimizing a snippet

2011-12-06 Thread Szabo, Patrick (LNG-VIE)
Hi, 

 

I'v got this piece of code:

 

def get_my_choices(gruppe):

users = User.objects.all()

choices_list = ()

for user in users:

try:

for groupe in gruppe:

for groupe2 in user.groups.all():

if groupe2 == groupe and (user.id,user) not in
choices_list and groupe2.name not in
['Timesheet-Boss','TimeSheet-Manager','Projektleiter','Normal-User','Man
ager']:

choices_list += ((user.id,user),)


except:

pass

return choices_list

 

The parameter is the result of a user.groups.all() call. 

This function causes over db-queries and I was wondering if anyone sees
a way of optimizing that a little bit. 

I was playing around with values_list() but couldn't get it working.

 

Any ideas ?

 

regards 


. . . . . . . . . . . . . . . . . . . . . . . . . .
Ing. 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: AW: Performance

2011-12-06 Thread Felipe Morales
Sorry, I was wrong, the sintax is:

queryset = Model.objects.filter().select_related('field', 'field2')

2011/12/6 Felipe Morales 

> No, when you use the select_related method, the query that generated is:
>
> SELECT * FROM tablename
>  INNER JOIN tablename2 ON (tablename.field = tablename2.field)
>  
>  WHERE 
>
> The problem is when you have a null value in a field that is foreing key.
>
> You'll can try to fix this or you'll can set foreing key fields name
> manually as a list:
>
> queryset = Model.objects.filter().select_related(fields=['field',
> 'field2'])
>
> the main idea is exclude fields that contains null values. Probably this
> will produce more than one query.
>
> apologies, my english is quite bad
>
>
> 2011/12/6 Szabo, Patrick (LNG-VIE) 
>
>  Okay it seems that specifying which Foreign-Keys it should follow solves
>> the problem. 
>>
>> Is this a known issue and can I be sure that this won’t cause any further
>> trouble !?
>>
>> ** **
>>
>>  . . . . . . . . . . . . . . . . . . . . . . . . . .
>>
>>  **
>>
>> Ing. Patrick Szabo
>> XSLT Developer
>>
>> LexisNexis
>> Marxergasse 25, 1030 Wien
>>
>> patrick.sz...@lexisnexis.at
>>
>> Tel.: 00431 534521573
>>
>> Fax: +43 (1) 534 52 - 146
>>
>>
>> *Von:* django-users@googlegroups.com [mailto:
>> django-users@googlegroups.com] *Im Auftrag von *Szabo, Patrick (LNG-VIE)
>> *Gesendet:* Dienstag, 06. Dezember 2011 08:29
>> *An:* django-users@googlegroups.com
>> *Betreff:* AW: AW: Performance
>>
>> ** **
>>
>> Thank you, i could cut my queries in half which brings almost a second J*
>> ***
>>
>> Unfortunately the function seems to effect the results.
>>
>> ** **
>>
>> If I run the query with select_related() I get 151 objects. 
>>
>> Without select_related() I get 199. 
>>
>> ** **
>>
>> Is there something I can to to overcome this ?!
>>
>> ** **
>>
>> *Von:* django-users@googlegroups.com [mailto:
>> django-users@googlegroups.com] *Im Auftrag von *Felipe Morales
>> *Gesendet:* Montag, 05. Dezember 2011 17:50
>> *An:* django-users@googlegroups.com
>> *Betreff:* Re: AW: Performance
>>
>> ** **
>>
>> Patrick, 
>>
>> ** **
>>
>> try to use select_related() method instead of only filter() when you get
>> a list of elements, e.g. :
>>
>> ** **
>>
>> queryset = Model.objects.filter().select_related()
>>
>> ** **
>>
>> by this way you'll get only one query instead 800
>>
>> ** **
>>
>> good luck!
>>
>> ** **
>>
>> Felipe
>>
>> 2011/12/5 Nikolas Stevenson-Molnar 
>>
>> It would help to know a little more about your code here. Could you give
>> some examples?
>>
>> ** **
>>
>> _NIk
>>
>> ** **
>>
>> On Dec 5, 2011, at 3:18 AM, Szabo, Patrick (LNG-VIE) wrote:
>>
>> ** **
>>
>> Okay that toolbar is really useful and also looks kind of nice J…Thanks
>> for that.
>>
>> I’ve already found the problem….somehow my app triggers 800 queries just
>> for a simple page.
>>
>> Can I somehow find out which part of my code is causing those queries ?!*
>> ***
>>
>>  
>>
>> patrick
>>
>>  
>>
>> ** **
>>
>> . . . . . . . . . . . . . . . . . . . . . . . . . .
>>
>> Ing. Patrick Szabo
>> XSLT Developer
>>
>> LexisNexis
>> Marxergasse 25, 1030 Wien
>>
>> patrick.sz...@lexisnexis.at
>>
>> Tel.: 00431 534521573
>>
>> Fax: +43 (1) 534 52 - 146
>>
>> ** **
>>
>> *Von:* django-users@googlegroups.com [mailto:
>> django-users@googlegroups.com] *Im Auftrag von *Nikolas Stevenson-Molnar
>> *Gesendet:* Montag, 05. Dezember 2011 08:14
>> *An:* Nikolas Stevenson-Molnar
>> *Cc:* django-users@googlegroups.com
>> *Betreff:* Re: Performance
>>
>>  
>>
>> A bit more searching turned up something even better... looks like the
>> Django folks address this directly:
>> https://code.djangoproject.com/wiki/ProfilingDjango
>>
>>  
>>
>> _Nik
>>
>>  
>>
>> On Dec 4, 2011, at 11:03 PM, Nikolas Stevenson-Molnar wrote:
>>
>> ** **
>>
>> I haven't done this myself, but I would assume you could use the Python
>> profiler. Here's one project that facilitates profiling a WSGI app
>> (assuming you're using Django via WSGI): http://repoze.org/
>>
>>  
>>
>> Others here may have more experience with profiling web apps.
>>
>>  
>>
>> _Nik
>>
>>  
>>
>> On Dec 4, 2011, at 10:55 PM, Szabo, Patrick (LNG-VIE) wrote:
>>
>> ** **
>>
>> Hi,
>>
>>  
>>
>> In the last couple of weeks my app has become quite slowly and I’m
>> wondering why that is.
>>
>> Are there any debugging tools where I can see what takes how much time ?*
>> ***
>>
>>  
>>
>> cheers
>>
>>  
>>
>> . . . . . . . . . . . . . . . . . . . . . . . . . .
>>
>> Ing. 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 t

Re: Django E-Commerce Framework

2011-12-06 Thread CrabbyPete
Roll your own and use packages like django-authorize and django-paypal
they are easy to use and don't bring along lots of baggage.

On Dec 6, 8:19 am, Andre Terra  wrote:
> I haven't worked with either one of them, but satchmo[1] is also often
> mentioned.
>
> Django packages also has a list of e-commerce tools for django [2].
>
> Hope that helps!
>
> Cheers,
> AT
>
> [1]http://www.satchmoproject.com/
> [2]http://djangopackages.com/grids/g/ecommerce/
>
> On Tue, Dec 6, 2011 at 10:55 AM, Reinout van Rees wrote:
>
>
>
>
>
>
>
> > On 06-12-11 06:40, Md,Mehedi Hasan Kabir(Tanim) wrote:
>
> >> Can anyone give me some suggestion/link for Django E-Commerce Framework?
>
> > No personal experience, but the one I see mentioned most often: django
> > lightning fast shop.http://www.getlfs.com/
>
> > Reinout
>
> > --
> > Reinout van Rees                    http://reinout.vanrees.org/
> > rein...@vanrees.org            
> > http://www.nelen-schuurmans.**nl/
> > "If you're not sure what to do, make something. -- Paul Graham"
>
> > --
> > 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 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: One from from multiple models using ModelForm

2011-12-06 Thread CrabbyPete
That is to bad. I have a project that I use mongodb and mongotools and
I can do the following with one form and it works great. I wonder if
any other form tools can do it

class UserForm ( MongoForm ):
class Meta:
document = User
fields = ('first_name','last_name')


class ProfileForm ( UserForm ):
class Meta(UserForm.Meta):
document = Profile

On Dec 4, 11:56 am, akaariai  wrote:
> On Dec 4, 6:05 pm,CrabbyPete wrote:
>
>
>
>
>
>
>
>
>
> > I wanted to combine two models into one form so I created the
> > following
>
> > class UserForm( ModelForm ):
> >     class Meta:
> >         model = User
> >         fields = ('email','first_name','last_name')
>
> > class ProfileForm( ModelForm ):
> >     class Meta:
> >         model = Profile
>
> > class UserProfile ( UserForm, ProfileForm )
> >      class Meta( UserForm.Meta, ProfileForm.Meta)
> >           exclude = ('user',)
>
> > It only inherits UserForm
>
> > Is there a way to create one form using 2 modelform or to have
> > ProfileForm inherit from UserForm and add
> > Profile form data. Something like this
>
> I don't think that is possible.
>
> You will need to use both forms separately, and if you need combined
> validation or something like that, then do that in your view code. You
> can create a wrapper class which behaves mostly like a form, but
> delegates the actions to the two underlying forms. (eg is_valid():
> return form1.is_valid() and form2.is_valid()). Making it behave
> exactly like a single form will be hard.
>
>  - Anssi

-- 
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: How to deploy new code to the Production Server?

2011-12-06 Thread Kevin Daum
I use pip and virtualenv for reproducible environments, nginx and
gunicorn as production web servers, init.d scripts (on debian) for
managing gunicorn (and just about everything other important process
on the server), mercurial for source control and fabric for
deployment. I keep all files necessary for deployment in the project
directory (and therefore in source control) so that they stay
together. This includes templates for nginx configuration and the init
script, since I use fabric for both initial deployment and all
subsequent updates.

I have three separate settings files for deployment, test, and
production. They don't import from each other yet, but that would be
much better (thanks John). Fabric symlinks settings.py to whichever
one is appropriate for the environment.

My fabric file has separate functions for test and production which
just set some fabric environment variables (domain, IP, etc.).

This setup has worked well thus far. In the future I'd like to have
the settings, fabfiles, nginx and init script templates all import
common settings from some central place.

-- 
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: help optimizing a snippet

2011-12-06 Thread Tom Evans
On Tue, Dec 6, 2011 at 1:42 PM, Szabo, Patrick (LNG-VIE)
 wrote:
> Hi,
>
>
>
> I’v got this piece of code:
>
>
>
> def get_my_choices(gruppe):
>
>     users = User.objects.all()
>
>     choices_list = ()
>
>     for user in users:
>
>     try:
>
>     for groupe in gruppe:
>
>     for groupe2 in user.groups.all():
>
>     if groupe2 == groupe and (user.id,user) not in
> choices_list and groupe2.name not in
> ['Timesheet-Boss','TimeSheet-Manager','Projektleiter','Normal-User','Manager']:
>
>     choices_list += ((user.id,user),)
>
> except:
>
>     pass
>
>     return choices_list
>
>
>
> The parameter is the result of a user.groups.all() call.
>
> This function causes over db-queries and I was wondering if anyone sees a
> way of optimizing that a little bit.
>
> I was playing around with values_list() but couldn’t get it working.
>

If gruppe is a queryset, then isn't this equivalent:

def get_my_choices(groups):
bad_group_names = [ 'blah', 'wibble' ]
grps = groups.exclude(name__in=bad_group_names)
qs = User.objects.filter(groups__in=grps)
return [ (user.id, user) for user in qs ]

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.



Re: help optimizing a snippet

2011-12-06 Thread Felipe Morales
Hi,

Maybe I can't understand you, but try with

u = User.objects.filter(groups__name__in = gruppe).exclude(groups__name__in=
*'Timesheet-Boss'*,*'TimeSheet-Manager'*,*'Projektleiter'*,*'Normal-User'*,*
'Manager'*]).values_list('id', 'username')

2011/12/6 Szabo, Patrick (LNG-VIE) 

>  Hi, 
>
> ** **
>
> I’v got this piece of code:
>
> ** **
>
> def *get_my_choices*(gruppe):
>
> users = User.objects.all()
>
> choices_list = ()
>
> for user in users:
>
> try:
>
> for groupe in gruppe:
>
> for groupe2 in user.groups.all():
>
> if groupe2 == groupe and (user.id,user) not inchoices_list
> and groupe2.name not in [*'Timesheet-Boss'*,*'TimeSheet-Manager'*,*
> 'Projektleiter'*,*'Normal-User'*,*'Manager'*]:
>
> choices_list += ((user.id,user),)*
> ***
>
> except:
>
> pass
>
> return choices_list
>
> ** **
>
> The parameter is the result of a user.groups.all() call. 
>
> This function causes over db-queries and I was wondering if anyone sees a
> way of optimizing that a little bit. 
>
> I was playing around with values_list() but couldn’t get it working.
>
> ** **
>
> Any ideas ?
>
> ** **
>
> regards 
>
>  . . . . . . . . . . . . . . . . . . . . . . . . . .
>
>  **
>
> Ing. 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.
>



-- 
Felipe Morales C.
Ingenierío de Ejecución en Computación e Informática.

-- 
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: Template filter with multiple non-string arguments?

2011-12-06 Thread Nan

This is actually one case where that probably won't work --
some_other_var is a dict that needs a specific key set to
object.field's value on each run through the loop, and it seems
ridiculous to make a copy of it for each object in object_list.

I think the only solution is going to be a big fancy template tag to
update the context -- although that seems like overkill.  Does the
ticket [1] relating to this need a design decision or just a patch?

[1] https://code.djangoproject.com/ticket/1199


On Dec 6, 7:49 am, Reinout van Rees  wrote:
> On 06-12-11 02:05, Nan wrote:
>
> > So, yes, I know one can combine template filter arguments by quoting
> > them into a single concatenated string...  But what if one needs to do
> > something that amounts to the following?
>
> > {% for object in object_list %}
> >      {{ some_other_var|custom_filter(constant_string, object.field)|
> > some_other_filter|etc }}
> > {% endfor %}
>
> > Obviously one can't within the loop convert the argument list into a
> > string.  Is there any workaround for this that isn't horribly ugly?
>
> Sounds like your best bet is to try and do it in your Python view code
> instead of in your template.
>
> Reinout
>
> --
> Reinout van Rees                    http://reinout.vanrees.org/
> rein...@vanrees.org            http://www.nelen-schuurmans.nl/
> "If you're not sure what to do, make something. -- Paul Graham"

-- 
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: help optimizing a snippet

2011-12-06 Thread Szabo, Patrick (LNG-VIE)
Amazing12 queries left and that's hell of a lot faster J

 

Thank you guys !

 

Von: django-users@googlegroups.com [mailto:django-users@googlegroups.com] Im 
Auftrag von Felipe Morales
Gesendet: Dienstag, 06. Dezember 2011 15:24
An: django-users@googlegroups.com
Betreff: Re: help optimizing a snippet

 

Hi, 

 

Maybe I can't understand you, but try with

 

u = User.objects.filter(groups__name__in = 
gruppe).exclude(groups__name__in='Timesheet-Boss','TimeSheet-Manager','Projektleiter','Normal-User','Manager']).values_list('id',
 'username')

 

2011/12/6 Szabo, Patrick (LNG-VIE) 

Hi, 

 

I'v got this piece of code:

 

def get_my_choices(gruppe):

users = User.objects.all()

choices_list = ()

for user in users:

try:

for groupe in gruppe:

for groupe2 in user.groups.all():

if groupe2 == groupe and (user.id,user) not in choices_list 
and groupe2.name not in 
['Timesheet-Boss','TimeSheet-Manager','Projektleiter','Normal-User','Manager']:

choices_list += ((user.id,user),)

except:

pass

return choices_list

 

The parameter is the result of a user.groups.all() call. 

This function causes over db-queries and I was wondering if anyone sees a way 
of optimizing that a little bit. 

I was playing around with values_list() but couldn't get it working.

 

Any ideas ?

 

regards 

. . . . . . . . . . . . . . . . . . . . . . . . . .

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





 

-- 
Felipe Morales C.
Ingenierío de Ejecución en Computación e Informática.

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


. . . . . . . . . . . . . . . . . . . . . . . . . .
Ing. 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: help optimizing a snippet

2011-12-06 Thread Tom Evans
On Tue, Dec 6, 2011 at 2:24 PM, Felipe Morales  wrote:
> Hi,
>
> Maybe I can't understand you, but try with
>
> u = User.objects.filter(groups__name__in =
> gruppe).exclude(groups__name__in='Timesheet-Boss','TimeSheet-Manager','Projektleiter','Normal-User','Manager']).values_list('id',
> 'username')
>

That won't return the same results, it will exclude users who have a
group with one of the proscribed names, but are also in another group
that is not, which the original code did not do.

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.



Is there a model to allow Django to insert or append records in the TabularInline style to the main table?

2011-12-06 Thread vfclists
Following the style of the Django tutorial I want to add records in
the TabularInline style on the main table, not in the master/detail
style used in the tutorial.

The ideal approach would be to have a list_display and specify how
many empty rows should be inserted or appended to the list when you
click to add records.

Is there a way to accomplish this in Django? I am starting on 1.3

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



many-to-many queryset question

2011-12-06 Thread Carsten Fuchs

Hi all,

looking at the example models Author and Entry at 
https://docs.djangoproject.com/en/1.3/topics/db/queries/, I would like 
to run a query like this:


SetOfAuthors = Authors.objects.filter(...)
qs = Entry.objects.filter(authors__in=SetOfAuthors)

such that (pseudo-code):

for e in qs:
"e.authors is a subset of (or equal to) SetOfAuthors"

However, when I try it, the true result seems to be an intersection:

for e in qs:
		"There is (at least one) an author in e.authors that is also in 
SetOfAuthors"



How do I have to phrase the query in order to obtain only entries whose 
authors are all in SetOfAuthors?


Best regards,
Carsten



--
   Cafu - the open-source Game and Graphics Engine
for multiplayer, cross-platform, real-time 3D Action
  Learn more at http://www.cafu.de

--
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: many-to-many queryset question

2011-12-06 Thread Felipe Morales
could you possibly show the query generated?...

# print qs.query

2011/12/6 Carsten Fuchs 

> Hi all,
>
> looking at the example models Author and Entry at
> https://docs.djangoproject.**com/en/1.3/topics/db/queries/,
> I would like to run a query like this:
>
>SetOfAuthors = Authors.objects.filter(...)
>qs = Entry.objects.filter(authors__**in=SetOfAuthors)
>
> such that (pseudo-code):
>
>for e in qs:
>"e.authors is a subset of (or equal to) SetOfAuthors"
>
> However, when I try it, the true result seems to be an intersection:
>
>for e in qs:
>"There is (at least one) an author in e.authors that is
> also in SetOfAuthors"
>
>
> How do I have to phrase the query in order to obtain only entries whose
> authors are all in SetOfAuthors?
>
> Best regards,
> Carsten
>
>
>
> --
>   Cafu - the open-source Game and Graphics Engine
> for multiplayer, cross-platform, real-time 3D Action
>  Learn more at http://www.cafu.de
>
> --
> 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
> .
>
>


-- 
Felipe Morales C.
Ingenierío de Ejecución en Computación e Informática.

-- 
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 E-Commerce Framework

2011-12-06 Thread Denhua
Hi Pete,

Do you mean django-authorizenet?
I can't find a django-authorize.

Thanks,
Dennis

On Dec 6, 9:04 am, CrabbyPete  wrote:
> Roll your own and use packages like django-authorize and django-paypal
> they are easy to use and don't bring along lots of baggage.
>
> On Dec 6, 8:19 am, Andre Terra  wrote:
>
>
>
>
>
>
>
> > I haven't worked with either one of them, but satchmo[1] is also often
> > mentioned.
>
> > Django packages also has a list of e-commerce tools for django [2].
>
> > Hope that helps!
>
> > Cheers,
> > AT
>
> > [1]http://www.satchmoproject.com/
> > [2]http://djangopackages.com/grids/g/ecommerce/
>
> > On Tue, Dec 6, 2011 at 10:55 AM, Reinout van Rees 
> > wrote:
>
> > > On 06-12-11 06:40, Md,Mehedi Hasan Kabir(Tanim) wrote:
>
> > >> Can anyone give me some suggestion/link for Django E-Commerce Framework?
>
> > > No personal experience, but the one I see mentioned most often: django
> > > lightning fast shop.http://www.getlfs.com/
>
> > > Reinout
>
> > > --
> > > Reinout van Rees                    http://reinout.vanrees.org/
> > > rein...@vanrees.org            
> > > http://www.nelen-schuurmans.**nl/
> > > "If you're not sure what to do, make something. -- Paul Graham"
>
> > > --
> > > 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 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: Query with no-correspondence results

2011-12-06 Thread wgis
I get
(Carrots, Flavor,2.0)

I want to list all the contexts in the "Carrot template", withou
having to search and merge the ones missing.
So if the result was

(Carrots, Flavour, 2.0)
(Carrots, Smell, 0.0)
(Carrots, Usability, 0.0)
(Carrots, Size, 0.0)
or
(Carrots, Flavour, 2.0)
(Carrots, Smell, null)
(Carrots, Usability, null)
(Carrots, Size, null)

I could just list them, without further querying.

On 6 Dez, 12:46, Reinout van Rees  wrote:
> On 06-12-11 06:43, wgis wrote:
>
> > But then I would have something like
> > (Carrots, Flavor,2.0)
> > as the result
>
> > instead of the desired
>
> > (Carrots, Flavour, 2.0)
> > (Carrots, Smell, 0.0)
> > (Carrots, Usability, 0.0)
> > (Carrots, Size, 0.0)
>
> That's the same, right? At least,
>
> Vote.objects.filter(thing=carrot).values_list('thing', 'context', 'vote)
>
> should return a list of those lists.
>
> What do you get with a plain Vote.objects.filter(thing=carrot) ?
>
> Reinout
>
> --
> Reinout van Rees                    http://reinout.vanrees.org/
> rein...@vanrees.org            http://www.nelen-schuurmans.nl/
> "If you're not sure what to do, make something. -- Paul Graham"

-- 
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: Query with no-correspondence results

2011-12-06 Thread Andre Terra
I'll admit that I read through the thread in about a minute, so forgive me
if I'm completely off, but isn't this something that can be solved through
aggregation[1]?

And you don't want votes, but rather *contexts*, because all of these
matter to you, whereas votes can be 0 (default). Speaking of which, why not
define "default = 0" for votes rather than using NOT NULL?


[1] http://django.me/aggregation



Cheers,
AT


On Tue, Dec 6, 2011 at 6:11 PM, wgis  wrote:

> I get
> (Carrots, Flavor,2.0)
>
> I want to list all the contexts in the "Carrot template", withou
> having to search and merge the ones missing.
> So if the result was
>
> (Carrots, Flavour, 2.0)
> (Carrots, Smell, 0.0)
> (Carrots, Usability, 0.0)
> (Carrots, Size, 0.0)
> or
> (Carrots, Flavour, 2.0)
> (Carrots, Smell, null)
> (Carrots, Usability, null)
> (Carrots, Size, null)
>
> I could just list them, without further querying.
>
> On 6 Dez, 12:46, Reinout van Rees  wrote:
> > On 06-12-11 06:43, wgis wrote:
> >
> > > But then I would have something like
> > > (Carrots, Flavor,2.0)
> > > as the result
> >
> > > instead of the desired
> >
> > > (Carrots, Flavour, 2.0)
> > > (Carrots, Smell, 0.0)
> > > (Carrots, Usability, 0.0)
> > > (Carrots, Size, 0.0)
> >
> > That's the same, right? At least,
> >
> > Vote.objects.filter(thing=carrot).values_list('thing', 'context', 'vote)
> >
> > should return a list of those lists.
> >
> > What do you get with a plain Vote.objects.filter(thing=carrot) ?
> >
> > Reinout
> >
> > --
> > Reinout van Reeshttp://reinout.vanrees.org/
> > rein...@vanrees.orghttp://www.nelen-schuurmans.nl/
> > "If you're not sure what to do, make something. -- Paul Graham"
>
> --
> 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: Query with no-correspondence results

2011-12-06 Thread Reinout van Rees

On 06-12-11 21:11, wgis wrote:

I get
(Carrots, Flavor,2.0)

I want to list all the contexts in the "Carrot template", withou
having to search and merge the ones missing.
So if the result was

(Carrots, Flavour, 2.0)
(Carrots, Smell, 0.0)
(Carrots, Usability, 0.0)
(Carrots, Size, 0.0)
or
(Carrots, Flavour, 2.0)
(Carrots, Smell, null)
(Carrots, Usability, null)
(Carrots, Size, null)


Ah! Now I get your point. You also want the "empty" results for which 
there's no SQL data. Sorry, but I don't see a way in which you can do 
that with an SQL query (and so also not with a Django query).


In case you want all contexts, you'll have to query for those 
specifically. And afterwards grab the results belonging to that context. 
So you won't escape a for loop and some manual work, I'm afraid.



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

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



custom attributes of model field

2011-12-06 Thread trubliphone

Hello,

Is there a way in Django to add custom attributes to a model fields 
(without resorting to subclassing fields)?


I would like to only display certain fields in certain sections of my 
template.  (Eventually, each type of field will be displayed in a 
separate tab.)  I thought about adding a custom attribute to each field 
to identify which section it should go in.  But, so far, I've had no luck.


I have a few field types:


class Enum(set):
def __getattr__(self, name):
if name in self:
return name
raise AttributeError

FieldTypes = Enum(["one","two","three",])


And a few models:


class Model1(models.Model):
  a = models.CharField()
  b = models.ForeignKey('Model2')
  c = models.IntegerField()
  a.type = FieldTypes.one  # this obviously doesn't work
  b.type = FieldTypes.two  # this obviously doesn't work
  c.type = FieldTypes.three  # this obviously doesn't work

class Model2(models.Model):
  d = models.CharField()


And a form:


class Form1(forms.ModelForm):
  class Meta:
model = Mode1


And a template:


  {% for fieldType in FieldTypes %}

  {% for field in form %}
{% if field.type = fieldType %}
  {{ field }}
 {% endif %}
  {% endfor %}

  {% endfor %}


But this doesn't work.

Ideas?  Or another suggestion for only placing certain fields in certain 
sections of the page?


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.



Re: Django E-Commerce Framework

2011-12-06 Thread Stuart Laughlin
I have firsthand experience implementing satchmo for a very large
storefront, and I can heartily recommend it. People who recommend
writing your own ecommerce platform have an overly romanticized
perspective. In my opinion ecommerce is not where you want to make
your own mistakes and go by trial and error. Better to benefit from
the experience, mistakes, and corrections of others when it comes to
ecommerce. Leave the wheel reinventing for your blog. :)

Another advantage of satchmo (and please forgive the self-promotion)
is that you can purchase a companion mobile application that extends
your website to iphones, ipads, android devices, and the like via apps
native to each platform. Preliminary information is at
http://www.johnheerman.com./portfolio/ with a dedicated site coming
Real Soon Now.


--Stuart

On Dec 5, 11:40 pm, "Md,Mehedi Hasan Kabir(Tanim)"
 wrote:
> Hi
>
> Can anyone give me some suggestion/link for Django E-Commerce Framework?
>
> Regards
> Tanim

-- 
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: Query with no-correspondence results

2011-12-06 Thread Ian Clelland
On Tue, Dec 6, 2011 at 1:35 PM, Reinout van Rees wrote:

> Ah! Now I get your point. You also want the "empty" results for which
> there's no SQL data. Sorry, but I don't see a way in which you can do that
> with an SQL query (and so also not with a Django query).
>
> In case you want all contexts, you'll have to query for those
> specifically. And afterwards grab the results belonging to that context. So
> you won't escape a for loop and some manual work, I'm afraid.
>
>
Raw SQL:
select thing, name, vote from mydatabase_votecontext left join
mydatabase_vote on (mydatabase_vote.context_id = mydatabase_votecontext.id)
where thing='Carrot' and user='Me'

That should return null if there is no vote. If you'd rather have zeros,
then use this:

select thing, name, ifnull(vote, 0.0) from mydatabase_votecontext left join
mydatabase_vote on (mydatabase_vote.context_id = mydatabase_votecontext.id)
where thing='Carrot' and user='Me'

There still might be a way to do it with the ORM; but you can definitely
use raw sql for this.


-- 
Regards,
Ian Clelland


-- 
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: Management commands inside namespaced packages not found

2011-12-06 Thread cberner
I see. The namespaced packages weren't a problem until I tried to
install them with egg-links, so it seems like this is more of a
deficiency in setuptools. I'll look around for a solution

On Dec 6, 4:54 am, Reinout van Rees  wrote:
> On 06-12-11 06:34, cberner wrote:
>
>
>
>
>
>
>
>
>
> > I've run into an issue with namespaced packages that are installed in
> > development mode.
>
> > I have two packages that are installed with pip in development mode
> > (pip install develop):
> > A.B.management.commands (code in ~/A.B/A/B/management/commands/) and
> > A.C.management.commands (~/A.C/A/C/management/commands)
>
> > A.B and A.C can be distributed separately via pip, and A is just a
> > namespace package (our company name, in my case).
>
> > The problem is that management commands in A.C aren't detected,
> > because manage.py relies on imp.find_module, and when installed in
> > development mode, setuptools uses egg-links (symlinks), which means
> > that find_module('A') returns the path to A.B (because it comes first
> > alphabetically), but not the path to A.C.
>
> > When the packages are installed (not in development mode) everything
> > works fine, because the packages are merged into the same directory
> > hierarchy in site-packages. Anyone have suggestions for fixing this?
>
> Django doesn't really like namespace packages. The problem is with the
> applications in the INSTALLED_APPS list. Did you add 'A' in there? Then
> it is logical that it only finds one of the two.
>
> You ought to add both 'B' and 'C' in the INSTALLED_APPS list.
>
> For my, this defeats the purpose of namespace packages a bit. I was used
> myself to companyname.product packages, but in Django I've switched to
> packages named companyname-product (with a dash) and modules named
> companyname_product (with an underscore).
>
> - You still have the companyname prefix.
>
> - You get the full "companyname_product" in INSTALLED_APPS.
>
> - You visually see the difference between the package dir and the python
> module dir.
>
> Reinout
>
> --
> Reinout van Rees                    http://reinout.vanrees.org/
> rein...@vanrees.org            http://www.nelen-schuurmans.nl/
> "If you're not sure what to do, make something. -- Paul Graham"

-- 
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: Query with no-correspondence results

2011-12-06 Thread Reinout van Rees

On 06-12-11 22:48, Ian Clelland wrote:

Raw SQL:
select thing, name, vote from mydatabase_votecontext left join
mydatabase_vote on (mydatabase_vote.context_id =
mydatabase_votecontext.id ) where
thing='Carrot' and user='Me'

That should return null if there is no vote. If you'd rather have zeros,
then use this:

select thing, name, ifnull(vote, 0.0) from mydatabase_votecontext left
join mydatabase_vote on (mydatabase_vote.context_id =
mydatabase_votecontext.id ) where
thing='Carrot' and user='Me'

There still might be a way to do it with the ORM; but you can definitely
use raw sql for this.


Till two years ago I didn't touch an sql database for 8 years as I used 
zope's luxurious python object database :-) So I'm happily proven wrong 
in what SQL can do :-)




Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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: Internationalization and localization

2011-12-06 Thread Lachlan Musicman
There's no official support for translation of what you have in your
DB - but that's because it's not a core need of most projects, coupled
with the fact that there are a number of ways to do it, none of which
are more correct than the other. For example - do you have a mirror db
per language, or is each translation part of the objects in the
original DB?

Basically, it comes down to what you need, best fit, extensibility and
personal taste.

There are two projects in particular that address this issue that I'm
aware of, django-rosetta and django-hvad. There is a third,
django-multilingual, but it explicitly states "THIS PROJECT IS *NOT*
SUPPORTED AND SHOULD NOT BE USED UNLESS YOU KNOW EXACTLY WHAT YOU'RE
DOING!!!" (caps aren't mine)

You can see more about them here:

http://djangopackages.com/grids/g/i18n/

Cheers
L.

On Wed, Dec 7, 2011 at 00:40, Andres Reyes  wrote:
> At the moment i don't know of any official support for that kind of
> internationalization from Django, there are a number of different Packages
> that try to address the problem with some level of success. In one project
> of mine i used the approach described
> in http://snippets.dzone.com/posts/show/2979 . You must remember however
> that in the end Django Models are only a representation of the data in your
> database, you can design you database to handle multiple languages just as
> you would wth PHP or any other framework.
>
>
>
> 2011/12/5 rentgeeen 
>>
>> I have a question about internationalization -
>> https://docs.djangoproject.com/en/dev/topics/i18n/internationalization/
>>
>> What I want to how to translate stuff from DB, all at django official
>> say is about static content, what I have only found is this:
>>
>> http://packages.python.org/django-easymode/i18n/index.html
>>
>> Easymode
>>
>> I think there is more official way from Django no?
>>
>> 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.
>>
>
>
>
> --
> Andrés Reyes Monge
> armo...@gmail.com
> +(505)-8873-7217
>
> --
> 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: Internationalization and localization

2011-12-06 Thread rentgeeen
I am using

EASYMODE

And that created in my DB 3 INFO textfields for each language, and
when is 1 language selected it will show particular text corresponding
to selected language.

But what I want to achieve is if I give somebody link:

it/sample/
en/sample/

it will show that page in that language, now I have to choose language
and then go to the page and see it in that language...



On Dec 6, 7:03 pm, Lachlan Musicman  wrote:
> There's no official support for translation of what you have in your
> DB - but that's because it's not a core need of most projects, coupled
> with the fact that there are a number of ways to do it, none of which
> are more correct than the other. For example - do you have a mirror db
> per language, or is each translation part of the objects in the
> original DB?
>
> Basically, it comes down to what you need, best fit, extensibility and
> personal taste.
>
> There are two projects in particular that address this issue that I'm
> aware of, django-rosetta and django-hvad. There is a third,
> django-multilingual, but it explicitly states "THIS PROJECT IS *NOT*
> SUPPORTED AND SHOULD NOT BE USED UNLESS YOU KNOW EXACTLY WHAT YOU'RE
> DOING!!!" (caps aren't mine)
>
> You can see more about them here:
>
> http://djangopackages.com/grids/g/i18n/
>
> Cheers
> L.
>
>
>
>
>
>
>
> On Wed, Dec 7, 2011 at 00:40, Andres Reyes  wrote:
> > At the moment i don't know of any official support for that kind of
> > internationalization from Django, there are a number of different Packages
> > that try to address the problem with some level of success. In one project
> > of mine i used the approach described
> > in http://snippets.dzone.com/posts/show/2979 . You must remember however
> > that in the end Django Models are only a representation of the data in your
> > database, you can design you database to handle multiple languages just as
> > you would wth PHP or any other framework.
>
> > 2011/12/5 rentgeeen 
>
> >> I have a question about internationalization -
> >>https://docs.djangoproject.com/en/dev/topics/i18n/internationalization/
>
> >> What I want to how to translate stuff from DB, all at django official
> >> say is about static content, what I have only found is this:
>
> >>http://packages.python.org/django-easymode/i18n/index.html
>
> >> Easymode
>
> >> I think there is more official way from Django no?
>
> >> 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.
>
> > --
> > Andrés Reyes Monge
> > armo...@gmail.com
> > +(505)-8873-7217
>
> > --
> > 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: Updating parent record, when child record changes

2011-12-06 Thread Mike Dewhirst

On 6/12/2011 8:40pm, zobbo wrote:

I asked a similar question last week but got no responses - here's a
related but hopefully simpler question.

What is the recommended way to update a field on a parent record when
one or more of it's child records (held in inlines) are modified? I
could hook on post_save on the inlines, but if you have 50 inline you
only really want to do the processing at the end of the last inline
record to be saved.

I want to update a status field on the parent record, whose value will
vary depending on the child records.


I think I would implement a post_save signal[1] on the child and 
register a listener[2] for that signal on the parent. When detected it 
could trigger a parental review of the children (or child) and that 
would take whatever action you want.


[1] 
https://docs.djangoproject.com/en/1.3/ref/signals/#django.db.models.signals.post_save


[2] 
https://docs.djangoproject.com/en/1.3/topics/signals/#listening-to-signals


Mike





Ian



--
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: Internationalization and localization

2011-12-06 Thread kenneth gonsalves
On Mon, 2011-12-05 at 19:00 -0800, rentgeeen wrote:
> What I want to how to translate stuff from DB, all at django official
> say is about static content, what I have only found is this:
> 
> 

django-modeltranslation
-- 
regards
Kenneth Gonsalves

-- 
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: filtering on a model method

2011-12-06 Thread kenneth gonsalves
On Tue, 2011-12-06 at 13:04 +, Tom Evans wrote:
> > say I have a model method like get_age(self), can I filter on this?
> >
> > Mymodel.objects.filter(get_age() = 5) (this does not work, but any
> ideas
> > would be appreciated)
> 
> You can't do this. Querysets are interfaces to the database, so all
> filtering must be on attributes present or computable in the database.
> Presumably age is calculated from something in the database? 

thanks for confirming this - it is a much needed feature if at all
possible.
-- 
regards
Kenneth Gonsalves

-- 
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 E-Commerce Framework

2011-12-06 Thread kenneth gonsalves
On Tue, 2011-12-06 at 08:11 -0500, Daniel Cure V. wrote:
> You can try with Satchmo.Its a very robust framework.

is it ecommerce?
-- 
regards
Kenneth Gonsalves

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