# django_session

session_key: s7py7znezl1ylufx254c96c73qrp6ylz
expire_date: 2025-10-11 03:07:21.873061
session_data:
  .eJxVjEEOwiAQRe_C2pCBUkCX7j0DmRlAqgaS0q6Md7dNutDtf-_9twi4LiWsPc1hiuIilDj9boT8THUH8YH13iS3uswTyV2RB-3y1mJ6XQ_376BgL1tNqC140IgGz4jjqBmcMYw-2UzsBkUuR1Ds3WDJ8maq5NkAGcgWQHy-6Sk30w:1v2LHN:tTM1tdyR0jdf5qmgXwEgVM9I1gqeWqW2gJw1_5Ovi20


session_key: osyvygm9pd4fgke1dx68bddwt6mz3lvx
expire_date: 2025-10-11 14:55:04.799316
session_data:
  .eJxVjEEOwiAQRe_C2pCBUkCX7j0DmRlAqgaS0q6Md7dNutDtf-_9twi4LiWsPc1hiuIilDj9boT8THUH8YH13iS3uswTyV2RB-3y1mJ6XQ_376BgL1tNqC140IgGz4jjqBmcMYw-2UzsBkUuR1Ds3WDJ8maq5NkAGcgWQHy-6Sk30w:1v2WKG:Uumnqj4WM-wo3XYFUuvPp2tUOgiku8oAfT6BPMdCzg8


session_key: brxgterdih0st6jvdt1obsbc8oq6dgld
expire_date: 2025-10-11 18:47:56.672196
session_data:
  .eJxVjEEOwiAQRe_C2pCBUkCX7j0DmRlAqgaS0q6Md7dNutDtf-_9twi4LiWsPc1hiuIilDj9boT8THUH8YH13iS3uswTyV2RB-3y1mJ6XQ_376BgL1tNqC140IgGz4jjqBmcMYw-2UzsBkUuR1Ds3WDJ8maq5NkAGcgWQHy-6Sk30w:1v2Zxc:DDoP-wQIsGSTIgJTIinkb9fr3egpybP5WvIcAdluYY0


session_key: ru8kcbcvnpzq7j4tbvjh53h1n7equpzk
expire_date: 2025-10-12 05:08:55.060083
session_data:
  .eJxVjEEOwiAQRe_C2pCBUkCX7j0DmRlAqgaS0q6Md7dNutDtf-_9twi4LiWsPc1hiuIilDj9boT8THUH8YH13iS3uswTyV2RB-3y1mJ6XQ_376BgL1tNqC140IgGz4jjqBmcMYw-2UzsBkUuR1Ds3WDJ8maq5NkAGcgWQHy-6Sk30w:1v2jeZ:567LoZ1XxcKV95ky01hPVd8pHJWNOpY-CyIktOKdjpo


session_key: 9s4q1dw5hhwfdibbb4bm2zdu0difg2e7
expire_date: 2025-12-09 16:33:56.111561
session_data:
  .eJxVjEEOwiAQRe_C2pCBUkCX7j0DmRlAqgaS0q6Md7dNutDtf-_9twi4LiWsPc1hiuIilDj9boT8THUH8YH13iS3uswTyV2RB-3y1mJ6XQ_376BgL1tNqC140IgGz4jjqBmcMYw-2UzsBkUuR1Ds3WDJ8maq5NkAGcgWQHy-6Sk30w:1vNvzI:dOYvchAiKqgKfhImpmbETZZc7UF-ed4uKU9x3jMofTQ


session_key: 3yi6onohdpbnwcyyigsioewujq7hxlly
expire_date: 2025-12-20 08:19:12.857953
session_data:
  .eJxVjEEOwiAQRe_C2pCBUkCX7j0DmRlAqgaS0q6Md7dNutDtf-_9twi4LiWsPc1hiuIilDj9boT8THUH8YH13iS3uswTyV2RB-3y1mJ6XQ_376BgL1tNqC140IgGz4jjqBmcMYw-2UzsBkUuR1Ds3WDJ8maq5NkAGcgWQHy-6Sk30w:1vRnVY:w1sURFeBpzWgFSUlY7cb68KDb_M43xNdgI3ozCL3uks


# blog_blog

