Re: User Login in django

2009-11-04 Thread Julien Petitperrin
On Wed, Nov 4, 2009 at 10:31 AM, Daniel Roseman wrote:

>
> On Nov 4, 4:26 am, Denis Bahati  wrote:
> > Am real need to reinvent the wheel because i have a project which needs
> to
> > define some user roles, and enable users to update the status of their
> own
> > properties and not the other property. Thanks in advance for any help you
> > give me.
>

Or just create your own authentication backends using your User models,
Django will be able to handle session as usual and you will have what you
want for your user model


http://docs.djangoproject.com/en/dev/topics/auth/#specifying-authentication-backends

I hope this helps,

Julien

--~--~-~--~~~---~--~~
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: Form that updates a list of items?

2009-11-03 Thread Julien Petitperrin
On Mon, Nov 2, 2009 at 5:28 PM, Nick Arnett  wrote:

>
>
> On Mon, Nov 2, 2009 at 3:30 AM, Julien Petitperrin <
> julien.petitper...@gmail.com> wrote:
>
>> Hello,
>>
>> I had this kind of issue a few days ago. I found this:
>>
>>
>> http://collingrady.wordpress.com/2008/02/18/editing-multiple-objects-in-django-with-newforms/
>>
>> I hope this helps you to find a way to do your multiple items edit form.
>
>
>
> Ah, that does look helpful and I wondered it I might do better to create
> one form per line, as it suggests.
>
> Nick
>

I am happy to help,

You should create one form per item and choose a smart prefix for each form
created, this example show only how to add multiple items.
But you can edit items too by using id as a prefix you will be able to get
an instance of the object for form creation.

something like that:

form_submit = False
if request.POST:
# POST data => we should try to validate
# always keep a list of ids of the item you edit
ids_string = request.POST.get('ids', None)
ids = ids_string.split(',')
form_submit = True
# we have post DATA we should validate/submit change
# MyModelForm is a ModelForm Class
all_forms = [MyModelForm(request.POST, prefix=str(id),
instance=model.objects.get(pk=id)) for id in ids]
if all( [ form.is_valid() for form in all_forms] ):
# All forms are valid we can update and save the object
for form in all_forms:
# update object field
form.save()
Message( id=None, user=request.user, message=_(u"success")
).save()
return ttpResponseRedirect(
"Where/you/want/after/a/valid/edit/")
else:
Message( id=None, user=request.user, message=_(u"fail") ).save()

if not form_submit:
# no POST data we should initiate the forms
# handle ids
ids_string = request.GET.get('ids', None)
ids = ids_string.split(',')
# Create the Custom ModelForm
all_forms = [ MyModelForm(prefix=str(id),
instance=model.objects.get(pk=id)) for id in ids ]

Hope this still helps

--~--~-~--~~~---~--~~
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: Form that updates a list of items?

2009-11-02 Thread Julien Petitperrin
Hello,

I had this kind of issue a few days ago. I found this:

http://collingrady.wordpress.com/2008/02/18/editing-multiple-objects-in-django-with-newforms/

I hope this helps you to find a way to do your multiple items edit form.

Have a nice day,
Julien.

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