[{"data":1,"prerenderedAt":3640},["ShallowReactive",2],{"navigation":3,"/working-with-files/files-in-models":1016,"/working-with-files/files-in-models-surround":3635},[4,54,89,123,165,211,253,331,389,439,462,488,514,540,578,624,650,672,702,736,774,800,850,856,862,868,874,928],{"title":5,"path":6,"stem":7,"children":8},"Introduction and Foundations","/introduction-and-foundations","01.introduction-and-foundations/01.index",[9,10,14,18,22,26,30,34,38,42,46,50],{"title":5,"path":6,"stem":7},{"title":11,"path":12,"stem":13},"What is Django","/introduction-and-foundations/what-is-django","01.introduction-and-foundations/02.what-is-django",{"title":15,"path":16,"stem":17},"Key Concepts and Philosophy","/introduction-and-foundations/key-concepts-and-philosophy","01.introduction-and-foundations/03.key-concepts-and-philosophy",{"title":19,"path":20,"stem":21},"MVC vs MVT: Understanding Django's Architecture","/introduction-and-foundations/mvc-vs-mvt","01.introduction-and-foundations/04.mvc-vs-mvt",{"title":23,"path":24,"stem":25},"Project Structure Overview","/introduction-and-foundations/project-structure-overview","01.introduction-and-foundations/05.project-structure-overview",{"title":27,"path":28,"stem":29},"Installing Django","/introduction-and-foundations/installing-django","01.introduction-and-foundations/06.installing-django",{"title":31,"path":32,"stem":33},"Creating Your First Django Project","/introduction-and-foundations/creating-first-project","01.introduction-and-foundations/07.creating-first-project",{"title":35,"path":36,"stem":37},"Creating Your First Django App","/introduction-and-foundations/creating-first-app","01.introduction-and-foundations/08.creating-first-app",{"title":39,"path":40,"stem":41},"Your First Django \"Hello World\"","/introduction-and-foundations/hello-world","01.introduction-and-foundations/09.hello-world",{"title":43,"path":44,"stem":45},"Django Quick Start Guide","/introduction-and-foundations/quick-start-guide","01.introduction-and-foundations/10.quick-start-guide",{"title":47,"path":48,"stem":49},"How Django Handles Requests","/introduction-and-foundations/how-django-handles-requests","01.introduction-and-foundations/11.how-django-handles-requests",{"title":51,"path":52,"stem":53},"Django Settings","/introduction-and-foundations/django-settings","01.introduction-and-foundations/12.django-settings",{"title":55,"path":56,"stem":57,"children":58},"The Development Environment","/development-environment","02.development-environment/1.index",[59,61,65,69,73,77,81,85],{"title":60,"path":56,"stem":57},"Development Environment",{"title":62,"path":63,"stem":64},"Recommended Tooling for Django Development","/development-environment/recommended-tooling","02.development-environment/2.recommended-tooling",{"title":66,"path":67,"stem":68},"Virtual Environments","/development-environment/virtual-environments","02.development-environment/3.virtual-environments",{"title":70,"path":71,"stem":72},"Django Admin and Management Commands","/development-environment/admin-and-management-commands","02.development-environment/4.admin-and-management-commands",{"title":74,"path":75,"stem":76},"Django Project Settings","/development-environment/project-settings","02.development-environment/5.project-settings",{"title":78,"path":79,"stem":80},"Managing Django Environments: Local, Staging, and Production","/development-environment/environments-local-staging-production","02.development-environment/6.environments-local-staging-production",{"title":82,"path":83,"stem":84},"Running Django Development Server","/development-environment/running-development-server","02.development-environment/7.running-development-server",{"title":86,"path":87,"stem":88},"Working with Django Shell","/development-environment/working-with-shell","02.development-environment/8.working-with-shell",{"title":90,"path":91,"stem":92,"children":93},"Templates and Presentation Layer","/templates-and-presentation","03.templates-and-presentation/1.index",[94,95,99,103,107,111,115,119],{"title":90,"path":91,"stem":92},{"title":96,"path":97,"stem":98},"Introduction to Django Templates","/templates-and-presentation/introduction-to-templates","03.templates-and-presentation/2.introduction-to-templates",{"title":100,"path":101,"stem":102},"The Django Template Language","/templates-and-presentation/django-template-language","03.templates-and-presentation/3.django-template-language",{"title":104,"path":105,"stem":106},"Template Inheritance","/templates-and-presentation/template-inheritance","03.templates-and-presentation/4.template-inheritance",{"title":108,"path":109,"stem":110},"Built-in Template Tags and Filters","/templates-and-presentation/built-in-template-tags-and-filters","03.templates-and-presentation/5.built-in-template-tags-and-filters",{"title":112,"path":113,"stem":114},"Including Static Files","/templates-and-presentation/including-static-files","03.templates-and-presentation/6.including-static-files",{"title":116,"path":117,"stem":118},"Working with Media Files","/templates-and-presentation/working-with-media-files","03.templates-and-presentation/7.working-with-media-files",{"title":120,"path":121,"stem":122},"Using Alternative Template Engines","/templates-and-presentation/using-alternative-template-engines","03.templates-and-presentation/8.using-alternative-template-engines",{"title":124,"path":125,"stem":126,"children":127},"URLs and Views","/urls-and-views","04.urls-and-views/01.index",[128,129,133,137,141,145,149,153,157,161],{"title":124,"path":125,"stem":126},{"title":130,"path":131,"stem":132},"The URL Dispatcher","/urls-and-views/the-url-dispatcher","04.urls-and-views/02.the-url-dispatcher",{"title":134,"path":135,"stem":136},"Writing Function-Based Views","/urls-and-views/writing-function-based-views","04.urls-and-views/03.writing-function-based-views",{"title":138,"path":139,"stem":140},"View Decorators","/urls-and-views/view-decorators","04.urls-and-views/04.view-decorators",{"title":142,"path":143,"stem":144},"Rendering Responses","/urls-and-views/rendering-responses","04.urls-and-views/05.rendering-responses",{"title":146,"path":147,"stem":148},"Redirects","/urls-and-views/redirects","04.urls-and-views/06.redirects",{"title":150,"path":151,"stem":152},"Handling HTTP Methods","/urls-and-views/handling-http-methods","04.urls-and-views/07.handling-http-methods",{"title":154,"path":155,"stem":156},"Conditional View Processing","/urls-and-views/conditional-view-processing","04.urls-and-views/08.conditional-view-processing",{"title":158,"path":159,"stem":160},"File Uploads","/urls-and-views/file-uploads","04.urls-and-views/09.file-uploads",{"title":162,"path":163,"stem":164},"Using Django Shortcut Functions","/urls-and-views/using-django-shortcut-functions","04.urls-and-views/10.using-django-shortcut-functions",{"title":166,"path":167,"stem":168,"children":169},"Class Based Views","/class-based-views","05.class-based-views/01.index",[170,171,175,179,183,187,191,195,199,203,207],{"title":166,"path":167,"stem":168},{"title":172,"path":173,"stem":174},"Introduction to Class-Based Views","/class-based-views/introduction-to-class-based-views","05.class-based-views/02.introduction-to-class-based-views",{"title":176,"path":177,"stem":178},"Common Base Classes","/class-based-views/common-base-classes","05.class-based-views/03.common-base-classes",{"title":180,"path":181,"stem":182},"Built-in Generic Views","/class-based-views/built-in-generic-views","05.class-based-views/04.built-in-generic-views",{"title":184,"path":185,"stem":186},"Views for CRUD Operations","/class-based-views/views-for-crud-operations","05.class-based-views/05.views-for-crud-operations",{"title":188,"path":189,"stem":190},"Handling Forms with Class-Based Views","/class-based-views/handling-forms-with-class-based-views","05.class-based-views/06.handling-forms-with-class-based-views",{"title":192,"path":193,"stem":194},"Using Mixins","/class-based-views/using-mixins","05.class-based-views/07.using-mixins",{"title":196,"path":197,"stem":198},"URL Configuration with Class-Based Views","/class-based-views/url-configuration-with-class-based-views","05.class-based-views/08.url-configuration-with-class-based-views",{"title":200,"path":201,"stem":202},"Subclassing Generic Views","/class-based-views/subclassing-generic-views","05.class-based-views/09.subclassing-generic-views",{"title":204,"path":205,"stem":206},"Asynchronous Class-Based Views","/class-based-views/asynchronous-class-based-views","05.class-based-views/10.asynchronous-class-based-views",{"title":208,"path":209,"stem":210},"Pagination","/class-based-views/pagination","05.class-based-views/11.pagination",{"title":212,"path":213,"stem":214,"children":215},"Forms and User Input","/forms-and-user-input","06.forms-and-user-input/01.index",[216,217,221,225,229,233,237,241,245,249],{"title":212,"path":213,"stem":214},{"title":218,"path":219,"stem":220},"Understanding HTML Forms","/forms-and-user-input/understanding-html-forms","06.forms-and-user-input/02.understanding-html-forms",{"title":222,"path":223,"stem":224},"Django's Role in Form Handling","/forms-and-user-input/djangos-role-in-form-handling","06.forms-and-user-input/03.djangos-role-in-form-handling",{"title":226,"path":227,"stem":228},"Creating Forms with Forms API","/forms-and-user-input/creating-forms-with-forms-api","06.forms-and-user-input/04.creating-forms-with-forms-api",{"title":230,"path":231,"stem":232},"Form Validation","/forms-and-user-input/form-validation","06.forms-and-user-input/05.form-validation",{"title":234,"path":235,"stem":236},"Built-in Fields and Widgets","/forms-and-user-input/built-in-fields-and-widgets","06.forms-and-user-input/06.built-in-fields-and-widgets",{"title":238,"path":239,"stem":240},"Form Rendering in Templates","/forms-and-user-input/form-rendering-in-templates","06.forms-and-user-input/07.form-rendering-in-templates",{"title":242,"path":243,"stem":244},"Model Forms","/forms-and-user-input/model-forms","06.forms-and-user-input/08.model-forms",{"title":246,"path":247,"stem":248},"Advanced Form Techniques","/forms-and-user-input/advanced-form-techniques","06.forms-and-user-input/09.advanced-form-techniques",{"title":250,"path":251,"stem":252},"Security Considerations for Forms","/forms-and-user-input/security-considerations-for-forms","06.forms-and-user-input/10.security-considerations-for-forms",{"title":254,"path":255,"stem":256,"children":257},"Models and Databases","/models-and-databases","07.models-and-databases/01.index",[258,259,263,267,271,275,279,283,287,291,295,299,303,307,311,315,319,323,327],{"title":254,"path":255,"stem":256},{"title":260,"path":261,"stem":262},"Understanding Django Models","/models-and-databases/understanding-django-models","07.models-and-databases/02.understanding-django-models",{"title":264,"path":265,"stem":266},"Defining Fields","/models-and-databases/defining-fields","07.models-and-databases/03.defining-fields",{"title":268,"path":269,"stem":270},"Relationships and Foreign Keys","/models-and-databases/relationships-and-foreign-keys","07.models-and-databases/04.relationships-and-foreign-keys",{"title":272,"path":273,"stem":274},"Examples of Relationship Patterns","/models-and-databases/examples-of-relationship-patterns","07.models-and-databases/05.examples-of-relationship-patterns",{"title":276,"path":277,"stem":278},"Making Queries","/models-and-databases/making-queries","07.models-and-databases/06.making-queries",{"title":280,"path":281,"stem":282},"Filtering, Ordering, and Slicing","/models-and-databases/filtering-ordering-slicing","07.models-and-databases/07.filtering-ordering-slicing",{"title":284,"path":285,"stem":286},"Managers and QuerySets","/models-and-databases/managers-and-querysets","07.models-and-databases/08.managers-and-querysets",{"title":288,"path":289,"stem":290},"Aggregation","/models-and-databases/aggregation","07.models-and-databases/09.aggregation",{"title":292,"path":293,"stem":294},"Search","/models-and-databases/search","07.models-and-databases/10.search",{"title":296,"path":297,"stem":298},"Raw SQL Queries","/models-and-databases/raw-sql-queries","07.models-and-databases/11.raw-sql-queries",{"title":300,"path":301,"stem":302},"Transactions","/models-and-databases/transactions","07.models-and-databases/12.transactions",{"title":304,"path":305,"stem":306},"Multiple Databases","/models-and-databases/multiple-databases","07.models-and-databases/13.multiple-databases",{"title":308,"path":309,"stem":310},"Tablespaces","/models-and-databases/tablespaces","07.models-and-databases/14.tablespaces",{"title":312,"path":313,"stem":314},"Composite Primary Keys","/models-and-databases/composite-primary-keys","07.models-and-databases/15.composite-primary-keys",{"title":316,"path":317,"stem":318},"Database Instrumentation","/models-and-databases/database-instrumentation","07.models-and-databases/16.database-instrumentation",{"title":320,"path":321,"stem":322},"Database Optimization","/models-and-databases/database-optimization","07.models-and-databases/17.database-optimization",{"title":324,"path":325,"stem":326},"Fixtures","/models-and-databases/fixtures","07.models-and-databases/18.fixtures",{"title":328,"path":329,"stem":330},"Signals","/models-and-databases/signals","07.models-and-databases/19.signals",{"title":332,"path":333,"stem":334,"children":335},"Migrations","/migrations","08.migrations/01.index",[336,337,341,345,349,353,357,361,365,369,373,377,381,385],{"title":332,"path":333,"stem":334},{"title":338,"path":339,"stem":340},"How Migrations Work","/migrations/how-migrations-work","08.migrations/02.how-migrations-work",{"title":342,"path":343,"stem":344},"Management Commands","/migrations/management-commands","08.migrations/03.management-commands",{"title":346,"path":347,"stem":348},"Dependencies and Workflow","/migrations/dependencies-and-workflow","08.migrations/04.dependencies-and-workflow",{"title":350,"path":351,"stem":352},"Transaction Handling","/migrations/transaction-handling","08.migrations/05.transaction-handling",{"title":354,"path":355,"stem":356},"Adding Migrations to Apps","/migrations/adding-migrations-to-apps","08.migrations/06.adding-migrations-to-apps",{"title":358,"path":359,"stem":360},"Reversing Migrations","/migrations/reversing-migrations","08.migrations/07.reversing-migrations",{"title":362,"path":363,"stem":364},"Historical Models","/migrations/historical-models","08.migrations/08.historical-models",{"title":366,"path":367,"stem":368},"Considerations When Removing Fields","/migrations/considerations-when-removing-fields","08.migrations/09.considerations-when-removing-fields",{"title":370,"path":371,"stem":372},"Data Migrations","/migrations/data-migrations","08.migrations/10.data-migrations",{"title":374,"path":375,"stem":376},"Squashing Migrations","/migrations/squashing-migrations","08.migrations/11.squashing-migrations",{"title":378,"path":379,"stem":380},"Serializing Values","/migrations/serializing-values","08.migrations/12.serializing-values",{"title":382,"path":383,"stem":384},"Supporting Multiple Django Versions","/migrations/supporting-multiple-django-versions","08.migrations/13.supporting-multiple-django-versions",{"title":386,"path":387,"stem":388},"Django Serialization Framework","/migrations/django-serialization-framework","08.migrations/14.django-serialization-framework",{"title":390,"path":391,"stem":392,"children":393},"Authentication and Authorization","/authentication-and-authorization","09.authentication-and-authorization/01.index",[394,395,399,403,407,411,415,419,423,427,431,435],{"title":390,"path":391,"stem":392},{"title":396,"path":397,"stem":398},"Overview of Django's Authentication System","/authentication-and-authorization/overview-of-django-authentication-system","09.authentication-and-authorization/02.overview-of-django-authentication-system",{"title":400,"path":401,"stem":402},"Users and Groups","/authentication-and-authorization/users-and-groups","09.authentication-and-authorization/03.users-and-groups",{"title":404,"path":405,"stem":406},"Permissions","/authentication-and-authorization/permissions","09.authentication-and-authorization/04.permissions",{"title":408,"path":409,"stem":410},"Password Management","/authentication-and-authorization/password-management","09.authentication-and-authorization/05.password-management",{"title":412,"path":413,"stem":414},"Authentication Views","/authentication-and-authorization/authentication-views","09.authentication-and-authorization/06.authentication-views",{"title":416,"path":417,"stem":418},"Login and Logout","/authentication-and-authorization/login-and-logout","09.authentication-and-authorization/07.login-and-logout",{"title":420,"path":421,"stem":422},"Custom User Models","/authentication-and-authorization/custom-user-models","09.authentication-and-authorization/08.custom-user-models",{"title":424,"path":425,"stem":426},"Middleware for Authentication","/authentication-and-authorization/middleware-for-authentication","09.authentication-and-authorization/09.middleware-for-authentication",{"title":428,"path":429,"stem":430},"Authorization in Views and Templates","/authentication-and-authorization/authorization-in-views-and-templates","09.authentication-and-authorization/10.authorization-in-views-and-templates",{"title":432,"path":433,"stem":434},"Integrating Social Authentication","/authentication-and-authorization/integrating-social-authentication","09.authentication-and-authorization/11.integrating-social-authentication",{"title":436,"path":437,"stem":438},"Security Best Practices","/authentication-and-authorization/security-best-practices","09.authentication-and-authorization/12.security-best-practices",{"title":440,"path":441,"stem":442,"children":443},"Sessions, Cookies, and State","/sessions-cookies-state","10.sessions-cookies-state/01.index",[444,446,450,454,458],{"title":445,"path":441,"stem":442},"Sessions, Cookies, and State Management",{"title":447,"path":448,"stem":449},"Introduction to Sessions","/sessions-cookies-state/introduction-to-sessions","10.sessions-cookies-state/02.introduction-to-sessions",{"title":451,"path":452,"stem":453},"Working with Cookies","/sessions-cookies-state/working-with-cookies","10.sessions-cookies-state/03.working-with-cookies",{"title":455,"path":456,"stem":457},"Server-Side Session Storage Options","/sessions-cookies-state/server-side-session-storage-options","10.sessions-cookies-state/04.server-side-session-storage-options",{"title":459,"path":460,"stem":461},"Session Security","/sessions-cookies-state/session-security","10.sessions-cookies-state/05.session-security",{"title":463,"path":464,"stem":465,"children":466},"Working with Files","/working-with-files","11.working-with-files/01.index",[467,468,472,476,480,484],{"title":463,"path":464,"stem":465},{"title":469,"path":470,"stem":471},"Files in Models","/working-with-files/files-in-models","11.working-with-files/02.files-in-models",{"title":473,"path":474,"stem":475},"The File Object","/working-with-files/the-file-object","11.working-with-files/03.the-file-object",{"title":477,"path":478,"stem":479},"Storage Backends","/working-with-files/storage-backends","11.working-with-files/04.storage-backends",{"title":481,"path":482,"stem":483},"Using Cloud Storage Providers","/working-with-files/using-cloud-storage-providers","11.working-with-files/05.using-cloud-storage-providers",{"title":485,"path":486,"stem":487},"Managing Media in Production","/working-with-files/managing-media-in-production","11.working-with-files/06.managing-media-in-production",{"title":489,"path":490,"stem":491,"children":492},"Admin Site","/admin-site","12.admin-site/01.index",[493,494,498,502,506,510],{"title":489,"path":490,"stem":491},{"title":495,"path":496,"stem":497},"Enabling the Admin","/admin-site/enabling-the-admin","12.admin-site/02.enabling-the-admin",{"title":499,"path":500,"stem":501},"Registering Models","/admin-site/registering-models","12.admin-site/03.registering-models",{"title":503,"path":504,"stem":505},"Customizing Admin Display","/admin-site/customizing-admin-display","12.admin-site/04.customizing-admin-display",{"title":507,"path":508,"stem":509},"Admin Actions","/admin-site/admin-actions","12.admin-site/05.admin-actions",{"title":511,"path":512,"stem":513},"Admin Security Best Practices","/admin-site/admin-security-best-practices","12.admin-site/06.admin-security-best-practices",{"title":515,"path":516,"stem":517,"children":518},"Middleware","/middleware","13.middleware/01.index",[519,520,524,528,532,536],{"title":515,"path":516,"stem":517},{"title":521,"path":522,"stem":523},"Middleware Overview","/middleware/middleware-overview","13.middleware/02.middleware-overview",{"title":525,"path":526,"stem":527},"Built-in Middleware","/middleware/built-in-middleware","13.middleware/03.built-in-middleware",{"title":529,"path":530,"stem":531},"Creating Custom Middleware","/middleware/creating-custom-middleware","13.middleware/04.creating-custom-middleware",{"title":533,"path":534,"stem":535},"Middleware Ordering","/middleware/middleware-ordering","13.middleware/05.middleware-ordering",{"title":537,"path":538,"stem":539},"Performance and Debugging","/middleware/performance-and-debugging","13.middleware/06.performance-and-debugging",{"title":541,"path":542,"stem":543,"children":544},"Security","/security","14.security/01.index",[545,546,550,554,558,562,566,570,574],{"title":541,"path":542,"stem":543},{"title":547,"path":548,"stem":549},"Django Security Philosophy","/security/django-security-philosophy","14.security/02.django-security-philosophy",{"title":551,"path":552,"stem":553},"Cross Site Request Forgery","/security/cross-site-request-forgery","14.security/03.cross-site-request-forgery",{"title":555,"path":556,"stem":557},"Cross Site Scripting","/security/cross-site-scripting","14.security/04.cross-site-scripting",{"title":559,"path":560,"stem":561},"SQL Injection Protection","/security/sql-injection-protection","14.security/05.sql-injection-protection",{"title":563,"path":564,"stem":565},"Clickjacking Protection","/security/clickjacking-protection","14.security/06.clickjacking-protection",{"title":567,"path":568,"stem":569},"HTTPS Setup and HSTS","/security/https-setup-and-hsts","14.security/07.https-setup-and-hsts",{"title":571,"path":572,"stem":573},"Password Storage and Cryptography","/security/password-storage-and-cryptography","14.security/08.password-storage-and-cryptography",{"title":575,"path":576,"stem":577},"Secure Deployment Checklist","/security/secure-deployment-checklist","14.security/09.secure-deployment-checklist",{"title":579,"path":580,"stem":581,"children":582},"Testing","/testing","15.testing/01.index",[583,584,588,592,596,600,604,608,612,616,620],{"title":579,"path":580,"stem":581},{"title":585,"path":586,"stem":587},"Introduction to Django Testing","/testing/introduction-to-django-testing","15.testing/02.introduction-to-django-testing",{"title":589,"path":590,"stem":591},"Writing and Running Tests","/testing/writing-and-running-tests","15.testing/03.writing-and-running-tests",{"title":593,"path":594,"stem":595},"Test Tools","/testing/test-tools","15.testing/04.test-tools",{"title":597,"path":598,"stem":599},"Testing Models","/testing/testing-models","15.testing/05.testing-models",{"title":601,"path":602,"stem":603},"Testing Views","/testing/testing-views","15.testing/06.testing-views",{"title":605,"path":606,"stem":607},"Testing Forms","/testing/testing-forms","15.testing/07.testing-forms",{"title":609,"path":610,"stem":611},"Testing Templates","/testing/testing-templates","15.testing/08.testing-templates",{"title":613,"path":614,"stem":615},"Testing Authentication","/testing/testing-authentication","15.testing/09.testing-authentication",{"title":617,"path":618,"stem":619},"Advanced Testing Topics","/testing/advanced-testing-topics","15.testing/10.advanced-testing-topics",{"title":621,"path":622,"stem":623},"Performance Testing","/testing/performance-testing","15.testing/11.performance-testing",{"title":625,"path":626,"stem":627,"children":628},"Static Assets and Frontend Integration","/static-assets-and-frontend-integration","16.static-assets-and-frontend-integration/01.index",[629,630,634,638,642,646],{"title":625,"path":626,"stem":627},{"title":631,"path":632,"stem":633},"Working with Static Files","/static-assets-and-frontend-integration/working-with-static-files","16.static-assets-and-frontend-integration/02.working-with-static-files",{"title":635,"path":636,"stem":637},"Integrating CSS and JavaScript","/static-assets-and-frontend-integration/integrating-css-and-javascript","16.static-assets-and-frontend-integration/03.integrating-css-and-javascript",{"title":639,"path":640,"stem":641},"Using Build Tools like Vite or Webpack","/static-assets-and-frontend-integration/using-build-tools-like-vite-or-webpack","16.static-assets-and-frontend-integration/04.using-build-tools-like-vite-or-webpack",{"title":643,"path":644,"stem":645},"Using React or Vue with Django","/static-assets-and-frontend-integration/using-react-or-vue-with-django","16.static-assets-and-frontend-integration/05.using-react-or-vue-with-django",{"title":647,"path":648,"stem":649},"Managing CORS","/static-assets-and-frontend-integration/managing-cors","16.static-assets-and-frontend-integration/06.managing-cors",{"title":651,"path":652,"stem":653,"children":654},"Internationalization and Localization","/internationalization-and-localization","17.internationalization-and-localization/01.index",[655,656,660,664,668],{"title":651,"path":652,"stem":653},{"title":657,"path":658,"stem":659},"Enabling Translation","/internationalization-and-localization/enabling-translation","17.internationalization-and-localization/02.enabling-translation",{"title":661,"path":662,"stem":663},"Translating Text in Code and Templates","/internationalization-and-localization/translating-text-in-code-and-templates","17.internationalization-and-localization/03.translating-text-in-code-and-templates",{"title":665,"path":666,"stem":667},"Timezone Support","/internationalization-and-localization/timezone-support","17.internationalization-and-localization/04.timezone-support",{"title":669,"path":670,"stem":671},"Locale Middleware","/internationalization-and-localization/locale-middleware","17.internationalization-and-localization/05.locale-middleware",{"title":673,"path":674,"stem":675,"children":676},"Caching","/caching","18.caching/01.index",[677,678,682,686,690,694,698],{"title":673,"path":674,"stem":675},{"title":679,"path":680,"stem":681},"Introduction to Caching","/caching/introduction-to-caching","18.caching/02.introduction-to-caching",{"title":683,"path":684,"stem":685},"Cache Backends","/caching/cache-backends","18.caching/03.cache-backends",{"title":687,"path":688,"stem":689},"Per View Caching","/caching/per-view-caching","18.caching/04.per-view-caching",{"title":691,"path":692,"stem":693},"Low Level Cache API","/caching/low-level-cache-api","18.caching/05.low-level-cache-api",{"title":695,"path":696,"stem":697},"Template Fragment Caching","/caching/template-fragment-caching","18.caching/06.template-fragment-caching",{"title":699,"path":700,"stem":701},"Deployment Level Caching Patterns","/caching/deployment-level-caching-patterns","18.caching/07.deployment-level-caching-patterns",{"title":703,"path":704,"stem":705,"children":706},"Asynchronous Django","/asynchronous-django","19.asynchronous-django/01.index",[707,708,712,716,720,724,728,732],{"title":703,"path":704,"stem":705},{"title":709,"path":710,"stem":711},"Introduction to ASGI","/asynchronous-django/introduction-to-asgi","19.asynchronous-django/02.introduction-to-asgi",{"title":713,"path":714,"stem":715},"Async Views","/asynchronous-django/async-views","19.asynchronous-django/03.async-views",{"title":717,"path":718,"stem":719},"Async ORM Status","/asynchronous-django/async-orm-status","19.asynchronous-django/04.async-orm-status",{"title":721,"path":722,"stem":723},"WebSockets with Channels","/asynchronous-django/websockets-with-channels","19.asynchronous-django/05.websockets-with-channels",{"title":725,"path":726,"stem":727},"Background Tasks with Celery or RQ","/asynchronous-django/background-tasks-with-celery-or-rq","19.asynchronous-django/06.background-tasks-with-celery-or-rq",{"title":729,"path":730,"stem":731},"Asynchronous Support","/asynchronous-django/asynchronous-support","19.asynchronous-django/07.asynchronous-support",{"title":733,"path":734,"stem":735},"Django's Tasks Framework","/asynchronous-django/django-tasks-framework","19.asynchronous-django/08.django-tasks-framework",{"title":737,"path":738,"stem":739,"children":740},"Deployment","/deployment","20.deployment/01.index",[741,742,746,750,754,758,762,766,770],{"title":737,"path":738,"stem":739},{"title":743,"path":744,"stem":745},"Preparing for Production","/deployment/preparing-for-production","20.deployment/02.preparing-for-production",{"title":747,"path":748,"stem":749},"Using WSGI and ASGI Servers","/deployment/using-wsgi-and-asgi-servers","20.deployment/03.using-wsgi-and-asgi-servers",{"title":751,"path":752,"stem":753},"Deploying on Linux Servers","/deployment/deploying-on-linux-servers","20.deployment/04.deploying-on-linux-servers",{"title":755,"path":756,"stem":757},"Using Docker","/deployment/using-docker","20.deployment/05.using-docker",{"title":759,"path":760,"stem":761},"Cloud Deployment Guides","/deployment/cloud-deployment-guides","20.deployment/06.cloud-deployment-guides",{"title":763,"path":764,"stem":765},"Scaling and Load Balancing","/deployment/scaling-and-load-balancing","20.deployment/07.scaling-and-load-balancing",{"title":767,"path":768,"stem":769},"Monitoring and Logging","/deployment/monitoring-and-logging","20.deployment/08.monitoring-and-logging",{"title":771,"path":772,"stem":773},"Backup Strategies","/deployment/backup-strategies","20.deployment/09.backup-strategies",{"title":775,"path":776,"stem":777,"children":778},"Performance and Optimization","/performance-and-optimization","21.performance-and-optimization/01.index",[779,780,784,788,792,796],{"title":775,"path":776,"stem":777},{"title":781,"path":782,"stem":783},"Query Optimization","/performance-and-optimization/query-optimization","21.performance-and-optimization/02.query-optimization",{"title":785,"path":786,"stem":787},"Template Rendering Optimization","/performance-and-optimization/template-rendering-optimization","21.performance-and-optimization/03.template-rendering-optimization",{"title":789,"path":790,"stem":791},"Using Select Related and Prefetch Related","/performance-and-optimization/using-select-related-and-prefetch-related","21.performance-and-optimization/04.using-select-related-and-prefetch-related",{"title":793,"path":794,"stem":795},"Caching Strategies","/performance-and-optimization/caching-strategies","21.performance-and-optimization/05.caching-strategies",{"title":797,"path":798,"stem":799},"Profiling Django Apps","/performance-and-optimization/profiling-django-apps","21.performance-and-optimization/06.profiling-django-apps",{"title":801,"path":802,"stem":803,"children":804},"Advanced and Expert Topics","/advanced-and-expert-topics","22.advanced-and-expert-topics/01.index",[805,806,810,814,818,822,826,830,834,838,842,846],{"title":801,"path":802,"stem":803},{"title":807,"path":808,"stem":809},"System Architecture Patterns","/advanced-and-expert-topics/system-architecture-patterns","22.advanced-and-expert-topics/02.system-architecture-patterns",{"title":811,"path":812,"stem":813},"Domain Driven Design with Django","/advanced-and-expert-topics/domain-driven-design-with-django","22.advanced-and-expert-topics/03.domain-driven-design-with-django",{"title":815,"path":816,"stem":817},"Building Large Scale Django Projects","/advanced-and-expert-topics/building-large-scale-django-projects","22.advanced-and-expert-topics/04.building-large-scale-django-projects",{"title":819,"path":820,"stem":821},"Plugin Architectures for Django Apps","/advanced-and-expert-topics/plugin-architectures-for-django-apps","22.advanced-and-expert-topics/05.plugin-architectures-for-django-apps",{"title":823,"path":824,"stem":825},"Extending Django's Core","/advanced-and-expert-topics/extending-djangos-core","22.advanced-and-expert-topics/06.extending-djangos-core",{"title":827,"path":828,"stem":829},"Custom ORM Expressions","/advanced-and-expert-topics/custom-orm-expressions","22.advanced-and-expert-topics/07.custom-orm-expressions",{"title":831,"path":832,"stem":833},"Custom Management Commands","/advanced-and-expert-topics/custom-management-commands","22.advanced-and-expert-topics/08.custom-management-commands",{"title":835,"path":836,"stem":837},"Working with Signals","/advanced-and-expert-topics/working-with-signals","22.advanced-and-expert-topics/09.working-with-signals",{"title":839,"path":840,"stem":841},"Building Reusable Django Packages","/advanced-and-expert-topics/building-reusable-django-packages","22.advanced-and-expert-topics/10.building-reusable-django-packages",{"title":843,"path":844,"stem":845},"Integrating Microservices","/advanced-and-expert-topics/integrating-microservices","22.advanced-and-expert-topics/11.integrating-microservices",{"title":847,"path":848,"stem":849},"Advanced Security Hardening","/advanced-and-expert-topics/advanced-security-hardening","22.advanced-and-expert-topics/12.advanced-security-hardening",{"title":851,"path":852,"stem":853,"children":854},"Logging in Django","/logging-in-django","23.logging-in-django/01.index",[855],{"title":851,"path":852,"stem":853},{"title":857,"path":858,"stem":859,"children":860},"FAQ and Troubleshooting","/faq-and-troubleshooting","24.faq-and-troubleshooting/01.index",[861],{"title":857,"path":858,"stem":859},{"title":863,"path":864,"stem":865,"children":866},"External Packages and Ecosystem","/external-packages-and-ecosystem","25.external-packages-and-ecosystem/01.index",[867],{"title":863,"path":864,"stem":865},{"title":869,"path":870,"stem":871,"children":872},"Django Internals and Contributing","/django-internals-and-contributing","26.django-internals-and-contributing/01.index",[873],{"title":869,"path":870,"stem":871},{"title":875,"path":876,"stem":877,"children":878},"Microservices with Django","/microservices-with-django","27.microservices-with-django/01.index",[879,880,884,888,892,896,900,904,908,912,916,920,924],{"title":875,"path":876,"stem":877},{"title":881,"path":882,"stem":883},"What Is a Microservice?","/microservices-with-django/what-is-a-microservice","27.microservices-with-django/02.what-is-a-microservice",{"title":885,"path":886,"stem":887},"Introducing the Django Microservices Architecture","/microservices-with-django/django-microservices-architecture","27.microservices-with-django/03.django-microservices-architecture",{"title":889,"path":890,"stem":891},"Setting Up the Development and Runtime Environment","/microservices-with-django/development-environment","27.microservices-with-django/04.development-environment",{"title":893,"path":894,"stem":895},"Cloud-native Data Processing with MongoDB","/microservices-with-django/cloud-native-data-processing","27.microservices-with-django/05.cloud-native-data-processing",{"title":897,"path":898,"stem":899},"Creating RESTful APIs for Microservices","/microservices-with-django/restful-apis","27.microservices-with-django/06.restful-apis",{"title":901,"path":902,"stem":903},"Orchestrating Microservices with Celery and RabbitMQ","/microservices-with-django/orchestrating-celery-rabbitmq","27.microservices-with-django/07.orchestrating-celery-rabbitmq",{"title":905,"path":906,"stem":907},"Testing Microservices","/microservices-with-django/testing-microservices","27.microservices-with-django/08.testing-microservices",{"title":909,"path":910,"stem":911},"Deploying Microservices","/microservices-with-django/deploying-microservices","27.microservices-with-django/09.deploying-microservices",{"title":913,"path":914,"stem":915},"Securing Microservices","/microservices-with-django/securing-microservices","27.microservices-with-django/10.securing-microservices",{"title":917,"path":918,"stem":919},"Improving Microservices Performance with Caching","/microservices-with-django/performance-caching","27.microservices-with-django/11.performance-caching",{"title":921,"path":922,"stem":923},"Best Practices","/microservices-with-django/best-practices","27.microservices-with-django/12.best-practices",{"title":925,"path":926,"stem":927},"Transforming a Monolithic Web App into a Microservice version","/microservices-with-django/monolith-to-microservices","27.microservices-with-django/13.monolith-to-microservices",{"title":929,"path":930,"stem":931,"children":932},"Releases","/releases","releases",[933,936,940,944,948,952,956,960,964,968,972,976,980,984,988,992,996,1000,1004,1008,1012],{"title":934,"path":930,"stem":935},"Django Releases","releases/index",{"title":937,"path":938,"stem":939},"Django 5.1.10 release notes","/releases/5.1.10","releases/5.1.10",{"title":941,"path":942,"stem":943},"Django 5.1.11 release notes","/releases/5.1.11","releases/5.1.11",{"title":945,"path":946,"stem":947},"Django 5.1.12 release notes","/releases/5.1.12","releases/5.1.12",{"title":949,"path":950,"stem":951},"Django 5.1.13 release notes","/releases/5.1.13","releases/5.1.13",{"title":953,"path":954,"stem":955},"Django 5.1.14 release notes","/releases/5.1.14","releases/5.1.14",{"title":957,"path":958,"stem":959},"Django 5.1.15 release notes","/releases/5.1.15","releases/5.1.15",{"title":961,"path":962,"stem":963},"Django 5.2 release notes","/releases/5.2","releases/5.2",{"title":965,"path":966,"stem":967},"Django 5.2.1 release notes","/releases/5.2.1","releases/5.2.1",{"title":969,"path":970,"stem":971},"Django 5.2.10 release notes","/releases/5.2.10","releases/5.2.10",{"title":973,"path":974,"stem":975},"Django 5.2.2 release notes","/releases/5.2.2","releases/5.2.2",{"title":977,"path":978,"stem":979},"Django 5.2.3 release notes","/releases/5.2.3","releases/5.2.3",{"title":981,"path":982,"stem":983},"Django 5.2.4 release notes","/releases/5.2.4","releases/5.2.4",{"title":985,"path":986,"stem":987},"Django 5.2.5 release notes","/releases/5.2.5","releases/5.2.5",{"title":989,"path":990,"stem":991},"Django 5.2.6 release notes","/releases/5.2.6","releases/5.2.6",{"title":993,"path":994,"stem":995},"Django 5.2.7 release notes","/releases/5.2.7","releases/5.2.7",{"title":997,"path":998,"stem":999},"Django 5.2.8 release notes","/releases/5.2.8","releases/5.2.8",{"title":1001,"path":1002,"stem":1003},"Django 5.2.9 release notes","/releases/5.2.9","releases/5.2.9",{"title":1005,"path":1006,"stem":1007},"Django 6.0 release notes","/releases/6.0","releases/6.0",{"title":1009,"path":1010,"stem":1011},"Django 6.0.1 release notes","/releases/6.0.1","releases/6.0.1",{"title":1013,"path":1014,"stem":1015},"Django 6.1 release notes - UNDER DEVELOPMENT","/releases/6.1","releases/6.1",{"id":1017,"title":469,"body":1018,"description":1028,"extension":3630,"links":3631,"meta":3632,"navigation":1081,"path":470,"seo":3633,"stem":471,"__hash__":3634},"docs/11.working-with-files/02.files-in-models.md",{"type":1019,"value":1020,"toc":3605},"minimark",[1021,1025,1029,1034,1041,1245,1250,1271,1275,1283,1459,1463,1468,1733,1737,1740,2056,2060,2063,2431,2435,2439,2642,2646,2892,2896,2899,3222,3226,3230,3379,3383,3535,3538,3541,3558,3562,3576,3580,3594,3598,3601],[1022,1023,469],"h1",{"id":1024},"files-in-models",[1026,1027,1028],"p",{},"Django provides specialized model fields for handling file uploads. These fields integrate seamlessly with Django's storage system and provide built-in validation and security features.",[1030,1031,1033],"h2",{"id":1032},"filefield","FileField",[1026,1035,1036,1037,1040],{},"The ",[1038,1039,1033],"code",{}," is the base field for handling file uploads:",[1042,1043,1048],"pre",{"className":1044,"code":1045,"language":1046,"meta":1047,"style":1047},"language-python shiki shiki-themes material-theme-lighter vitesse-light vitesse-dark","from django.db import models\n\nclass Document(models.Model):\n    title = models.CharField(max_length=200)\n    file = models.FileField(upload_to='documents/')\n    uploaded_at = models.DateTimeField(auto_now_add=True)\n    \n    def __str__(self):\n        return self.title\n","python","",[1038,1049,1050,1076,1083,1109,1142,1177,1205,1211,1229],{"__ignoreMap":1047},[1051,1052,1055,1059,1063,1067,1070,1073],"span",{"class":1053,"line":1054},"line",1,[1051,1056,1058],{"class":1057},"siDh9","from",[1051,1060,1062],{"class":1061},"sftqT"," django",[1051,1064,1066],{"class":1065},"soVBu",".",[1051,1068,1069],{"class":1061},"db ",[1051,1071,1072],{"class":1057},"import",[1051,1074,1075],{"class":1061}," models\n",[1051,1077,1079],{"class":1053,"line":1078},2,[1051,1080,1082],{"emptyLinePlaceholder":1081},true,"\n",[1051,1084,1086,1090,1094,1097,1101,1103,1106],{"class":1053,"line":1085},3,[1051,1087,1089],{"class":1088},"s5Kfy","class",[1051,1091,1093],{"class":1092},"sD-vU"," Document",[1051,1095,1096],{"class":1065},"(",[1051,1098,1100],{"class":1099},"sYn-s","models",[1051,1102,1066],{"class":1065},[1051,1104,1105],{"class":1099},"Model",[1051,1107,1108],{"class":1065},"):\n",[1051,1110,1112,1115,1118,1121,1123,1127,1129,1133,1135,1139],{"class":1053,"line":1111},4,[1051,1113,1114],{"class":1061},"    title ",[1051,1116,1117],{"class":1065},"=",[1051,1119,1120],{"class":1061}," models",[1051,1122,1066],{"class":1065},[1051,1124,1126],{"class":1125},"siWMO","CharField",[1051,1128,1096],{"class":1065},[1051,1130,1132],{"class":1131},"sqOPj","max_length",[1051,1134,1117],{"class":1065},[1051,1136,1138],{"class":1137},"s7CZa","200",[1051,1140,1141],{"class":1065},")\n",[1051,1143,1145,1149,1152,1154,1156,1158,1160,1163,1165,1169,1173,1175],{"class":1053,"line":1144},5,[1051,1146,1148],{"class":1147},"sSC40","    file",[1051,1150,1151],{"class":1065}," =",[1051,1153,1120],{"class":1061},[1051,1155,1066],{"class":1065},[1051,1157,1033],{"class":1125},[1051,1159,1096],{"class":1065},[1051,1161,1162],{"class":1131},"upload_to",[1051,1164,1117],{"class":1065},[1051,1166,1168],{"class":1167},"sbYkP","'",[1051,1170,1172],{"class":1171},"sTbE_","documents/",[1051,1174,1168],{"class":1167},[1051,1176,1141],{"class":1065},[1051,1178,1180,1183,1185,1187,1189,1192,1194,1197,1199,1203],{"class":1053,"line":1179},6,[1051,1181,1182],{"class":1061},"    uploaded_at ",[1051,1184,1117],{"class":1065},[1051,1186,1120],{"class":1061},[1051,1188,1066],{"class":1065},[1051,1190,1191],{"class":1125},"DateTimeField",[1051,1193,1096],{"class":1065},[1051,1195,1196],{"class":1131},"auto_now_add",[1051,1198,1117],{"class":1065},[1051,1200,1202],{"class":1201},"s8XtY","True",[1051,1204,1141],{"class":1065},[1051,1206,1208],{"class":1053,"line":1207},7,[1051,1209,1210],{"class":1061},"    \n",[1051,1212,1214,1217,1221,1223,1227],{"class":1053,"line":1213},8,[1051,1215,1216],{"class":1088},"    def",[1051,1218,1220],{"class":1219},"sJdAF"," __str__",[1051,1222,1096],{"class":1065},[1051,1224,1226],{"class":1225},"sRjD_","self",[1051,1228,1108],{"class":1065},[1051,1230,1232,1235,1239,1241],{"class":1053,"line":1231},9,[1051,1233,1234],{"class":1057},"        return",[1051,1236,1238],{"class":1237},"se3Ec"," self",[1051,1240,1066],{"class":1065},[1051,1242,1244],{"class":1243},"sBPpx","title\n",[1246,1247,1249],"h3",{"id":1248},"key-parameters","Key Parameters",[1251,1252,1253,1260,1266],"ul",{},[1254,1255,1256,1259],"li",{},[1257,1258,1162],"strong",{},": Specifies the subdirectory where files will be stored",[1254,1261,1262,1265],{},[1257,1263,1264],{},"storage",": Custom storage backend (optional)",[1254,1267,1268,1270],{},[1257,1269,1132],{},": Maximum length of the filename (default: 100)",[1030,1272,1274],{"id":1273},"imagefield","ImageField",[1026,1276,1036,1277,1279,1280,1282],{},[1038,1278,1274],{}," extends ",[1038,1281,1033],{}," with image-specific validation:",[1042,1284,1286],{"className":1044,"code":1285,"language":1046,"meta":1047,"style":1047},"from django.db import models\n\nclass Profile(models.Model):\n    user = models.OneToOneField('auth.User', on_delete=models.CASCADE)\n    avatar = models.ImageField(\n        upload_to='avatars/',\n        default='avatars/default.jpg',\n        help_text='Upload a profile picture'\n    )\n    bio = models.TextField(blank=True)\n",[1038,1287,1288,1302,1306,1323,1364,1380,1397,1413,1428,1433],{"__ignoreMap":1047},[1051,1289,1290,1292,1294,1296,1298,1300],{"class":1053,"line":1054},[1051,1291,1058],{"class":1057},[1051,1293,1062],{"class":1061},[1051,1295,1066],{"class":1065},[1051,1297,1069],{"class":1061},[1051,1299,1072],{"class":1057},[1051,1301,1075],{"class":1061},[1051,1303,1304],{"class":1053,"line":1078},[1051,1305,1082],{"emptyLinePlaceholder":1081},[1051,1307,1308,1310,1313,1315,1317,1319,1321],{"class":1053,"line":1085},[1051,1309,1089],{"class":1088},[1051,1311,1312],{"class":1092}," Profile",[1051,1314,1096],{"class":1065},[1051,1316,1100],{"class":1099},[1051,1318,1066],{"class":1065},[1051,1320,1105],{"class":1099},[1051,1322,1108],{"class":1065},[1051,1324,1325,1328,1330,1332,1334,1337,1339,1341,1344,1346,1349,1352,1354,1356,1358,1362],{"class":1053,"line":1111},[1051,1326,1327],{"class":1061},"    user ",[1051,1329,1117],{"class":1065},[1051,1331,1120],{"class":1061},[1051,1333,1066],{"class":1065},[1051,1335,1336],{"class":1125},"OneToOneField",[1051,1338,1096],{"class":1065},[1051,1340,1168],{"class":1167},[1051,1342,1343],{"class":1171},"auth.User",[1051,1345,1168],{"class":1167},[1051,1347,1348],{"class":1065},",",[1051,1350,1351],{"class":1131}," on_delete",[1051,1353,1117],{"class":1065},[1051,1355,1100],{"class":1125},[1051,1357,1066],{"class":1065},[1051,1359,1361],{"class":1360},"sFGJz","CASCADE",[1051,1363,1141],{"class":1065},[1051,1365,1366,1369,1371,1373,1375,1377],{"class":1053,"line":1144},[1051,1367,1368],{"class":1061},"    avatar ",[1051,1370,1117],{"class":1065},[1051,1372,1120],{"class":1061},[1051,1374,1066],{"class":1065},[1051,1376,1274],{"class":1125},[1051,1378,1379],{"class":1065},"(\n",[1051,1381,1382,1385,1387,1389,1392,1394],{"class":1053,"line":1179},[1051,1383,1384],{"class":1131},"        upload_to",[1051,1386,1117],{"class":1065},[1051,1388,1168],{"class":1167},[1051,1390,1391],{"class":1171},"avatars/",[1051,1393,1168],{"class":1167},[1051,1395,1396],{"class":1065},",\n",[1051,1398,1399,1402,1404,1406,1409,1411],{"class":1053,"line":1207},[1051,1400,1401],{"class":1131},"        default",[1051,1403,1117],{"class":1065},[1051,1405,1168],{"class":1167},[1051,1407,1408],{"class":1171},"avatars/default.jpg",[1051,1410,1168],{"class":1167},[1051,1412,1396],{"class":1065},[1051,1414,1415,1418,1420,1422,1425],{"class":1053,"line":1213},[1051,1416,1417],{"class":1131},"        help_text",[1051,1419,1117],{"class":1065},[1051,1421,1168],{"class":1167},[1051,1423,1424],{"class":1171},"Upload a profile picture",[1051,1426,1427],{"class":1167},"'\n",[1051,1429,1430],{"class":1053,"line":1231},[1051,1431,1432],{"class":1065},"    )\n",[1051,1434,1436,1439,1441,1443,1445,1448,1450,1453,1455,1457],{"class":1053,"line":1435},10,[1051,1437,1438],{"class":1061},"    bio ",[1051,1440,1117],{"class":1065},[1051,1442,1120],{"class":1061},[1051,1444,1066],{"class":1065},[1051,1446,1447],{"class":1125},"TextField",[1051,1449,1096],{"class":1065},[1051,1451,1452],{"class":1131},"blank",[1051,1454,1117],{"class":1065},[1051,1456,1202],{"class":1201},[1051,1458,1141],{"class":1065},[1246,1460,1462],{"id":1461},"image-validation","Image Validation",[1026,1464,1465,1467],{},[1038,1466,1274],{}," automatically validates that uploaded files are valid images:",[1042,1469,1471],{"className":1044,"code":1470,"language":1046,"meta":1047,"style":1047},"from PIL import Image\nfrom django.core.exceptions import ValidationError\n\ndef validate_image_size(image):\n    \"\"\"Custom validator for image dimensions\"\"\"\n    if image:\n        with Image.open(image) as img:\n            if img.width > 1920 or img.height > 1080:\n                raise ValidationError('Image dimensions cannot exceed 1920x1080 pixels.')\n\nclass Photo(models.Model):\n    title = models.CharField(max_length=100)\n    image = models.ImageField(\n        upload_to='photos/',\n        validators=[validate_image_size]\n    )\n",[1038,1472,1473,1486,1507,1511,1528,1541,1552,1580,1616,1635,1639,1657,1681,1697,1713,1728],{"__ignoreMap":1047},[1051,1474,1475,1477,1480,1483],{"class":1053,"line":1054},[1051,1476,1058],{"class":1057},[1051,1478,1479],{"class":1237}," PIL",[1051,1481,1482],{"class":1057}," import",[1051,1484,1485],{"class":1061}," Image\n",[1051,1487,1488,1490,1492,1494,1497,1499,1502,1504],{"class":1053,"line":1078},[1051,1489,1058],{"class":1057},[1051,1491,1062],{"class":1061},[1051,1493,1066],{"class":1065},[1051,1495,1496],{"class":1061},"core",[1051,1498,1066],{"class":1065},[1051,1500,1501],{"class":1061},"exceptions ",[1051,1503,1072],{"class":1057},[1051,1505,1506],{"class":1061}," ValidationError\n",[1051,1508,1509],{"class":1053,"line":1085},[1051,1510,1082],{"emptyLinePlaceholder":1081},[1051,1512,1513,1516,1520,1522,1526],{"class":1053,"line":1111},[1051,1514,1515],{"class":1088},"def",[1051,1517,1519],{"class":1518},"sljsM"," validate_image_size",[1051,1521,1096],{"class":1065},[1051,1523,1525],{"class":1524},"sCyAa","image",[1051,1527,1108],{"class":1065},[1051,1529,1530,1534,1538],{"class":1053,"line":1144},[1051,1531,1533],{"class":1532},"sm7ve","    \"\"\"",[1051,1535,1537],{"class":1536},"sVyVU","Custom validator for image dimensions",[1051,1539,1540],{"class":1532},"\"\"\"\n",[1051,1542,1543,1546,1549],{"class":1053,"line":1179},[1051,1544,1545],{"class":1057},"    if",[1051,1547,1548],{"class":1061}," image",[1051,1550,1551],{"class":1065},":\n",[1051,1553,1554,1557,1560,1562,1565,1567,1569,1572,1575,1578],{"class":1053,"line":1207},[1051,1555,1556],{"class":1057},"        with",[1051,1558,1559],{"class":1061}," Image",[1051,1561,1066],{"class":1065},[1051,1563,1564],{"class":1125},"open",[1051,1566,1096],{"class":1065},[1051,1568,1525],{"class":1125},[1051,1570,1571],{"class":1065},")",[1051,1573,1574],{"class":1057}," as",[1051,1576,1577],{"class":1061}," img",[1051,1579,1551],{"class":1065},[1051,1581,1582,1585,1587,1589,1592,1596,1599,1602,1604,1606,1609,1611,1614],{"class":1053,"line":1213},[1051,1583,1584],{"class":1057},"            if",[1051,1586,1577],{"class":1061},[1051,1588,1066],{"class":1065},[1051,1590,1591],{"class":1243},"width",[1051,1593,1595],{"class":1594},"sVsLi"," >",[1051,1597,1598],{"class":1137}," 1920",[1051,1600,1601],{"class":1594}," or",[1051,1603,1577],{"class":1061},[1051,1605,1066],{"class":1065},[1051,1607,1608],{"class":1243},"height",[1051,1610,1595],{"class":1594},[1051,1612,1613],{"class":1137}," 1080",[1051,1615,1551],{"class":1065},[1051,1617,1618,1621,1624,1626,1628,1631,1633],{"class":1053,"line":1231},[1051,1619,1620],{"class":1057},"                raise",[1051,1622,1623],{"class":1125}," ValidationError",[1051,1625,1096],{"class":1065},[1051,1627,1168],{"class":1167},[1051,1629,1630],{"class":1171},"Image dimensions cannot exceed 1920x1080 pixels.",[1051,1632,1168],{"class":1167},[1051,1634,1141],{"class":1065},[1051,1636,1637],{"class":1053,"line":1435},[1051,1638,1082],{"emptyLinePlaceholder":1081},[1051,1640,1642,1644,1647,1649,1651,1653,1655],{"class":1053,"line":1641},11,[1051,1643,1089],{"class":1088},[1051,1645,1646],{"class":1092}," Photo",[1051,1648,1096],{"class":1065},[1051,1650,1100],{"class":1099},[1051,1652,1066],{"class":1065},[1051,1654,1105],{"class":1099},[1051,1656,1108],{"class":1065},[1051,1658,1660,1662,1664,1666,1668,1670,1672,1674,1676,1679],{"class":1053,"line":1659},12,[1051,1661,1114],{"class":1061},[1051,1663,1117],{"class":1065},[1051,1665,1120],{"class":1061},[1051,1667,1066],{"class":1065},[1051,1669,1126],{"class":1125},[1051,1671,1096],{"class":1065},[1051,1673,1132],{"class":1131},[1051,1675,1117],{"class":1065},[1051,1677,1678],{"class":1137},"100",[1051,1680,1141],{"class":1065},[1051,1682,1684,1687,1689,1691,1693,1695],{"class":1053,"line":1683},13,[1051,1685,1686],{"class":1061},"    image ",[1051,1688,1117],{"class":1065},[1051,1690,1120],{"class":1061},[1051,1692,1066],{"class":1065},[1051,1694,1274],{"class":1125},[1051,1696,1379],{"class":1065},[1051,1698,1700,1702,1704,1706,1709,1711],{"class":1053,"line":1699},14,[1051,1701,1384],{"class":1131},[1051,1703,1117],{"class":1065},[1051,1705,1168],{"class":1167},[1051,1707,1708],{"class":1171},"photos/",[1051,1710,1168],{"class":1167},[1051,1712,1396],{"class":1065},[1051,1714,1716,1719,1722,1725],{"class":1053,"line":1715},15,[1051,1717,1718],{"class":1131},"        validators",[1051,1720,1721],{"class":1065},"=[",[1051,1723,1724],{"class":1125},"validate_image_size",[1051,1726,1727],{"class":1065},"]\n",[1051,1729,1731],{"class":1053,"line":1730},16,[1051,1732,1432],{"class":1065},[1030,1734,1736],{"id":1735},"dynamic-upload-paths","Dynamic Upload Paths",[1026,1738,1739],{},"Create dynamic upload paths based on model data:",[1042,1741,1743],{"className":1044,"code":1742,"language":1046,"meta":1047,"style":1047},"def user_directory_path(instance, filename):\n    \"\"\"File will be uploaded to MEDIA_ROOT/user_\u003Cid>/\u003Cfilename>\"\"\"\n    return f'user_{instance.user.id}/{filename}'\n\ndef date_directory_path(instance, filename):\n    \"\"\"Organize files by date\"\"\"\n    from datetime import datetime\n    return f'uploads/{datetime.now().strftime(\"%Y/%m/%d\")}/{filename}'\n\nclass UserFile(models.Model):\n    user = models.ForeignKey('auth.User', on_delete=models.CASCADE)\n    file = models.FileField(upload_to=user_directory_path)\n    \nclass DatedUpload(models.Model):\n    name = models.CharField(max_length=100)\n    file = models.FileField(upload_to=date_directory_path)\n",[1038,1744,1745,1764,1773,1815,1819,1836,1845,1858,1910,1914,1931,1966,1989,1993,2010,2033],{"__ignoreMap":1047},[1051,1746,1747,1749,1752,1754,1757,1759,1762],{"class":1053,"line":1054},[1051,1748,1515],{"class":1088},[1051,1750,1751],{"class":1518}," user_directory_path",[1051,1753,1096],{"class":1065},[1051,1755,1756],{"class":1524},"instance",[1051,1758,1348],{"class":1065},[1051,1760,1761],{"class":1524}," filename",[1051,1763,1108],{"class":1065},[1051,1765,1766,1768,1771],{"class":1053,"line":1078},[1051,1767,1533],{"class":1532},[1051,1769,1770],{"class":1536},"File will be uploaded to MEDIA_ROOT/user_\u003Cid>/\u003Cfilename>",[1051,1772,1540],{"class":1532},[1051,1774,1775,1778,1781,1784,1788,1790,1792,1795,1797,1800,1803,1806,1808,1811,1813],{"class":1053,"line":1085},[1051,1776,1777],{"class":1057},"    return",[1051,1779,1780],{"class":1088}," f",[1051,1782,1783],{"class":1171},"'user_",[1051,1785,1787],{"class":1786},"s3h35","{",[1051,1789,1756],{"class":1061},[1051,1791,1066],{"class":1065},[1051,1793,1794],{"class":1243},"user",[1051,1796,1066],{"class":1065},[1051,1798,1799],{"class":1243},"id",[1051,1801,1802],{"class":1786},"}",[1051,1804,1805],{"class":1171},"/",[1051,1807,1787],{"class":1786},[1051,1809,1810],{"class":1061},"filename",[1051,1812,1802],{"class":1786},[1051,1814,1427],{"class":1171},[1051,1816,1817],{"class":1053,"line":1111},[1051,1818,1082],{"emptyLinePlaceholder":1081},[1051,1820,1821,1823,1826,1828,1830,1832,1834],{"class":1053,"line":1144},[1051,1822,1515],{"class":1088},[1051,1824,1825],{"class":1518}," date_directory_path",[1051,1827,1096],{"class":1065},[1051,1829,1756],{"class":1524},[1051,1831,1348],{"class":1065},[1051,1833,1761],{"class":1524},[1051,1835,1108],{"class":1065},[1051,1837,1838,1840,1843],{"class":1053,"line":1179},[1051,1839,1533],{"class":1532},[1051,1841,1842],{"class":1536},"Organize files by date",[1051,1844,1540],{"class":1532},[1051,1846,1847,1850,1853,1855],{"class":1053,"line":1207},[1051,1848,1849],{"class":1057},"    from",[1051,1851,1852],{"class":1061}," datetime ",[1051,1854,1072],{"class":1057},[1051,1856,1857],{"class":1061}," datetime\n",[1051,1859,1860,1862,1864,1867,1869,1872,1874,1877,1880,1883,1885,1888,1891,1894,1896,1898,1900,1902,1904,1906,1908],{"class":1053,"line":1213},[1051,1861,1777],{"class":1057},[1051,1863,1780],{"class":1088},[1051,1865,1866],{"class":1171},"'uploads/",[1051,1868,1787],{"class":1786},[1051,1870,1871],{"class":1061},"datetime",[1051,1873,1066],{"class":1065},[1051,1875,1876],{"class":1125},"now",[1051,1878,1879],{"class":1065},"().",[1051,1881,1882],{"class":1125},"strftime",[1051,1884,1096],{"class":1065},[1051,1886,1887],{"class":1167},"\"",[1051,1889,1890],{"class":1171},"%Y/%m/",[1051,1892,1893],{"class":1786},"%d",[1051,1895,1887],{"class":1167},[1051,1897,1571],{"class":1065},[1051,1899,1802],{"class":1786},[1051,1901,1805],{"class":1171},[1051,1903,1787],{"class":1786},[1051,1905,1810],{"class":1061},[1051,1907,1802],{"class":1786},[1051,1909,1427],{"class":1171},[1051,1911,1912],{"class":1053,"line":1231},[1051,1913,1082],{"emptyLinePlaceholder":1081},[1051,1915,1916,1918,1921,1923,1925,1927,1929],{"class":1053,"line":1435},[1051,1917,1089],{"class":1088},[1051,1919,1920],{"class":1092}," UserFile",[1051,1922,1096],{"class":1065},[1051,1924,1100],{"class":1099},[1051,1926,1066],{"class":1065},[1051,1928,1105],{"class":1099},[1051,1930,1108],{"class":1065},[1051,1932,1933,1935,1937,1939,1941,1944,1946,1948,1950,1952,1954,1956,1958,1960,1962,1964],{"class":1053,"line":1641},[1051,1934,1327],{"class":1061},[1051,1936,1117],{"class":1065},[1051,1938,1120],{"class":1061},[1051,1940,1066],{"class":1065},[1051,1942,1943],{"class":1125},"ForeignKey",[1051,1945,1096],{"class":1065},[1051,1947,1168],{"class":1167},[1051,1949,1343],{"class":1171},[1051,1951,1168],{"class":1167},[1051,1953,1348],{"class":1065},[1051,1955,1351],{"class":1131},[1051,1957,1117],{"class":1065},[1051,1959,1100],{"class":1125},[1051,1961,1066],{"class":1065},[1051,1963,1361],{"class":1360},[1051,1965,1141],{"class":1065},[1051,1967,1968,1970,1972,1974,1976,1978,1980,1982,1984,1987],{"class":1053,"line":1659},[1051,1969,1148],{"class":1147},[1051,1971,1151],{"class":1065},[1051,1973,1120],{"class":1061},[1051,1975,1066],{"class":1065},[1051,1977,1033],{"class":1125},[1051,1979,1096],{"class":1065},[1051,1981,1162],{"class":1131},[1051,1983,1117],{"class":1065},[1051,1985,1986],{"class":1125},"user_directory_path",[1051,1988,1141],{"class":1065},[1051,1990,1991],{"class":1053,"line":1683},[1051,1992,1210],{"class":1061},[1051,1994,1995,1997,2000,2002,2004,2006,2008],{"class":1053,"line":1699},[1051,1996,1089],{"class":1088},[1051,1998,1999],{"class":1092}," DatedUpload",[1051,2001,1096],{"class":1065},[1051,2003,1100],{"class":1099},[1051,2005,1066],{"class":1065},[1051,2007,1105],{"class":1099},[1051,2009,1108],{"class":1065},[1051,2011,2012,2015,2017,2019,2021,2023,2025,2027,2029,2031],{"class":1053,"line":1715},[1051,2013,2014],{"class":1061},"    name ",[1051,2016,1117],{"class":1065},[1051,2018,1120],{"class":1061},[1051,2020,1066],{"class":1065},[1051,2022,1126],{"class":1125},[1051,2024,1096],{"class":1065},[1051,2026,1132],{"class":1131},[1051,2028,1117],{"class":1065},[1051,2030,1678],{"class":1137},[1051,2032,1141],{"class":1065},[1051,2034,2035,2037,2039,2041,2043,2045,2047,2049,2051,2054],{"class":1053,"line":1730},[1051,2036,1148],{"class":1147},[1051,2038,1151],{"class":1065},[1051,2040,1120],{"class":1061},[1051,2042,1066],{"class":1065},[1051,2044,1033],{"class":1125},[1051,2046,1096],{"class":1065},[1051,2048,1162],{"class":1131},[1051,2050,1117],{"class":1065},[1051,2052,2053],{"class":1125},"date_directory_path",[1051,2055,1141],{"class":1065},[1030,2057,2059],{"id":2058},"file-validation","File Validation",[1026,2061,2062],{},"Implement custom validation for file types and sizes:",[1042,2064,2066],{"className":1044,"code":2065,"language":1046,"meta":1047,"style":1047},"import os\nfrom django.core.exceptions import ValidationError\n\ndef validate_file_extension(value):\n    \"\"\"Validate file extension\"\"\"\n    ext = os.path.splitext(value.name)[1]\n    valid_extensions = ['.pdf', '.doc', '.docx', '.txt']\n    if not ext.lower() in valid_extensions:\n        raise ValidationError('Unsupported file extension.')\n\ndef validate_file_size(value):\n    \"\"\"Validate file size (max 5MB)\"\"\"\n    filesize = value.size\n    if filesize > 5 * 1024 * 1024:  # 5MB\n        raise ValidationError(\"File size cannot exceed 5MB.\")\n\nclass Document(models.Model):\n    title = models.CharField(max_length=200)\n    file = models.FileField(\n        upload_to='documents/',\n        validators=[validate_file_extension, validate_file_size]\n    )\n",[1038,2067,2068,2075,2093,2097,2111,2120,2157,2204,2230,2248,2252,2265,2274,2289,2319,2336,2340,2357,2380,2395,2410,2426],{"__ignoreMap":1047},[1051,2069,2070,2072],{"class":1053,"line":1054},[1051,2071,1072],{"class":1057},[1051,2073,2074],{"class":1061}," os\n",[1051,2076,2077,2079,2081,2083,2085,2087,2089,2091],{"class":1053,"line":1078},[1051,2078,1058],{"class":1057},[1051,2080,1062],{"class":1061},[1051,2082,1066],{"class":1065},[1051,2084,1496],{"class":1061},[1051,2086,1066],{"class":1065},[1051,2088,1501],{"class":1061},[1051,2090,1072],{"class":1057},[1051,2092,1506],{"class":1061},[1051,2094,2095],{"class":1053,"line":1085},[1051,2096,1082],{"emptyLinePlaceholder":1081},[1051,2098,2099,2101,2104,2106,2109],{"class":1053,"line":1111},[1051,2100,1515],{"class":1088},[1051,2102,2103],{"class":1518}," validate_file_extension",[1051,2105,1096],{"class":1065},[1051,2107,2108],{"class":1524},"value",[1051,2110,1108],{"class":1065},[1051,2112,2113,2115,2118],{"class":1053,"line":1144},[1051,2114,1533],{"class":1532},[1051,2116,2117],{"class":1536},"Validate file extension",[1051,2119,1540],{"class":1532},[1051,2121,2122,2125,2127,2130,2132,2135,2137,2140,2142,2144,2146,2149,2152,2155],{"class":1053,"line":1179},[1051,2123,2124],{"class":1061},"    ext ",[1051,2126,1117],{"class":1065},[1051,2128,2129],{"class":1061}," os",[1051,2131,1066],{"class":1065},[1051,2133,2134],{"class":1243},"path",[1051,2136,1066],{"class":1065},[1051,2138,2139],{"class":1125},"splitext",[1051,2141,1096],{"class":1065},[1051,2143,2108],{"class":1125},[1051,2145,1066],{"class":1065},[1051,2147,2148],{"class":1243},"name",[1051,2150,2151],{"class":1065},")[",[1051,2153,2154],{"class":1137},"1",[1051,2156,1727],{"class":1065},[1051,2158,2159,2162,2164,2167,2169,2172,2174,2176,2179,2182,2184,2186,2188,2191,2193,2195,2197,2200,2202],{"class":1053,"line":1207},[1051,2160,2161],{"class":1061},"    valid_extensions ",[1051,2163,1117],{"class":1065},[1051,2165,2166],{"class":1065}," [",[1051,2168,1168],{"class":1167},[1051,2170,2171],{"class":1171},".pdf",[1051,2173,1168],{"class":1167},[1051,2175,1348],{"class":1065},[1051,2177,2178],{"class":1167}," '",[1051,2180,2181],{"class":1171},".doc",[1051,2183,1168],{"class":1167},[1051,2185,1348],{"class":1065},[1051,2187,2178],{"class":1167},[1051,2189,2190],{"class":1171},".docx",[1051,2192,1168],{"class":1167},[1051,2194,1348],{"class":1065},[1051,2196,2178],{"class":1167},[1051,2198,2199],{"class":1171},".txt",[1051,2201,1168],{"class":1167},[1051,2203,1727],{"class":1065},[1051,2205,2206,2208,2211,2214,2216,2219,2222,2225,2228],{"class":1053,"line":1213},[1051,2207,1545],{"class":1057},[1051,2209,2210],{"class":1594}," not",[1051,2212,2213],{"class":1061}," ext",[1051,2215,1066],{"class":1065},[1051,2217,2218],{"class":1125},"lower",[1051,2220,2221],{"class":1065},"()",[1051,2223,2224],{"class":1594}," in",[1051,2226,2227],{"class":1061}," valid_extensions",[1051,2229,1551],{"class":1065},[1051,2231,2232,2235,2237,2239,2241,2244,2246],{"class":1053,"line":1231},[1051,2233,2234],{"class":1057},"        raise",[1051,2236,1623],{"class":1125},[1051,2238,1096],{"class":1065},[1051,2240,1168],{"class":1167},[1051,2242,2243],{"class":1171},"Unsupported file extension.",[1051,2245,1168],{"class":1167},[1051,2247,1141],{"class":1065},[1051,2249,2250],{"class":1053,"line":1435},[1051,2251,1082],{"emptyLinePlaceholder":1081},[1051,2253,2254,2256,2259,2261,2263],{"class":1053,"line":1641},[1051,2255,1515],{"class":1088},[1051,2257,2258],{"class":1518}," validate_file_size",[1051,2260,1096],{"class":1065},[1051,2262,2108],{"class":1524},[1051,2264,1108],{"class":1065},[1051,2266,2267,2269,2272],{"class":1053,"line":1659},[1051,2268,1533],{"class":1532},[1051,2270,2271],{"class":1536},"Validate file size (max 5MB)",[1051,2273,1540],{"class":1532},[1051,2275,2276,2279,2281,2284,2286],{"class":1053,"line":1683},[1051,2277,2278],{"class":1061},"    filesize ",[1051,2280,1117],{"class":1065},[1051,2282,2283],{"class":1061}," value",[1051,2285,1066],{"class":1065},[1051,2287,2288],{"class":1243},"size\n",[1051,2290,2291,2293,2296,2299,2302,2305,2308,2310,2312,2315],{"class":1053,"line":1699},[1051,2292,1545],{"class":1057},[1051,2294,2295],{"class":1061}," filesize ",[1051,2297,2298],{"class":1594},">",[1051,2300,2301],{"class":1137}," 5",[1051,2303,2304],{"class":1594}," *",[1051,2306,2307],{"class":1137}," 1024",[1051,2309,2304],{"class":1594},[1051,2311,2307],{"class":1137},[1051,2313,2314],{"class":1065},":",[1051,2316,2318],{"class":2317},"s9Tkl","  # 5MB\n",[1051,2320,2321,2323,2325,2327,2329,2332,2334],{"class":1053,"line":1715},[1051,2322,2234],{"class":1057},[1051,2324,1623],{"class":1125},[1051,2326,1096],{"class":1065},[1051,2328,1887],{"class":1167},[1051,2330,2331],{"class":1171},"File size cannot exceed 5MB.",[1051,2333,1887],{"class":1167},[1051,2335,1141],{"class":1065},[1051,2337,2338],{"class":1053,"line":1730},[1051,2339,1082],{"emptyLinePlaceholder":1081},[1051,2341,2343,2345,2347,2349,2351,2353,2355],{"class":1053,"line":2342},17,[1051,2344,1089],{"class":1088},[1051,2346,1093],{"class":1092},[1051,2348,1096],{"class":1065},[1051,2350,1100],{"class":1099},[1051,2352,1066],{"class":1065},[1051,2354,1105],{"class":1099},[1051,2356,1108],{"class":1065},[1051,2358,2360,2362,2364,2366,2368,2370,2372,2374,2376,2378],{"class":1053,"line":2359},18,[1051,2361,1114],{"class":1061},[1051,2363,1117],{"class":1065},[1051,2365,1120],{"class":1061},[1051,2367,1066],{"class":1065},[1051,2369,1126],{"class":1125},[1051,2371,1096],{"class":1065},[1051,2373,1132],{"class":1131},[1051,2375,1117],{"class":1065},[1051,2377,1138],{"class":1137},[1051,2379,1141],{"class":1065},[1051,2381,2383,2385,2387,2389,2391,2393],{"class":1053,"line":2382},19,[1051,2384,1148],{"class":1147},[1051,2386,1151],{"class":1065},[1051,2388,1120],{"class":1061},[1051,2390,1066],{"class":1065},[1051,2392,1033],{"class":1125},[1051,2394,1379],{"class":1065},[1051,2396,2398,2400,2402,2404,2406,2408],{"class":1053,"line":2397},20,[1051,2399,1384],{"class":1131},[1051,2401,1117],{"class":1065},[1051,2403,1168],{"class":1167},[1051,2405,1172],{"class":1171},[1051,2407,1168],{"class":1167},[1051,2409,1396],{"class":1065},[1051,2411,2413,2415,2417,2420,2422,2424],{"class":1053,"line":2412},21,[1051,2414,1718],{"class":1131},[1051,2416,1721],{"class":1065},[1051,2418,2419],{"class":1125},"validate_file_extension",[1051,2421,1348],{"class":1065},[1051,2423,2258],{"class":1125},[1051,2425,1727],{"class":1065},[1051,2427,2429],{"class":1053,"line":2428},22,[1051,2430,1432],{"class":1065},[1030,2432,2434],{"id":2433},"working-with-file-fields","Working with File Fields",[1246,2436,2438],{"id":2437},"accessing-file-properties","Accessing File Properties",[1042,2440,2442],{"className":1044,"code":2441,"language":1046,"meta":1047,"style":1047},"# In views or templates\ndocument = Document.objects.get(pk=1)\n\n# File URL\nfile_url = document.file.url\n\n# File path\nfile_path = document.file.path\n\n# File name\nfilename = document.file.name\n\n# File size\nfile_size = document.file.size\n\n# Check if file exists\nif document.file:\n    print(f\"File exists: {document.file.name}\")\n",[1038,2443,2444,2449,2479,2483,2488,2508,2512,2517,2535,2539,2544,2562,2566,2571,2588,2592,2597,2610],{"__ignoreMap":1047},[1051,2445,2446],{"class":1053,"line":1054},[1051,2447,2448],{"class":2317},"# In views or templates\n",[1051,2450,2451,2454,2456,2458,2460,2463,2465,2468,2470,2473,2475,2477],{"class":1053,"line":1078},[1051,2452,2453],{"class":1061},"document ",[1051,2455,1117],{"class":1065},[1051,2457,1093],{"class":1061},[1051,2459,1066],{"class":1065},[1051,2461,2462],{"class":1243},"objects",[1051,2464,1066],{"class":1065},[1051,2466,2467],{"class":1125},"get",[1051,2469,1096],{"class":1065},[1051,2471,2472],{"class":1131},"pk",[1051,2474,1117],{"class":1065},[1051,2476,2154],{"class":1137},[1051,2478,1141],{"class":1065},[1051,2480,2481],{"class":1053,"line":1085},[1051,2482,1082],{"emptyLinePlaceholder":1081},[1051,2484,2485],{"class":1053,"line":1111},[1051,2486,2487],{"class":2317},"# File URL\n",[1051,2489,2490,2493,2495,2498,2500,2503,2505],{"class":1053,"line":1144},[1051,2491,2492],{"class":1061},"file_url ",[1051,2494,1117],{"class":1065},[1051,2496,2497],{"class":1061}," document",[1051,2499,1066],{"class":1065},[1051,2501,2502],{"class":1243},"file",[1051,2504,1066],{"class":1065},[1051,2506,2507],{"class":1243},"url\n",[1051,2509,2510],{"class":1053,"line":1179},[1051,2511,1082],{"emptyLinePlaceholder":1081},[1051,2513,2514],{"class":1053,"line":1207},[1051,2515,2516],{"class":2317},"# File path\n",[1051,2518,2519,2522,2524,2526,2528,2530,2532],{"class":1053,"line":1213},[1051,2520,2521],{"class":1061},"file_path ",[1051,2523,1117],{"class":1065},[1051,2525,2497],{"class":1061},[1051,2527,1066],{"class":1065},[1051,2529,2502],{"class":1243},[1051,2531,1066],{"class":1065},[1051,2533,2534],{"class":1243},"path\n",[1051,2536,2537],{"class":1053,"line":1231},[1051,2538,1082],{"emptyLinePlaceholder":1081},[1051,2540,2541],{"class":1053,"line":1435},[1051,2542,2543],{"class":2317},"# File name\n",[1051,2545,2546,2549,2551,2553,2555,2557,2559],{"class":1053,"line":1641},[1051,2547,2548],{"class":1061},"filename ",[1051,2550,1117],{"class":1065},[1051,2552,2497],{"class":1061},[1051,2554,1066],{"class":1065},[1051,2556,2502],{"class":1243},[1051,2558,1066],{"class":1065},[1051,2560,2561],{"class":1243},"name\n",[1051,2563,2564],{"class":1053,"line":1659},[1051,2565,1082],{"emptyLinePlaceholder":1081},[1051,2567,2568],{"class":1053,"line":1683},[1051,2569,2570],{"class":2317},"# File size\n",[1051,2572,2573,2576,2578,2580,2582,2584,2586],{"class":1053,"line":1699},[1051,2574,2575],{"class":1061},"file_size ",[1051,2577,1117],{"class":1065},[1051,2579,2497],{"class":1061},[1051,2581,1066],{"class":1065},[1051,2583,2502],{"class":1243},[1051,2585,1066],{"class":1065},[1051,2587,2288],{"class":1243},[1051,2589,2590],{"class":1053,"line":1715},[1051,2591,1082],{"emptyLinePlaceholder":1081},[1051,2593,2594],{"class":1053,"line":1730},[1051,2595,2596],{"class":2317},"# Check if file exists\n",[1051,2598,2599,2602,2604,2606,2608],{"class":1053,"line":2342},[1051,2600,2601],{"class":1057},"if",[1051,2603,2497],{"class":1061},[1051,2605,1066],{"class":1065},[1051,2607,2502],{"class":1243},[1051,2609,1551],{"class":1065},[1051,2611,2612,2615,2617,2620,2623,2625,2628,2630,2632,2634,2636,2638,2640],{"class":1053,"line":2359},[1051,2613,2614],{"class":1219},"    print",[1051,2616,1096],{"class":1065},[1051,2618,2619],{"class":1088},"f",[1051,2621,2622],{"class":1171},"\"File exists: ",[1051,2624,1787],{"class":1786},[1051,2626,2627],{"class":1125},"document",[1051,2629,1066],{"class":1065},[1051,2631,2502],{"class":1243},[1051,2633,1066],{"class":1065},[1051,2635,2148],{"class":1243},[1051,2637,1802],{"class":1786},[1051,2639,1887],{"class":1171},[1051,2641,1141],{"class":1065},[1246,2643,2645],{"id":2644},"programmatic-file-assignment","Programmatic File Assignment",[1042,2647,2649],{"className":1044,"code":2648,"language":1046,"meta":1047,"style":1047},"from django.core.files import File\nfrom django.core.files.base import ContentFile\n\n# Assign existing file\nwith open('/path/to/file.pdf', 'rb') as f:\n    document = Document()\n    document.title = \"My Document\"\n    document.file.save('document.pdf', File(f))\n\n# Create file from content\ncontent = b\"This is file content\"\ndocument = Document()\ndocument.title = \"Generated Document\"\ndocument.file.save('generated.txt', ContentFile(content))\n",[1038,2650,2651,2671,2696,2700,2705,2739,2751,2772,2806,2810,2815,2832,2842,2859],{"__ignoreMap":1047},[1051,2652,2653,2655,2657,2659,2661,2663,2666,2668],{"class":1053,"line":1054},[1051,2654,1058],{"class":1057},[1051,2656,1062],{"class":1061},[1051,2658,1066],{"class":1065},[1051,2660,1496],{"class":1061},[1051,2662,1066],{"class":1065},[1051,2664,2665],{"class":1061},"files ",[1051,2667,1072],{"class":1057},[1051,2669,2670],{"class":1061}," File\n",[1051,2672,2673,2675,2677,2679,2681,2683,2686,2688,2691,2693],{"class":1053,"line":1078},[1051,2674,1058],{"class":1057},[1051,2676,1062],{"class":1061},[1051,2678,1066],{"class":1065},[1051,2680,1496],{"class":1061},[1051,2682,1066],{"class":1065},[1051,2684,2685],{"class":1061},"files",[1051,2687,1066],{"class":1065},[1051,2689,2690],{"class":1061},"base ",[1051,2692,1072],{"class":1057},[1051,2694,2695],{"class":1061}," ContentFile\n",[1051,2697,2698],{"class":1053,"line":1085},[1051,2699,1082],{"emptyLinePlaceholder":1081},[1051,2701,2702],{"class":1053,"line":1111},[1051,2703,2704],{"class":2317},"# Assign existing file\n",[1051,2706,2707,2710,2713,2715,2717,2720,2722,2724,2726,2729,2731,2733,2735,2737],{"class":1053,"line":1144},[1051,2708,2709],{"class":1057},"with",[1051,2711,2712],{"class":1219}," open",[1051,2714,1096],{"class":1065},[1051,2716,1168],{"class":1167},[1051,2718,2719],{"class":1171},"/path/to/file.pdf",[1051,2721,1168],{"class":1167},[1051,2723,1348],{"class":1065},[1051,2725,2178],{"class":1167},[1051,2727,2728],{"class":1171},"rb",[1051,2730,1168],{"class":1167},[1051,2732,1571],{"class":1065},[1051,2734,1574],{"class":1057},[1051,2736,1780],{"class":1061},[1051,2738,1551],{"class":1065},[1051,2740,2741,2744,2746,2748],{"class":1053,"line":1179},[1051,2742,2743],{"class":1061},"    document ",[1051,2745,1117],{"class":1065},[1051,2747,1093],{"class":1125},[1051,2749,2750],{"class":1065},"()\n",[1051,2752,2753,2756,2758,2761,2763,2766,2769],{"class":1053,"line":1207},[1051,2754,2755],{"class":1061},"    document",[1051,2757,1066],{"class":1065},[1051,2759,2760],{"class":1243},"title",[1051,2762,1151],{"class":1065},[1051,2764,2765],{"class":1167}," \"",[1051,2767,2768],{"class":1171},"My Document",[1051,2770,2771],{"class":1167},"\"\n",[1051,2773,2774,2776,2778,2780,2782,2785,2787,2789,2792,2794,2796,2799,2801,2803],{"class":1053,"line":1213},[1051,2775,2755],{"class":1061},[1051,2777,1066],{"class":1065},[1051,2779,2502],{"class":1243},[1051,2781,1066],{"class":1065},[1051,2783,2784],{"class":1125},"save",[1051,2786,1096],{"class":1065},[1051,2788,1168],{"class":1167},[1051,2790,2791],{"class":1171},"document.pdf",[1051,2793,1168],{"class":1167},[1051,2795,1348],{"class":1065},[1051,2797,2798],{"class":1125}," File",[1051,2800,1096],{"class":1065},[1051,2802,2619],{"class":1125},[1051,2804,2805],{"class":1065},"))\n",[1051,2807,2808],{"class":1053,"line":1231},[1051,2809,1082],{"emptyLinePlaceholder":1081},[1051,2811,2812],{"class":1053,"line":1435},[1051,2813,2814],{"class":2317},"# Create file from content\n",[1051,2816,2817,2820,2822,2825,2827,2830],{"class":1053,"line":1641},[1051,2818,2819],{"class":1061},"content ",[1051,2821,1117],{"class":1065},[1051,2823,2824],{"class":1088}," b",[1051,2826,1887],{"class":1167},[1051,2828,2829],{"class":1171},"This is file content",[1051,2831,2771],{"class":1167},[1051,2833,2834,2836,2838,2840],{"class":1053,"line":1659},[1051,2835,2453],{"class":1061},[1051,2837,1117],{"class":1065},[1051,2839,1093],{"class":1125},[1051,2841,2750],{"class":1065},[1051,2843,2844,2846,2848,2850,2852,2854,2857],{"class":1053,"line":1683},[1051,2845,2627],{"class":1061},[1051,2847,1066],{"class":1065},[1051,2849,2760],{"class":1243},[1051,2851,1151],{"class":1065},[1051,2853,2765],{"class":1167},[1051,2855,2856],{"class":1171},"Generated Document",[1051,2858,2771],{"class":1167},[1051,2860,2861,2863,2865,2867,2869,2871,2873,2875,2878,2880,2882,2885,2887,2890],{"class":1053,"line":1699},[1051,2862,2627],{"class":1061},[1051,2864,1066],{"class":1065},[1051,2866,2502],{"class":1243},[1051,2868,1066],{"class":1065},[1051,2870,2784],{"class":1125},[1051,2872,1096],{"class":1065},[1051,2874,1168],{"class":1167},[1051,2876,2877],{"class":1171},"generated.txt",[1051,2879,1168],{"class":1167},[1051,2881,1348],{"class":1065},[1051,2883,2884],{"class":1125}," ContentFile",[1051,2886,1096],{"class":1065},[1051,2888,2889],{"class":1125},"content",[1051,2891,2805],{"class":1065},[1030,2893,2895],{"id":2894},"multiple-file-fields","Multiple File Fields",[1026,2897,2898],{},"Handle multiple file types in a single model:",[1042,2900,2902],{"className":1044,"code":2901,"language":1046,"meta":1047,"style":1047},"class Article(models.Model):\n    title = models.CharField(max_length=200)\n    content = models.TextField()\n    \n    # Different file types\n    featured_image = models.ImageField(\n        upload_to='articles/images/',\n        blank=True,\n        null=True\n    )\n    pdf_version = models.FileField(\n        upload_to='articles/pdfs/',\n        blank=True,\n        null=True,\n        validators=[validate_pdf_extension]\n    )\n    attachments = models.ManyToManyField(\n        'Attachment',\n        blank=True\n    )\n\nclass Attachment(models.Model):\n    name = models.CharField(max_length=100)\n    file = models.FileField(upload_to='attachments/')\n    uploaded_at = models.DateTimeField(auto_now_add=True)\n",[1038,2903,2904,2921,2943,2958,2962,2967,2982,2997,3008,3018,3022,3037,3052,3062,3072,3083,3087,3103,3115,3123,3127,3131,3148,3171,3199],{"__ignoreMap":1047},[1051,2905,2906,2908,2911,2913,2915,2917,2919],{"class":1053,"line":1054},[1051,2907,1089],{"class":1088},[1051,2909,2910],{"class":1092}," Article",[1051,2912,1096],{"class":1065},[1051,2914,1100],{"class":1099},[1051,2916,1066],{"class":1065},[1051,2918,1105],{"class":1099},[1051,2920,1108],{"class":1065},[1051,2922,2923,2925,2927,2929,2931,2933,2935,2937,2939,2941],{"class":1053,"line":1078},[1051,2924,1114],{"class":1061},[1051,2926,1117],{"class":1065},[1051,2928,1120],{"class":1061},[1051,2930,1066],{"class":1065},[1051,2932,1126],{"class":1125},[1051,2934,1096],{"class":1065},[1051,2936,1132],{"class":1131},[1051,2938,1117],{"class":1065},[1051,2940,1138],{"class":1137},[1051,2942,1141],{"class":1065},[1051,2944,2945,2948,2950,2952,2954,2956],{"class":1053,"line":1085},[1051,2946,2947],{"class":1061},"    content ",[1051,2949,1117],{"class":1065},[1051,2951,1120],{"class":1061},[1051,2953,1066],{"class":1065},[1051,2955,1447],{"class":1125},[1051,2957,2750],{"class":1065},[1051,2959,2960],{"class":1053,"line":1111},[1051,2961,1210],{"class":1061},[1051,2963,2964],{"class":1053,"line":1144},[1051,2965,2966],{"class":2317},"    # Different file types\n",[1051,2968,2969,2972,2974,2976,2978,2980],{"class":1053,"line":1179},[1051,2970,2971],{"class":1061},"    featured_image ",[1051,2973,1117],{"class":1065},[1051,2975,1120],{"class":1061},[1051,2977,1066],{"class":1065},[1051,2979,1274],{"class":1125},[1051,2981,1379],{"class":1065},[1051,2983,2984,2986,2988,2990,2993,2995],{"class":1053,"line":1207},[1051,2985,1384],{"class":1131},[1051,2987,1117],{"class":1065},[1051,2989,1168],{"class":1167},[1051,2991,2992],{"class":1171},"articles/images/",[1051,2994,1168],{"class":1167},[1051,2996,1396],{"class":1065},[1051,2998,2999,3002,3004,3006],{"class":1053,"line":1213},[1051,3000,3001],{"class":1131},"        blank",[1051,3003,1117],{"class":1065},[1051,3005,1202],{"class":1201},[1051,3007,1396],{"class":1065},[1051,3009,3010,3013,3015],{"class":1053,"line":1231},[1051,3011,3012],{"class":1131},"        null",[1051,3014,1117],{"class":1065},[1051,3016,3017],{"class":1201},"True\n",[1051,3019,3020],{"class":1053,"line":1435},[1051,3021,1432],{"class":1065},[1051,3023,3024,3027,3029,3031,3033,3035],{"class":1053,"line":1641},[1051,3025,3026],{"class":1061},"    pdf_version ",[1051,3028,1117],{"class":1065},[1051,3030,1120],{"class":1061},[1051,3032,1066],{"class":1065},[1051,3034,1033],{"class":1125},[1051,3036,1379],{"class":1065},[1051,3038,3039,3041,3043,3045,3048,3050],{"class":1053,"line":1659},[1051,3040,1384],{"class":1131},[1051,3042,1117],{"class":1065},[1051,3044,1168],{"class":1167},[1051,3046,3047],{"class":1171},"articles/pdfs/",[1051,3049,1168],{"class":1167},[1051,3051,1396],{"class":1065},[1051,3053,3054,3056,3058,3060],{"class":1053,"line":1683},[1051,3055,3001],{"class":1131},[1051,3057,1117],{"class":1065},[1051,3059,1202],{"class":1201},[1051,3061,1396],{"class":1065},[1051,3063,3064,3066,3068,3070],{"class":1053,"line":1699},[1051,3065,3012],{"class":1131},[1051,3067,1117],{"class":1065},[1051,3069,1202],{"class":1201},[1051,3071,1396],{"class":1065},[1051,3073,3074,3076,3078,3081],{"class":1053,"line":1715},[1051,3075,1718],{"class":1131},[1051,3077,1721],{"class":1065},[1051,3079,3080],{"class":1125},"validate_pdf_extension",[1051,3082,1727],{"class":1065},[1051,3084,3085],{"class":1053,"line":1730},[1051,3086,1432],{"class":1065},[1051,3088,3089,3092,3094,3096,3098,3101],{"class":1053,"line":2342},[1051,3090,3091],{"class":1061},"    attachments ",[1051,3093,1117],{"class":1065},[1051,3095,1120],{"class":1061},[1051,3097,1066],{"class":1065},[1051,3099,3100],{"class":1125},"ManyToManyField",[1051,3102,1379],{"class":1065},[1051,3104,3105,3108,3111,3113],{"class":1053,"line":2359},[1051,3106,3107],{"class":1167},"        '",[1051,3109,3110],{"class":1171},"Attachment",[1051,3112,1168],{"class":1167},[1051,3114,1396],{"class":1065},[1051,3116,3117,3119,3121],{"class":1053,"line":2382},[1051,3118,3001],{"class":1131},[1051,3120,1117],{"class":1065},[1051,3122,3017],{"class":1201},[1051,3124,3125],{"class":1053,"line":2397},[1051,3126,1432],{"class":1065},[1051,3128,3129],{"class":1053,"line":2412},[1051,3130,1082],{"emptyLinePlaceholder":1081},[1051,3132,3133,3135,3138,3140,3142,3144,3146],{"class":1053,"line":2428},[1051,3134,1089],{"class":1088},[1051,3136,3137],{"class":1092}," Attachment",[1051,3139,1096],{"class":1065},[1051,3141,1100],{"class":1099},[1051,3143,1066],{"class":1065},[1051,3145,1105],{"class":1099},[1051,3147,1108],{"class":1065},[1051,3149,3151,3153,3155,3157,3159,3161,3163,3165,3167,3169],{"class":1053,"line":3150},23,[1051,3152,2014],{"class":1061},[1051,3154,1117],{"class":1065},[1051,3156,1120],{"class":1061},[1051,3158,1066],{"class":1065},[1051,3160,1126],{"class":1125},[1051,3162,1096],{"class":1065},[1051,3164,1132],{"class":1131},[1051,3166,1117],{"class":1065},[1051,3168,1678],{"class":1137},[1051,3170,1141],{"class":1065},[1051,3172,3174,3176,3178,3180,3182,3184,3186,3188,3190,3192,3195,3197],{"class":1053,"line":3173},24,[1051,3175,1148],{"class":1147},[1051,3177,1151],{"class":1065},[1051,3179,1120],{"class":1061},[1051,3181,1066],{"class":1065},[1051,3183,1033],{"class":1125},[1051,3185,1096],{"class":1065},[1051,3187,1162],{"class":1131},[1051,3189,1117],{"class":1065},[1051,3191,1168],{"class":1167},[1051,3193,3194],{"class":1171},"attachments/",[1051,3196,1168],{"class":1167},[1051,3198,1141],{"class":1065},[1051,3200,3202,3204,3206,3208,3210,3212,3214,3216,3218,3220],{"class":1053,"line":3201},25,[1051,3203,1182],{"class":1061},[1051,3205,1117],{"class":1065},[1051,3207,1120],{"class":1061},[1051,3209,1066],{"class":1065},[1051,3211,1191],{"class":1125},[1051,3213,1096],{"class":1065},[1051,3215,1196],{"class":1131},[1051,3217,1117],{"class":1065},[1051,3219,1202],{"class":1201},[1051,3221,1141],{"class":1065},[1030,3223,3225],{"id":3224},"file-field-options","File Field Options",[1246,3227,3229],{"id":3228},"common-options","Common Options",[1042,3231,3233],{"className":1044,"code":3232,"language":1046,"meta":1047,"style":1047},"class MediaFile(models.Model):\n    file = models.FileField(\n        upload_to='media/',\n        max_length=255,           # Max filename length\n        blank=True,               # Allow empty in forms\n        null=True,                # Allow NULL in database\n        default='default.jpg',    # Default file\n        help_text='Upload a file', # Form help text\n        verbose_name='Media File' # Admin display name\n    )\n",[1038,3234,3235,3252,3266,3281,3296,3309,3322,3340,3358,3375],{"__ignoreMap":1047},[1051,3236,3237,3239,3242,3244,3246,3248,3250],{"class":1053,"line":1054},[1051,3238,1089],{"class":1088},[1051,3240,3241],{"class":1092}," MediaFile",[1051,3243,1096],{"class":1065},[1051,3245,1100],{"class":1099},[1051,3247,1066],{"class":1065},[1051,3249,1105],{"class":1099},[1051,3251,1108],{"class":1065},[1051,3253,3254,3256,3258,3260,3262,3264],{"class":1053,"line":1078},[1051,3255,1148],{"class":1147},[1051,3257,1151],{"class":1065},[1051,3259,1120],{"class":1061},[1051,3261,1066],{"class":1065},[1051,3263,1033],{"class":1125},[1051,3265,1379],{"class":1065},[1051,3267,3268,3270,3272,3274,3277,3279],{"class":1053,"line":1085},[1051,3269,1384],{"class":1131},[1051,3271,1117],{"class":1065},[1051,3273,1168],{"class":1167},[1051,3275,3276],{"class":1171},"media/",[1051,3278,1168],{"class":1167},[1051,3280,1396],{"class":1065},[1051,3282,3283,3286,3288,3291,3293],{"class":1053,"line":1111},[1051,3284,3285],{"class":1131},"        max_length",[1051,3287,1117],{"class":1065},[1051,3289,3290],{"class":1137},"255",[1051,3292,1348],{"class":1065},[1051,3294,3295],{"class":2317},"           # Max filename length\n",[1051,3297,3298,3300,3302,3304,3306],{"class":1053,"line":1144},[1051,3299,3001],{"class":1131},[1051,3301,1117],{"class":1065},[1051,3303,1202],{"class":1201},[1051,3305,1348],{"class":1065},[1051,3307,3308],{"class":2317},"               # Allow empty in forms\n",[1051,3310,3311,3313,3315,3317,3319],{"class":1053,"line":1179},[1051,3312,3012],{"class":1131},[1051,3314,1117],{"class":1065},[1051,3316,1202],{"class":1201},[1051,3318,1348],{"class":1065},[1051,3320,3321],{"class":2317},"                # Allow NULL in database\n",[1051,3323,3324,3326,3328,3330,3333,3335,3337],{"class":1053,"line":1207},[1051,3325,1401],{"class":1131},[1051,3327,1117],{"class":1065},[1051,3329,1168],{"class":1167},[1051,3331,3332],{"class":1171},"default.jpg",[1051,3334,1168],{"class":1167},[1051,3336,1348],{"class":1065},[1051,3338,3339],{"class":2317},"    # Default file\n",[1051,3341,3342,3344,3346,3348,3351,3353,3355],{"class":1053,"line":1213},[1051,3343,1417],{"class":1131},[1051,3345,1117],{"class":1065},[1051,3347,1168],{"class":1167},[1051,3349,3350],{"class":1171},"Upload a file",[1051,3352,1168],{"class":1167},[1051,3354,1348],{"class":1065},[1051,3356,3357],{"class":2317}," # Form help text\n",[1051,3359,3360,3363,3365,3367,3370,3372],{"class":1053,"line":1231},[1051,3361,3362],{"class":1131},"        verbose_name",[1051,3364,1117],{"class":1065},[1051,3366,1168],{"class":1167},[1051,3368,3369],{"class":1171},"Media File",[1051,3371,1168],{"class":1167},[1051,3373,3374],{"class":2317}," # Admin display name\n",[1051,3376,3377],{"class":1053,"line":1435},[1051,3378,1432],{"class":1065},[1246,3380,3382],{"id":3381},"storage-backend","Storage Backend",[1042,3384,3386],{"className":1044,"code":3385,"language":1046,"meta":1047,"style":1047},"from django.core.files.storage import default_storage\nfrom myapp.storage import CustomStorage\n\nclass Document(models.Model):\n    # Use default storage\n    file1 = models.FileField(upload_to='docs/')\n    \n    # Use custom storage\n    file2 = models.FileField(\n        upload_to='docs/',\n        storage=CustomStorage()\n    )\n",[1038,3387,3388,3412,3428,3432,3448,3453,3481,3485,3490,3505,3519,3531],{"__ignoreMap":1047},[1051,3389,3390,3392,3394,3396,3398,3400,3402,3404,3407,3409],{"class":1053,"line":1054},[1051,3391,1058],{"class":1057},[1051,3393,1062],{"class":1061},[1051,3395,1066],{"class":1065},[1051,3397,1496],{"class":1061},[1051,3399,1066],{"class":1065},[1051,3401,2685],{"class":1061},[1051,3403,1066],{"class":1065},[1051,3405,3406],{"class":1061},"storage ",[1051,3408,1072],{"class":1057},[1051,3410,3411],{"class":1061}," default_storage\n",[1051,3413,3414,3416,3419,3421,3423,3425],{"class":1053,"line":1078},[1051,3415,1058],{"class":1057},[1051,3417,3418],{"class":1061}," myapp",[1051,3420,1066],{"class":1065},[1051,3422,3406],{"class":1061},[1051,3424,1072],{"class":1057},[1051,3426,3427],{"class":1061}," CustomStorage\n",[1051,3429,3430],{"class":1053,"line":1085},[1051,3431,1082],{"emptyLinePlaceholder":1081},[1051,3433,3434,3436,3438,3440,3442,3444,3446],{"class":1053,"line":1111},[1051,3435,1089],{"class":1088},[1051,3437,1093],{"class":1092},[1051,3439,1096],{"class":1065},[1051,3441,1100],{"class":1099},[1051,3443,1066],{"class":1065},[1051,3445,1105],{"class":1099},[1051,3447,1108],{"class":1065},[1051,3449,3450],{"class":1053,"line":1144},[1051,3451,3452],{"class":2317},"    # Use default storage\n",[1051,3454,3455,3458,3460,3462,3464,3466,3468,3470,3472,3474,3477,3479],{"class":1053,"line":1179},[1051,3456,3457],{"class":1061},"    file1 ",[1051,3459,1117],{"class":1065},[1051,3461,1120],{"class":1061},[1051,3463,1066],{"class":1065},[1051,3465,1033],{"class":1125},[1051,3467,1096],{"class":1065},[1051,3469,1162],{"class":1131},[1051,3471,1117],{"class":1065},[1051,3473,1168],{"class":1167},[1051,3475,3476],{"class":1171},"docs/",[1051,3478,1168],{"class":1167},[1051,3480,1141],{"class":1065},[1051,3482,3483],{"class":1053,"line":1207},[1051,3484,1210],{"class":1061},[1051,3486,3487],{"class":1053,"line":1213},[1051,3488,3489],{"class":2317},"    # Use custom storage\n",[1051,3491,3492,3495,3497,3499,3501,3503],{"class":1053,"line":1231},[1051,3493,3494],{"class":1061},"    file2 ",[1051,3496,1117],{"class":1065},[1051,3498,1120],{"class":1061},[1051,3500,1066],{"class":1065},[1051,3502,1033],{"class":1125},[1051,3504,1379],{"class":1065},[1051,3506,3507,3509,3511,3513,3515,3517],{"class":1053,"line":1435},[1051,3508,1384],{"class":1131},[1051,3510,1117],{"class":1065},[1051,3512,1168],{"class":1167},[1051,3514,3476],{"class":1171},[1051,3516,1168],{"class":1167},[1051,3518,1396],{"class":1065},[1051,3520,3521,3524,3526,3529],{"class":1053,"line":1641},[1051,3522,3523],{"class":1131},"        storage",[1051,3525,1117],{"class":1065},[1051,3527,3528],{"class":1125},"CustomStorage",[1051,3530,2750],{"class":1065},[1051,3532,3533],{"class":1053,"line":1659},[1051,3534,1432],{"class":1065},[1030,3536,921],{"id":3537},"best-practices",[1246,3539,541],{"id":3540},"security",[1251,3542,3543,3546,3552,3555],{},[1254,3544,3545],{},"Always validate file types and sizes",[1254,3547,3548,3549,3551],{},"Use ",[1038,3550,1162],{}," to organize files",[1254,3553,3554],{},"Implement virus scanning for production",[1254,3556,3557],{},"Serve files through Django views for access control",[1246,3559,3561],{"id":3560},"performance","Performance",[1251,3563,3564,3567,3570,3573],{},[1254,3565,3566],{},"Use appropriate image formats (WebP, AVIF)",[1254,3568,3569],{},"Implement image resizing and thumbnails",[1254,3571,3572],{},"Consider CDN for file serving",[1254,3574,3575],{},"Use cloud storage for scalability",[1246,3577,3579],{"id":3578},"organization","Organization",[1251,3581,3582,3585,3588,3591],{},[1254,3583,3584],{},"Create logical directory structures",[1254,3586,3587],{},"Use meaningful file names",[1254,3589,3590],{},"Implement file cleanup for deleted records",[1254,3592,3593],{},"Consider file versioning for important documents",[1030,3595,3597],{"id":3596},"next-steps","Next Steps",[1026,3599,3600],{},"Now that you understand file fields in models, let's explore the File object and how Django handles uploaded files internally.",[3602,3603,3604],"style",{},"html pre.shiki code .siDh9, html code.shiki .siDh9{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#1E754F;--shiki-default-font-style:inherit;--shiki-dark:#4D9375;--shiki-dark-font-style:inherit}html pre.shiki code .sftqT, html code.shiki .sftqT{--shiki-light:#90A4AE;--shiki-default:#393A34;--shiki-dark:#DBD7CAEE}html pre.shiki code .soVBu, html code.shiki .soVBu{--shiki-light:#39ADB5;--shiki-default:#999999;--shiki-dark:#666666}html pre.shiki code .s5Kfy, html code.shiki .s5Kfy{--shiki-light:#9C3EDA;--shiki-default:#AB5959;--shiki-dark:#CB7676}html pre.shiki code .sD-vU, html code.shiki .sD-vU{--shiki-light:#E2931D;--shiki-default:#2E8F82;--shiki-dark:#5DA994}html pre.shiki code .sYn-s, html code.shiki .sYn-s{--shiki-light:#E2931D;--shiki-default:#59873A;--shiki-dark:#80A665}html pre.shiki code .siWMO, html code.shiki .siWMO{--shiki-light:#6182B8;--shiki-default:#393A34;--shiki-dark:#DBD7CAEE}html pre.shiki code .sqOPj, html code.shiki .sqOPj{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#B07D48;--shiki-default-font-style:inherit;--shiki-dark:#BD976A;--shiki-dark-font-style:inherit}html pre.shiki code .s7CZa, html code.shiki .s7CZa{--shiki-light:#F76D47;--shiki-default:#2F798A;--shiki-dark:#4C9A91}html pre.shiki code .sSC40, html code.shiki .sSC40{--shiki-light:#90A4AE;--shiki-default:#B07D48;--shiki-dark:#BD976A}html pre.shiki code .sbYkP, html code.shiki .sbYkP{--shiki-light:#39ADB5;--shiki-default:#B5695977;--shiki-dark:#C98A7D77}html pre.shiki code .sTbE_, html code.shiki .sTbE_{--shiki-light:#91B859;--shiki-default:#B56959;--shiki-dark:#C98A7D}html pre.shiki code .s8XtY, html code.shiki .s8XtY{--shiki-light:#39ADB5;--shiki-default:#1E754F;--shiki-dark:#4D9375}html pre.shiki code .sJdAF, html code.shiki .sJdAF{--shiki-light:#6182B8;--shiki-default:#998418;--shiki-dark:#B8A965}html pre.shiki code .sRjD_, html code.shiki .sRjD_{--shiki-light:#E53935;--shiki-light-font-style:italic;--shiki-default:#393A34;--shiki-default-font-style:inherit;--shiki-dark:#DBD7CAEE;--shiki-dark-font-style:inherit}html pre.shiki code .se3Ec, html code.shiki .se3Ec{--shiki-light:#90A4AE;--shiki-default:#A65E2B;--shiki-dark:#C99076}html pre.shiki code .sBPpx, html code.shiki .sBPpx{--shiki-light:#E53935;--shiki-default:#393A34;--shiki-dark:#DBD7CAEE}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sFGJz, html code.shiki .sFGJz{--shiki-light:#E53935;--shiki-default:#A65E2B;--shiki-dark:#C99076}html pre.shiki code .sljsM, html code.shiki .sljsM{--shiki-light:#6182B8;--shiki-default:#59873A;--shiki-dark:#80A665}html pre.shiki code .sCyAa, html code.shiki .sCyAa{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#393A34;--shiki-default-font-style:inherit;--shiki-dark:#DBD7CAEE;--shiki-dark-font-style:inherit}html pre.shiki code .sm7ve, html code.shiki .sm7ve{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#B5695977;--shiki-default-font-style:inherit;--shiki-dark:#C98A7D77;--shiki-dark-font-style:inherit}html pre.shiki code .sVyVU, html code.shiki .sVyVU{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#B56959;--shiki-default-font-style:inherit;--shiki-dark:#C98A7D;--shiki-dark-font-style:inherit}html pre.shiki code .sVsLi, html code.shiki .sVsLi{--shiki-light:#39ADB5;--shiki-default:#AB5959;--shiki-dark:#CB7676}html pre.shiki code .s3h35, html code.shiki .s3h35{--shiki-light:#F76D47;--shiki-default:#A65E2B;--shiki-dark:#C99076}html pre.shiki code .s9Tkl, html code.shiki .s9Tkl{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#A0ADA0;--shiki-default-font-style:inherit;--shiki-dark:#758575DD;--shiki-dark-font-style:inherit}",{"title":1047,"searchDepth":1054,"depth":1078,"links":3606},[3607,3610,3613,3614,3615,3619,3620,3624,3629],{"id":1032,"depth":1078,"text":1033,"children":3608},[3609],{"id":1248,"depth":1085,"text":1249},{"id":1273,"depth":1078,"text":1274,"children":3611},[3612],{"id":1461,"depth":1085,"text":1462},{"id":1735,"depth":1078,"text":1736},{"id":2058,"depth":1078,"text":2059},{"id":2433,"depth":1078,"text":2434,"children":3616},[3617,3618],{"id":2437,"depth":1085,"text":2438},{"id":2644,"depth":1085,"text":2645},{"id":2894,"depth":1078,"text":2895},{"id":3224,"depth":1078,"text":3225,"children":3621},[3622,3623],{"id":3228,"depth":1085,"text":3229},{"id":3381,"depth":1085,"text":3382},{"id":3537,"depth":1078,"text":921,"children":3625},[3626,3627,3628],{"id":3540,"depth":1085,"text":541},{"id":3560,"depth":1085,"text":3561},{"id":3578,"depth":1085,"text":3579},{"id":3596,"depth":1078,"text":3597},"md",null,{},{"title":469,"description":1028},"CjMWqeUCnZF6xpeZq7CqUmceOm3qMOMmENZd-17V9Ks",[3636,3638],{"title":463,"path":464,"stem":465,"description":3637,"children":-1},"Django provides powerful tools for handling file uploads, storage, and management. Whether you're dealing with user-uploaded images, documents, or any other file type, Django's file handling system offers flexibility, security, and scalability.",{"title":473,"path":474,"stem":475,"description":3639,"children":-1},"Django's file handling system centers around the File object, which provides a consistent interface for working with files regardless of their storage backend. Understanding the File object is crucial for advanced file manipulation and custom storage implementations.",1772474933158]