title: I phone 16-pro max
slug: i-phone-16-pro-max
author: Admin
created_at: 2025-09-26 17:49:40.112666
updated_at: 2025-09-26 21:10:36.292557
image: blog_image/i-phone-16-pro-max/attachments/i-phone-16-pro-max_attachments.webp
meta_title: I phone 16-pro max
meta_description: I phone 16-pro max
meta_keywords: I phone 16-pro max, iphone , apple
meta_image: blog_image/i-phone-16-pro-max/meta/i-phone-16-pro-max_meta.webp
content:
  <p><strong>iPhone 16 Pro Max The Apple iPhone 1</strong>6 Pro Max continues to surprise Apple fans with its array of upgraded features. Available in multiple colors, it offers an exceptional camera for stunning photography and high-quality video recording. Its impressive performance makes it stand out among other devices, delivering speed and power beyond expectations. With an excellent battery life, even heavy users can easily last a full day. The iPhone 16 Pro Max is sure to captivate Apple enthusiasts. iPhone 16 Pro Max Features Comes with a larger screen with a more accurate visual display under sunlight A sturdy build with more colors and shades makes it more attractive than ever Upgraded and mighty latest version of Bionic pro chipset for extraordinary performance Triple camera system with versatile camera features to keep your memory colorful every time Multiple video action modes can be helpful for creators to upgrade the quality of content Large battery life with remarkable optimization allows to use the phone for more than a day Store everything you want like photos, videos and other large files without any hassle A new button added several functionalities to control the camera and capture effortlessly Emergency SOS via satellite has the ability to call or sending sms in a crucial situation More functions in Dynamic Island and Apple intelligence integrated Siri for more convenience Why Choose Apple Gadgets? Introducing Apple Gadgets, the unrivaled leader for gadgets in Bangladesh. Experience the convenience of two-way shopping with Apple Gadgets. Whether you prefer the seamless online experience of Apple Gadgets website or the personal touch of our physical outlets, we&#39;ve got you covered. Effortlessly find and purchase your dream products including iPhone 16 Pro Max with the assurance of always getting the best deal.</p>


title: QA interview qsn set 1
slug: qa-interview-qsn-set-1-1759039475
author: Admin
created_at: 2025-09-28 06:04:35.905441
updated_at: 2025-10-01 11:36:13.825690
image: blog_image/qa-interview-qsn-set-1/attachments/qa-interview-qsn-set-1_attachments.jpeg
meta_title: QA interview QSN
meta_description: Interview qsn qa
meta_keywords: Interview
meta_image: blog_image/qa-interview-qsn-set-1/meta/qa-interview-qsn-set-1_meta.jpeg
content:
  <p>Basic QA Questions What is QA?<br />
  QA ensures that the product meets requirements and is free of defects through testing and process improvement.<br />
  What is the difference between QA, QC, and Testing? QA &rarr; Process-oriented (preventing defects). QC &rarr; Product-oriented (finding defects). Testing &rarr; Execution of test cases to find bugs. What is the Software Development Life Cycle (SDLC)?<br />
  Stages: Requirement &rarr; Design &rarr; Development &rarr; Testing &rarr; Deployment &rarr; Maintenance. What is the Software Testing Life Cycle (STLC)?<br />
  Stages: Requirement Analysis &rarr; Test Planning &rarr; Test Case Design &rarr; Test Environment Setup &rarr; Test Execution &rarr; Test Closure. 🔹 Testing Concepts Difference between functional and non-functional testing? Functional &rarr; Validates what the system does (login, signup, etc.). Non-functional &rarr; Validates how well the system works (performance, security, usability). What is regression testing? Retesting after changes to ensure old features still work. What is smoke testing? Quick test to check if the main functionality is working before deeper testing. What is sanity testing? Focused test to check if a specific bug fix or feature works. What is difference between severity and priority? Severity &rarr; Impact of bug (Critical/High/Low). Priority &rarr; Urgency to fix (Immediate/Normal/Low). 🔹 Test Artifacts What is a test case? A document that describes input, execution steps, and expected output. What is a bug/defect life cycle? New &rarr; Assigned &rarr; Open &rarr; Fixed &rarr; Retest &rarr; Verified &rarr; Closed (or Reopen). What is a test plan? A document describing scope, objectives, approach, resources, schedule, and deliverables of testing. 🔹 Automation &amp; Tools Have you worked with automation tools? Example: Selenium for UI automation, JMeter for performance testing, Postman for API testing. What&rsquo;s the difference between manual and automation testing? Manual &rarr; Done by human testers. Automation &rarr; Scripts/tools perform tests, faster for repetitive tasks. 🔹 API Testing (Hot Topic in QA Interviews) Difference between GET, POST, PUT, PATCH, DELETE? GET &rarr; Retrieve data. POST &rarr; Create new data. PUT &rarr; Update/replace existing data. PATCH &rarr; Update part of the data. DELETE &rarr; Remove data. What status codes do you know? 200 &rarr; OK 201 &rarr; Created 400 &rarr; Bad Request 401 &rarr; Unauthorized 403 &rarr; Forbidden 404 &rarr; Not Found 500 &rarr; Internal Server Error 🔹 Behavioral QA Questions What do you do if you find a critical bug just before release? Report immediately &rarr; Explain risk &rarr; Work with dev team &rarr; Escalate if needed. How do you ensure quality in your testing? Follow requirements, prepare detailed test cases, peer reviews, maintain test coverage. Tell me about a bug you found that was difficult to reproduce. (Be ready with a story: intermittent issue, steps to reproduce, logs/screenshots).</p>


