2

I am reworking an application since it would benefit from having a RESTful backend. I feel that I have somehow taken a wrong turn by combining the rest API and the regular HTTP into a single app.

This means they share the urls.py and the views.py and are competing for urls and stuff gets mixed up (like applying the format_suffix_patterns to all urls).

I hope to get an opinion (or confirmation) that it would be a much better plan to roll it into two separate applications.

old plan

manage.py
/project
/combinedapp
    admin.py
    models.py
    urls.py       # both types of urls
    views.py      # both views

new plan

manage.py
/project
/restapp
    urls.py      # only the rest endpoints
    views.py     # api stuff: links to httpapp.models
/httpapp
    admin.py     # like a normal app
    models.py
    urls.py
    views.py

As you can tell I am new to this and trying to prevent shooting myself in the foot.

1 Answer 1

2

I decided to refactor the project following the new plan. These are the results:

  • It was very easy to do: approximately 15 minutes of work to make a new app, move some files and split to content.
  • Protip: the new app is for the rest api. That way you conserve the existing table names and such.
  • Results are just fine: clear separation of concerns and urls.

Conclusion never mix a rest-api with an HTTP app.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.