SimpleHumble I need your help with this common commment fault
On Sunday, April 28, 2019 at 3:35:23 PM UTC-4, SimpleHumble wrote:
>
> Sorry there was a mistake in previous mail please ignore.
> form_valid function will not work use post function above it in
> ArticleCommentCreateView
> Find atta
Hi, Britto,
Sorry for my late reply.
Thank you so much!
I learnt a lot.
Looks like you created a function called get_context_data and put all
comment data from Comment database into context with key 'comments'.
You then called 'comments' in the template. Now I don't need
reated_name='comment' i
Hi, Britto,
Wow, it's working as expected!
Thank you so much. (*So sorry, one more question below, please find it!*)
Basically, you added blank=True for author field and article field in
Comment model.
In this way, I don't need to set author/article field in CommentCreateView.
Instead, we have
If you don't want to display article and author in the template. Use custom
form design instead of {% form.as_p %} tag.
Something like
this will render only comment field on template. You should not remove
those fields as those are required to process form.
Share the code as zip will exam it and
Please share the form and form template as well.
On Sun, 28 Apr 2019, 02:37 Atsunori Kaneshige I really appreciate if anybody could give me an advice about form_valid.
>
> Here is what I want to do.
> I am making a simple blog.
> I am making simple features:
> 1) only superuser can create article
set form.instance.article = request.POST.get('article')
and add article in fields too like fields = ('comment', 'article')
it should work flawlessly.
Regards
Britto
On Sun, 28 Apr 2019 at 09:30, Atsunori Kaneshige wrote:
> Hi, Britto,
>
> Thank you very much for your reply!
> I tried form.ins
Hi, Britto,
Thank you very much for your reply!
I tried form.instance.article = *self.*request.POST.get('article'), I still
got an error shown below.
RelatedObjectDoesNotExist at /articles/2/comment/
Comment has no article.
Request Method: POST
Request URL: http://127.0.0.1:8000/articles/2/c
The best way to debug it is add a print function with dir function just
before the error occurring line and see what are available attributes in
request.POST object like this print(dir("", request.POST,
"")) . Also without dir function will show what is available in
POST.
Look at th
Sorry, when I make a comment, I get this error.
Any advice would be really appreciated!
AttributeError at /articles/2/comment/
'WSGIRequest' object has no attribute 'article'
Request Method: POST
Request URL: http://127.0.0.1:8000/articles/2/comment/
Django Version: 2.1.5
Exception Type: Attr
I really appreciate if anybody could give me an advice about form_valid.
Here is what I want to do.
I am making a simple blog.
I am making simple features:
1) only superuser can create articles.
2) logged-in users can make comments to articles.
I followed along tutorials and mostly done.
*But las
10 matches
Mail list logo