Re: Django (cache?) make some mistake with formset generated class

2013-11-07 Thread Bastien Sevajol
You're right! I mistake with python object logic :/ Sorry ! 
Thank's !

Le jeudi 7 novembre 2013 14:45:45 UTC+1, Simone Federici a écrit :
>
>
> On Thu, Nov 7, 2013 at 11:54 AM, Bastien Sevajol 
> <sevajol...@gmail.com
> > wrote:
>
>> formsets = {}
>
>
> this class variable is in ModelFormsetManager class namespace
> so it is shared across the subclasses.
>
> You are using formsets to save before the object class, and after the 
> instances,
> so when in the formset there is the instance of the last "view", and you 
> try to call it
> create the instance of an class works, call the instance return object is 
> not callable exception
>
> your last solution solve only apparently the superclass-namespace issue.
>
>
> regards
>  

-- 
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/f3e7a325-ac20-4eaa-98fe-dcb6059e0931%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Django (cache?) make some mistake with formset generated class

2013-11-07 Thread Bastien Sevajol
Hello, i don't know if it's a django or python problem. But i correct a 
strange bug and would know why my code was bugging and if it was django, 
python, or me. The situation (and solution) is exposed 
herebut
 i reproduce it here:

I've two page, each of one display a form and a formset. They have same 
code logic:

*views*

> from django.forms.models import inlineformset_factoryfrom 
> djStock.stock.models import MyAModelfrom djStock.stock.forms.MyAModelForm 
> import MyAModelFormfrom djStock.stock.models import MyBModelfrom 
> djStock.stock.forms.MyBModelForm import MyBModelForm
> def a_create(request):
>
>   form = MyAModelForm()
>   formset_factory = inlineformset_factory(MyAModel, MyAModel.things.through)
>   formset = formset_factory()
>   [...]
> def b_create(request):
>
>   form = MyBModelForm()
>   formset_factory = inlineformset_factory(MyBModel, MyBModel.things.through)
>   formset = formset_factory()
>   [...]
>
> (With this code, all work fine) So i made refactoring and write some class 
(i removed unecessary code for exemple):

*ModelFormsetManager*

> from django.forms.models import inlineformset_factory
> class ModelFormsetManager(object):
>
>   form = None
>   formsets = {}
>
>   def initialize_formset(self, name, entity, related_entity):
> self.formsets[name] = inlineformset_factory(entity, related_entity)
>
> # for debug at the end of question
> print self.formsets[name]
>
>   def __init__(self, request, form_class):
> if request.method == 'POST':
>   [...]
> else:
>   self.form = form_class()
>   for formset_name, formset in self.formsets.iteritems():
>
> # for debug at the end of question
> print formset
>
> self.formsets[formset_name] = formset()
>
> *
*

*MyAModelManager*

> from ..models import MyAModelfrom ..forms.MyAModelForm import 
> MyAModelFormfrom djStock.stock.managers.ModelFormsetManager import 
> ModelFormsetManager
> class MyAModelManager(ModelFormsetManager):
>
>   def __init__(self, request):
> self.initialize_formset('things', MyAModel, MyAModel.things.through)
> super(MyAModelManager, self).__init__(request, MyAModelForm)
>
> *MyBModelManager*

> from ..models import MyBModelfrom ..forms.MyBModelForm import 
> MyBModelFormfrom djStock.stock.managers.ModelFormsetManager import 
> ModelFormsetManager
> class MyBModelManager(ModelFormsetManager):
>
>   def __init__(self, request):
> self.initialize_formset('things', MyBModel, MyBModel.references.through
> super(MyBModelManager, self).__init__(request, MyBModelForm)
>
>
With this refactoring my views look like:

> def a_create(request):
>   a_manager = MyAModelManager(request=request)
>   [...]
> def b_create(request):
>   b_manager = MyBModelManager(request=request)
>   [...]
>
>  

Okay, now the strange bug (keep in mind one thing: actions order is 
important): 

   - When i load *a_create* view, all is displayed correctly (reloading 
   page to). 

Prints displays that:

>  'django.forms.formsets.MyAModelThingFormFormSet'>
>
>
   - I load *b_create* view, an error raised.

Prints displays that:

>  'django.forms.formsets.MyBModelThingFormFormSet'>
>
>
And error is:

> File 
> "/home/bux/.python/envs/djStock/local/lib/python2.7/site-packages/django/core/handlers/base.py",
>  line 115, in get_response
> response = callback(request, *callback_args, **callback_kwargs)
>   File "/home/bux/Private/projets/djStock/stock/views/b.py", line 28, in 
> b_create
> b_manager = MyBModelManager(request=request)
>   File 
> "/home/bux/Private/projets/djStock/../djStock/stock/managers/MyBModelManager.py",
>  line 9, in __init__
> super(MyBModelManager, self).__init__(request, MyBModelForm)
>   File 
> "/home/bux/Private/projets/djStock/../djStock/stock/managers/ModelFormsetManager.py",
>  line 31, in __init__
> self.formsets[formset_name] = formset()TypeError: 
> 'MyAModelThingFormFormSet' object is not callable
>
> *Important note*: At "formset()" django is trying to call My 
> *A*ModelThingFormFormSet whereas My 
*B* ModelThingFormFormSet (print confirm it showing 
MyBModelThingFormFormSet). That's one of strange point.

   - 
   
   If i reload *b_create* view, same error. If i reload *a_create* view 
   it's always working.
   - 
   
   I turn off *python manage.py runserver |...]* and run it again
   - 
   
   I load *b_create* view (previously rasing error), now it's *working*.
   
Prints displays that:

>  'django.forms.formsets.MyBModelThingFormFormSet'>
>
>
   - I load *a_create* view (previously working), now it is *not* working.

Prints displays that:

>  'django.forms.formsets.MyAModelThingFormFormSet'>
>
> And error is:

> Traceback (most recent call last):
>   File 
> "/home/bux/.python/envs/djStock/local/lib/python2.7/site-packages/django/core/handlers/base.py",
>  line 115, in get_response
> response = callback(request, 

Re: html templates and dynamic loading

2013-08-26 Thread Bastien Amiel

Le 24/08/2013 04:44, Mantas Zilinskis a écrit :

this might help you

http://stackoverflow.com/questions/1879872/django-update-div-with-ajax

let me know if you need more help


Thank you for this good pointer.




On Fri, Aug 23, 2013 at 10:51 AM, Bastien Amiel <b.am...@evs.com 
<mailto:b.am...@evs.com>> wrote:


Le 23/08/2013 17:01, Mantas Zilinskis a écrit :

can you post all of chat.html



On Fri, Aug 23, 2013 at 7:04 AM, Bastien Amiel <b.am...@evs.com
<mailto:b.am...@evs.com>> wrote:

Le 23/08/2013 11:26, Huu Da Tran a écrit :

On Thursday, August 22, 2013 8:42:04 AM UTC-4, Bastien Amiel
wrote:

I need to update the chat when an event come but :

1.
If I update my chat sub page, inputs are reset (seems
logic since html
is recreated).


You can always have some field that keep when the chat was
started (in the session), and redisplay everything since
that time.

Then what would be the good / best method to update only
the chat content ?
(I have 2 ideas but they don't seems very Django'ic)

2.
For now, I update the content every XX ms with a
periodic request client
side.
Would it be possible / preferable to have a push from
server when new
data comes or is there a better way to update this kind
of content ?


Trying to hack django to get server push would be hell (look
into tornado). If you really need server push, you may need
to look into other technologies, like nodejs.

Using the periodic request client-side is what is mostly done.


Hope this helps.

HD.


1.
My question was not clear enough,
Let's admit i have this template page :

/{% for elem in data %}//
////
//{{ elem.datetime }}//
//{{ elem.name <http://elem.name>
}} ://
//{{ elem.text }}//
////
//{% endfor %}//
//Text : /

