4👍
✅
You can just follow the relationship:
def get_success_url(self):
return reverse('to-journals', kwargs={'slug': self.object.journal_name.slug})
2👍
Your self.object
is a to_journal_entry
. You probably want to use the to_journal
, you can do that by obtaining the journal_name
:
class ToJournalEntriesList(LoginRequiredMixin, CreateView):
model = to_journal_entry
template_name = 'to_journals/to_journal_entries_list.html'
fields = ('body',)
def get_success_url(self):
return reverse('to-journals', kwargs={ 'slug': self.object.journal_name.slug })
Note: usually the names of the models are written in PerlCase, so
JournalEntry
instead of.to_journal_entry
- [Django]-Show request.DATA in Django 500 error caused by Rest Framework
- [Django]-DRF: Always apply default permission class
- [Django]-Model datetime field validation for fields with auto_now
- [Django]-Dyld: Library not loaded: @rpath/libpcre.1.dylib
- [Django]-Django – putting HTML tags inside blocks of text subject to translation
Source:stackexchange.com