Re: Adding several user models

2017-10-24 Thread James Schneider
On Oct 24, 2017 3:46 AM, "Andréas Kühne" wrote: Hi all, I would love to pick your collective brains for a second. I am working on an application that will be first and foremost an administration system. As such there will be very few users in the system. It will have a front end developed in ang

Re: Automatically assign model instance to the user who created it. And only that user can edit/delete the instance.

2017-10-24 Thread Jack Zhang
Thanks for your response. This is an off-topic question but I can't figure out how to get 'request' working. I'm using the CreateView generic class, so there's no space to insert 'request'. This is what my code looks like. When I try to run it, it tells me that request is not found. class

Re: Automatically assign model instance to the user who created it. And only that user can edit/delete the instance.

2017-10-24 Thread mohammad k
for question 2 : def get_queryset(self): # the user want to edit this post must be owner this post post_qs = super(UpdatePost, self).get_queryset() return post_qs.filter(user=self.request.user) On Tue, Oct 24, 2017 at 8:04 PM, mohammad k wrote: > try that in your views > >

Re: Automatically assign model instance to the user who created it. And only that user can edit/delete the instance.

2017-10-24 Thread mohammad k
try that in your views form = Dog_Form(request.POST) if form.is_valid(): form_save = form.save(commit=False) form_save.user = request.user # user is logged in form.save() On Tue, Oct 24, 2017 at 7:37 PM, Jack Zhang wrote: > Let's say I have a model called 'Dogs'. Users can create

Automatically assign model instance to the user who created it. And only that user can edit/delete the instance.

2017-10-24 Thread Jack Zhang
Let's say I have a model called 'Dogs'. Users can create instances of Dogs. Let's say we have a user called User1. I have 2 questions: 1. When User1 creates an instance of Dogs, how do I automatically assign that instance to User1? I tried using a model field like this but it doesn't pick t

Re: Input Widget with multiple input_type attr

2017-10-24 Thread mohammad k
forms.TextInput(attrs={'type': 'hidden'}) On Tue, Oct 24, 2017 at 7:08 PM, gugsrs wrote: > But isn't there any other way to change that attribute from my template > for example? > > Thank you for the reply. > > On Saturday, October 21, 2017 at 4:19:21 AM UTC-2, k2527806 wrote: >> >> forms.CharFi

Re: Input Widget with multiple input_type attr

2017-10-24 Thread gugsrs
But isn't there any other way to change that attribute from my template for example? Thank you for the reply. On Saturday, October 21, 2017 at 4:19:21 AM UTC-2, k2527806 wrote: > > forms.CharField(widget=forms.HiddenField) > > On Oct 21, 2017 12:45 AM, "gugsrs" > > wrote: > > Hello, > > I am ha

Adding several user models

2017-10-24 Thread Andréas Kühne
Hi all, I would love to pick your collective brains for a second. I am working on an application that will be first and foremost an administration system. As such there will be very few users in the system. It will have a front end developed in angular 5 and a Django rest framework backend. I