Re: Detecting modifications in ManyToMany field

2015-03-08 Thread Fabien Schwob
With the m2m changed signal I can only have the state of the object after
it has been saved. Not the difference between before and after the change.
On sam. 7 mars 2015 at 16:53 Vijay Khemlani  wrote:

> You might find the m2m_changed signal useful
>
> https://docs.djangoproject.com/en/1.7/ref/signals/#m2m-changed
> On Sat, Mar 7, 2015 at 7:57 AM, Fabien Schwob  wrote:
>
>> Hello,
>>
>> I would like to detect changes in a ManyToMany field, to update data
>> in the linked Model. I've two objects :
>>
>> class Category(models.Model):
>>  some fields ...
>>
>>
>> class Post(models.Model):
>>  some fields ...
>> categories = models.ManyToManyField(Category)
>>
>> And I would like to detect (in the admin and when accessing the object
>> in python) when categories are added or removed to a Post. To update
>> some fields in the Category model. But I've tried with :
>>
>>  * django.db.models.signals.m2m_changed, but it doesn't appear to be
>> trigged in the admin
>>  * by overriding Post.save(), but I get the same information before
>> and after the save() (I think it's because m2m are handled after
>> save() has finished) :
>>
>> def save(self, *args, **kwargs):
>> print Post.objects.get(pk=self.id).categories.all()
>> super(Post, self).save(*args, **kwargs)
>> print Post.objects.get(pk=self.id).categories.all()
>>
>> Any solutions to handle this case ? With a custom signal, or anything
>> else ?
>>
>> Thanks
>> --
>> Fabien Schwob
>>
>  --
>>
> 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 http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAL%3DxoZRnd7812MykJSsh3Avhh%2BiFk9J3g9nkhv61UA%3D4a9j8Ow%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAL%3DxoZRnd7812MykJSsh3Avhh%2BiFk9J3g9nkhv61UA%3D4a9j8Ow%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALn3ei0-ZNc2je48jNdt_E78jK%2BO-HCO8zpKyb3%2BtCMx0Ee9Xw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CALn3ei0-ZNc2je48jNdt_E78jK%2BO-HCO8zpKyb3%2BtCMx0Ee9Xw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAL%3DxoZQbykrPHhdeo8vVr2rD0R4owVhP%2Bd7OZ9fCux4qqStVNg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Detecting modifications in ManyToMany field

2015-03-07 Thread Fabien Schwob
Hello,

I would like to detect changes in a ManyToMany field, to update data
in the linked Model. I've two objects :

class Category(models.Model):
 some fields ...


class Post(models.Model):
 some fields ...
categories = models.ManyToManyField(Category)

And I would like to detect (in the admin and when accessing the object
in python) when categories are added or removed to a Post. To update
some fields in the Category model. But I've tried with :

 * django.db.models.signals.m2m_changed, but it doesn't appear to be
trigged in the admin
 * by overriding Post.save(), but I get the same information before
and after the save() (I think it's because m2m are handled after
save() has finished) :

def save(self, *args, **kwargs):
print Post.objects.get(pk=self.id).categories.all()
super(Post, self).save(*args, **kwargs)
print Post.objects.get(pk=self.id).categories.all()

Any solutions to handle this case ? With a custom signal, or anything else ?

Thanks
-- 
Fabien Schwob

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAL%3DxoZRnd7812MykJSsh3Avhh%2BiFk9J3g9nkhv61UA%3D4a9j8Ow%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Using multiples version of Django on the same server

2007-09-07 Thread Fabien Schwob

Hello,

I'm setting up a new server to host my Django projects and they don't
each use the same version of Django (0.95, 0.96 and svn). Is their a
way to configure each virtualhost to use their own version of Django ?

Thanks

-- 
Fabien SCHWOB

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ORM API and applications best practice

2007-08-15 Thread Fabien Schwob

Hello,

I'm currently rewriting an old Django project (the original was build
on Django 0.95), and I'm trying to rewrite it with the best practice.
My application is centered around a Clubber model which extend the
built-in User model. So the models are currently :

