Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango: How to override 3rd party views by using DRY principle?
    primarykey
    data
    text
    <p>I have created a separate app for a feature I am planning to extend using this 3rd party app and I don't intend to touch its code.</p> <p>The view I want to extend, posts a question or gets a form for a user to ask a question. I want to use this view to post an article. The form it uses is different. </p> <p>Psuedo code below:</p> <pre><code>post_question_view(request) If user is authenticated and read only, redirect somewhere else. form = form.Askquestionform(request.REQUEST) ( I would like to do form = form.AskArticleform()) If the request is post and form is valid, get clean data. (The article will include additional data) If user is authenticated, draft a question and write the question to the database. Generate a new-question-posted signal and redirect. (I don't have to make any changes here I guess) If user is not authenticated, create anonymous question, write it to the database and redirect to the login page. If the request is get fill in the form intial and render to ask_question.html (I would like to render to ask_article.html) </code></pre> <p>Most of the code is there with minor altercations that needs to be done. I need to fill in few blanks and add some new blanks to the existing code. How do I do this using the dry princliple? </p> <ol> <li>Should I create a wrapper for the 2 functions and based on the request, call the appropriate one? </li> <li>Is it possible to use a decorator? The form will contain new fields so without modifying the current view, I don't think its possible. </li> <li>Or is there no other way than to copy this view to my app and make the modifications? </li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload