Skip to content Skip to sidebar Skip to footer

How Do I 'autofill' A Createview Field

I have a model called Artist, and now I'm working on building a comment section for the Artist DetailView. I've built a model called ArtistComment, created a CreateView and added t

Solution 1:

To hide artist field remove artist from fields.

To get artist in ArtistCommentCreate views rewrite url as below:

  url(r'^(?P<artist>\d+)/artistcomment/add/$', login_required(views.ArtistCommentCreate.as_view()), name='artistcomment-add'),

and in your detail html:

<a data-toggle="modal"data-target="#artistcommentModal" href="{% url 'events:artistcomment-add' artist= artist.id%}">Add A New Comment</a>

in your comment view get artist pk as self.kwargs.get('artist')

Post a Comment for "How Do I 'autofill' A Createview Field"