In the clubber app:

class Clubber(models.Model):
user = models.ForeignKey(User, unique=True)
avatar = models.ImageField()
[ ... other fields ... ]

In the messagin app:

class InternalMessaging(models.Model):
from = models.ForeignKey(Clubber)
to = models.ForeignKey(Clubber)
content = models.TextField()

It allow me to easily access the clubber avatar from the message with
message_instance.from.avatar, but it had the drawback to force me to
bundle the Clubber app if I would like to re-use the messaging app.

I would like to use the User in the internal message instead of the
Clubber, but now I can't access the avatar field in a good way (with
select_related()). What is the good solution to solve this problem ?

Thanks

-- 
Fabien SCHWOB

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django app for managing sending email to users...

2007-08-06 Thread Fabien Schwob

Hello,

> I've set up django-mailer at Google Code:
>
> http://code.google.com/p/django-mailer/
>
> and written down a bunch of notes on the home page about use cases
> and functional requirements.
>
> If no one objects, we can continue discussion on this list, although
> I'm happy to start up django-mailer list at Google Groups if people
> prefer.

How is it possible to help ? I'm about to write somethink like
django-mailer for a website I maintain, so I think it's better to
contribute to django-mailer.

Does you already have an idea of the architecture of this future app ?

-- 
Fabien SCHWOB

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Error was: 'module' object has no attribute 'process_register'

2007-08-03 Thread Fabien Schwob

Hello,

I'm currently rewriting a website to take advantage of the new new
features of the trunk. I'm using named urls and the {% url  %}
tag. But from time to time, I get the following errors :

ViewDoesNotExist at /
Tried process_register in module chibbi.club.views. Error was:
'module' object has no attribute 'process_register'

Request Method: GET
Request URL:http://127.0.0.1:8000/
Exception Type: ViewDoesNotExist
Exception Value:Tried process_register in module chibbi.club.views.
Error was: 'module' object has no attribute 'process_register'
Exception Location:
C:\Python25\Lib\site-packages\django\core\urlresolvers.py in
_get_callback, line 184
Python Executable:  C:\Python25\python.exe
Python Version: 2.5.0

The problem is raised when the template encounter the following tag :
{% url clubber-public-profil connected.user %}

