حمید رضا عدالت نژاد
reading comprehension please
how the hell do you expect that any one knows your means ?
you just said
I don't understand why people is (are)buying books without knowing if the docs exist
Samor
Samor
Better find other internet resources like docs or books pdfs
Toko
Hey guys. I'm looking for django opensource project to participate on
Charly
Toko
I will do it if i can't some projects here cause I want to participate on project wich I can talk to the other person or administrator cause I'm a junior dev i want to do it to upgrade my skills
Anthony
Better find other internet resources like docs or books pdfs
I did take a course through udemy, and very much agree. The focus was mainly on class based views, but after playing with it for several months, I feel like it's learning math on the calculator.
Seems like the better way to learn is through defining your own functions. Once that's down, then use the cbv's as a shortcut for more rapid development.
Is that a fair statement?
liya'
Hello everyone, do you know how to make it so that when I log in to the token and the message is verified, it is immediately sent to the mail, please help
Ravindra
Moussa
MK
I get and error
CommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False
My settings.py has DEBUG = TRUE
ALLOWED_HOSTS = []
I have also tried ALLOWED_HOSTS = ['*']
then ALLOWED_HOSTS = ['localhost']
then ALLOWED_HOSTS = ['127.0.0.1']
then ALLOWED_HOSTS = ['localhost', '127.0.0.1']
once with DEBUG = FALSE and then with DEBUG = TRUE
... I also checked for views and urls for any filename mistyping and typo errors. Yet I am getting
CommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False.
I closed the session and changed the open .py file default from vscode and then with python. Yet this error is persistent *PLEASE HELP*
Alex
Alex
Doragonsureiyā
Tried it. Getting same error again
Rule 5️⃣: Never post walls of text or screen photos. Use paste bins like https://dpaste.org, https://hastebin.com, https://bin.kv2.dev or your favorite one!
MK
share code
https://dpaste.org/uBxiQ For settings.py
https://dpaste.org/WLRbX for blogapp/urls.py
https://dpaste.org/gsCzp for playground/urls.py
Toko
Toko
I recommend you to put * in this variable and check the result:
Toko
ALLOWED_HOST = {"*"}
MK
I tried ALLOWED_HOST = ['*']
Will check it in appended array element
MK
It still is not allowing the environment variables to identify DEBUG as True
I also implemented this and yet it is throwing the same error
CommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False.
https://dpaste.org/x1UQu
Is the filepath name used casesensitive?
MK
Ahmed
Alex
use github
MK
use github
https://github.com/kromation/Python/tree/main/Blog%20API
mahyar
Amirhossein:
Friends, I've encountered an issue in designing the serializer for the database's post section, and I would appreciate some guidance.
Blog models:
class Post(BaseModel):
    user = models.ForeignKey(get_user_model(), on_delete=models.CASCADE, related_name="posts")
    title = models.CharField(max_length=255)
    body = models.TextField()
    cover_image = models.ImageField(upload_to="post_cover_images/")
    status = models.BooleanField(default=False)
    published_at = models.DateTimeField(auto_now_add=True)
    created_at = None
    def __str__(self):
        return f"{self.user} - {self.title}"
   
class PostTag(BaseModel):
    tag = models.ForeignKey(Tag, on_delete=models.CASCADE, related_name="post_tags")
    post = models.ForeignKey(Post, on_delete=models.CASCADE, related_name="tags")
    def __str__(self):
        return f"{self.tag.name} - {self.post.title}"
   
class PostCategory(BaseModel):
    category = models.ForeignKey(Category, on_delete=models.CASCADE, related_name="post_categories")
    post = models.ForeignKey(Post, on_delete=models.CASCADE, related_name="categories")
When the user sends a POST request through the API, they naturally need to specify the tag, right? If I set up the serializer like this:
class PostSerializer(serializers.ModelSerializer):
    user = serializers.CharField(source="user.fullname", read_only=True)
    tags = PostTagSerializer()
    def create(self, validated_data):
        validated_data["user"] = self.context["request"].user
        return super().create(validated_data)
    class Meta:
        model = Post
        fields = '__all__'