and this view.py :

/def getchat(request)://
//template = loader.get_template('chat.html')//
//context  = RequestContext(request, { 'data': lines
})//# lines is an array with lines
//response = {'html' : template.render(context)}//
//return HttpResponse(json.dumps(response),
mimetype='application/json')/

and this javascript :

/function getchat()//
//{ //
//$.post('/getchat')//.done(function(data, textStatus,
jqXHR) //
//{//
//$("#chat").html(data["html"])//
//})//
//}

/Then whenever I call getchat() in javascript, the chat is
reloaded with all the old lines, this point is ok, but
 field is reseted too, which mean that if user was
typing, the content is erased.
I would say the solution is to create a second function in
view /getchatcontent/ that will send only the content so I do
not
update the whole thing. Do you think it is the right way ?


2.
lets use periodic request client-side.



Thank you for your answer



There is nothing more in chat.html
there is a base.html template that contains

///
//{% load staticfiles %}//






//post//
///


appchat.js


/$(document).ready(function()//
//{//
//$("#addline").click(function()//
//{//
//addline($("#chatname")[0].value,
$("#chatinput")[0].value);//
//$("#chatinput")[0].value = "" //
//})//
//setInterval(function() { getchat() }, 1000);//
//})//
//
//function addline(name, text)//
//{//
//$.post('/addline', {"name":name, "text":text})//
//.done(function() //{//})//
//}//
//
//function getchat()//
//{ //
//   $.post('/getchat')/
/
//.done(function(data, textStatus, jqXHR) //
//{//
   $("#chat").html(data["html"])//
//})//
//}/


Now you have everything, does this seems the right way to do what
I want to achieve with django or is there a better way ?



--
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: html templates and dynamic loading

2013-08-23 Thread Bastien Amiel

Le 23/08/2013 17:01, Mantas Zilinskis a écrit :

can you post all of chat.html



On Fri, Aug 23, 2013 at 7:04 AM, Bastien Amiel <b.am...@evs.com 
<mailto:b.am...@evs.com>> wrote:


Le 23/08/2013 11:26, Huu Da Tran a écrit :

On Thursday, August 22, 2013 8:42:04 AM UTC-4, Bastien Amiel wrote:

I need to update the chat when an event come but :

1.
If I update my chat sub page, inputs are reset (seems logic
since html
is recreated).


You can always have some field that keep when the chat was
started (in the session), and redisplay everything since that time.

Then what would be the good / best method to update only the
chat content ?
(I have 2 ideas but they don't seems very Django'ic)

2.
For now, I update the content every XX ms with a periodic
request client
side.
Would it be possible / preferable to have a push from server
when new
data comes or is there a better way to update this kind of
content ?


Trying to hack django to get server push would be hell (look into
tornado). If you really need server push, you may need to look
into other technologies, like nodejs.

Using the periodic request client-side is what is mostly done.


Hope this helps.

HD.


1.
My question was not clear enough,
Let's admit i have this template page :

/{% for elem in data %}//
////
//{{ elem.datetime }}//
//{{ elem.name <http://elem.name> }}
://
//{{ elem.text }}//
////
//{% endfor %}//
//Text : /

and this view.py :

/def getchat(request)://
//template = loader.get_template('chat.html')//
//context  = RequestContext(request, { 'data': lines })//#
lines is an array with lines
//response = {'html' : template.render(context)}//
//return HttpResponse(json.dumps(response),
mimetype='application/json')/

and this javascript :

/function getchat()//
//{ //
//$.post('/getchat')//.done(function(data, textStatus, jqXHR) //
//{//
//$("#chat").html(data["html"])//
//})//
//}

/Then whenever I call getchat() in javascript, the chat is
reloaded with all the old lines, this point is ok, but
 field is reseted too, which mean that if user was typing,
the content is erased.
I would say the solution is to create a second function in view
/getchatcontent/ that will send only the content so I do not
update the whole thing. Do you think it is the right way ?


2.
lets use periodic request client-side.



Thank you for your answer



There is nothing more in chat.html
there is a base.html template that contains

///
//{% load staticfiles %}//







//post//
///


appchat.js


/$(document).ready(function()//
//{//
//$("#addline").click(function()//
//{//
//addline($("#chatname")[0].value, $("#chatinput")[0].value);//
//$("#chatinput")[0].value = "" //
//})//
//setInterval(function() { getchat() }, 1000);//
//})//
//
//function addline(name, text)//
//{//
//$.post('/addline', {"name":name, "text":text})//
//.done(function() //{//})//
//}//
//
//function getchat()//
//{ //
//   $.post('/getchat')//
//.done(function(data, textStatus, jqXHR) //
//{//
   $("#chat").html(data["html"])//
//})//
//}/


Now you have everything, does this seems the right way to do what I want 
to achieve with django or is there a better way ?


--
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: html templates and dynamic loading

2013-08-23 Thread Bastien Amiel

Le 23/08/2013 11:26, Huu Da Tran a écrit :

On Thursday, August 22, 2013 8:42:04 AM UTC-4, Bastien Amiel wrote:

I need to update the chat when an event come but :

1.
If I update my chat sub page, inputs are reset (seems logic since
html
is recreated).


You can always have some field that keep when the chat was started (in 
the session), and redisplay everything since that time.


Then what would be the good / best method to update only the chat
content ?
(I have 2 ideas but they don't seems very Django'ic)

2.
For now, I update the content every XX ms with a periodic request
client
side.
Would it be possible / preferable to have a push from server when new
data comes or is there a better way to update this kind of content ?


Trying to hack django to get server push would be hell (look into 
tornado). If you really need server push, you may need to look into 
other technologies, like nodejs.


Using the periodic request client-side is what is mostly done.


Hope this helps.

HD.


1.
My question was not clear enough,
Let's admit i have this template page :

/{% for elem in data %}//
////
//{{ elem.datetime }}//
//{{ elem.name }} ://
//{{ elem.text }}//
////
//{% endfor %}//
//Text : /

and this view.py :

/def getchat(request)://
//template = loader.get_template('chat.html')//
//context  = RequestContext(request, { 'data': lines })//# lines is 
an array with lines

//response = {'html' : template.render(context)}//
//return HttpResponse(json.dumps(response), 
mimetype='application/json')/


and this javascript :

/function getchat()//
//{ //
//$.post('/getchat')//.done(function(data, textStatus, jqXHR) //
//{//
//$("#chat").html(data["html"])//
//})//
//}

/Then whenever I call getchat() in javascript, the chat is reloaded with 
all the old lines, this point is ok, but
 field is reseted too, which mean that if user was typing, the 
content is erased.
I would say the solution is to create a second function in view 
/getchatcontent/ that will send only the content so I do not

update the whole thing. Do you think it is the right way ?


2.
lets use periodic request client-side.



Thank you for your answer

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


html templates and dynamic loading

2013-08-22 Thread Bastien Amiel

Hi list,

I'm testing Django for a few days now and I have 2 questions.

I created for my tests a simple chat integrated in a base page (one 
template for the main page, and one for the chat).


I need to update the chat when an event come but :

1.
If I update my chat sub page, inputs are reset (seems logic since html 
is recreated).

Then what would be the good / best method to update only the chat content ?
(I have 2 ideas but they don't seems very Django'ic)

2.
For now, I update the content every XX ms with a periodic request client 
side.
Would it be possible / preferable to have a push from server when new 
data comes or is there a better way to update this kind of content ?



Thanks for reading

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Is it secure to have IDs show up in URLs?

