Re: Any way to force Django to commit a write so another process can read the correct data from DB?

2016-07-27 Thread Mike Dewhirst

On 28/07/2016 5:46 AM, Constantine Covtushenko wrote:

Hi Stodge,

As said in Django current version of documentation
,
'post_delete' signal is sent after record is deleted. This means also
that transaction is closed at that moment. And DB should not has deleted
instance any more.

I have double checked the Django code and can say that Django send that
signal just before transaction is committed.


Is this a Django bug?

Is it the same for post_save?

Mike


So technically instance should be inside DB for Hibernate processing.

I can suggest you to create a custom signal and send it after
transaction closed.
That should solve your problem.

Regards,

On Wed, Jul 27, 2016 at 5:27 PM, Stodge > wrote:

My website uses a combination of Django + Java apps to function. For
this particular problem, a record is deleted from the DB via a
TastyPie resource DELETE operation. A Django signal post_delete
handleris invoked, which submits a DELETE request to Jetty running
in the Java app. The Java app then performs a query using Hibernate.

What appears to be happening is that Django thinks the record was
deleted:

DynamicVolume.objects.filter(user=instance.user).count()

Returns ZERO.

However, the Java app thinks the record still exists unless I make
it sleep for several seconds before asking Hibernate to query the DB.

I've tried forcing Hibernate to clear its cache with no success. Is
there a way to force Django to commit the deletion (flush the cache)?

Thanks

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to django-users+unsubscr...@googlegroups.com
.
To post to this group, send email to django-users@googlegroups.com
.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit

https://groups.google.com/d/msgid/django-users/e76d5cfa-f4bc-41db-a322-0d44aa0719dd%40googlegroups.com

.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com
.
To post to this group, send email to django-users@googlegroups.com
.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CAK52boWeFYGOhk0CL%2BoEimreb2k%2BgFwL2rBb0imoPbmfpwo5Yw%40mail.gmail.com
.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/450c40f7-8997-6669-b307-b39825d00adb%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: Any way to force Django to commit a write so another process can read the correct data from DB?

2016-07-27 Thread Luis Zárate
I thing java apps have a cache and it is java who is not looking in the
database.  I was a similar problem with hirbernate time ago. But I never
solved other person solved it and I don't know how.

El miércoles, 27 de julio de 2016, Constantine Covtushenko <
constantine.covtushe...@gmail.com> escribió:
> Hi Stodge,
> As said in Django current version of documentation, 'post_delete' signal
is sent after record is deleted. This means also that transaction is closed
at that moment. And DB should not has deleted instance any more.
> I have double checked the Django code and can say that Django send that
signal just before transaction is committed.
> So technically instance should be inside DB for Hibernate processing.
> I can suggest you to create a custom signal and send it after transaction
closed.
> That should solve your problem.
> Regards,
> On Wed, Jul 27, 2016 at 5:27 PM, Stodge  wrote:
>>
>> My website uses a combination of Django + Java apps to function. For
this particular problem, a record is deleted from the DB via a TastyPie
resource DELETE operation. A Django signal post_delete handleris invoked,
which submits a DELETE request to Jetty running in the Java app. The Java
app then performs a query using Hibernate.
>>
>> What appears to be happening is that Django thinks the record was
deleted:
>>
>> DynamicVolume.objects.filter(user=instance.user).count()
>>
>> Returns ZERO.
>>
>> However, the Java app thinks the record still exists unless I make it
sleep for several seconds before asking Hibernate to query the DB.
>>
>> I've tried forcing Hibernate to clear its cache with no success. Is
there a way to force Django to commit the deletion (flush the cache)?
>>
>> Thanks
>>
>> --
>> You received this message because you are subscribed to the Google
Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/e76d5cfa-f4bc-41db-a322-0d44aa0719dd%40googlegroups.com
.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CAK52boWeFYGOhk0CL%2BoEimreb2k%2BgFwL2rBb0imoPbmfpwo5Yw%40mail.gmail.com
.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
"La utopía sirve para caminar" Fernando Birri

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG%2B5VyP4FfD5hdMYnd5jw0agx_u4nyDRH5U6mG9wvwxXxOQCnA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Any way to force Django to commit a write so another process can read the correct data from DB?

2016-07-27 Thread Constantine Covtushenko
Hi Stodge,

As said in Django current version of documentation
,
'post_delete' signal is sent after record is deleted. This means also that
transaction is closed at that moment. And DB should not has deleted
instance any more.

I have double checked the Django code and can say that Django send that
signal just before transaction is committed.
So technically instance should be inside DB for Hibernate processing.

I can suggest you to create a custom signal and send it after transaction
closed.
That should solve your problem.

Regards,

On Wed, Jul 27, 2016 at 5:27 PM, Stodge  wrote:

> My website uses a combination of Django + Java apps to function. For this
> particular problem, a record is deleted from the DB via a TastyPie resource
> DELETE operation. A Django signal post_delete handleris invoked, which
> submits a DELETE request to Jetty running in the Java app. The Java app
> then performs a query using Hibernate.
>
> What appears to be happening is that Django thinks the record was deleted:
>
> DynamicVolume.objects.filter(user=instance.user).count()
>
> Returns ZERO.
>
> However, the Java app thinks the record still exists unless I make it
> sleep for several seconds before asking Hibernate to query the DB.
>
> I've tried forcing Hibernate to clear its cache with no success. Is there
> a way to force Django to commit the deletion (flush the cache)?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e76d5cfa-f4bc-41db-a322-0d44aa0719dd%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK52boWeFYGOhk0CL%2BoEimreb2k%2BgFwL2rBb0imoPbmfpwo5Yw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Any way to force Django to commit a write so another process can read the correct data from DB?

