Ever tried posting nested data in DRF and hit the dreaded “writable nested fields not supported” error? In my latest article, I break down how to fix it cleanly — from overriding create() to adding transaction safety and optimizing with bulk_create(). You’ll learn: Why nested serializers fail on POST How .pop('items') saves your day The right way to separate read/write serializers Production-ready patterns for clean, scalable APIs Read the full breakdown here 👇 🔗 https://lnkd.in/d-3qARwR #Django #RESTFramework #Python #BackendDevelopment #APIs #SoftwareEngineering
Fixing Writable Nested Fields Error in DRF
More Relevant Posts
-
🚀 #100DaysOfPython – Day 3: Lambda Functions 👉 Lambda = small anonymous function (one line) Example: add = lambda a, b: a + b print(add(2, 3)) # 5 Used commonly with: nums = [1, 2, 3, 4] squared = list(map(lambda x: x*x, nums)) ✨ Short and quick ✨ Useful for simple operations ⚠️ But here’s the catch: If your logic is more than one line → use a normal function. 🔍 My takeaway: Lambdas are great for simple transformations, not for complex logic. Read more: https://lnkd.in/eSSCUfmi #Python #Coding #100DaysOfCode #Developer
To view or add a comment, sign in
-
Stateful UDFs just changed how Python scales. With @daft.cls, you can turn any Python class into a distributed operator that initialises once per worker and reuses state across every row. That means models, API clients, and database connections no longer get rebuilt on every call. The mental model stays simple: write normal Python classes, add a decorator, and Daft handles execution, scheduling, and parallelism. Find out more: https://lnkd.in/e79SePbN #PythonScaling #DaftCls #DistributedComputing #PythonClasses
To view or add a comment, sign in
-
-
called the same API endpoint 5 times in a row. without cache: 2.51s with lru_cache: 0.50s 5x faster. two lines of code. @functools.lru_cache(maxsize=128) def fetch_user(user_id): ... the cache info tells the real story: hits=4, misses=1 first call hits the actual API. next 4? served instantly from memory. this is how production systems handle repeated expensive calls — user profiles, config lookups, ML model loads, anything that doesn’t change every second. lru_cache ships with Python. no libraries. just import functools. two lines between slow and fast. #Python #Backend #DataEngineering #Performance
To view or add a comment, sign in
-
-
.0158 vs .0005 for the cached version. So searching bing: "does python lru cache return previous objects" "Yes — Python’s built‑in functools.lru_cache returns the exact same object instance that was previously computed and cached, not a copy" The overhead is in the object being recreated each call with Python objects being known to have slow creation time. There are better options for performance like writing the API in C++ with pistache or crow. Testing the time with 4 million unique users requesting their user info 3 times would be more informative. Reading that the returned data is a user data object with the changing value being a score and a constant for the username, the code needs refactoring as it muddies two use cases together. The username only needs sent the first time then only if it is or has been updated. The score is better sent via a socket or websocket if it changes in realtime and requires input from the server to be calculated or not sent at all if it can be calculated client side. If it needs to be broadcast to other client network peers with their response sent back to other peers a message queue is needed but if the peers response does not matter, the main server can handle the broadcasting. Database queries that can not just be returned by directly querying the database are not conducive to caching or not useful if they change infrequently or are only needed once or a few times at most. Having less than 4 million users, giving each user their own database on a single server can be easier than writing APIs if the data is just database table views (and the service is paid, reducing risk of hacking from users plus database caching can be used across multiple client applications)
called the same API endpoint 5 times in a row. without cache: 2.51s with lru_cache: 0.50s 5x faster. two lines of code. @functools.lru_cache(maxsize=128) def fetch_user(user_id): ... the cache info tells the real story: hits=4, misses=1 first call hits the actual API. next 4? served instantly from memory. this is how production systems handle repeated expensive calls — user profiles, config lookups, ML model loads, anything that doesn’t change every second. lru_cache ships with Python. no libraries. just import functools. two lines between slow and fast. #Python #Backend #DataEngineering #Performance
To view or add a comment, sign in
-
-
Why Tornado? Why Tornado Is Still The Best Choice For Developing Modern Async Python Applications Tornado has always had this slightly stubborn reputation. It never tried to become the “cool” framework, never chased trends, never rebranded itself every couple of years. And that is exactly why it still matters, especially in a world dominated by names like Flask, Django, and FastAPI. If you’ve spent any real time building async systems in Python, you eventually run into the same realization: abstraction is nice until it starts getting in your way. Tornado sits in a very particular place where it gives you just enough structure to move fast, but not so much that you lose control of how your system actually behaves. That balance is rare, and it is something developers often only appreciate after hitting the limits of Flask, stretching Django beyond its comfort zone, or leaning heavily on the convenience of FastAPI. Read more 👉 https://lnkd.in/eCxYNknP #Python #Tornado #FastAPI #Django #Flask
To view or add a comment, sign in
-
-
🚀 Excited to announce the release of the new version of DRF API Logger! This update includes several enhancements: - Profiling support to analyze API performance in greater depth - Identification of performance bottlenecks through profiling - Monitoring of API behavior - Auditing of request/response cycles For more details, visit the link: https://lnkd.in/gbzPYmt #django #python #djangorestframework #opensource #backend #api #performance #logging #coderssecret
To view or add a comment, sign in
-
🚀 Day 6/30 of My LeetCode Journey (Python + SQL) Consistency is slowly turning into confidence 💪📈 🔹 **Python Problem of the Day** 👉 *Plus One* Given an integer represented as an array of digits, increment the number by one and return the resulting array. 💡 *Key Concept:* Handling carry from the last digit (especially edge cases like 9 → 10). 🔹 **SQL Problem of the Day** 👉 *Game Play Analysis I* Given a table of player activity, write a query to find the first login date for each player. 💡 *Key Concept:* GROUP BY with MIN() to extract earliest dates. Every day learning something new, refining logic, and improving speed ⚡ Day 6 done ✅ #LeetCode #30DaysChallenge #Python #SQL #CodingJourney #Consistency #ProblemSolving #Learning
To view or add a comment, sign in
-
I built the fastest Python logging framework. 446K ops/sec. 2.7x faster than stdlib. 20% faster than Microsoft's picologging, which is written in C. It's a one-line migration: import logging → from logxide import logging Same getLogger(). Same format strings. Flask, Django, FastAPI all work. Sentry and OTLP are built in. Zero config. Wrote up the production guide with copy-paste examples. ⬇️ See comment #Python #Rust #OpenSource
To view or add a comment, sign in
-
𝗬𝗼𝘂𝗿 𝗰𝗼𝗹𝘂𝗺𝗻 𝗻𝗮𝗺𝗲𝘀 𝗺𝗶𝗴𝗵𝘁 𝗯𝗲 𝘁𝗵𝗲 𝗿𝗲𝗮𝘀𝗼𝗻 𝘁𝗵𝗶𝗻𝗴𝘀 𝗳𝗲𝗲𝗹 𝗺𝗲𝘀𝘀𝘆 I didn’t realize this at first. I had columns like: UserName, User name, USER_NAME Everything worked… until it didn’t. Small mistakes. Confusing errors. Wasted time. Then I started doing one simple thing: Normalize column names. lowercase snake_case consistent user_name → simple, clear, reliable. It feels small. But it makes your work much easier. Have you faced this problem before? 👇 #DataEngineering #DataScience #Python #Pandas #DataAnalytics
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development