I've the problem on :
* Django : trunk (I've make an svn up today) / Python : 2.5 / DB: Sqlite
* Django : trunk (from ~1 week) / Python : 2.4.4 / DB: Sqlite

Does someone know how to solve this issue ?

Thanks

-- 
Fabien SCHWOB

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django equivalent of ROR flash

2007-08-02 Thread Fabien Schwob

Hello,

> Does Django have this
> http://api.rubyonrails.com/classes/ActionController/Flash.html

Django provides something similar in the authentification app, but it
works only the the authentificated users :

http://www.djangoproject.com/documentation/authentication/#messages



-- 
Fabien SCHWOB

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Do I have to send shopping cart data to every template in my app?

2007-08-01 Thread Fabien Schwob

On 8/2/07, Greg <[EMAIL PROTECTED]> wrote:
>
> I've created a shopping cart.  I want to put something on the top of
> every page that let's people know how many items they have in their
> cart.  I have a lot of views that don't send any dictionary key's that
> contain shopping cart info.   If I want to do this...do I now have to
> edit every view return render_to_response line so that they all
> contain a key that contains my shopping cart info?

You could also try to use a context processor to populate the template
with the values of your shopping cart :

http://www.djangoproject.com/documentation/templates_python/#writing-your-own-context-processors

-- 
Fabien SCHWOB

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Best practices to provide Django on a shared host

2007-07-05 Thread Fabien Schwob

> Textdrive (Joyent) offers Django hosting.
>
> There is an install script that will setup Django for you:
> http://textusers.com/wiki/Installing_Django

The problem is that I would like to make my own configuration from a
raw Linux distribution (In my case a Ubuntu 6.10 or 7.04). So, with
this link I don't know how are Textdrive server configured.

My goal is for example to provide a tutorial on how to build something
like Gypsyhosting from a clean Ubuntu install.

Thanks

-- 
Fabien SCHWOB

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Best practices to provide Django on a shared host

2007-07-05 Thread Fabien Schwob

Hello,

I'm currently hosting  my Django websites on a dedicated server and it
works fine. I restart Apache when I make modifications since I'm alone
on the box.

But I've made evangelism for Django and I've convinced some friends to
use it. So I would like to take a new server and to set up a "Django
Shared Hosting". What is the best way to do that ?

- One Apache instance by user/website (I've seen that on
http://www.gypsyhosting.com/) ? But how to do that does someone have
some links to do that ?

- Using lighttpd and FGCI ?

- Using Apache and FCGI, so the user only need to *touch* the fcgi script.

My goal is to build my shared hosting and to create a document on how
to do that. So, any help are welcome.

Thanks.

-- 
Fabien Schwob

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Creating a decoration for the views

2006-10-24 Thread Fabien Schwob

>  # Create the decorator
>  def decorador(function):
>  def new_function(*args, **kwargs):
>  # Do what need do
>  return function(*args, **kwargs)
>  new_function.__doc__ = function.__doc__
>  new_function.__name__ = function.__name__
>  return new_function
>
>  # Then use it
>  @decorador
>  def another_function(params):
>  # bla bla bla

And how can I add vars to the function local namespace ?

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Creating a decoration for the views

2006-10-23 Thread Fabien Schwob

Hello,

I've some code which is duplicated between all my views and it violate
the DRY principle. So, I would like to use the decorators to eliminate
the duplicated code. Does someone has a simple example on how to do
that.

The code I would like to factorise is the following one :

if 'is_logged' not in request.session:
request.session['is_logged'] = False
if 'user_id' in request.session:
unread_messages_count =
InternalMessage.objects.filter(to_clubber__id=request.session['user_id'],read=False).count()
total_messages_count  =
InternalMessage.objects.filter(to_clubber__id=request.session['user_id']).count()
else:
unread_messages_count = total_messages_count = None

To summarize, I would like to :
- populate the function namespace with some vars
- manipulate the sessions

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



send_mail and ESMTP

2006-09-24 Thread Fabien Schwob

Hello,

I would like to know if someone here has already tried to send mail
using an ESMTP compatible server. When I'm trying to do that, I get
the following error :

smtplib.SMTPAuthenticationError: (535, 'authorization failed (#5.7.0)')

And I can't see if the problem come from Django or from the ESMTP
server. Has someone an idea on how to solve this problem ?

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Filter, ForeignKey and edit_inline

2006-08-17 Thread Fabien Schwob

> To do the filter you want, you can use the 'range' field lookup:
> import datetime
> start_date = datetime.date.today()
> end_date = some_other_date
> events =
> Event.objects.filter(eventdate__beginning_date__range=(start_date,
> end_date))
>
> If you've already picked an event, you can get its future eventdates
> with
> event.eventdate_set.filter(range=(start_date, end_date))

This solution work, but it seems that it's not possible to order the
event by the beginning date of the eventdate object. Does anyone have
an idea in order to solve this problem ?

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Django, mod_python and 403 error

2006-08-17 Thread Fabien Schwob

> Maybe try something like:
>
> 
> ...
> 
>SetHandler mod_python
>PythonHandler django.core.handlers.modpython
>PythonPath "['/home/cocoa'] + sys.path"
>SetEnv DJANGO_SETTINGS_MODULE chibbi.settings
> 
> ...
> 

I get the same error with this solution.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Django, mod_python and 403 error

2006-08-17 Thread Fabien Schwob

> It'd be a great help if you pasted the errors from Apache's error log.
> Also, what kind of 403 errors do you get -- could you include a link
> to a screenshot?

In the error log I get :
[Thu Aug 17 18:31:01 2006] [error] [client 86.73.128.192]
(13)Permission denied: cannot read directory for multi:
/home/cocoa/www/, referer: http://www.cocoa.fr/

And to see the front error :
http://www.cocoa.fr/lieux/

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Django, mod_python and 403 error

2006-08-16 Thread Fabien Schwob
Nobody have an idea on how to solve this problem ?

On 8/10/06, Fabien Schwob <[EMAIL PROTECTED]> wrote:
> Hello,
>
> The development of my Django site is on the way. And in order to try
> it online, I've decided to install it under Apache + mod_python. But
> when I'm trying to access it, I get a 403 errors on all pages except
> the index page.
>
> I've installed it at http://www.cocoa.fr and the virtual host
> configuration is the following one :
>
> 
> ServerAdmin [EMAIL PROTECTED]
> DocumentRoot /home/cocoa/www
> SuexecUserGroup cocoa users
> ServerName www.cocoa.fr
> ServerAlias cocoa.fr
> CustomLog logs/cocoa-access_log combined
> ScriptAlias /cgi-bin/ /home/cocoa/cgi-bin/
> AddHandler x-httpd-php5 .php
>
> SetHandler mod_python
> PythonHandler django.core.handlers.modpython
> PythonPath "['/home/cocoa'] + sys.path"
> SetEnv DJANGO_SETTINGS_MODULE chibbi.settings
> Alias /media "/home/cocoa/chibbi/media"
>
> 
>     SetHandler None
> 
> 
>
> The project is in the /home/cocoa/chibbi folder.
>
> Thanks in advance.
>


-- 
Fabien SCHWOB
_
Derrière chaque bogue, il y a un développeur, un homme qui s'est trompé.
(Bon, OK, parfois ils s'y mettent à plusieurs).

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Django, mod_python and 403 error

2006-08-09 Thread Fabien Schwob

Hello,

The development of my Django site is on the way. And in order to try
it online, I've decided to install it under Apache + mod_python. But
when I'm trying to access it, I get a 403 errors on all pages except
the index page.

I've installed it at http://www.cocoa.fr and the virtual host
configuration is the following one :


ServerAdmin [EMAIL PROTECTED]
DocumentRoot /home/cocoa/www
SuexecUserGroup cocoa users
ServerName www.cocoa.fr
ServerAlias cocoa.fr
CustomLog logs/cocoa-access_log combined
ScriptAlias /cgi-bin/ /home/cocoa/cgi-bin/
AddHandler x-httpd-php5 .php

SetHandler mod_python
PythonHandler django.core.handlers.modpython
PythonPath "['/home/cocoa'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE chibbi.settings
Alias /media "/home/cocoa/chibbi/media"


SetHandler None



The project is in the /home/cocoa/chibbi folder.

Thanks in advance.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Filter, ForeignKey and edit_inline

2006-07-22 Thread Fabien Schwob

Hello,

I'm currently developing a Django application and I've a problem in
how to use the filter() function. I've two models that can me resumed
as :

Class Event:
location = models.ForeignKey(Place)
name = models.CharField(maxlength=200)
public_price = models.FloatField(max_digits=10, decimal_places=2)
member_price = models.FloatField(max_digits=10, decimal_places=2)
description = models.TextField()
number_of_places = models.IntegerField()

class EventDate:
beginning_date = models.DateTimeField(core=True)
end_date = models.DateTimeField(core=True)
event = models.ForeignKey(Event, edit_inline=True)
used_tag = models.CharField(maxlength=50)

And I would like to select all the event that had at least an event
date where the beginning_date is going to happend ( > now). But I
don't know how to had an access to the EventDate objects from the
Event object.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Relations accros multiple apps

2006-06-16 Thread Fabien Schwob
Hello,

I'm about to create my first Django apps and I would like to know if
it's possible to have relationships between models accross multiple
apps. For example I would like to have :

App User:
class User:
#some fields

App Blog
class Blog:
author = models.ForeignKey(User.user)

Is-it possible to do that ?

Thanks

-- 
Fabien SCHWOB
_
Derrière chaque bogue, il y a un développeur, un homme qui s'est trompé.
(Bon, OK, parfois ils s'y mettent à plusieurs).

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---