Django app custom settings testing

2013-01-02 Thread Pedro J. Aramburu
Hi, I'm having troubles using the override_settings decorator. The thing is 
I'm writing an app that has it's own settings and I'm doing it with the 
approach of putting a settings.py file on the app folder with something 
like this:

from django.conf import settings
from django.core.exceptions import ImproperlyConfigured


SETTING_A = getattr(settings, 'APP_SETTING_A', False)

SETTING_B = getattr(settings, 'APP_SETTING_B', False)

if SETTING_A and not SETTING_B:
raise ImproperlyConfigured('"SETTING_A" is set to True but "SETTING_B" 
is missing.')
-
Where SETTING_B should be a tuple that depends on SETTING_A (I know I 
didn't type check yet). Then I use the settings importing app.settings. The 
thing is, I believe, that the settings are loaded once and as they're 
outside the project settings.py, override settings doesn't have any effect.

What would you recommend?

-- 
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/-/22xrwU84AG8J.
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 installation on Hostgator

2013-01-02 Thread John Neumann
You can also try this: https://my.hostgator.com/cgi/help/530 and/or this: 
https://my.hostgator.sg/cgi/help/python-install though iric it was riddled 
with issues. Been a bit since I had to do it without the ability to install 
things intelligently. Personally I'd suggest trying to install virtualenv 
and see if you can even get that to work. If you can't then you're probably 
screwed (again though I'd still suggest switching hosts).

On Wednesday, January 2, 2013 10:34:55 PM UTC-6, John Neumann wrote:
>
>
> You would be correct. You cannot install anything else on HostGator (it's 
> why I left them despite their fantastic customer support). You can see what 
> they do have installed here: 
> http://support.hostgator.com/articles/hosting-guide/hardware-software/python-modules
>
> Outside of those things you're hosed. Either find another host or lose the 
> libs. After I had the same problem I moved to WebFaction and couldn't be 
> happier there. They have great customer support as well (though I do miss 
> the ability to chat on the fly). 
>
> Also it would be easier to install django if you had another host. 
> Hostgator is great for most things outside of Python land. Again, like 
> Hostgator, but their Python/Django support is weak sauce.
>
> On Wednesday, January 2, 2013 6:32:10 PM UTC-6, Gjorge Karakabakov wrote:
>>
>> Hi, I've created a Django project but can't really seem to install it 
>> correctly on Hostgator.
>>
>> I've followed this tutorial: 
>> https://docs.google.com/document/pub?id=1jhvixMmTRGYHRbHaYlTHTNrtpziGotQMc0iBO0sTbIo
>>  
>> and created new project which worked. When I uploaded my own project I 
>> got server error - 500.
>> I'm presuming it has something to do with the additional apps i'm using:
>> endless-pagination, newsletter, sorl.thumbnail, django_extensions
>>
>> How can install them on the server? I can't really use sudo pip install 
>> there I don't have permissions.
>>
>> Also is there more detailed/easier way of installing django?
>>
>> Please explain in detail I'm really new at django.
>>
>> 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/-/Q88wygKPvGwJ.
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 installation on Hostgator

2013-01-02 Thread John Neumann

You would be correct. You cannot install anything else on HostGator (it's 
why I left them despite their fantastic customer support). You can see what 
they do have installed 
here: 
http://support.hostgator.com/articles/hosting-guide/hardware-software/python-modules

Outside of those things you're hosed. Either find another host or lose the 
libs. After I had the same problem I moved to WebFaction and couldn't be 
happier there. They have great customer support as well (though I do miss 
the ability to chat on the fly). 

Also it would be easier to install django if you had another host. 
Hostgator is great for most things outside of Python land. Again, like 
Hostgator, but their Python/Django support is weak sauce.

On Wednesday, January 2, 2013 6:32:10 PM UTC-6, Gjorge Karakabakov wrote:
>
> Hi, I've created a Django project but can't really seem to install it 
> correctly on Hostgator.
>
> I've followed this tutorial: 
> https://docs.google.com/document/pub?id=1jhvixMmTRGYHRbHaYlTHTNrtpziGotQMc0iBO0sTbIo
>  
> and created new project which worked. When I uploaded my own project I got 
> server error - 500.
> I'm presuming it has something to do with the additional apps i'm using:
> endless-pagination, newsletter, sorl.thumbnail, django_extensions
>
> How can install them on the server? I can't really use sudo pip install 
> there I don't have permissions.
>
> Also is there more detailed/easier way of installing django?
>
> Please explain in detail I'm really new at django.
>
> 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/-/SSuAJGDhjagJ.
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 installation on Hostgator

2013-01-02 Thread Gjorge Karakabakov
Hi, I've created a Django project but can't really seem to install it 
correctly on Hostgator.

I've followed this tutorial: 
https://docs.google.com/document/pub?id=1jhvixMmTRGYHRbHaYlTHTNrtpziGotQMc0iBO0sTbIo
 
and created new project which worked. When I uploaded my own project I got 
server error - 500.
I'm presuming it has something to do with the additional apps i'm using:
endless-pagination, newsletter, sorl.thumbnail, django_extensions

How can install them on the server? I can't really use sudo pip install 
there I don't have permissions.

Also is there more detailed/easier way of installing django?

Please explain in detail I'm really new at django.

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/-/uV-ReYjDkBUJ.
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.



Please help me understand this Geodjango GEOS API error

2013-01-02 Thread Benjamin Golder
I'm constantly running into several different errors when I try to use the 
GEOS API in my django apps.
These errors cause the development server to shut down, and they don't 
supply much information for debugging. If you have any ideas on how I can 
get closer to understanding or resolving these, I would greatly appreciate 
it. 

I've posted the details on Stack Overflow, here:
http://stackoverflow.com/questions/13517239/geodjango-geos-api-abort-trap-geos-function-errors

If there's other information I should post, please let me know.

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/-/BnL5c1re4jYJ.
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: Star Rating System In Django

2013-01-02 Thread Alec Taylor
=)

On Mon, Dec 31, 2012 at 11:12 AM, coded kid  wrote:

> Thanks! Agon works perfectly!
>
>
> On Sunday, 30 December 2012 14:46:24 UTC+1, coded kid wrote:
>>
>> The developer for agon rating is no more working on it and I guess it
>> won't work nice .
>>
>> Simple ratings is not working out for me. Don't know if there's a
>> JavaScript plugin for rating?
>>
>> On Sunday, 30 December 2012 14:08:10 UTC+1, Alec Taylor wrote:
>>>
>>> Agon (probably easiest):
>>> http://agon-ratings.**readthedocs.org/en/latest/**usage.html
>>>
>>> -or-
>>>
>>> https://github.com/dcramer/**django-ratings
>>>
>>> -or-
>>>
>>> https://github.com/coleifer/**django-simple-ratings
>>>
>>> On Mon, Dec 31, 2012 at 12:03 AM, coded kid 
>>> wrote:
>>> > Anyone know about any good package or tutorial or plugin for building
>>> > a star rating system in django? I tried using dcramer/django rating
>>> > but It's not working perfectly.
>>> >
>>> > If you know of any plugin, package on how to build a star rating
>>> > system, kindly post it below.
>>> >
>>> > 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...@googlegroups.com.
>>> > To unsubscribe from this group, send email to
>>> django-users...@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 view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/fTgXj2iqSf0J.
>
> 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: Happy new year

2013-01-02 Thread Joey "JoeLinux" Espinosa

I guess I should contribute to this free-for-all:

Happy New Year from Miami, hope all of you Django devs have a great and 
exciting year!


*Joey "JoeLinux" Espinosa*
Software Developer
http://about.me/joelinux

On 01/02/2013 11:48 AM, scriptflow wrote:

Happy New Year from Brazil

Feliz ano novo!!!

I'm indo Salvador right now indo Iberostar Bahia praia do forte...

[ ]`s to all...

Tiago Godoy


Enviado por Samsung Mobile

daniele sartiano  escreveu:
Happy new year from Italy!!

Ciao a tutti!

D.


2013/1/2 Evan >

Happy new year from Vietnam, wish you guys great things.


On Tuesday, January 1, 2013 4:42:13 AM UTC+7, cingusoft wrote:

Happy new year from spain to all django lovers.
I wish you a new year with tons of django projects.

Cheers
Cingusoft
BlackBerry de movistar, allí donde estés está tu oficin@

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

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: Happy new year

2013-01-02 Thread scriptflow
Happy New Year from Brazil

Feliz ano novo!!!

I'm indo Salvador right now indo Iberostar Bahia praia do forte...

[ ]`s to all...

Tiago Godoy


Enviado por Samsung Mobiledaniele sartiano  
escreveu:Happy new year from Italy!!

Ciao a tutti!

D.


2013/1/2 Evan 
Happy new year from Vietnam, wish you guys great things.


On Tuesday, January 1, 2013 4:42:13 AM UTC+7, cingusoft wrote:
Happy new year from spain to all django lovers. 
I wish you a new year with tons of django projects. 

Cheers 
Cingusoft 
BlackBerry de movistar, allí donde estés está tu oficin@
-- 
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/-/XzXh2V7JGwsJ.

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: Happy new year

2013-01-02 Thread Sreenivas Reddy T
Happy new Year from Hyderabad,Andhra Pradesh, India.


Best Regards,
Srinivas Reddy Thatiparthy
9703888668.

"Anyone who has never made a mistake has never tried anything new !!! "
--Albert Einstein


On Wed, Jan 2, 2013 at 9:50 PM, daniele sartiano  wrote:

> Happy new year from Italy!!
>
> Ciao a tutti!
>
> D.
>
>
> 2013/1/2 Evan 
>
>> Happy new year from Vietnam, wish you guys great things.
>>
>>
>> On Tuesday, January 1, 2013 4:42:13 AM UTC+7, cingusoft wrote:
>>>
>>> Happy new year from spain to all django lovers.
>>> I wish you a new year with tons of django projects.
>>>
>>> Cheers
>>> Cingusoft
>>> BlackBerry de movistar, allí donde estés está tu oficin@
>>
>>  --
>> 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/-/XzXh2V7JGwsJ.
>>
>> 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: Happy new year

2013-01-02 Thread daniele sartiano
Happy new year from Italy!!

Ciao a tutti!

D.


2013/1/2 Evan 

> Happy new year from Vietnam, wish you guys great things.
>
>
> On Tuesday, January 1, 2013 4:42:13 AM UTC+7, cingusoft wrote:
>>
>> Happy new year from spain to all django lovers.
>> I wish you a new year with tons of django projects.
>>
>> Cheers
>> Cingusoft
>> BlackBerry de movistar, allí donde estés está tu oficin@
>
>  --
> 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/-/XzXh2V7JGwsJ.
>
> 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: Happy new year

2013-01-02 Thread Evan
Happy new year from Vietnam, wish you guys great things.

On Tuesday, January 1, 2013 4:42:13 AM UTC+7, cingusoft wrote:
>
> Happy new year from spain to all django lovers. 
> I wish you a new year with tons of django projects. 
>
> Cheers 
> Cingusoft 
> BlackBerry de movistar, allí donde estés está tu oficin@

-- 
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/-/XzXh2V7JGwsJ.
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: Serve static files in production server

2013-01-02 Thread Stefano Tranquillini


On Sunday, December 30, 2012 6:01:24 PM UTC+1, Amirouche wrote:
>
> Héllo Stefano,
>
> On Sunday, December 30, 2012 1:27:12 PM UTC+1, Stefano Tranquillini wrote:
>>
>> Hi all.
>> in the appfog ML we were fighting again the possibility to serve static 
>> file in django without using an external server.
>> So far AF does not provide a setup of the server to split the server in 
>> static and dynamic (django) folders.
>> so, one of the solution is to use this
>>
>> # urls.py 
>> urlpatterns += patterns('', 
>> url(r'^static/(?P.*)$', 'django.views.static.serve', { 
>> 'document_root': settings.STATIC_ROOT}) 
>> )
>>
>> but, is it ok to use this trick in django or will it lead to problems 
>> (aka memory problems and stuff like that)?
>>
>
> The documentation state «Again, this view is *not* hardened for 
> production use» [1]
>
> What is the particular issue your are facing ? Maybe tproxy [2] can help.
>

the problem is that the appfog server does not provide a way to set up 
static part. so for convenience i (we) tried to use a workaround for 
solving the problem.

ciao
 

>
> Regards,
>
> Amirouche
>
> [1] 
> https://docs.djangoproject.com/en/dev/howto/static-files/#django.views.static.serve
> [2] https://github.com/benoitc/tproxy
>
>>

-- 
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/-/_Rh0njYy--UJ.
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 signals.post_save() and conditions.

2013-01-02 Thread kirill . yakovenko
Hello,

I'm not sure that I've understood you completely. What condition are you 
going to apply to a signal?

Best regards,
Kirill Yakovenko

On Wednesday, January 2, 2013 4:34:35 PM UTC+7, ysfjwd wrote:
>
> Is there a way to check a condition on sender model before processing a 
> command. My code
>
> user_logged_in.connect(update_last_login)
>
> def create_activation_code(sender, instance, created, **kwargs):
> print 'The signal is called'
> if created:
> print 'the singal goes to created'
> if not instance.is_active:
> print 'the signal evaluates the active state'
> activation = Activation.objects.create(user=instance)
> activation.get_code()
> activation.save()
> else:
> print 'the signal fails to evaluate active state'
>
> signals.post_save.connect(create_activation_code, sender=User)
>
> can conditions be applied on signals?
>
> //ysfjwd
>

-- 
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/-/Mlo0g69piH4J.
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 objects sorted by time of last comment

2013-01-02 Thread akaariai
On 2 tammi, 08:50, Vibhu Rishi  wrote:
> Hi All,
>
> A very happy new year to you all !
>
> I am working on a website I am making as my hobby project. It is to do with
> motorcycle touring.
>
> I have done some initial work on it, and incrementally making changes as
> and when I can.
>
> I am trying to figure out the following issue :
> 1. I have a forum object where people can start threads.
> 2. the forum object uses the django comments module along with mptt. So far
> so good.
> 3. Now, I want to show the "latest commented on" posts. But I am not able
> to figure it out.
>
> For reference :http://bikenomads.herokuapp.com/
>
> On the box on the right, I want to show the posts based on the last comment
> time. However, all I can do right now is show the last post based on
> creation time (this is a field for the post object). I am not able to
> figure out how to sort based on comment time.
>
> Solutions :
> 1. Ideally there should be a way to sort object by comment time using the
> inbuilt comments module in django. Is this possible ?
> 2. Alternatively, I will need to update the post model to have another
> field for 'last_comment_time' and when someone posts a comment, I will need
> to update this field. I would rather not do this as I will need to make
> sure all the objects using comments will need to have this exact field.
>
> What would you suggest ?

The ORM doesn't offer a way to do the query you want. The query will
be something like this:
select * from post
  left join comment on comment.object_id = post.id and
comment.object_type = 'post'
and comment.timestamp = (select max(timestamp) from
comment
  where object_id = post.id and
comment.object_type = 'post'
 )
 order by comment.timestamp;
(Assuming unique comment timestamp per post).

There are two underlying problems. First, Django's ORM doesn't
currently offer any way to generate more than single column equality
comparison in the JOIN clause. We are working on removing this
limitation from 1.6 (actually, the underlying limitation is already
somewhat gone). Second, the SQL needed isn't exactly nice. There are
multiple ways to write the same SQL, and how they perform differ
somewhat depending on the used DB and the amount of data.

So, what can you do pre 1.6? One way is to use views and some hackery
to do what you want.

class LatestComment(models.Model):
post = models.OneToOneField(Post, primary_key=True,
on_delete=models.DO_NOTHING, related_name='latest_comment')
{{ duplicate the columns in comment model here - you don't need
content type id }}

class Meta:
managed = False
db_table = 'latest_post_comment_view'

Then, create a view like this in the DB:

create or replace view "latest_post_comment_view" as (
select object_id as post_id, ...
  from comment
 where object_type = 'post'
 group by post_id, ...
having max(timestamp) = timestamp
);

The SQL above is untested. In any case, you should now be able to do:
 
Post.objects.select_related('latest_comment').order_by('latest_comment__timestamp')

You will need to repeat the above for all the models with comments

Managing the raw SQL needed for the views can be somewhat ugly. The
last_comment_time field might be easier to implement & maintain. That
being said I have been using the above technique successfully in
production systems.

I do wish Django will one day have latest_related() functionality. I
find I need that often, and as the above shows this isn't easily
doable currently.

 - 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: Bulk delete - performance / object collection

2013-01-02 Thread akaariai
A note about the upcoming 1.5: The delete() was optimized so that it
doesn't fetch the objects if it doesn't have to. The "doesn't have to"
translates to:
 - no delete signals defined for the model
 - no cascades

That being said using DSE might be the right choice for you.

 - Anssi

On 2 tammi, 14:17, George Lund  wrote:
> Thank you very much for this. I'll catch up with those threads and read
> more about DSE, which looks really interesting work.
>
> regards
>
> George
>
> On Wednesday, 2 January 2013 11:50:54 UTC, Cal Leeming [Simplicity Media
>
>
>
>
>
>
>
> Ltd] wrote:
>
> > Hi George,
>
> > This is one area I spent quite a lot of time in personally, see;
>
> >https://groups.google.com/forum/?fromgroups=#!msg/django-users/iRhWD0...
> >https://groups.google.com/forum/#!topic/django-users/hgLrwMoFLII
>
> > Bulk operations using the ORM isn't always the right thing to do - and it
> > entirely depends on what you consider bulk and acceptable performance.
>
> > You might want to look at the source code for this, to see how they handle
> > bulk operations (they implemented the same bulk_update approach mentioned
> > in the above threads)
> >http://pypi.python.org/pypi/dse
>
> > Although bypassing the ORM might feel wrong at first, sometimes it is
> > completely acceptable - you just need to make sure you don't abuse/misuse
> > it unnecessarily.
>
> > Cal
>
> > On Wed, Jan 2, 2013 at 11:29 AM, George Lund  > > wrote:
>
> >> I'm trying to bulk-delete several million rows from my database.
>
> >> The docs for Django 
> >> 1.3say
> >>  "this will, whenever possible, be executed purely in SQL". A pure-SQL
> >> delete is what I want in this case, so that's fine.
>
> >> However, the code is never getting as far as running any SQL.
>
> >> Interrupting the script shows that the delete method on the QuerySet is
> >> trying to use a "Collector" to construct model instances for each row I'm
> >> trying to delete. This is going to take too long (and may in fact consume
> >> all the memory available) -- I don't think it's practical to wait in this
> >> case. (I've tried waiting over half an hour!)
>
> >> (I'm looking at django.db.models.query.QuerySet.delete and 
> >> django.db.models.deletion.Collector.collect
> >> / Collector.add.)
>
> >> What's the point in doing the delete "purely in SQL" if all of the
> >> objects are getting constructed anyway? Why do they need to be "collected"
> >> before the SQL DELETE is run? The model instance in this case has no
> >> child rows, to which the delete might need to be cascaded.
>
> >> Meanwhile I can construct the SQL by hand easily enough, but I feel this
> >> isn't doing things the right way.
>
> >> thanks for any help
>
> >> George
>
> >> --
> >> 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/-/W4LqKzcnlaYJ.
> >> To post to this group, send email to 
> >> django...@googlegroups.com
> >> .
> >> To unsubscribe from this group, send email to
> >> django-users...@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: Bulk delete - performance / object collection

2013-01-02 Thread George Lund
Thank you very much for this. I'll catch up with those threads and read 
more about DSE, which looks really interesting work.

regards

George

On Wednesday, 2 January 2013 11:50:54 UTC, Cal Leeming [Simplicity Media 
Ltd] wrote:
>
> Hi George,
>
> This is one area I spent quite a lot of time in personally, see;
>
> https://groups.google.com/forum/?fromgroups=#!msg/django-users/iRhWD0FtW8k/0KAMF3ub-ZYJ
> https://groups.google.com/forum/#!topic/django-users/hgLrwMoFLII
>
> Bulk operations using the ORM isn't always the right thing to do - and it 
> entirely depends on what you consider bulk and acceptable performance.
>
> You might want to look at the source code for this, to see how they handle 
> bulk operations (they implemented the same bulk_update approach mentioned 
> in the above threads)
> http://pypi.python.org/pypi/dse
>
> Although bypassing the ORM might feel wrong at first, sometimes it is 
> completely acceptable - you just need to make sure you don't abuse/misuse 
> it unnecessarily.
>
> Cal
>
> On Wed, Jan 2, 2013 at 11:29 AM, George Lund  > wrote:
>
>> I'm trying to bulk-delete several million rows from my database.
>>
>> The docs for Django 
>> 1.3say
>>  "this will, whenever possible, be executed purely in SQL". A pure-SQL 
>> delete is what I want in this case, so that's fine.
>>
>> However, the code is never getting as far as running any SQL.
>>
>> Interrupting the script shows that the delete method on the QuerySet is 
>> trying to use a "Collector" to construct model instances for each row I'm 
>> trying to delete. This is going to take too long (and may in fact consume 
>> all the memory available) -- I don't think it's practical to wait in this 
>> case. (I've tried waiting over half an hour!)
>>
>> (I'm looking at django.db.models.query.QuerySet.delete and 
>> django.db.models.deletion.Collector.collect 
>> / Collector.add.)
>>
>> What's the point in doing the delete "purely in SQL" if all of the 
>> objects are getting constructed anyway? Why do they need to be "collected" 
>> before the SQL DELETE is run? The model instance in this case has no 
>> child rows, to which the delete might need to be cascaded.
>>
>> Meanwhile I can construct the SQL by hand easily enough, but I feel this 
>> isn't doing things the right way.
>>
>> thanks for any help
>>
>> George
>>
>> -- 
>> 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/-/W4LqKzcnlaYJ.
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/q1ZxexzIdX8J.
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: Bulk delete - performance / object collection

2013-01-02 Thread George Lund

>
> > Meanwhile I can construct the SQL by hand easily enough, but I feel this 
> > isn't doing things the right way. 
>
> I've had this discussion with other developers. Many feel they need to 
> slavishly adhere to the ORM and if you don't you're some type of evil 
> entity. I could not disagree more. Django and the ORM are tools, and 
> should be used only when they are the right tools for the job. I'd 
> just go ahead and do the delete in SQL.
>

I don't think SQL is evil, but there are lots of reasons why mixing 
programming languages (and abstraction levels) to solve a problem isn't 
really ideal.

>From a very personal point of view I'd like to see archaic languages like 
SQL go away for ever one day, in the meantime I completely agree that if 
the ORM doesn't do what's needed then the right choice is to go with 
whatever tools will :-)

thanks
George

-- 
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/-/x6y5ORLtg3wJ.
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: Bulk delete - performance / object collection

2013-01-02 Thread Cal Leeming [Simplicity Media Ltd]
That's an interesting perspective actually..

"Don't be a slave of your mind (or ORM)"

Cal

On Wed, Jan 2, 2013 at 12:01 PM, Larry Martell wrote:

> On Wed, Jan 2, 2013 at 4:29 AM, George Lund  wrote:
> > I'm trying to bulk-delete several million rows from my database.
> >
> > The docs for Django 1.3 say "this will, whenever possible, be executed
> > purely in SQL". A pure-SQL delete is what I want in this case, so that's
> > fine.
> >
> > However, the code is never getting as far as running any SQL.
> >
> > Interrupting the script shows that the delete method on the QuerySet is
> > trying to use a "Collector" to construct model instances for each row I'm
> > trying to delete. This is going to take too long (and may in fact consume
> > all the memory available) -- I don't think it's practical to wait in this
> > case. (I've tried waiting over half an hour!)
> >
> > (I'm looking at django.db.models.query.QuerySet.delete and
> > django.db.models.deletion.Collector.collect / Collector.add.)
> >
> > What's the point in doing the delete "purely in SQL" if all of the
> objects
> > are getting constructed anyway? Why do they need to be "collected" before
> > the SQL DELETE is run? The model instance in this case has no child
> rows, to
> > which the delete might need to be cascaded.
> >
> > Meanwhile I can construct the SQL by hand easily enough, but I feel this
> > isn't doing things the right way.
>
> I've had this discussion with other developers. Many feel they need to
> slavishly adhere to the ORM and if you don't you're some type of evil
> entity. I could not disagree more. Django and the ORM are tools, and
> should be used only when they are the right tools for the job. I'd
> just go ahead and do the delete in SQL.
>
> --
> 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: Bulk delete - performance / object collection

2013-01-02 Thread Larry Martell
On Wed, Jan 2, 2013 at 4:29 AM, George Lund  wrote:
> I'm trying to bulk-delete several million rows from my database.
>
> The docs for Django 1.3 say "this will, whenever possible, be executed
> purely in SQL". A pure-SQL delete is what I want in this case, so that's
> fine.
>
> However, the code is never getting as far as running any SQL.
>
> Interrupting the script shows that the delete method on the QuerySet is
> trying to use a "Collector" to construct model instances for each row I'm
> trying to delete. This is going to take too long (and may in fact consume
> all the memory available) -- I don't think it's practical to wait in this
> case. (I've tried waiting over half an hour!)
>
> (I'm looking at django.db.models.query.QuerySet.delete and
> django.db.models.deletion.Collector.collect / Collector.add.)
>
> What's the point in doing the delete "purely in SQL" if all of the objects
> are getting constructed anyway? Why do they need to be "collected" before
> the SQL DELETE is run? The model instance in this case has no child rows, to
> which the delete might need to be cascaded.
>
> Meanwhile I can construct the SQL by hand easily enough, but I feel this
> isn't doing things the right way.

I've had this discussion with other developers. Many feel they need to
slavishly adhere to the ORM and if you don't you're some type of evil
entity. I could not disagree more. Django and the ORM are tools, and
should be used only when they are the right tools for the job. I'd
just go ahead and do the delete in SQL.

-- 
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: Bulk delete - performance / object collection

2013-01-02 Thread Cal Leeming [Simplicity Media Ltd]
Hi George,

This is one area I spent quite a lot of time in personally, see;
https://groups.google.com/forum/?fromgroups=#!msg/django-users/iRhWD0FtW8k/0KAMF3ub-ZYJ
https://groups.google.com/forum/#!topic/django-users/hgLrwMoFLII

Bulk operations using the ORM isn't always the right thing to do - and it
entirely depends on what you consider bulk and acceptable performance.

You might want to look at the source code for this, to see how they handle
bulk operations (they implemented the same bulk_update approach mentioned
in the above threads)
http://pypi.python.org/pypi/dse

Although bypassing the ORM might feel wrong at first, sometimes it is
completely acceptable - you just need to make sure you don't abuse/misuse
it unnecessarily.

Cal

On Wed, Jan 2, 2013 at 11:29 AM, George Lund  wrote:

> I'm trying to bulk-delete several million rows from my database.
>
> The docs for Django 
> 1.3say
>  "this will, whenever possible, be executed purely in SQL". A pure-SQL
> delete is what I want in this case, so that's fine.
>
> However, the code is never getting as far as running any SQL.
>
> Interrupting the script shows that the delete method on the QuerySet is
> trying to use a "Collector" to construct model instances for each row I'm
> trying to delete. This is going to take too long (and may in fact consume
> all the memory available) -- I don't think it's practical to wait in this
> case. (I've tried waiting over half an hour!)
>
> (I'm looking at django.db.models.query.QuerySet.delete and 
> django.db.models.deletion.Collector.collect
> / Collector.add.)
>
> What's the point in doing the delete "purely in SQL" if all of the objects
> are getting constructed anyway? Why do they need to be "collected" before
> the SQL DELETE is run? The model instance in this case has no child rows,
> to which the delete might need to be cascaded.
>
> Meanwhile I can construct the SQL by hand easily enough, but I feel this
> isn't doing things the right way.
>
> thanks for any help
>
> George
>
> --
> 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/-/W4LqKzcnlaYJ.
> 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.



Bulk delete - performance / object collection

2013-01-02 Thread George Lund
I'm trying to bulk-delete several million rows from my database.

The docs for Django 
1.3say
 "this will, whenever possible, be executed purely in SQL". A pure-SQL 
delete is what I want in this case, so that's fine.

However, the code is never getting as far as running any SQL.

Interrupting the script shows that the delete method on the QuerySet is 
trying to use a "Collector" to construct model instances for each row I'm 
trying to delete. This is going to take too long (and may in fact consume 
all the memory available) -- I don't think it's practical to wait in this 
case. (I've tried waiting over half an hour!)

(I'm looking at django.db.models.query.QuerySet.delete and 
django.db.models.deletion.Collector.collect 
/ Collector.add.)

What's the point in doing the delete "purely in SQL" if all of the objects 
are getting constructed anyway? Why do they need to be "collected" before 
the SQL DELETE is run? The model instance in this case has no child rows, 
to which the delete might need to be cascaded.

Meanwhile I can construct the SQL by hand easily enough, but I feel this 
isn't doing things the right way.

thanks for any help

George

-- 
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/-/W4LqKzcnlaYJ.
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 signals.post_save() and conditions.

2013-01-02 Thread ysfjwd
Is there a way to check a condition on sender model before processing a 
command. My code

user_logged_in.connect(update_last_login)

def create_activation_code(sender, instance, created, **kwargs):
print 'The signal is called'
if created:
print 'the singal goes to created'
if not instance.is_active:
print 'the signal evaluates the active state'
activation = Activation.objects.create(user=instance)
activation.get_code()
activation.save()
else:
print 'the signal fails to evaluate active state'

signals.post_save.connect(create_activation_code, sender=User)

can conditions be applied on signals?

//ysfjwd

-- 
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/-/NsRz1xo-3-kJ.
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: When I set DEBUG=False, my 404.html doesn't appear

2013-01-02 Thread Dae_James
Thank you while I've solve the problem. It's because some browsers show 
their own 404 page if the size of the 404 page server returns less than 512 
bytes.
So just uncheck the "show friendly error page" in Interner Option in 
Control Panel, my 404 page will appear.

在 2012年12月29日星期六UTC+8下午11时59分11秒,Dae_James写道:
>
>  I put my 404.html into root of the directory specified in TEMPLATE_DIRS. 
> However, when I visit an inexisting page, the browser's 404.html appears 
> rather than my own 404.html page.
> What's wrong with me ? 
> PS: I've set the DEBUG variable in settings.py to False.
>  
> --
> Dae James
>

-- 
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/-/-15XMk7i_YwJ.
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: Question about URL namespaces

2013-01-02 Thread Dae_James
So what does instance actually mean here?  Does it just mean another copy 
of the app directory with a different directory name?

在 2012年12月30日星期日UTC+8上午3时06分03秒,Ryan Blunden写道:
>
> I've never used this feature but I believe it was created so that for a 
> single Django project, you could provide multiple administration apps. For 
> example, you might have one for customers and one for back office staff 
> that expose different models, have different permissions etc.
>
> So to answer your question about what "application" means in this context, 
> it means a Django application (e.g. django.contrib.admin).
>
> Cheers,
> Ryan
>
> On 29/12/2012, at 4:44 AM, "Dae James"  
> wrote:
>
> When I was reading django's URL document, I come across "URL namespaces".
> The raw sentence is "When you need to deploy multiple instances of a 
> single application, it can be helpful to be able to differentiate between 
> instances."
> I'm very confused here. What the application here refer to? Does it mean  
> models ? Or something else I don't know?
> Thank you~~
>  
> --
> Dae James
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django...@googlegroups.com
> .
> To unsubscribe from this group, send email to 
> django-users...@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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/UElaFuMkhv0J.
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.