質問編集履歴
1
views.pyを追加しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -186,6 +186,60 @@
|
|
186
186
|
|
187
187
|
|
188
188
|
|
189
|
+
```viewss.py
|
190
|
+
|
191
|
+
#GroupMember作成
|
192
|
+
|
193
|
+
class MemberCreateView(LoginRequiredMixin, generic.CreateView):
|
194
|
+
|
195
|
+
model = GroupMember
|
196
|
+
|
197
|
+
template_name = 'group_add_friend.html'
|
198
|
+
|
199
|
+
form_class = MemberCreateForm
|
200
|
+
|
201
|
+
success_url = reverse_lazy('process:sop_list')
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
def get_form_kwargs(self):
|
206
|
+
|
207
|
+
kwargs = super(MemberCreateView, self).get_form_kwargs()
|
208
|
+
|
209
|
+
kwargs.update({'place_member': self.request.user})
|
210
|
+
|
211
|
+
return kwargs
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
def form_valid(self, form):
|
216
|
+
|
217
|
+
group = form.save(commit=False)
|
218
|
+
|
219
|
+
group.owner = self.request.user
|
220
|
+
|
221
|
+
group.save()
|
222
|
+
|
223
|
+
messages.success(self.request, 'Group Memberを作成しました。')
|
224
|
+
|
225
|
+
return super().form_valid(form)
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
def form_invalid(self, form):
|
230
|
+
|
231
|
+
messages.error(self.request, "Group Memberの作成に失敗しました。")
|
232
|
+
|
233
|
+
return super().form_invalid(form)
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
```
|
240
|
+
|
241
|
+
|
242
|
+
|
189
243
|
|
190
244
|
|
191
245
|
### 試したこと
|