Welcome to our tutorial on Django – Stu Sesh with Miloo Pictures [S01.E15] | Prod. MENVCE! In this tutorial, we will cover all the steps needed to create a Django project that showcases Miloo Pictures.
Before we begin, make sure you have Django installed on your machine. If not, you can install it using the following command:
pip install django
Now, let’s start by creating a new Django project. Open your terminal and run the following command:
django-admin startproject miloo_pictures
This will create a new directory called miloo_pictures
with the necessary files and folders for a Django project. Navigate to this directory by running:
cd miloo_pictures
Next, let’s create a new Django app within our project. Run the following command:
python manage.py startapp pictures
This will create a new directory called pictures
with the necessary files and folders for a Django app.
Now, let’s configure our project settings. Open the miloo_pictures/settings.py
file and add pictures
to the INSTALLED_APPS
list:
INSTALLED_APPS = [
...
'pictures',
]
Next, let’s define our models. Create a new file called models.py
within the pictures
directory and add the following code:
from django.db import models
class Picture(models.Model):
title = models.CharField(max_length=100)
image = models.ImageField(upload_to='images/')
created_at = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.title
Don’t forget to run migrations to create the database tables for our models. Run the following commands:
python manage.py makemigrations
python manage.py migrate
Next, let’s create a serializer for our model. Create a new file called serializers.py
within the pictures
directory and add the following code:
from rest_framework import serializers
from .models import Picture
class PictureSerializer(serializers.ModelSerializer):
class Meta:
model = Picture
fields = '__all__'
Now, let’s create our views. Create a new file called views.py
within the pictures
directory and add the following code:
from rest_framework import viewsets
from .models import Picture
from .serializers import PictureSerializer
class PictureViewSet(viewsets.ModelViewSet):
queryset = Picture.objects.all()
serializer_class = PictureSerializer
Finally, let’s define our URLs. Open the miloo_pictures/urls.py
file and add the following code:
from django.urls import path, include
from rest_framework.routers import DefaultRouter
from pictures import views
router = DefaultRouter()
router.register(r'pictures', views.PictureViewSet)
urlpatterns = [
path('', include(router.urls)),
]
And that’s it! You have now created a Django project that showcases Miloo Pictures. You can now run the development server by running the following command:
python manage.py runserver
Visit http://127.0.0.1:8000/pictures/
in your browser to see the list of pictures. You can also use tools like Postman to test your API endpoints.
I hope you found this tutorial helpful. Happy coding!
Street Sesh Ep1 Out Now: https://www.youtube.com/watch?v=QTCpOwSCZF8
Kim+NiC❤❤💍💍🫶🏻💋
Boah ist das scheisse
Jemand 2025 hier?
Jemand 2087 hier!
Jemand 2025 hier ?
Mann, bruder, bester Mann
Muss nicht
Was Geht jemand aus 2024
wie gross ist django
Ja
Ich
Einfach schon 2 Jahre alt
geile rap wow uhr geil
Ja ich
2024 und immer noch da Django auf die 1
Jemanden 2024 hir
Mehr davon bitte
Video ist geisteskrank
Ist noch jemand da😊