2012-03-23 Thread Bastien
Sorry maybe my post was not very clear, I am talking about public content 
here, that should be accessed by anyone, even anonymous users not logged in.
For instance if we talk about photos, publicly available, the url would 
look something like /photos/1, /photos/2  1 and 2 being the pk of the 
object in the db. If someone wants to download or link to these photos in a 
totally uncontrollable way (without using an API), with that system we are 
making it very easy to do mass content leakage. I don't want to promote 
security by obscurity here, just want to know what people in the group 
think about it and what solutions can be implemented, or if it is relevant 
at all.

The idea of slug could do the trick, but wouldn't it require some sort of 
date or title or a combination of both in the url? Not the most convenient 
in this case.

On Friday, March 23, 2012 12:17:02 PM UTC+1, Bastian Ballmann wrote:
>
> Hi Bastien,
>
> it's the task of the backend to manage the authorization including
> users and permissions. 
>
> If the view and permission system allows all users to see everything
> and you dont want it that way than you have to check permission in your
> views.
> See 
> https://docs.djangoproject.​com/en/1.3/topics/auth/<https://docs.djangoproject.com/en/1.3/topics/auth/>
>
> This has nothing to do with having the id in the url or not cause
> hiding the id wont help you get a more secure system if your auth
> backend is crappy. Security by obscurity doesnt work.
>
> HTH && Greets
>
> Basti
>
>
> Am Fri, 23 Mar 2012 04:06:45 -0700 (PDT)
> schrieb Bastien <>:
>
> > I am concerned about seeing the IDs of objects appearing in the URL
> > and in a totally predictable manner. It is very convenient and clean
> > to do all sorts of things but can be abused very easily to retrieve
> > all the content of the site, ie: photos... 
> > Is it a good idea to try to change this behavior? Maybe with some
> > sort of middleware? Is there any project doing it already? For
> > instance the urls in Instagram seem to be encoded at least.
> > 
>
> -- 
>  Bastian Ballmann / Web Developer
> Notch Interactive GmbH / Badenerstrasse 571 / 8048 Zürich
> Phone +41 43 818 20 91 / www.notch-interactive.com
>
>

-- 
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/-/JXu3CCHKtaQJ.
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 it secure to have IDs show up in URLs?

2012-03-23 Thread Bastien
I am concerned about seeing the IDs of objects appearing in the URL and in 
a totally predictable manner. It is very convenient and clean to do all 
sorts of things but can be abused very easily to retrieve all the content 
of the site, ie: photos... 
Is it a good idea to try to change this behavior? Maybe with some sort of 
middleware? Is there any project doing it already? For instance the urls in 
Instagram seem to be encoded at least.

-- 
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/-/UBBLhaPnHf4J.
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: apache + mod_python + svn

2009-07-14 Thread Bastien

ok my bad, I didn't realize that the structure of the project had
changed within the directory now that it is controlled by subversion
and of course at the root of the directory there is no settings file,
instead I have to go to the ultimate revision.

Thanks,
Bastien

On Jul 14, 11:43 am, Bastien <bastien.roche...@gmail.com> wrote:
> Hi,
>
> I know this is slightly off topic but such a common situation that I
> guess somebody has already run into it.
>
> I have just deployed my project on a remote debian server with apache
> and mod_python following the documentation and it just works very
> well.
>
> Now I need to use subversion to keep updating the project so I
> installed it via 'apt-get install subversion' and 'apt-get install
> libapache2-svn'. That's where I made a mistake because I'm only using
> svn via ssh so I did not need that apache mod.
>
> What happened is that when installing libapache2-svn my apache config
> files were modified and I was asked to restart the server and suddenly
> I was granted with a mod_python error instead of my home page.
>
> If anybody can spot what is wrong or knows what files have been
> changed so I can change them back that would be of great help. Here is
> the error message if is of any relevance:
>
> MOD_PYTHON ERROR
>
> ProcessId:      23452
> Interpreter:    '78.XX.XX.XX' <- my public IP
>
> ServerName:     '78.XX.XX.XX'
> DocumentRoot:   '/var/www/'
>
> URI:            '/'
> Location:       '/'
> Directory:      None
> Filename:       '/var/www/'
> PathInfo:       ''
>
> Phase:          'PythonHandler'
> Handler:        'django.core.handlers.modpython'
>
> ImportError: Could not import settings 'settings' (Is it on sys.path?
> Does it have syntax errors?): No module named settings
>
> One last thing the path of the project has changed but I updated it in
> the apache2/sites-available/default and restarted apache.
>
> Thank you,
> Bastien
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



apache + mod_python + svn

2009-07-14 Thread Bastien

Hi,

I know this is slightly off topic but such a common situation that I
guess somebody has already run into it.

I have just deployed my project on a remote debian server with apache
and mod_python following the documentation and it just works very
well.

Now I need to use subversion to keep updating the project so I
installed it via 'apt-get install subversion' and 'apt-get install
libapache2-svn'. That's where I made a mistake because I'm only using
svn via ssh so I did not need that apache mod.

What happened is that when installing libapache2-svn my apache config
files were modified and I was asked to restart the server and suddenly
I was granted with a mod_python error instead of my home page.

If anybody can spot what is wrong or knows what files have been
changed so I can change them back that would be of great help. Here is
the error message if is of any relevance:

MOD_PYTHON ERROR

ProcessId:  23452
Interpreter:'78.XX.XX.XX' <- my public IP

ServerName: '78.XX.XX.XX'
DocumentRoot:   '/var/www/'

URI:'/'
Location:   '/'
Directory:  None
Filename:   '/var/www/'
PathInfo:   ''

Phase:  'PythonHandler'
Handler:'django.core.handlers.modpython'

ImportError: Could not import settings 'settings' (Is it on sys.path?
Does it have syntax errors?): No module named settings

One last thing the path of the project has changed but I updated it in
the apache2/sites-available/default and restarted apache.

Thank you,
Bastien
--~--~-~--~~~---~--~~
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 custom render a checkbox list?

2009-07-09 Thread Bastien

Thank you Jashugan,

that's the way I went too but I thought there was a cleaner method,
right now it's working properly so I'll leave it alone but I'll have a
look later to see if I can improve that.

Bastien

On Jul 8, 6:09 pm, Jashugan <jashu...@gmail.com> wrote:
> On Jul 8, 5:26 am, Bastien <bastien.roche...@gmail.com> wrote:
>
> > I would like to
> > have the control of every checkbox the same way I can control the
> > fields of a form
>
> I think the easiest way to do this is to create a custom widget.
> Here's what I did:
>
> class CheckboxSelectMultiple(widgets.CheckboxSelectMultiple):
>   """Simply adds a class to the ul element, which allows the CSS to
> select it."""
>   def render(self, *args, **kwargs):
>     output = super(CheckboxSelectMultiple, self).render(*args,
> **kwargs)
>     return mark_safe(output.replace(u'', u''))
>
> You can modify the render method to produce the HTML output you want.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



How to custom render a checkbox list?

2009-07-08 Thread Bastien

Hi,

I have a list of checkboxes rendered automatically by django. It's a
list of the months of the year so the user can say when a shop is
opened. It works well but the design is not that great in the page so
instead of having all the checkboxes rendered as  I would like to
have the control of every checkbox the same way I can control the
fields of a form (that can be displayed as a  too but that can be
overridden).

so I have:

in my forms.py (a modelForm):
months_open = forms.MultipleChoiceField(choices = MONTH_LIST,
widget=forms.CheckboxSelectMultiple)

in my template:
{{ form.months_open }}

it is rendered as:

...

Do you think there is a way I can use something like
{{ form.months_open.month1 }} ?

thank you,
Bastien
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



request.path or request.path_info?

2009-07-06 Thread Bastien

Hi,

I could not find any valuable documentation about the differences
between request.path and request.path_info. anybody knows a bit about
them?

Thanks,
Bastien
--~--~-~--~~~---~--~~
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: best practice to have a list of mixed objects

2009-07-02 Thread Bastien

thanks I didn't know about that one, I'll give it a try!

On Jul 2, 12:57 pm, Jarek Zgoda <jarek.zg...@redefine.pl> wrote:
> Wiadomość napisana w dniu 2009-07-02, o godz. 12:45, przez Bastien:
>
> > I am trying to have a list of various types of objects, for example a
> > list mixed with users' profile, users' photo... to try to order all
> > these elements together by the amount of votes they received.
>
> > I use the list() function to store each query in a different variable
> > and then I extend() the list in only one variable.
>
> > I'm sure there's a better way to do that, if you have any idea you're
> > welcome to share it!
>
> If all objects have same named attribute for votes (i.e.  
> profile.votes, photo.votes) you may use attrgetter() to sort ordinal  
> Python list, eg.:
>
> import operator
> my_objects.sort(key=operator.attrgetter('votes'))
>
> --
> Artificial intelligence stands no chance against natural stupidity
>
> Jarek Zgoda, R, Redefine
> jarek.zg...@redefine.pl
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



best practice to have a list of mixed objects

2009-07-02 Thread Bastien

Hello,

I am trying to have a list of various types of objects, for example a
list mixed with users' profile, users' photo... to try to order all
these elements together by the amount of votes they received.

I use the list() function to store each query in a different variable
and then I extend() the list in only one variable.

I'm sure there's a better way to do that, if you have any idea you're
welcome to share it!

Thanks,
Bastien
--~--~-~--~~~---~--~~
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 convert a unicode string into something that can call an object?

2009-06-18 Thread Bastien

Thank you both, I think the dictionary is the safest method here but
I'm glad to know the existence of eval too because I've been searching
for it all day and sure will use it in the future.

Bastien

On Jun 18, 6:52 pm, Alex Gaynor <alex.gay...@gmail.com> wrote:
> On Thu, Jun 18, 2009 at 11:50 AM, Dennis Schmidt <metzelti...@googlemail.com
>
>
>
>
>
> > wrote:
>
> > object = eval(request.POST['type']).objects.get(pk=int(request.POST
> > ['id']))
>
> > should work. But you have to be very careful with what's inside of
> > your 'type' param, since it will get executed as Python code. So
> > always make sure nobody can inject malicious code there.
>
> > On 18 Jun., 18:40, Bastien <bastien.roche...@gmail.com> wrote:
> > > Hi,
>
> > > in one of my views I receive some unicode from javascript, namely I
> > > receive a type of object and its pk. Then I do this:
>
> > >             object = request.POST['type'].objects.get(pk=int
> > > (request.POST['id']))
> > > and of course Django tells me that a unicode object has no attribute
> > > 'objects'. So how could I convert this request.POST to something
> > > usable in this case?
>
> > > thanks,
> > > Bastien
>
> I wouldn't use eval here, as verifying that the contents of the string are
> safe is more trouble than it's worth, I would simply use a dictionary to map
> possible types to the classes themsleves, something like
>
> types = {
>     'user': User,
>     'article': Article,
>
> }
>
> types[request.POST['type']].objects
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



How to convert a unicode string into something that can call an object?

2009-06-18 Thread Bastien

Hi,

in one of my views I receive some unicode from javascript, namely I
receive a type of object and its pk. Then I do this:

object = request.POST['type'].objects.get(pk=int
(request.POST['id']))
and of course Django tells me that a unicode object has no attribute
'objects'. So how could I convert this request.POST to something
usable in this case?

thanks,
Bastien

--~--~-~--~~~---~--~~
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: reverse url fails on existing url

2009-06-16 Thread Bastien

thanks!! both works.
Bastien

On Jun 16, 11:10 am, Brian May <br...@microcomaustralia.com.au> wrote:
> On Tue, Jun 16, 2009 at 02:07:01AM -0700, Bastien wrote:
> > I don't understand how this works, on my url without arguments I can
> > use the template tag {% url ... %} and it just works but as soon as I
> > have an argument like this one:
>
> >     url(r'^users/(?P.+)/comments/$',
> >         view=public_comments,
> >         name='public_comments'),
>
> > and I call it via:
>
> >     {% url public_comments args=user.username %}
>
> > then I get :
>
> > Caught an exception while rendering: Reverse for public_comments' with
> > arguments '()' and keyword arguments '{'args': u'my_name'}' not found.
>
> I haven't double checked, but I think that should read:
>
> {% url public_comments user.username %}
>
> or
>
> {% url public_comments username=user.username %}
> --
> Brian May <br...@microcomaustralia.com.au>
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



reverse url fails on existing url

2009-06-16 Thread Bastien

Hello,

I don't understand how this works, on my url without arguments I can
use the template tag {% url ... %} and it just works but as soon as I
have an argument like this one:

url(r'^users/(?P.+)/comments/$',
view=public_comments,
name='public_comments'),

and I call it via:

{% url public_comments args=user.username %}

then I get :

Caught an exception while rendering: Reverse for public_comments' with
arguments '()' and keyword arguments '{'args': u'my_name'}' not found.

anybody has an idea?
thanks,
Bastien

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



Re: get all the comments from a user

2009-06-15 Thread Bastien

I was searching in the included template tags but obviously doing a
database search works very well:

Comment.objects.filter(user_name='myname')

thanks,
Bastien

On Jun 15, 3:09 pm, Bastien <bastien.roche...@gmail.com> wrote:
> Hi,
>
> with the django comments app how can I get all the comments form a
> given user?
>
> thanks,
> Bastien
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



get all the comments from a user

2009-06-15 Thread Bastien

Hi,

with the django comments app how can I get all the comments form a
given user?

thanks,
Bastien
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



How to access a form subfield? form design?

2009-06-15 Thread Bastien

Hi,

I have a multi choice field to choose 1 or many months in checkboxes:

in forms.py:
months_open = forms.MultipleChoiceField(choices = MONTH_LIST,
widget=forms.CheckboxSelectMultiple)

then in my template I use {{ form.months_open }} to make the list
appear. Now that works but the list appears as a raw list without
style so I would like to change the order of the months but don't know
how to access them. I tried things like {{ form.months_open.1 }} or
{{ form.months_open[0] }} , I tried a for loop to get what's inside
but there's nothing I can do.

Anybody can tell me how this works?
Thanks.
Bastien
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



passing variables to other views / initial function executed before every views

2009-06-09 Thread Bastien

Hi,

I need to use some kind of box (thickbox or other) popping up in front
of any page that a user is redirected to after successfully
registering a new account. The user gets redirected to the page she
initially opened before being sent to the registration form. So it
could be any page on the site. So I need a function that catches a
messages on every page. What I did is putting a reference to that
message in the base template that is inherited everywhere as such:
{{ pop_up_message }}. If there is nothing sent to that variable then
nothing happens and the page loads without popping anything. If there
is something in that variable then the corresponding pop_up box is
called via javascript.

Now it gives me 2 problems.

First, the variable {{ pop_up_message }} can only be filled if I
reload the same page and set it in the context. For example in the
registration process, if the form doesn't validate at the time of
sending it via POST the variable is set to display an error pop up
message and the template reloads with that message filled. But if the
registration process validates then a redirect occurs and I am unable
to set this variable in the context or pass it to the other views. Is
there a way to do that? right now I pass this message in the URL and
the javascript catches it just the same way but it's very ugly and I'm
sure there's another way.

Second, the person who wrote the javascript part of that system tells
me the part where we catch the message to know if a pop up box should
appear or not should be made with Django and not javascript. He tells
me there is a way to write a function that would be executed before
every views to catch this message without having to rewrite every
single view. It sounds really strange and not very Djangoish. Does
such a function exist? Doesn't catching a message on every page is
javascripts' job?

thanks for your light,
Bastien
--~--~-~--~~~---~--~~
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: Where should I do post form data processing?

