This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
video { | |
max-width: 100%; | |
height: auto; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<video controls poster="path/to/poster-image.jpg" width="640" height="360"> | |
<source src="video.mp4" type="video/mp4"> | |
<source src="video.webm" type="video/webm"> | |
<p>Your browser does not support the video tag. Please <a href="video.mp4">download the video</a>.</p> | |
</video> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<video src="path/to/your/video.mp4"></video> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<img src="path/to/image.jpg" alt="Description" loading="lazy"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<picture> | |
<source media="(min-width: 800px)" srcset="large-hero.webp" type="image/webp"> | |
<source media="(min-width: 800px)" srcset="large-hero.jpg" type="image/jpeg"> | |
<source srcset="small-mobile-hero.webp" type="image/webp"> | |
<img src="small-mobile-hero.jpg" alt="Person hiking on a mountain trail"> | |
</picture> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<img srcset="image-small.jpg 480w, image-medium.jpg 800w, image-large.jpg 1200w" src="image-large.jpg" alt="A panoramic view of mountains at sunrise" width="1200" height="800"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<img src="path/to/your/image.jpg" alt="A descriptive alternative text for the image"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProductSerializer(serializers.ModelSerializer): | |
category = CategorySerializer(read_only=True) # Nested serializer | |
class Meta: | |
model = Product | |
fields = ['name', 'price', 'category'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProductViewSet(viewsets.ReadOnlyModelViewSet): | |
queryset = Product.objects.select_related('category').all() # Optimize here | |
serializer_class = ProductSerializer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProductSerializer(serializers.ModelSerializer): | |
class Meta: | |
model = Product | |
fields = ['id', 'name', 'price'] # Only include these fields | |
# OR: exclude = ['description', 'created_at'] |