2016-07-27 Thread Stodge
My website uses a combination of Django + Java apps to function. For this 
particular problem, a record is deleted from the DB via a TastyPie resource 
DELETE operation. A Django signal post_delete handleris invoked, which 
submits a DELETE request to Jetty running in the Java app. The Java app 
then performs a query using Hibernate.

What appears to be happening is that Django thinks the record was deleted:

DynamicVolume.objects.filter(user=instance.user).count()

Returns ZERO.

However, the Java app thinks the record still exists unless I make it sleep 
for several seconds before asking Hibernate to query the DB.

I've tried forcing Hibernate to clear its cache with no success. Is there a 
way to force Django to commit the deletion (flush the cache)?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e76d5cfa-f4bc-41db-a322-0d44aa0719dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I do a multiple select in the Admin filters ?

2016-07-27 Thread Hurlu
Woo , finally did it !

For those coming after me , here is how I did :
Your 
struggle probably comes from the self.value() never being a list , right ? 
Well then, if you override the template filter.html to add a "multiple" to 
the , then , in your redefinition of the queryset() function, do a 
self.value = request.GET.getlist("[Insert parameter_name from your 
filter]"), then you'll get the list you clicked back in the Django admin !
 (The problem being that django uses request.GET.items() to retrieve the 
self.value(). Alas, as stated in this documentation, 

 
this method only gets the last item of the QueryDict object, unlike 
getlist() !

There is still one little problem to fix, being that , when loading the new 
page, the filter is being "resetted", containing only the last item of the 
QueryDict. I believe that's nothing that an handy JS /JQuery script can't 
handle though, so I may edit this comment adding the script when I manage 
to get it to work. 

Cheers! 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f1416a0e-8a86-4c8f-882e-f1cd2565d1f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Installation

2016-07-27 Thread Sergiy Khohlov
Take a look at
https://jeffknupp.com/blog/2012/02/09/starting-a-django-project-the-right-way/
this is perfect doc related to your situation s.

27 лип. 2016 12:04 "Its Eternity"  пише:

Hey, a friend recently wrote my a web-app for me to use however I am not
sure how I deploy the web app onto my VPS. I've looked at the tutorials on
Django but it says that  I can only use it for development. Is there a
method for me to get Django for public use?

-- 
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/95e91756-b960-4021-8603-e3ee21c3b4b9%40googlegroups.com

.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADTRxJMBN2Voi0pqOoc7iY_rjzbwX9e99kSktsWqXjN3GrRQPQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Installation

2016-07-27 Thread Julien Castets
On Wed, Jul 27, 2016 at 10:16 AM, Its Eternity  wrote:
> Hey, a friend recently wrote my a web-app for me to use however I am not
> sure how I deploy the web app onto my VPS. I've looked at the tutorials on
> Django but it says that  I can only use it for development. Is there a

Hi,

I created a Python image a while ago for Scaleway, a cloud computing
provider (https://www.scaleway.com/). To host a Django application on
Scaleway using this image, you need to:
* create an account
* start a new server, click on "choose image", use the "imagehub" tab
and select the "Python" image
* start the server and ssh into it

The /root/README.txt file explains how to create a Django application:

$> pip install django
$> cd /var/www
$> django-admin startproject my_django_project
$> ln -s /etc/nginx/sites-available/my_website /etc/nginx/sites-enabled/
$> ln -s /etc/uwsgi/apps-available/my_django_project.ini
/etc/uwsgi/apps-enabled/
$> service uwsgi restart
$> service nginx restart

More details on the image's github:
https://github.com/scaleway-community/scaleway-python/tree/master/overlay

Disclaimer: I work at Scaleway

Regards,
-- 
Julien Castets
+33 (0)6.85.20.10.03

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADF714bp8M0binr_75dQh%2Bjhu-rwuXvtPqfz8LWvHZyyoyGXYQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Installation

2016-07-27 Thread Its Eternity
Hey, a friend recently wrote my a web-app for me to use however I am not 
sure how I deploy the web app onto my VPS. I've looked at the tutorials on 
Django but it says that  I can only use it for development. Is there a 
method for me to get Django for public use?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/95e91756-b960-4021-8603-e3ee21c3b4b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Best way to keep the current selection

2016-07-27 Thread Javier Guerra Giraldez
On 27 July 2016 at 02:02, Lee Hinde  wrote:
> To maintain state, after any ad-hoc query, I store the ids for the found 
> records:
>
> self.request.session['query.classes.last_ids'] = 
> list(queryset.values_list('id', flat=True))

add a new model: Previous_Searchs or something like this, with
metadata on the search (user, date, sort critera, etc) and a many2many
link to the found records.

it makes it easy to repeat a search, keep it for longer, name it, or
even share it


-- 
Javier

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFkDaoQ7_0jHOFdoPUL3G6GizWvFZub354Vjcog-LTb3ZKQ8-A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.