2009-06-03 Thread Bastien

thanks that's brilliant! I'm going to re-read the doc anyway.
Bastien

On Jun 3, 6:36 pm, Jashugan <jashu...@gmail.com> wrote:
> On Jun 3, 8:20 am, Bastien <bastien.roche...@gmail.com> wrote:
>
> > Yes it seems to be the logical solution. And does this override the
> > save() method? I guess yes so I'll have to save the entire form by
> > hand.
>
> Well it only overrides the save method if you are using a ModelForm.
> If you are, then you don't need to necessarily do all the saving by
> hand.  You would just call the super method, like so:
>
> def save(self, *args, **kwargs):
>   instance = super(MyForm, self).save(*args, **kwargs)
>   category, created = Category.objects.get_or_create
> (name=self.cleaned_data['activity'])
>   instance.category = category
>   instance.save()
--~--~-~--~~~---~--~~
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: Where should I do post form data processing?

2009-06-03 Thread Bastien

Yes it seems to be the logical solution. And does this override the
save() method? I guess yes so I'll have to save the entire form by
hand. I think I'm in for a good documentation reading... thanks for
your guidance Jashugan.
Bastien

On Jun 3, 5:11 pm, Jashugan <jashu...@gmail.com> wrote:
> On Jun 3, 2:09 am, Bastien <bastien.roche...@gmail.com> wrote:
>
> > Hi,
>
> > I have a form where the user chooses her activity and then I
> > automatically fill the category field in the database according to her
> > activity. My question is where should live the code that do that? I
> > want it to be triggered once the user hits the submit button of the
> > form, I take the activity of the user, check in which category it is
> > and set the category field.
>
> Personally I create a save field on the form (just like it was a model
> form). Then my view code looks like:
>
> ## views.py
>
> if request.method == 'POST':
>   form = MyForm(request.POST)
>   if form.is_valid():
>     form.save()
>     # redirect as usual
>
> ## forms.py
>
> class MyForm(forms.Form):
>   activity = forms.CharField()
>
>   def save(self):
>     # do your saving here
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Where should I do post form data processing?

2009-06-03 Thread Bastien

Hi,

I have a form where the user chooses her activity and then I
automatically fill the category field in the database according to her
activity. My question is where should live the code that do that? I
want it to be triggered once the user hits the submit button of the
form, I take the activity of the user, check in which category it is
and set the category field.

I couldn't find a place for that code, in the forms.py the
clean_category(self): is triggered at the right moment but it's not
intended to do that, is it? I tried but it only works when there is
actually a category entered. If not, I get a 'local variable
'category' referenced before assignment'. May be it's better to use
signals here?

Thanks,
Bastien
--~--~-~--~~~---~--~~
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: Migrating (importing) SQL dump for one model

2009-06-01 Thread Bastien

Thanks Kevin, it looks like it's not going to be easy. I think I will
create the model by hand since it's not a lot of work and then I will
load the data I have in the dump directly with the PostgreSQL tools
and not doing it with Django.
Bastien

On Jun 1, 10:26 am, "K.Berkhout" <ke...@berkhout.us> wrote:
> I think a database migration tool is what you're looking for.
> I've no experience with such tools, but you could look 
> onhttp://code.djangoproject.com/wiki/SchemaEvolutionfor database
> migration tools currently available.
>
> Kevin
>
> On 1 jun, 10:09, Bastien <bastien.roche...@gmail.com> wrote:
>
>
>
> > Hi,
>
> > I have a running Django project with users, and a profile app for the
> > users to fill in info on their profile. This model is quite simple
> > with only a few fields, I want to replace it. I have a preexisting
> > database dump that contains data about existing users of a different
> > proforject with different fields that I'd like to import and replace
> > the existing Django model with.
>
> > The database I'm using is PostgreSQL and the database dump I'd like to
> > import is also PostgreSQL. Is there a simple way to do that? Is there
> > a tool to import an SQL dump directly into Django and that creates the
> > model? Or is there a more complex way to do it?
>
> > Thank you,
> > Bastien
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Migrating (importing) SQL dump for one model

2009-06-01 Thread Bastien

Hi,

I have a running Django project with users, and a profile app for the
users to fill in info on their profile. This model is quite simple
with only a few fields, I want to replace it. I have a preexisting
database dump that contains data about existing users of a different
proforject with different fields that I'd like to import and replace
the existing Django model with.

The database I'm using is PostgreSQL and the database dump I'd like to
import is also PostgreSQL. Is there a simple way to do that? Is there
a tool to import an SQL dump directly into Django and that creates the
model? Or is there a more complex way to do it?

Thank you,
Bastien
--~--~-~--~~~---~--~~
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: prepopulate file fields in forms after validation errors

2009-05-26 Thread Bastien

Thank you Daniel, then the users will just re enter the files and feel
secure :)

On May 26, 1:42 pm, Daniel Roseman <roseman.dan...@googlemail.com>
wrote:
> On May 26, 12:30 pm, Bastien <bastien.roche...@gmail.com> wrote:
>
> > Hi,
>
> > When I have some validation errors in my forms they automatically get
> > reloaded after POST with all the fields already filled with what the
> > user already introduced before POST and she only has to change
> > whatever was wrong in the first place. But for files or images, the
> > path disappears and the user has to choose again which image she wants
> > to upload. I'd like these fields to appear populated along the others.
>
> > I thought sending form = Form(request.POST, request.FILES) to the
> > template was enough. Is there something I missed or do these fields
> > need to be populated in another way?
>
> > thanks,
> > Bastien
>
> This question comes up here occasionally. Here's what I said last
> time:
>
> This isn't a Django issue. It's a standard property of browsers: you
> can't set an initial value for file input fields. This is a security
> measure, to stop malicious pages uploading files from your hard drive
> without your explicit instruction.
> There isn't really any way round it, except to do something extremely
> complicated like GMail does and upload the file in the background
> while the user fills in the form, then replace the file field with a
> reference to the uploaded version of the file.
> --
> DR.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



prepopulate file fields in forms after validation errors

2009-05-26 Thread Bastien

Hi,

When I have some validation errors in my forms they automatically get
reloaded after POST with all the fields already filled with what the
user already introduced before POST and she only has to change
whatever was wrong in the first place. But for files or images, the
path disappears and the user has to choose again which image she wants
to upload. I'd like these fields to appear populated along the others.

I thought sending form = Form(request.POST, request.FILES) to the
template was enough. Is there something I missed or do these fields
need to be populated in another way?

thanks,
Bastien
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Global date format in fields

2009-05-14 Thread Bastien

Hi,

I needed to change the date format the user sees in a field and I used
'input_formats'. But I was wondering if there was a setting to change
it for the whole project, kind of a locale for dates. I tried to add
DATE_FORMAT / DATETIME_FORMAT to the settings file but it did not
change the behavior of the DateFields or DateTimeFields of my forms.

Thanks,
Bastien
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



i18n of words that switch place in a sentence

2009-05-11 Thread Bastien

Hi,

I'm sure this is in the doc but I can't find it. Is there a way to
change a word's place in a sentence according to the language setting?

What I need is to translate the term 'ago' from english to a few other
languages that place it in front of the time, an example will explain
it better:

english : 'user x commented 18 minutes ago' would translate to spanish
as :
'usuario x ha comentado *hace* 18 minutos'

and of course I would like to keep using the '18 minutes' part as a
variable so I can't just translate the whole sentence.

anyone?
--~--~-~--~~~---~--~~
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: autofilling select boxes

2009-05-11 Thread Bastien

Hi,