title: a
slug: a-1760422105
author: Admin
created_at: 2025-10-14 06:08:25.507528
updated_at: 2025-10-14 06:08:25.507578
content:
  <p>bottle==0.13.2</p>

  <p>bottle-websocket==0.2.9</p>

  <p>certifi==2024.8.30</p>

  <p>cffi==1.17.1</p>

  <p>charset-normalizer==3.4.0</p>

  <p>Eel==0.17.0</p>

  <p>future==1.0.0</p>

  <p>gdcm==1.1</p>

  <p>gevent==24.10.3</p>

  <p>gevent-websocket==0.10.1</p>

  <p>greenlet==3.1.1</p>

  <p>idna==3.10</p>

  <p>itk==5.4.0</p>

  <p>itk-core==5.4.0</p>

  <p>itk-filtering==5.4.0</p>

  <p>itk-io==5.4.0</p>

  <p>itk-numerics==5.4.0</p>

  <p>itk-registration==5.4.0</p>

  <p>itk-segmentation==5.4.0</p>

  <p>numpy==2.1.2</p>

  <p>ordered-set==4.1.0</p>

  <p>packaging==24.1</p>

  <p>pefile==2023.2.7</p>

  <p>pillow==11.0.0</p>

  <p>pycparser==2.22</p>

  <p>pydicom==3.0.1</p>

  <p>pyinstaller==6.11.0</p>

  <p>pyinstaller-hooks-contrib==2024.9</p>

  <p>pylibjpeg==2.0.1</p>

  <p>pylibjpeg-libjpeg==2.3.0</p>

  <p>pyparsing==3.2.0</p>

  <p>requests==2.32.3</p>

  <p>requests-toolbelt==1.0.0</p>

  <p>setuptools==75.2.0</p>

  <p>urllib3==2.2.3</p>

  <p>watchdog==5.0.3</p>

  <p>whichcraft==0.6.1</p>

  <p>zope.event==5.0</p>

  <p>zope.interface==7.1.1</p>

  <p>zstandard==0.23.0</p>

  <p>&nbsp;</p>