In this case, the user will select the tag from a list of tags, right? (Although this shouldn't happen; the tag should be added dynamically by the user). But the post hasn't been created yet to select from the list of posts being added right now.
MK
Shinoj
How to convert numbers to word in django
Marco dev
Fauzaan一
https://github.com/kromation/Python/tree/main/Blog%20API
main issue is in the manage.py file. i think you modified it?
you need to remove those lines you added at the top next to the comments saying "added to remove error" and also the settings module is not BlogApp.settings but it is blogapp.settings (lowercase)
also you have an issue in playground/apps.py :
it should be default_auto_field and not default.auto.field
changing these runs the server
Bujji
At the moment user registration is sending email notification to reviewer Replicate the emailsend trigger from the user registration in the comment create in commentlogview set
Bujji
Please help this task
MK
Srini
Where we can get Django templates
Charly
Where we can get Django templates
You don't. You get HTML templates and you adapt them to Django. There are almost no Django templates because it all depends on what data you send on your views and the specific logic
حمید رضا عدالت نژاد
Where we can get Django templates
Do you mean like HTML template? you can use bootstrap but Django developers should consider that the Django is really a full-stack web framework with great backend abilities and you need to know HTML CSS to develop your app , and if you, not it is better to use someone for front, or your app gets ugly and that's the factor for someone to enter your web site.
anyway Bootstrap has lots of sites that provide templates and components.. you can build from bootstrap site or download it from websites with html templates for bootstrap that a search will provide you some good websites
Srini
حمید رضا عدالت نژاد
Like complete projects
there are top 45 django project code bases
https://www.geeksforgeeks.org/django-projects/
Никайтос
Hello!
I've got auth system with email confirmation for mobile app. It looks like this
class AppLoginConfirmCreateAPIView(generics.CreateAPIView):
"""
APIView for confirming login. (Only for APP)
"""
permission_classes = []
authentication_classes = ()
serializer_class = AppLoginConfirmCodeSerializer
@swagger_auto_schema(responses={201: TokenRefreshSerializer()})
def post(self, request, *args, **kwargs):
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
return Response(
data=get_tokens_for_user(self.request.user),
status=status.HTTP_201_CREATED
)
class AppLoginConfirmCodeSerializer(ValidateRegisterCodeSerializer):
"""
Serializer for confirming login using a code.
This serializer is used to confirm the login by validating the code provided by the user.
"""
def validate(self, attrs) -> Dict:
"""
Validate the login code.
This method validates the login code against the provided OTC token.
"""
login_otc = LoginOTC.objects.filter(id=attrs['otc_token']).first()
self.validate_otc_token_expiration(login_otc)
self.validate_match_code(attrs['code'], login_otc.code)
try:
request = self.context["request"]
except KeyError:
pass
user = login_otc.apply(password=None)
login(request, user, backend='django.contrib.auth.backends.ModelBackend')
return attrs
If I test this confirmation via Postman, API, Swagger, whatever - it works 1st try, but when frontend tries to make this request (by clicking 'Continue' button in the app) - the first one sends 500 code with message "Something went wrong", and only seconds one works as expected. Why could this error happen?
Maxim
Hello!
I've got auth system with email confirmation for mobile app. It looks like this
class AppLoginConfirmCreateAPIView(generics.CreateAPIView):
"""
APIView for confirming login. (Only for APP)
"""
permission_classes = []
authentication_classes = ()
serializer_class = AppLoginConfirmCodeSerializer
@swagger_auto_schema(responses={201: TokenRefreshSerializer()})
def post(self, request, *args, **kwargs):
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
return Response(
data=get_tokens_for_user(self.request.user),
status=status.HTTP_201_CREATED
)
class AppLoginConfirmCodeSerializer(ValidateRegisterCodeSerializer):
"""
Serializer for confirming login using a code.
This serializer is used to confirm the login by validating the code provided by the user.
"""
def validate(self, attrs) -> Dict:
"""
Validate the login code.
This method validates the login code against the provided OTC token.
"""
login_otc = LoginOTC.objects.filter(id=attrs['otc_token']).first()
self.validate_otc_token_expiration(login_otc)
self.validate_match_code(attrs['code'], login_otc.code)
try:
request = self.context["request"]
except KeyError:
pass
user = login_otc.apply(password=None)
login(request, user, backend='django.contrib.auth.backends.ModelBackend')
return attrs
If I test this confirmation via Postman, API, Swagger, whatever - it works 1st try, but when frontend tries to make this request (by clicking 'Continue' button in the app) - the first one sends 500 code with message "Something went wrong", and only seconds one works as expected. Why could this error happen?
What could be the error?
Кит
Hi, I get the idea, but I can't explain it. Why use Django REST Framework and Django Ninja if you can return data (not HTML) without them?
Кит
Кит
The following question arose. I want to move the database separately from the site (I will conditionally make an API to it through some API framework, it is not important). How to make this API secure (to exclude the possibility of unauthorized access. So that, conditionally, only my site can access it)
Кит
Кит
🕹 Alireza 🕹
N
Hi team
I am willing to learn django could you please help me with roadmap
Dmytro
Hi everyone
Dmytro
I want to learn cronjob in django
Dmytro
Could you tell me about this more detail?
Dmytro
Dark
I am learning about deployment of Django project on Railway App and I am facing an issue while deploying the Django project.
I am facing an error which says : Dockerfile Dockerfile does not exist
Although I have correctly given the location of my Dockerfile in railway.toml file, but I am unable to figure out why this error is occurring.
kim
Where can I deploy my django project?
Dmytro
Mayur
I am getting url has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Mirco
حمید رضا عدالت نژاد
You need to enable cors backend side
you need to install this and add coreheaders to your installed app
pip install django-cors-headers
INSTALLED_APPS = [
...
'corsheaders',
...
]
MIDDLEWARE = [
...
'corsheaders.middleware.CorsMiddleware',
...
]
then you can configure cors setting using CORS_ALLOWED_ORIGINS
Alireza
Hi guys, I'm kinda new.
I'm trying to test my API's (DRF), but my test keeps failing and I don't understand why.
here is the test:
https://pastefy.app/gz3G5hum
the request returns a 401 response but I can't understand what I'm doing wrong.
can someone help?
Alireza
حمید رضا عدالت نژاد
Alireza
Yup it really helps with basic or specific stuff
Jack
Hello,
Anyone ever worked with Django and Tailwindcss.
Need guidance/help deploying the app to Cpanel
Vivek Yadav
Toheeb Àdúràmọ́mi
Just about to start learning. Although I have learnt Python to a certain level. ANy important advice for a newcomer?😄
Maxim
Toheeb Àdúràmọ́mi
Yeah. I can see clearly –Django. I'm not here for Python