I have just done it, using jquery, and I'm also new to this but it was
very easy. The logic I used is as follow:
I had a preexisting view where a user selects various criteria to add
to a blog entry like theme, geographical zone, tags... a jquery script
tracks the user inputs and for each change sends a POST to a view that
I wrote to search for related items that returns back a json list that
jquery reads to populate an html select multiple with the blog
entries' id in the value so when the user saves the blog entry, it
passes all the info as POST again to another view including the id of
0 or more other blog entries that might be related and have been
selected by the user.

I hope it's understandable and helps,
Bastien

On May 11, 8:18 am, jai <jayapa...@gmail.com> wrote:
> You can use Dojo or jquerry.
>
> On May 11, 10:44 am, newbie <mara.ku...@gmail.com> wrote:
>
>
>
> > Hi,
>
> >           I'm new to django and also ajax. I want to create a form
> > which has a select box and based on the selection made, the options of
> > another select box are generated. I've achieved this task in web2py
> > but i'm porting my application into django and cudnt find a good start
> > using ajax in django. So it wud be of a great help if some1 cud help
> > me in this regard.
>
> > thanks,
> > nazgi.
--~--~-~--~~~---~--~~
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: restrict choice of recursive many to many relation

2009-05-06 Thread Bastien

Thank you George the 'limit_choices_to' param is exactly what I was
looking for. I had never used or seen it before.

Bastien

On May 5, 10:45 pm, George Song <geo...@damacy.net> wrote:
> On 5/5/2009 12:29 PM, Bastien wrote:
>
> > This is quite new to me, I have done a recursive (self) many to many
> > relation between blog entries so they can be linked together if the
> > user thinks they are semantically related. It works but I would like
> > to restrict the choices I can see in the admin list box: right now I
> > can see every blog entry but I would like to see only the blog entries
> > that belong to a given category. Can I refine the query?
>
> > That's what I have for now:
> > related_entries  = models.ManyToManyField('self', blank=True,
> > symmetrical=False, related_name='original_entries')
>
> There's also `limit_choices_to` param:
> <http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.mod...>
>
> --
> George
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



restrict choice of recursive many to many relation

2009-05-05 Thread Bastien

Hi,

This is quite new to me, I have done a recursive (self) many to many
relation between blog entries so they can be linked together if the
user thinks they are semantically related. It works but I would like
to restrict the choices I can see in the admin list box: right now I
can see every blog entry but I would like to see only the blog entries
that belong to a given category. Can I refine the query?

That's what I have for now:
related_entries  = models.ManyToManyField('self', blank=True,
symmetrical=False, related_name='original_entries')

Thanks,
Bastien

--~--~-~--~~~---~--~~
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: count the number of times an object / class has been instantiated

2009-04-30 Thread Bastien

Sorry if my question is a bit off topic, sometimes my mind tends to
forget that python has not been created just for django... and thanks
for the answer Andy.

Bastien

On Apr 30, 1:40 pm, Andy Mikhailenko <neith...@gmail.com> wrote:
> Hi, your question does not seem to be related to Django. Anyway:
>
> class A:
>     cnt = 0
>     def __init__(self):
>         A.cnt += 1
>
> If you want to count saved instances of a Django model, use
> MyModel.objects.count().
>
> Cheers,
> Andy
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



count the number of times an object / class has been instantiated

2009-04-30 Thread Bastien

Hi,

Just for curiosity, anyone knows about a way to count how many times
an object or a class has been instantiated? I could add a simple
counter as a method of the class but what would trigger it?

thanks,
Bastien
--~--~-~--~~~---~--~~
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: Login redirect url truncated

2009-04-29 Thread Bastien

Thanks Malcolm,

That was very informative. I tried the percent encoding trick with no
success. Now I'll try the second part and post here if I am
successful.

Thanks,
Bastien

On Apr 29, 6:50 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:
> On Wed, 2009-04-29 at 07:43 -0700, Bastien wrote:
> > Hi,
>
> > I'm trying to get Django to do the following:
>
> > A user must be logged in to comment on a content. If the user is not
> > logged in then I provide a link to the login page and use the 'next'
> > function to take her back to the content page where the comment box
> > will be waiting for her to fill it.
>
> > It almost works, the only thing is that the comment box can be quite
> > far away down the page if there are lots of comments and I would like
> > to go to it directly adding a '#comment_form' at the end the 'next'
> > url. That's what I do, I call a url that looks like this:
> >http://mysite.com/accounts/login/?next=/content/#comment_formbut the
> > url returned by the login is a stripped down version that doesn't
> > contain the trailing part with the '#comment_form'.
>
> You need to do some URL encoding here and/or possibly something extra in
> the view. The anchor portion of the URL (the part following the "#") is
> not sent to the server when the URL is submitted. This is arguably
> somewhat of a flaw in the way HTTP URI's are interpreted by browsers,
> but that's the way things work, so we have to work with it. You can send
> URLs containing anchor elements from the server to the browser, but
> browsers won't send the anchor to the server.
>
> As a first step, try percent-encoding the "#" (%23). That might then
> work out of the box. If it doesn't, the next step would be to add a
> wrapper around the login view and convert the URL you submit to the URL
> you want to redirect to before calling the real login() view and passing
> in the true target URL.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Login redirect url truncated

2009-04-29 Thread Bastien

Hi,

I'm trying to get Django to do the following:

A user must be logged in to comment on a content. If the user is not
logged in then I provide a link to the login page and use the 'next'
function to take her back to the content page where the comment box
will be waiting for her to fill it.

It almost works, the only thing is that the comment box can be quite
far away down the page if there are lots of comments and I would like
to go to it directly adding a '#comment_form' at the end the 'next'
url. That's what I do, I call a url that looks like this:
http://mysite.com/accounts/login/?next=/content/#comment_form but the
url returned by the login is a stripped down version that doesn't
contain the trailing part with the '#comment_form'.

Any idea on what I missed?

thanks,
Bastien
--~--~-~--~~~---~--~~
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 get request.user inside a model method?

2009-04-23 Thread Bastien

Karen, thanks, I think I will follow the way of the custom template
tag.
Bastien


On Apr 22, 4:32 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Wed, Apr 22, 2009 at 5:13 AM, Bastien <bastien.roche...@gmail.com> wrote:
>
> > The last thread about that is quite old, I was wondering if there is
> > any new way to do that?
>
> Likely nothing has changed.  It's still the case that models are independent
> of requests, so trying to tightly couple them can lead to problems.  What it
> request.user when you are manipulating a model from a shell prompt or an
> independent Python script?
>
> > I wrote a method in a model that requires the current user and I use
> > this method in a template so I guess I can't pass any argument, can I?
>
> No, you can't pass a arguments to methods in templates.  Template tags are
> quite easy to write, though, so you might try looking into that.
>
> Karen
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



How to get request.user inside a model method?

2009-04-22 Thread Bastien

The last thread about that is quite old, I was wondering if there is
any new way to do that?

I wrote a method in a model that requires the current user and I use
this method in a template so I guess I can't pass any argument, can I?

thanks,
Bastien
--~--~-~--~~~---~--~~
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: Models Aliases

2009-04-20 Thread Bastien

Thanks Alex, I didn't know this function, that's what I needed!
Bastien