title: sql
slug: sql-1760526777
author: Admin
created_at: 2025-10-15 11:12:57.835642
updated_at: 2025-10-15 11:12:57.835721
content:
  <p>1. Data Definition Language (DDL) ■ What is DDL in SQL? ■ DDL stands for Data Definition Language. It defines and modifies the structure of database objects. ■ Write a query to create a table named employees. CREATE TABLE employees (id INT PRIMARY KEY, name VARCHAR(50), salary DECIMAL(10,2)); ■ How to add a new column in an existing table? ALTER TABLE employees ADD COLUMN department VARCHAR(30); ■ How to remove a table permanently? DROP TABLE employees; ■ How to delete all data but keep the structure? TRUNCATE TABLE employees; 2. Data Manipulation Language (DML) ■ What is DML? ■ DML (Data Manipulation Language) is used to manipulate data stored in database tables. ■ Write a query to insert data into a table. INSERT INTO employees (id, name, salary) VALUES (1, &#39;Rahim&#39;, 45000.00); ■ Write a query to update salary of an employee. UPDATE employees SET salary = 50000 WHERE id = 1; ■ How to delete a record from a table? DELETE FROM employees WHERE id = 1; ■ Display all employees. SELECT * FROM employees; 3. Data Control Language (DCL) &amp; Transaction Control Language (TCL) ■ What is the use of GRANT and REVOKE? ■ GRANT gives privileges to users, while REVOKE removes them. ■ Write an example of GRANT. GRANT SELECT, UPDATE ON employees TO user1; ■ What is COMMIT in SQL? ■ COMMIT saves all transactions permanently to the database. ■ Write a query to rollback changes. ROLLBACK; 4. Joins ■ What are different types of joins? ■ INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN. ■ Show query for INNER JOIN. SELECT e.name, d.department FROM employees e INNER JOIN departments d ON e.dept_id = d.id; ■ Write query for LEFT JOIN. SELECT e.name, d.department FROM employees e LEFT JOIN departments d ON e.dept_id = d.id; 5. Subqueries ■ What is a subquery? ■ A subquery is a query inside another SQL query. ■ Example: Find employees earning more than average salary. SELECT name FROM employees WHERE salary &gt; (SELECT AVG(salary) FROM employees); 6. Views and Indexes ■ What is a view? ■ A view is a virtual table based on the result of an SQL query. ■ Write a query to create a view. CREATE VIEW high_salary AS SELECT name, salary FROM employees WHERE salary &gt; 60000; ■ How to create an index? CREATE INDEX idx_name ON employees(name); 7. Functions and Grouping ■ List some aggregate functions. ■ COUNT(), SUM(), AVG(), MIN(), MAX() ■ Find average salary. SELECT AVG(salary) FROM employees; ■ Group employees by department and count them. SELECT department, COUNT(*) FROM employees GROUP BY department; ■ Filter grouped results using HAVING. SELECT department, COUNT(*) FROM employees GROUP BY department HAVING COUNT(*) &gt; 5; 8. Clauses and Conditions ■ What is WHERE used for? ■ To filter rows based on a condition. ■ Display all employees older than 30. SELECT * FROM employees WHERE age &gt; 30; ■ Order employees by name ascending. SELECT * FROM employees ORDER BY name ASC; ■ Limit result to top 5 employees. SELECT * FROM employees LIMIT 5; 9. Theory &amp; Concepts ■ What is a primary key? ■ A column that uniquely identifies each row in a table. ■ What is a foreign key? ■ A key used to link two tables together. ■ Define normalization. ■ Normalization is the process of organizing data to reduce redundancy. ■ What are constraints? ■ Rules applied to columns such as NOT NULL, UNIQUE, CHECK, DEFAULT, PRIMARY KEY, FOREIGN KEY.</p>


title: On_Delete Cascade
slug: on_delete-cascade-1765009486
author: Admin
created_at: 2025-12-06 08:24:46.704759
updated_at: 2025-12-06 08:29:39.513349
image: blog_image/on_delete-cascade/attachments/on_delete-cascade_attachments.png
meta_title: On_Delete Cascade
meta_keywords: DRF,Django, On_delete
meta_image: blog_image/on_delete-cascade/meta/on_delete-cascade_meta.png
content:
  <h1>What is <code>on_delete</code> in Django?</h1>

  <p>When you create a <strong>ForeignKey</strong>, you must tell Django:</p>

  <p>➡️ <strong>What should happen to the child object if the parent object is deleted?</strong></p>

  <p>Example:</p>

  <pre>
  <code>student = models.ForeignKey(Student, on_delete=WHAT_HAPPENS_HERE) 
  </code></pre>

  <hr />
  <h1>✅ 1. <code>models.CASCADE</code></h1>

  <h3><strong>Meaning:</strong></h3>

  <p>If the parent is deleted &rarr; delete the child too.</p>

  <h3>Example:</h3>

  <div class="bg-token-sidebar-surface-primary contain-inline-size corner-superellipse/1.1 relative rounded-2xl">
  <div class="overflow-y-auto p-4" dir="ltr"><code>class Student(models.Model):<br />
  &nbsp; name = models.CharField(max_length=100)<br />
  class Result(models.Model):<br />
  &nbsp;&nbsp;student = models.ForeignKey(Student, on_delete=models.CASCADE) </code></div>
  </div>

  <p>If Student <strong>Rafi</strong> is deleted &rarr; all of Rafi&#39;s Results are also deleted.</p>

  <h3>When to use?</h3>

  <p>✔ When child data makes no sense without parent<br />
  ✔ Example: Results cannot exist without a student</p>

  <hr />
  <h1>✅ 2. <code>models.SET_NULL</code></h1>

  <h3><strong>Meaning:</strong></h3>

  <p>If parent is deleted &rarr; set the FK to <code>NULL</code>.</p>

  <h3>Example</h3>

  <p>class Student(models.Model):<br />
  &nbsp; &nbsp; name = models.CharField(max_length=100)</p>

  <p>class Result(models.Model):<br />
  &nbsp; &nbsp; student = models.ForeignKey(Student, on_delete=<code>models.SET_NULL)</code></p>

  <p>If Student <strong>Rafi</strong> is deleted &rarr; Result records will stay, but:</p>

  <pre>
  <code>student = NULL 
  </code></pre>

  <h3>When to use?</h3>

  <p>✔ When child can exist without parent<br />
  ✔ Example: Blog post author deleted &rarr; post remains</p>

  <hr />
  <h1>✅ 3. <code>models.PROTECT</code></h1>

  <h3><strong>Meaning:</strong></h3>

  <p><strong>Prevent deletion</strong> of parent if child exists.</p>

  <h3>Example:</h3>

  <div class="bg-token-sidebar-surface-primary contain-inline-size corner-superellipse/1.1 relative rounded-2xl">
  <div class="overflow-y-auto p-4" dir="ltr"><code>student = models.ForeignKey(Student, on_delete=models.PROTECT) </code></div>
  </div>

  <p>If you try to delete a Student who has results:</p>

  <p>❌ Django throws an error: <em>ProtectedError</em><br />
  ✔ This stops accidental data loss</p>

  <h3>When to use?</h3>

  <p>✔ Very important data<br />
  ✔ Example: Cannot delete Category that still has products</p>

  <hr />
  <h1>✅ 4. <code>models.SET_DEFAULT</code></h1>

  <h3><strong>Meaning:</strong></h3>

  <p>If parent is deleted &rarr; set FK to a default value.</p>

  <h3>Example:</h3>

  <div class="bg-token-sidebar-surface-primary contain-inline-size corner-superellipse/1.1 relative rounded-2xl">
  <div class="overflow-y-auto p-4" dir="ltr"><code>class Result(models.Model):<br />
  student = models.ForeignKey( Student, on_delete=models.SET_DEFAULT, default=1 ) </code></div>
  </div>

  <p>If the linked student is deleted &rarr; student will become <strong>ID = 1</strong>.</p>

  <h3>When to use?</h3>

  <p>✔ Use when you want a fallback<br />
  ✔ Example: Deleted author &rarr; assign to &quot;Unknown Author&quot;</p>

  <hr />
  <h1>✅ 5. <code>models.DO_NOTHING</code></h1>

  <h3><strong>Meaning:</strong></h3>

  <p>Do nothing.<br />
  Django won&#39;t touch child objects.</p>

  <p>BUT ⚠️<br />
  If DB has restrictions, you get errors.</p>

  <h3>Example:</h3>

  <pre>
  <code>on_delete=models.DO_NOTHING 
  </code></pre>

  <h3>When to use?</h3>

  <p>❌ Almost never recommended<br />
  ✔ Only when you handle deletion manually</p>

  <hr />
  <h1>✅ 6. <code>models.RESTRICT</code> (Django 3.1+)</h1>

  <h3><strong>Meaning:</strong></h3>

  <p>Like PROTECT, but safer and more predictable.</p>

  <p>If child exists &rarr; prevent parent deletion.</p>

  <h3>Example:</h3>

  <pre>
  <code>student = models.ForeignKey(Student, on_delete=models.RESTRICT) 
  </code></pre>

  <h3>When to use?</h3>

  <p>✔ Use instead of PROTECT<br />
  ✔ Prevents accidental deletion cleanly</p>

  <hr />
  <h1>🎯 Summary (Easy to Remember)</h1>

  <div class="TyagGW_tableContainer">
  <div class="TyagGW_tableWrapper flex flex-col-reverse group w-fit">
  <table class="min-w-(--thread-content-width) w-fit">
  	<thead>
  		<tr>
  			<th>Option</th>
  			<th>What Happens</th>
  		</tr>
  	</thead>
  	<tbody>
  		<tr>
  			<td><strong>CASCADE</strong></td>
  			<td>Delete children</td>
  		</tr>
  		<tr>
  			<td><strong>SET_NULL</strong></td>
  			<td>Make FK = NULL</td>
  		</tr>
  		<tr>
  			<td><strong>SET_DEFAULT</strong></td>
  			<td>Set default value</td>
  		</tr>
  		<tr>
  			<td><strong>PROTECT</strong></td>
  			<td>Block delete (throws error)</td>
  		</tr>
  		<tr>
  			<td><strong>RESTRICT</strong></td>
  			<td>Block delete (better than PROTECT)</td>
  		</tr>
  		<tr>
  			<td><strong>DO_NOTHING</strong></td>
  			<td>Do nothing (dangerous)</td>
  		</tr>
  	</tbody>
  </table>
  </div>
  </div>


title: DRF Authentication
slug: drf-authentication-1765010393
author: Admin
created_at: 2025-12-06 08:39:53.606307
updated_at: 2025-12-06 08:41:46.779846
image: blog_image/drf-authentication/attachments/drf-authentication_attachments.png
meta_title: DRF Authentication
meta_keywords: DRF,Django,jwt,Authtications
meta_image: blog_image/drf-authentication/meta/drf-authentication_meta.png
content:
  <h2><span style="font-size:17pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000"><strong>DRF Authentication</strong></span></span></span></h2>

  <h3><span style="font-size:13pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000"><strong>Signup (API)</strong></span></span></span></h3>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">from django.contrib.auth.models import User</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">from rest_framework import serializers, viewsets, status</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">from rest_framework.response import Response</span></span></span></p>

  <p>&nbsp;</p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">class UserSerializer(serializers.ModelSerializer):</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">&nbsp;&nbsp;&nbsp;&nbsp;class Meta:</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;model = User</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fields = [&#39;id&#39;, &#39;username&#39;, &#39;email&#39;, &#39;password&#39;]</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;extra_kwargs = {&#39;password&#39;: {&#39;write_only&#39;: True}}</span></span></span></p>

  <p>&nbsp;</p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">&nbsp;&nbsp;&nbsp;&nbsp;def create(self, validated_data):</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;user = User.objects.create(</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;username=validated_data[&#39;username&#39;],</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;email=validated_data[&#39;email&#39;],</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;password=make_password(validated_data[&#39;password&#39;])</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return user</span></span></span></p>

  <p>&nbsp;</p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">class UserViewSet(viewsets.ModelViewSet):</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">&nbsp;&nbsp;&nbsp;&nbsp;queryset = User.objects.all()</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">&nbsp;&nbsp;&nbsp;&nbsp;serializer_class = UserSerializer</span></span></span></p>

  <p>&nbsp;</p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">&nbsp;&nbsp;&nbsp;&nbsp;def create(self, request, *args, **kwargs):</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;serializer = self.get_serializer(data=request.data)</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;serializer.is_valid(raise_exception=True)</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.perform_create(serializer)</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return Response(serializer.data, status=status.HTTP_201_CREATED)</span></span></span></p>

  <p>&nbsp;</p>

  <h3><span style="font-size:13pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000"><strong>Token Authentication</strong></span></span></span></h3>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000"># settings.py</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">REST_FRAMEWORK = {</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">&nbsp;&nbsp;&nbsp;&nbsp;&#39;DEFAULT_AUTHENTICATION_CLASSES&#39;: [</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#39;rest_framework.authentication.TokenAuthentication&#39;,</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">&nbsp;&nbsp;&nbsp;&nbsp;],</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">}</span></span></span></p>

  <p>&nbsp;</p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000"># create token</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">from rest_framework.authtoken.models import Token</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">from django.contrib.auth.models import User</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">user = User.objects.get(username=&#39;john&#39;)</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">token = Token.objects.create(user=user)</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">print(token.key)</span></span></span></p>

  <p>&nbsp;</p>

  <h3><span style="font-size:13pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000"><strong>Protect API Endpoints</strong></span></span></span></h3>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">from rest_framework.permissions import IsAuthenticated</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">from rest_framework.views import APIView</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">from rest_framework.response import Response</span></span></span></p>

  <p>&nbsp;</p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">class HelloView(APIView):</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">&nbsp;&nbsp;&nbsp;&nbsp;permission_classes = [IsAuthenticated]</span></span></span></p>

  <p>&nbsp;</p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">&nbsp;&nbsp;&nbsp;&nbsp;def get(self, request):</span></span></span></p>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return Response({&quot;message&quot;: f&quot;Hello, {request.user.username}&quot;})</span></span></span></p>

  <p>&nbsp;</p>

  <ul>
  	<li style="list-style-type:disc"><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">Client sends token in header:</span></span></span><br />
  	&nbsp;</li>
  </ul>

  <p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">Authorization: Token &lt;your_token&gt;</span></span></span></p>

  <p><br />
  <br />
  <span style="font-size:18px"><strong>Serialiers.py</strong></span></p>

  <p>from rest_framework import serializers<br />
  from django.contrib.auth.models import User<br />
  from django.contrib.auth import authenticate</p>

  <p>class UserSerializer(serializers.ModelSerializer):<br />
  &nbsp; &nbsp; class Meta:<br />
  &nbsp; &nbsp; &nbsp; &nbsp; model = User<br />
  &nbsp; &nbsp; &nbsp; &nbsp; fields = [&#39;id&#39;, &#39;username&#39;, &#39;email&#39;]<br />
  class UserRegistrationSerializer(serializers.ModelSerializer):<br />
  &nbsp; &nbsp; password = serializers.CharField(write_only=True)</p>

  <p>&nbsp; &nbsp; class Meta:<br />
  &nbsp; &nbsp; &nbsp; &nbsp; model = User<br />
  &nbsp; &nbsp; &nbsp; &nbsp; fields = [&#39;id&#39;, &#39;username&#39;, &#39;email&#39;, &#39;password&#39; ]</p>

  <p>&nbsp; &nbsp; def create(self, validated_data):<br />
  &nbsp; &nbsp; &nbsp; &nbsp; user = User(<br />
  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; username=validated_data[&#39;username&#39;],<br />
  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; email=validated_data[&#39;email&#39;]<br />
  &nbsp; &nbsp; &nbsp; &nbsp; )<br />
  &nbsp; &nbsp; &nbsp; &nbsp; user.set_password(validated_data[&#39;password&#39;])<br />
  &nbsp; &nbsp; &nbsp; &nbsp; user.save()<br />
  &nbsp; &nbsp; &nbsp; &nbsp; return user<br />
  class UserLoginSerializer(serializers.Serializer):<br />
  &nbsp; &nbsp; username = serializers.CharField(required=True)<br />
  &nbsp; &nbsp; password = serializers.CharField(required=True ,write_only=True)</p>

  <p>&nbsp;</p>

  <p><strong><span style="font-size:16px">views.py</span></strong></p>

  <p>from django.shortcuts import render<br />
  from django.contrib.auth.models import User<br />
  from rest_framework import viewsets , generics<br />
  from rest_framework.response import Response<br />
  from rest_framework import status<br />
  from .serializers import UserSerializer , UserRegistrationSerializer , UserLoginSerializer<br />
  from rest_framework.permissions import AllowAny<br />
  from django.contrib.auth import authenticate<br />
  from rest_framework_simplejwt.tokens import RefreshToken</p>

  <p>class UserRegistrationViewset(generics.CreateAPIView):<br />
  &nbsp; &nbsp; queryset = User.objects.all()<br />
  &nbsp; &nbsp; serializer_class = UserRegistrationSerializer<br />
  &nbsp; &nbsp; permission_classes = [AllowAny]<br />
  class LoginViewset(generics.GenericAPIView):<br />
  &nbsp; &nbsp; serializer_class = UserLoginSerializer<br />
  &nbsp; &nbsp; def post(self, request, *args, **kwargs):<br />
  &nbsp; &nbsp; &nbsp; &nbsp; username = request.data.get(&#39;username&#39;)<br />
  &nbsp; &nbsp; &nbsp; &nbsp; password = request.data.get(&#39;password&#39;)<br />
  &nbsp; &nbsp; &nbsp; &nbsp; user = authenticate(username=username, password=password)<br />
  &nbsp; &nbsp; &nbsp; &nbsp; if user is not None:<br />
  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; refresh = RefreshToken.for_user(user)<br />
  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; serializer = UserSerializer(user)<br />
  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data = {<br />
  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;refresh&#39;: str(refresh),<br />
  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;access&#39;: str(refresh.access_token),<br />
  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;user&#39;: serializer.data<br />
  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p>

  <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return Response(data, status=status.HTTP_200_OK)<br />
  &nbsp; &nbsp; &nbsp; &nbsp; else:<br />
  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return Response({&quot;error&quot;: &quot;Invalid credentials&quot;}, status=status.HTTP_401_UNAUTHORIZED)<br />
  &nbsp;</p>

  <p>&nbsp;</p>

  <p><strong><span style="font-size:16px">Urls.py</span></strong></p>

  <p>from django.urls import path , include<br />
  from .views import UserRegistrationViewset , LoginViewset</p>

  <p>urlpatterns = [<br />
  &nbsp; &nbsp; path(&#39;register/&#39;, UserRegistrationViewset.as_view(), name=&#39;user-register&#39;),<br />
  &nbsp; &nbsp; path(&#39;login/&#39;, LoginViewset.as_view(), name=&#39;user-login&#39;),<br />
  ]<br />
  <br />
  link:&nbsp;<a href="http://github.com/rafitalavi/jvai_task_1/tree/main/studentmanagement">https://github.com/rafitalavi/jvai_task_1/tree/main/studentmanagement</a></p>

  <hr />
  <h2><span style="font-size:17pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000"><strong>Comparison Table</strong></span></span></span></h2>

  <div>
  <table cellspacing="0" style="border-collapse:collapse; border:none; width:417px">
  	<tbody>
  		<tr>
  			<td style="vertical-align:top; width:98px">
  			<p style="text-align:center"><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000"><strong>Feature</strong></span></span></span></p>
  			</td>
  			<td style="vertical-align:top; width:122px">
  			<p style="text-align:center"><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000"><strong>Django</strong></span></span></span></p>
  			</td>
  			<td style="vertical-align:top; width:197px">
  			<p style="text-align:center"><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000"><strong>DRF</strong></span></span></span></p>
  			</td>
  		</tr>
  		<tr>
  			<td style="vertical-align:top; width:98px">
  			<p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">Signup</span></span></span></p>
  			</td>
  			<td style="vertical-align:top; width:122px">
  			<p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">✅</span></span></span></p>
  			</td>
  			<td style="vertical-align:top; width:197px">
  			<p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">✅ (API)</span></span></span></p>
  			</td>
  		</tr>
  		<tr>
  			<td style="vertical-align:top; width:98px">
  			<p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">Login</span></span></span></p>
  			</td>
  			<td style="vertical-align:top; width:122px">
  			<p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">✅</span></span></span></p>
  			</td>
  			<td style="vertical-align:top; width:197px">
  			<p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">✅ (Token/JWT)</span></span></span></p>
  			</td>
  		</tr>
  		<tr>
  			<td style="vertical-align:top; width:98px">
  			<p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">Session</span></span></span></p>
  			</td>
  			<td style="vertical-align:top; width:122px">
  			<p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">✅</span></span></span></p>
  			</td>
  			<td style="vertical-align:top; width:197px">
  			<p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">✅</span></span></span></p>
  			</td>
  		</tr>
  		<tr>
  			<td style="vertical-align:top; width:98px">
  			<p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">Token</span></span></span></p>
  			</td>
  			<td style="vertical-align:top; width:122px">
  			<p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">❌</span></span></span></p>
  			</td>
  			<td style="vertical-align:top; width:197px">
  			<p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">✅</span></span></span></p>
  			</td>
  		</tr>
  		<tr>
  			<td style="vertical-align:top; width:98px">
  			<p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">JWT</span></span></span></p>
  			</td>
  			<td style="vertical-align:top; width:122px">
  			<p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">❌</span></span></span></p>
  			</td>
  			<td style="vertical-align:top; width:197px">
  			<p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">✅</span></span></span></p>
  			</td>
  		</tr>
  		<tr>
  			<td style="vertical-align:top; width:98px">
  			<p><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000">Protect View</span></span></span></p>
  			</td>
  			<td style="vertical-align:top; width:122px">
  			<p><span style="font-size:11pt"><span style="font-family:'Roboto Mono',monospace"><span style="color:#188038">@login_required</span></span></span></p>
  			</td>
  			<td style="vertical-align:top; width:197px">
  			<p><span style="font-size:11pt"><span style="font-family:'Roboto Mono',monospace"><span style="color:#188038">IsAuthenticated</span></span></span><span style="font-size:11pt"><span style="font-family:Arial,sans-serif"><span style="color:#000000"> permission</span></span></span></p>

  			<p>&nbsp;</p>

  			<p><br />
  			&nbsp;</p>

  			<p>&nbsp;</p>
  			</td>
  		</tr>
  	</tbody>
  </table>
  </div>


# home_websetting

title: We Blog
email: rafitalavi12345@gmail.com
phone: 01631381099
address: Niketon , Mohakhale-1204
facebook: https://www.facebook.com
linkedin: https://www.facebook.com
instagram: https://www.facebook.com
twitter: https://www.facebook.com
meta_title: We Blog
logo: logo/26bb1a46-0582-42aa-8a6f-0074b140876f.png
smtp_host: weblog2.botvictus.com
smtp_password: Admin@#2001@
smtp_user: rafit@weblog2.botvictus.com
google_map:
  <iframe src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d26794.27052624626!2d90.41434902325176!3d23.732398588506992!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x3755b9b1a2cf9cf1%3A0x40c9c38899727082!2sAsgar%20Ali%20Medical%20College%20%26%20Hospital!5e0!3m2!1sen!2sbd!4v1758963948603!5m2!1sen!2sbd" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>

short_descriptions:
  We Blog is your go-to platform for insightful articles, tutorials, and stories. Join our community of writers and readers who share a passion for knowledge and creativity.

meta_description:
  We Blog is your go-to platform for insightful articles, tutorials, and stories. Join our community of writers and readers who share a passion for knowledge and creativity.


