0

In a school project, my team and I have to create a shopping website with a very specific server-side architecture. We agreed to use python and turned ourselves towards Django since it seemed to offer more functionalities than other possible frameworks. Be aware that none of us ever used Django in the past. We aren't masters at deploying application on the web either (we are all learning).

Here's my problem: two weeks in the project, our teacher told us that we were not allowed to use any ORM. To me, this meant bye bye to Django models and that we have to create everything on our own.

Here are my questions: as we already have created all our python classes, is there any way for us to use them alongside our Django app? I have not seen any example online of people using their own python classes within a Django app. If it were possible, where should we instantiate all our objects? Would it be easier to just go with another framework (I am thinking about Flask). Am I just missing important information about how Django works and asking a dumb question?

We have 4 weeks completed and 6 more to go before finishing our project. I often see online "use Flask before using Django" since it is simpler to use. We decided on Django because in the project description, Django was recommended but not Flask.

Thanks for the help.

2
  • I'm not sure I understand your question. Django is just Python; you can define and use whatever classes you want. Commented Oct 14, 2017 at 14:49
  • Where would I instantiate such classes so that my app uses them? I need to use mapper objects. When I deploy my Django application, which python script is ran? Should I just instantiate my objects there? From my understanding, when you do a HTTP request on a Django app, the app goes through its list of urls and if there is a match, it returns to the user the corresponding view. I am just confused as to where my custom made classes comes in in this Django flow ??? Commented Oct 14, 2017 at 15:12

1 Answer 1

2

Without being an absolute Django expert, here is my opinion.

The Django ORM is far from being the only feature this Framework has to offer (URLs routing, test client, user sessions variables, etc.), but surely it is one the main component you want to use while working with Django since it is often directly linked to other core features of Django.

If using the ORM is completely forbidden, a lot of features out of the box won't be available for you. One of the main features I can think about is the admin interface. You won't be able to use it if the ORM is not an option for you.

So, in my opinion, you should go for another Framework like Flask. Mainly because without using the ORM, some of the Django value is gone.

Hope it helps!

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

6 Comments

@Daniel Roseman has a good point though. I assumed your goal was to create a database schema ? Do you need a database for your project ? Because if not, I will remove my answer since you can define and use python class if you want.
We do need to use a database for our project. I am just confused on the proper way of using my python classes alongside a Django project. Where should we instantiate our objects within the whole Django flow ? I have not seen any example online, they are all using models.
Yes, the ORM act like an additional layer between the database and your project. So, by creating models, you're able to interact with the database using python object instead of raw SQL queries. So if your goal is to create classes to store in the database, this is what models do in Django. But, as you said in the question, you're not allowed to use Django's ORM. Therefore, you can't be using those models and this is why I suggested you go for another framework.
You also seem to mix a lot of Django features together. I know you're running out of time for your projet, but this is in my opinion the fastest way to get an idea on Django and understanding the flow of the Framework, here is the tutorial
Ok but what if the classes that I made deal with the SQL queries. Its as if we created our own ORMs. Where would I use these classes in the Django flow? From what I understand, when a HTTP request is sent to a Django app, the app will go through its urls and return the corresponding view to the user. Where does our classes come in in this? in the views.py ? I do not want to instantiate new objects every time a page is accessed. The objects should be instantiated whenever I deploy my Django app, and remain in memory until the app is shut down.
|

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.