On Apr 20, 1:40 pm, Alex Koshelev <daeva...@gmail.com> wrote:
> Hi, Bastien.
>
> I think the simple solution with property may be the best aproach if
> you cannot change dependent code:
>
> user = property(lambda self: self.author)
>
>
>
> On Mon, Apr 20, 2009 at 3:37 PM, Bastien <bastien.roche...@gmail.com> wrote:
>
> > You're right Dougal, I *should* do that I have various apps already
> > working with the whole project trying to access object.user in general
> > and I was wondering if there was a clean way to alias author. I'm
> > already using some workarounds but it's dirty...
>
> > On Apr 20, 1:26 pm, Dougal Matthews <douga...@gmail.com> wrote:
> >> why don't you just access entry.author rather than entry.user?
> >> I think perhaps I'm not quite following your question.
>
> >> Dougal
>
> >> ---
> >> Dougal Matthews - @d0ugalhttp://www.dougalmatthews.com/
>
> >> 2009/4/20 Bastien <bastien.roche...@gmail.com>
>
> >> > Hi,
>
> >> > I searched the doc but couldn't find anything about this: I have a
> >> > model for a blog entry that contains a foreign key to user and is
> >> > named author. But that would be really convenient for me if the object
> >> > would respond to the keyword 'user' as well: entry.user doesn't exist
> >> > in the model but I would like it to return what entry.author usually
> >> > returns, just like an alias. Does anything like that exists in Django?
> >> > is it considered good practice? I could just use the author key or
> >> > rename it to user but what happens is that I have various applications
> >> > that already work with either object.user or object.author and I don't
> >> > want to rewrite them all. 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: Models Aliases

2009-04-20 Thread Bastien

You're right Dougal, I *should* do that I have various apps already
working with the whole project trying to access object.user in general
and I was wondering if there was a clean way to alias author. I'm
already using some workarounds but it's dirty...


On Apr 20, 1:26 pm, Dougal Matthews <douga...@gmail.com> wrote:
> why don't you just access entry.author rather than entry.user?
> I think perhaps I'm not quite following your question.
>
> Dougal
>
> ---
> Dougal Matthews - @d0ugalhttp://www.dougalmatthews.com/
>
> 2009/4/20 Bastien <bastien.roche...@gmail.com>
>
>
>
>
>
> > Hi,
>
> > I searched the doc but couldn't find anything about this: I have a
> > model for a blog entry that contains a foreign key to user and is
> > named author. But that would be really convenient for me if the object
> > would respond to the keyword 'user' as well: entry.user doesn't exist
> > in the model but I would like it to return what entry.author usually
> > returns, just like an alias. Does anything like that exists in Django?
> > is it considered good practice? I could just use the author key or
> > rename it to user but what happens is that I have various applications
> > that already work with either object.user or object.author and I don't
> > want to rewrite them all. 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
-~--~~~~--~~--~--~---



Models Aliases

2009-04-20 Thread Bastien

Hi,

I searched the doc but couldn't find anything about this: I have a
model for a blog entry that contains a foreign key to user and is
named author. But that would be really convenient for me if the object
would respond to the keyword 'user' as well: entry.user doesn't exist
in the model but I would like it to return what entry.author usually
returns, just like an alias. Does anything like that exists in Django?
is it considered good practice? I could just use the author key or
rename it to user but what happens is that I have various applications
that already work with either object.user or object.author and I don't
want to rewrite them all. 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: timesince template tag filter format

2009-04-20 Thread Bastien

I end up using a custom template tag by 'realmac' found here:
http://www.djangosnippets.org/snippets/557/ that calculate the age
from the birthdate and only returns the years.


On Apr 18, 11:06 pm, Bastien <bastien.roche...@gmail.com> wrote:
> Hi,
>
> I'm using the timesince filter in a template where I print a list of
> users along with some info about these users. Among this info I print
> the user's age which I get from the user's birthdate and I return the
> result of {{ user.get_profile.birthdate|timesince }} to get the age.
> Everything works fine but the format returned is of the type 'year,
> month' and I just want to print the year. I tried to format this with |
> date or with |time or to find some doc about this but I can't get
> nowhere.
>
> Anybody has an idea? 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: How to display the recent comments

2009-04-18 Thread Bastien

Thanks Alex, I didn't think about it that way, so far I've just used
the template tags for the comment system but I'll start using it like
that.


On Apr 19, 12:42 am, Alex Gaynor <alex.gay...@gmail.com> wrote:
> On Sat, Apr 18, 2009 at 6:40 PM, Bastien <bastien.roche...@gmail.com> wrote:
>
> > Hi,
>
> > I try to find the way to display the recent comments for a given site,
> > regardless of app / model but the doc doesn't show much, anybody has
> > it already? thanks
>
> Comment is just a model so you can interact and preform queries with it the
> same way you would with any model:
>
> from django,contrib.comments.models import Comment
> Comment.objects.all().filter(site=1).order_by('-submit_date')[:10]
>
> Would give you the 10 most recent comments on site '1'.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
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 to retrieve users from a given group

2009-04-18 Thread Bastien

Matthias your point is interesting and your code works just as well so
thanks!


On Apr 17, 3:51 pm, Matthias Kestenholz
<matthias.kestenh...@gmail.com> wrote:
> On Fri, Apr 17, 2009 at 3:18 PM, Daniel Roseman
>
>
>
>
>
> <roseman.dan...@googlemail.com> wrote:
>
> > On Apr 17, 1:23 pm, Bastien <bastien.roche...@gmail.com> wrote:
> >> Hi,
>
> >> I'm trying to retrieve a list of users belonging  to a given group but
> >> don't understand how to do it. It must be a sort of many to many query
> >> but I can't get it to work.
>
> >> I would like to do something like this:
>
> >> basic_users_list = User.objects.filter(groups__in=Group.objects.get
> >> (name='basic'))
>
> >> but django tells me that:
>
> >> 'Group' object is not iterable
>
> >> If there is another way to do some actions on a given group then I
> >> would be as happy.
>
> >> thanks for your guidance.
>
> > Does this not work?
> > basic_users_list = User.objects.filter(
> >    groups=Group.objects.get(name='basic'))
>
> You're hitting the database twice which seems unnecessary given that
> you don't do anything with the group object.
>
> You could simply use the following piece of code and be done with it:
>
> basic_users_list = User.objects.filter(groups__name='basic')
>
> Or have I missed something?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



How to display the recent comments

2009-04-18 Thread Bastien

Hi,

I try to find the way to display the recent comments for a given site,
regardless of app / model but the doc doesn't show much, anybody has
it already? 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
-~--~~~~--~~--~--~---



timesince template tag filter format

2009-04-18 Thread Bastien

Hi,

I'm using the timesince filter in a template where I print a list of
users along with some info about these users. Among this info I print
the user's age which I get from the user's birthdate and I return the
result of {{ user.get_profile.birthdate|timesince }} to get the age.
Everything works fine but the format returned is of the type 'year,
month' and I just want to print the year. I tried to format this with |
date or with |time or to find some doc about this but I can't get
nowhere.

Anybody has an idea? 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: Query to retrieve users from a given group

2009-04-17 Thread Bastien

Thanks Daniel, it works!


On Apr 17, 3:18 pm, Daniel Roseman <roseman.dan...@googlemail.com>
wrote:
> On Apr 17, 1:23 pm, Bastien <bastien.roche...@gmail.com> wrote:
>
>
>
>
>
> > Hi,
>
> > I'm trying to retrieve a list of users belonging  to a given group but
> > don't understand how to do it. It must be a sort of many to many query
> > but I can't get it to work.
>
> > I would like to do something like this:
>
> > basic_users_list = User.objects.filter(groups__in=Group.objects.get
> > (name='basic'))
>
> > but django tells me that:
>
> > 'Group' object is not iterable
>
> > If there is another way to do some actions on a given group then I
> > would be as happy.
>
> > thanks for your guidance.
>
> Does this not work?
> basic_users_list = User.objects.filter(
>     groups=Group.objects.get(name='basic'))
>
> --
> DR.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Query to retrieve users from a given group

2009-04-17 Thread Bastien

Hi,

I'm trying to retrieve a list of users belonging  to a given group but
don't understand how to do it. It must be a sort of many to many query
but I can't get it to work.

I would like to do something like this:

basic_users_list = User.objects.filter(groups__in=Group.objects.get
(name='basic'))

but django tells me that:

'Group' object is not iterable

If there is another way to do some actions on a given group then I
would be as happy.

