mea
I need help who has ever hosted Django on a cPanel
Mohammad Hossein
I need help who has ever hosted Django on a cPanel
I did. But please specify your problem
Mohammad Hossein
development !
In development there is no need to do collectstatic if you're running locally
park seo joon
my pc got some problems so I'm just doing my college project through android termux
Android might be different for PC I think you should relate that to termux users
Poya
Hello friends, I am a junior backend developer in Django and I could not find a company to work for and increase my experience. I want to raise my level and gain more experience, but the problem I have is that I'm all at home and I only learned Django with youtube, ai and other sites, and I don't know what I should do right now to increase my level. Can you guide me what exactly I should do?
Luis
And put it online.
mea
I did. But please specify your problem
There's always a 403 error whenever someone is on the admin panel either adding an item or updating
Nima
Hi,I have a django question posted on stackoverflow;can anybody help debug it? Thank you in advance. https://stackoverflow.com/questions/78833962/i-have-made-an-otp-code-function-in-django-and-i-dont-know-how-to-debug-itit-s
Mohammad Hossein
There's always a 403 error whenever someone is on the admin panel either adding an item or updating
Sorry, I never encountered that issue. Are you sure your host is included in ALLOWED_HOSTS?
mea
Sorry, I never encountered that issue. Are you sure your host is included in ALLOWED_HOSTS?
the site is already working on the cPanel I have set the allowed host
Kartik
Does anyone have notes for django ??
Doragonsureiyā
Does anyone have notes for django ??
Looking for Django tutorials? you can follow these three recommended ones: * Official documentation and tutorial * Tutorial from MDN * Tutorial from django-girls
DD
guys, how do you make automigration in docker container? With docker compose command, shell script or another way?
DD
You can use docker compose exec or shell into the container and run it
if its first migration and im getting errors? :)
Charly
if its first migration and im getting errors? :)
Are you getting errors? Show them
Charly
And what exactly you did
DD
Are you getting errors? Show them
the error is that models were not created and db is new
Charly
the error is that models were not created and db is new
The python error not your interpretation of it
DD
The python error not your interpretation of it
relation “all my tables” does not exist
DD
The python error not your interpretation of it
checking my postgresql it doesnt have any migration as well
Charly
relation “all my tables” does not exist
Ok if you don't paste the real error we cant help
Charly
https://dpaste.org/XFbWm
And this by running which specific command?
DD
And this by running which specific command?
Its inside docker container, so after docker compose build and trying to exec it im getting this
DD
yes but which command!
sudo docker compose -f docker-compose.prod.yml up -d —build backend
Charly
and which command did you ran inside the container
DD
AFTER that
docker exec doesnt work at all, misstyped it, thats what logs giving me
DD
docker logs <container>
clouded
docker exec doesnt work at all, misstyped it, thats what logs giving me
Please share a paste of your docker-compose.yaml file and your Dockerfile, if there's any.
Charly
docker exec doesnt work at all, misstyped it, thats what logs giving me
what error shows the docker exec, and I'm not talking about the logs, but the error you get that makes you said that it was misstyped
clouded
That's irrelevant, he just need tor un igrations
I wonder what runs when the container is started. It appears all he does is docker-compose up, so the relevant command might be in the compose or Dockerfile.
clouded
https://dpaste.org/4dTvh#L47,48
DD
what error shows the docker exec, and I'm not talking about the logs, but the error you get that makes you said that it was misstyped
Error response from daemon: Container 50838b8c1f3662e3221287d2eb355a2fd08f55298453767e60b01ca76c790553 is restarting, wait until the container is running
DD
https://dpaste.org/4dTvh#L47,48
yea that's it, this 2 lines doesnt work and i dunno why
DD
i think i should try some shell script as entrypoint
DD
i checked the connection between my db and django, it works well, but still i dont understand why it doesnt migrate
clouded
That's irrelevant, he just need tor un igrations
Is it possible that he needs to create those migrations first?
DD
spent 7h
DD
want to sleep really bad, but it should be working at 9am :(
Charly
Is it possible that he needs to create those migrations first?
I guess his migrations don't work even locally outside docker, so that maybe is the solution
cj
yea that's it, this 2 lines doesnt work and i dunno why
be sure the migration files were created before even trying to run migrate
Charly
What about tutorial video please share
We don't recommend videotutorials because they come obsolete very fast
Jay Dwarkadhish
from rest_framework import serializers from .models import User,UserDetail,UserProfile class UserProfileSerializer(serializers.ModelSerializer): class Meta: model = UserProfile fields = '__all__' class UserDetailSerializer(serializers.ModelSerializer): class Meta: model = UserDetail fields = '__all__' class UserSerializer(serializers.ModelSerializer): id = serializers.IntegerField(read_only=True) name = serializers.CharField() email = serializers.EmailField() password = serializers.CharField() created_at = serializers.DateTimeField(read_only=True) updated_at = serializers.DateTimeField(read_only=True) user_profile = UserProfileSerializer() user_details = UserDetailSerializer() class Meta: model = User fields= ['id','name','email','password','created_at','updated_at','user_profile','user_details',] from rest_framework.generics import ListCreateAPIView,RetrieveUpdateDestroyAPIView class UserAPIView(ListCreateAPIView): """ Get, Update user profile """ queryset = User.objects.all() serializer_class = UserSerializer class UserRetrieveUpdateAPIView(RetrieveUpdateDestroyAPIView): queryset = User.objects.all() serializer_class = UserSerializer lookup_field ="pk"
Jay Dwarkadhish
AttributeError at /v1/user/all Got AttributeError when attempting to get a value for field user_profile on serializer UserSerializer. The serializer field might be named incorrectly and not match any attribute or key on the User instance. Original exception text was: 'User' object has no attribute 'user_profile'.
Jay Dwarkadhish
how i can solve?
️امیر
how i can solve?
Check your models
Disami
We don't recommend videotutorials because they come obsolete very fast
Yea that is true but doc some times get bulky if i may get some vid i could use them as a reference
Jay Dwarkadhish
Check your models
# Create your models here. from django.db import models class User(models.Model): name = models.CharField(max_length=100) email = models.EmailField() password = models.CharField(max_length=100) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) def __str__(self): return self.name class UserDetail(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) age = models.IntegerField(help_text="Enter Age") address = models.CharField(max_length=100, blank=True) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) def __str__(self): return self.user.name class UserProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) bio = models.TextField() profile_picture = models.ImageField(upload_to='profiles/', null=True, blank=True) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) def __str__(self): return self.user.name i want Nested Relationships in DRF Serializers
Maxim
how i can solve?
add it to the model or remove it from the serializer
️امیر
And also it's better if you add related_name to relations
Disami
I am not fan of vid tutorial but there is in time when i need to understand behind the scene but the video on.you tube i was getting is just follow steps of doc to do something.i need video that could teach me different way in different scenarios.any.help
Armin
Hey guys, I built a simple project with Django and React and I wanna deploy it . What's the best option for deployment?
Armin
Heroku doesn't allow me use their services because of the location I live. I tried Render but the problem with Render is that on their free plan they don't give you access to a terminal so you either have to run collectstatic in your development environment and all the statics file will end up on your GitHub repo which is ugly, or you have to deal with a admin panel that don't have any css styling.
Armin
Are they fully separated projects or you have th hybrid solution ?
They are separated, on my local environment the Django server runs on the port 8000 and the React project runs on the port 5173 and communities with that Django server
Armin
I wanna give AWS a try but I think it needs some extra knowledge to deploy on Aws compared to Paas services that allows you to deploy your application with a few clicks