Django
Applying Tests Using Unmanaged Model (feat. Table XXX doesn't exist)
Previously, I mentioned at work that we plan to reorganize the legacy code, which was written in Raw Query, into a Django ORM-based structure. Some of the dilemmas I wrote about last time have been somewhat resolved, and methodologies for organizing project structures and files have been sorted out, so I’m planning to post about what happened while categorizing the models. While analyzing the existing SQL Query, I checked which tables were joined with others and how much they were affected, and I think the model classification went well. Then, I encountered an issue while writing test codes to see if it worked properly. A pleasant? error occurred for the developer.
April 20, 2022
Parsing Data Through PUT in Class View
Request has no Attribute ‘data’ I’m going to discuss an issue that arose as we restructured views that were initially designed functionally into class views at my company. There are some intriguing aspects when using Django, particularly when receiving data through REST Framework. In my case, an error occurred: AttributeError: request has no attribute 'data'. Let’s first take a look at the class I implemented. # urls.py urlpatterns = [ path('my_url/', views.MyView.as_view()) ] # views.py class MyView(View) def put(self, request): my_data = request.data # my business logic Of course, in JavaScript, correct data was being sent to myapp/my_url/. However, the variable request.data didn’t seem to exist.
April 12, 2022