thanks for your guidance.

--~--~-~--~~~---~--~~
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: Process multiple html forms in the same view

2009-04-14 Thread Bastien

Thank you Karen, that's exactly what I need "To give each Form its own
namespace".

On Apr 13, 10:57 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Mon, Apr 13, 2009 at 2:11 PM, Bastien <bastien.roche...@gmail.com> wrote:
> > ... So my question is how could the
> > view know which POST data belongs to which form or how can I change
> > the form fields name like the profile tags and post tags would become
> > tags_profile and tags_post respectively?
>
> I think you want to specify a prefix for your individual forms:
>
> http://docs.djangoproject.com/en/dev/ref/forms/api/#prefixes-for-forms
>
> Karen
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Process multiple html forms in the same view

2009-04-13 Thread Bastien

I have a classic user profile page where the user fills a form with
various field about her profile (name, address, about me...). On the
same page I have another form that is very similar to a blog post
entry (title, body...) that represents a message that the user can
optionaly fill if she wants to. I can only have one submit button for
the whole page and thus the 2 forms. They both submit the POST data to
the same URL (user_ profile) and in the view I process both forms.
Everything runs quite smoothly since the validation process
automatically uses the POST data that it needs and leaves the rest
(ie: validating user profile only uses the form values like name,
address, about me... and leaves things like title, body... for later
use). But my problem is that I have a few form fields in common in
both forms: zone (which is a list of geographical zones relevant to
the website), theme (another list) and the tags field. The view in its
current form is unabled to tell apart which one is from which form,
ie: it receives tags from both the user profile and the user optional
message and can't tell them apart. So my question is how could the
view know which POST data belongs to which form or how can I change
the form fields name like the profile tags and post tags would become
tags_profile and tags_post respectively?
--~--~-~--~~~---~--~~
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-Registration help

2009-03-13 Thread Bastien

Thank you very much James, I couldn't get a better answer. I will try
this right away and hopefully get back on the right path!

On Mar 13, 8:29 pm, James Bennett <ubernost...@gmail.com> wrote:
> On Fri, Mar 13, 2009 at 5:02 AM, Bastien <bastien.roche...@gmail.com> wrote:
> > I will answer my own question since I found the answer, may be it can
> > help someone:
>
> Unfortunately you found the wrong answer; if you're making changes to
> the code that came with django-registration, you're doin' it wrong.
>
> The "register" view takes keyword arguments precisely so that you can
> configure it without having to change its code. Simply set up your own
> URLConf (one you personally write yourself -- not by editing the
> included one in place), pointing to that view and passing the
> arguments you want to have passed, the same way you'd point at, say,
> one of Django's generic views and pass it arguments from your URLConf.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
--~--~-~--~~~---~--~~
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-Registration help

2009-03-13 Thread Bastien

I will answer my own question since I found the answer, may be it can
help someone:

in the views add this line:
from registration.forms import RegistrationFormTermsOfService

and then in the register function change form_class from
RegistrationForm to RegistrationFormTermsOfService

in the template registration_form you can now use the {{ form.tos }}

It's only a matter of form subclassing and is explained here
(somewhere down the page):
http://docs.djangoproject.com/en/dev/ref/forms/api/#ref-forms-api

On Mar 12, 5:56 pm, Bastien <bastien.roche...@gmail.com> wrote:
> Hi,
>
> I'd like to use the available functionality "terms of service" in
> Django-Registration but have no clue about how I do that. I already
> have the basic thing running on my project.
>
> 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
-~--~~~~--~~--~--~---



Django-Registration help

2009-03-12 Thread Bastien

Hi,

I'd like to use the available functionality "terms of service" in
Django-Registration but have no clue about how I do that. I already
have the basic thing running on my project.

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: Localize URLs

2009-03-12 Thread Bastien

I will! :)

On Mar 12, 3:26 pm, Dougal Matthews <douga...@gmail.com> wrote:
> OH yeah, Make sure you look at the cms2 branch in SVN. It's wy
> better!<http://trac.django-cms.org/trac/browser/branches/django-cms2>http://trac.django-cms.org/trac/browser/branches/django-cms2
> Cheers,
> Dougal
>
> ---
> Dougal Matthews - @d0ugalhttp://www.dougalmatthews.com/
>
> 2009/3/12 Bastien <bastien.roche...@gmail.com>
>
>
>
>
>
> > Thanks Dougal, I think you're right about django-cms supporting this
> > feature, I'm going to dive in their code.
>
> > Bastien
>
> > On Mar 12, 2:40 pm, Dougal Matthews <douga...@gmail.com> wrote:
> > > You may want to consider trying django-cms. They support these feature
> > > I believe. Of nothing else you could have a noesy at their code.
>
> > >http://django-cms.org/
>
> > > Dougal
>
> > > On 12/03/2009, Bastien <bastien.roche...@gmail.com> wrote:
>
> > > > Hello Django users,
>
> > > > I've been scratching my head trying to find a solution to have URLs
> > > > translated in various languages. So the typical 'about' would be
> > > > translated in 'a propos' in french and whatever other languages, like
> > > > all the static content. I also need to provide the user a way to write
> > > > flatpages (and other types of dynamic content) with a unique URL so
> > > > something like 'http://www.mysite.com/news/christmas_party'would
> > > > translate to 'http://www.mysite.com/nouvelles/fete_de_noel'infrench.
> > > > I think you see what I mean.
>
> > > > I couldn't find anything googling and although I understand the
> > > > readability argument I don't know if it's a good idea technically
> > > > speaking. Any help, point of view, documentation, already exisiting
> > > > app would be welcome.
>
> > > > Thanks
>
> > > --
> > > Sent from my mobile device
>
> > > ---
> > > Dougal Matthews - @d0ugalhttp://www.dougalmatthews.com/
--~--~-~--~~~---~--~~
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: Localize URLs

2009-03-12 Thread Bastien

Thanks Dougal, I think you're right about django-cms supporting this
feature, I'm going to dive in their code.

Bastien

On Mar 12, 2:40 pm, Dougal Matthews <douga...@gmail.com> wrote:
> You may want to consider trying django-cms. They support these feature
> I believe. Of nothing else you could have a noesy at their code.
>
> http://django-cms.org/
>
> Dougal
>
> On 12/03/2009, Bastien <bastien.roche...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hello Django users,
>
> > I've been scratching my head trying to find a solution to have URLs
> > translated in various languages. So the typical 'about' would be
> > translated in 'a propos' in french and whatever other languages, like
> > all the static content. I also need to provide the user a way to write
> > flatpages (and other types of dynamic content) with a unique URL so
> > something like 'http://www.mysite.com/news/christmas_party'would
> > translate to 'http://www.mysite.com/nouvelles/fete_de_noel'in french.
> > I think you see what I mean.
>
> > I couldn't find anything googling and although I understand the
> > readability argument I don't know if it's a good idea technically
> > speaking. Any help, point of view, documentation, already exisiting
> > app would be welcome.
>
> > Thanks
>
> --
> Sent from my mobile device
>
> ---
> Dougal Matthews - @d0ugalhttp://www.dougalmatthews.com/
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Localize URLs

2009-03-12 Thread Bastien

Hello Django users,

I've been scratching my head trying to find a solution to have URLs
translated in various languages. So the typical 'about' would be
translated in 'a propos' in french and whatever other languages, like
all the static content. I also need to provide the user a way to write
flatpages (and other types of dynamic content) with a unique URL so
something like 'http://www.mysite.com/news/christmas_party' would
translate to 'http://www.mysite.com/nouvelles/fete_de_noel' in french.
I think you see what I mean.

I couldn't find anything googling and although I understand the
readability argument I don't know if it's a good idea technically
speaking. Any help, point of view, documentation, already exisiting
app would be welcome.

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