Re: limit the instances created by the current logged in user where the user is a foreign key in the model.

2018-07-01 Thread Saloni Kalra
def clean(self): > super().clean()if > Feedback.objects.filter(user_id=self.user.pk).count() >= 3: > raise ValidationError(['You have already left feedback 3 times.']) > > == > > > form = FeedbackForm(request.user, request.POST) > > > On 01/07/1

limit the instances created by the current logged in user where the user is a foreign key in the model.

2018-07-01 Thread Saloni Kalra
I have a feedback app in which the user signs in, logs in and gives feedback. i wish to limit the number of feedbacks a user can give. how to do this and where? shall I user validation? -- You received this message because you are subscribed to the Google Groups "Django users" group. To

Cannot add choice filed with radio buttons in my model form using widget but only charfield.

2018-06-30 Thread Saloni Kalra
*post-form.html* {% extends "posts/post_base.html" %} {% load bootstrap3 %} {% block post_content %} {% if not form.instance.pk %} Create Post {% else %} Update Post {% endif %} {% csrf_token %} {% bootstrap_form form %} {% endblock %} *models.py* from django.conf import settings from

Re: how to add radiobuttons to my ModelForm

2018-06-26 Thread Saloni Kalra
kert wrote: > > Can you include your template code? The issue could be in there. > > On Sunday, June 24, 2018 at 10:15:50 AM UTC-5, Saloni Kalra wrote: >> >> I wish to add radio buttons fill in each parameter of my model and also >> to convert it to integer on t

how to add radiobuttons to my ModelForm

2018-06-24 Thread Saloni Kalra
I wish to add radio buttons fill in each parameter of my model and also to convert it to integer on the backend. But somehow its not changing. Kindly help. Thanks and regards, Saloni *Forms.py* class PostForm(forms.ModelForm): class Meta: fields =

Re: ValueError at /feedback/by/feedback/new Cannot assign "": "Feedback.user" must be a "User" instance.

2018-06-24 Thread Saloni Kalra
Alright! Thanks much! On Sun, 24 Jun 2018, 6:56 pm Melvyn Sopacua, wrote: > On zaterdag 23 juni 2018 21:10:27 CEST Saloni Kalra wrote: > > Thank you for your reply. I removes all the migrations and dropped the > > database. Now when I try to make migrations i get the followin

Re: how to pass the current user in reverse_lazy()

2018-06-24 Thread Saloni Kalra
Thanks much! On Sun, 24 Jun 2018, 5:50 pm Daniel Ale, wrote: > Great. > > On Sun, Jun 24, 2018, 13:18 Saloni Kalra > wrote: > >> Yes it did! Thanks much! >> >> On Sunday, 24 June 2018 17:14:31 UTC+5, Daniel Ale wrote: >>> >>> Override

Re: how to pass the current user in reverse_lazy()

2018-06-24 Thread Saloni Kalra
Yes it did! Thanks much! On Sunday, 24 June 2018 17:14:31 UTC+5, Daniel Ale wrote: > > Override the get_success_url(self) instead... That will work > > On Sun, Jun 24, 2018, 07:13 Saloni Kalra > wrote: > >> *DeleteView:* >> >> class DeletePost(Lo

how to pass the current user in reverse_lazy()

2018-06-24 Thread Saloni Kalra
*DeleteView:* class DeletePost(LoginRequiredMixin, SelectRelatedMixin, generic.DeleteView): username = self.object.user.username model = models.Post select_related = ("user","teacher","subject") success_url = reverse_lazy("posts:for_user", kwargs={'username':

Re: ValueError at /feedback/by/feedback/new Cannot assign "": "Feedback.user" must be a "User" instance.

2018-06-23 Thread Saloni Kalra
been swapped out. HINT: Update the relation to point at 'settings.AUTH_USER_MODEL'. On Saturday, 23 June 2018 23:25:25 UTC+5, Melvyn Sopacua wrote: > > On zaterdag 23 juni 2018 10:52:09 CEST Saloni Kalra wrote: > > > https://github.com/salonikalra/feedback > >

Cannot assign the current user to the ForeignKey field in my model.

2018-06-23 Thread Saloni Kalra
I am trying to build a feedback application for the teachers by the students. I have a proxy User that will the student. But I am not able to assign the user to the feedback model. I am a newbie. Please help. Thanks and regards, Saloni *models.py:* class User(auth.models.User,

ValueError at /feedback/by/feedback/new Cannot assign "": "Feedback.user" must be a "User" instance.

2018-06-23 Thread Saloni Kalra
https://github.com/salonikalra/feedback This is a feedback application for teachers by the students. I have been constntly getting the following error: ValueError at /feedback/by/feedback/new Cannot assign "": "Feedback.user" must be a "User" instance. Please help. Thanks. -- You received this