Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Not use Django static files
I am quite new to Django, and I hope my question is not too silly. I am currently running my project locally, and each time I do an API call with the browser, I see the server log something similar: my_table | [08/Jan/2023 20:20:42] "GET /static/rest_framework/css/default.css HTTP/1.1" 404 179 my_table | [08/Jan/2023 20:20:42] "GET /static/rest_framework/js/bootstrap.min.js HTTP/1.1" 404 179 my_table | [08/Jan/2023 20:20:42] "GET /static/rest_framework/js/jquery-3.5.1.min.js HTTP/1.1" 404 179 my_table | [08/Jan/2023 20:20:42] "GET /static/rest_framework/js/csrf.js HTTP/1.1" 404 179 my_table | [08/Jan/2023 20:20:42] "GET /static/rest_framework/js/ajax-form.js HTTP/1.1" 404 179 my_table | [08/Jan/2023 20:20:42] "GET /static/rest_framework/js/default.js HTTP/1.1" 404 179 my_table | [08/Jan/2023 20:20:42] "GET /static/rest_framework/js/prettify-min.js HTTP/1.1" 404 179 There are a tons of static files that are served via the API. If I do the same with Postman or similar, here is the log: my_table | [08/Jan/2023 20:25:12] "GET /api/v1/category/ HTTP/1.1" 200 2 It looks like it only sends the response I wanted, via JSON or whatever. I was wandering if there is a way to prevent Django from serving static files at all, since I will only use the Rest Framework, or maybe gRPC in the future, but never static files. I tried to delete the static file constant from settings, and then nothing … -
Use node module in django
I'm trying to use nodejs modules (lodash) inside of my Django app but nothing happen. The architecture is as follow: - myproject - dist - myapp - templates - index.html - apps.py - views.py - ... - myproject - settings.py - urls.py - ... - nodes_module - static - js - script.js - manage.py - package.json I edited my settings.py so nodes_module/ is considered as static: STATIC_URL = "/static/" STATIC_ROOT = 'dist/static/' STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), ('node_modules', os.path.join(BASE_DIR, 'node_modules/')), ) And here is the content of my index.html: hello <div id="result"></div> <script>console.log("yolo")</script> <!-- This should write "2 4 6 8 10" on console and page but doesn't --> {% load static %} <script src="{% static 'node_modules/lodash/lodash.js' %}"> import _ from 'lodash'; console.log("yolo2") const array = [1, 2, 3, 4, 5]; const doubled = _.map(array, function(n) {return n * 2;}); const resultElement = document.getElementById('result'); resultElement.innerHTML = doubled; console.log(doubled); </script> I got a lot of errors while trying but now, with this architecture and code, I don't have errors anymore but nothing appear on my page except the "hello". For some reasons, the first console.log("yolo") does appear on the console but not the second one console.log("yolo2"). It's like it never went … -
How can I add related models on the form at the same time?
I need your help with something. I'm new to the software field. I would like to consult you on an issue that I am stuck with. I don't know much about Django docs. My English is not very good. My problem is that I have two models, Boat model and Features model, I assigned a foreignkey to the features model and associated it with the boat model. I created two forms for these models. Features Model Boat Model BoatForm FeaturesForm I need to save the form at the same time in the views, but I can't assign the foreign key. In summary, while adding a new boat, I need to save its features at the same time. Sorry if the English pronunciations are wrong. -
How to check if a model is an intermediate model
Taking the example in the docs, I'm trying to check if a model is an intermediate model. from django.db import models class Person(models.Model): name = models.CharField(max_length=128) def __str__(self): return self.name class Group(models.Model): name = models.CharField(max_length=128) members = models.ManyToManyField(Person, through='Membership') def __str__(self): return self.name class Membership(models.Model): person = models.ForeignKey(Person, on_delete=models.CASCADE) group = models.ForeignKey(Group, on_delete=models.CASCADE) date_joined = models.DateField() invite_reason = models.CharField(max_length=64) So a function like this, that takes a model as input and returns true if the model is an intermediate model and false otherwise. def is_intermediate(model): pass # is_intermediate(Person) -> False # is_intermediate(Group) -> False # is_intermediate(Membership) -> True I believe Django REST Framework has a way of doing this with the has_through_model attribute. Looking at that, I wrote this: def is_intermediate(model): for field in model._meta.get_fields(): if field.is_relation: for related_field in field.related_model._meta.get_fields(): through = getattr(related_field.remote_field, "through", None) if through and not through._meta.auto_created and through == model._meta.model: return True return False And it works. But to me, this sounds entirely inefficient. Is there a more performant way of finding if a model is intermediate? -
Django custom user profile image not saving properly
I've got a custom user model that when the image is updated it adds characters to the file path making django unable to find the new updated profile image. MODELS.PY from django.db import models from django.contrib.auth.models import AbstractUser from PIL import Image from django.conf import settings import os class CustomUser(AbstractUser): username = models.CharField(max_length=255, unique=True) password = models.CharField(max_length=255) email = models.EmailField(unique=True) # Add any additional fields you want to store about users, such as their profile picture, etc. image = models.ImageField(default='default.png', upload_to='profile_pics', null=True, blank=True) def save(self, *args, **kwargs): # Check if the image field has changed if self.pk: orig = CustomUser.objects.get(pk=self.pk) if orig.image != self.image: # Delete the previous image file if orig.image: orig.image.delete(save=False) # Create a thumbnail image if self.image: try: image = Image.open(self.image) except FileNotFoundError: print("Image file not found:", self.image.path) return image.thumbnail((200, 200), Image.ANTIALIAS) # Save the image to the correct path image_path = os.path.join( settings.MEDIA_ROOT, self.image.field.upload_to, self.image.name) image.save(image_path) super().save(*args, **kwargs) Views.py class UserPostListView(ListView): model = Post template_name = 'gorl/user_posts.html' context_object_name = 'posts' # paginate_by = 5 def get_queryset(self): user = get_object_or_404( CustomUser, username=self.kwargs.get('username')) return Post.objects.filter(author=user).order_by('-date_posted') def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) user = get_object_or_404( CustomUser, username=self.kwargs.get('username')) context['user'] = user context['show_profile_settings'] = self.request.user.username == user.username context['comments'] = Comment.objects.all() total_likes … -
Ktor client - CSRF post request
I am doing a project where I am using django for server and ktor client for jetpack compose application to make request.However the CSRF protection reject my login request(An unsafe post request). As django has a built-in CSRF protection middleware, when I am testing the login post request with localhost, the server return Forbidden (CSRF cookie not set.): /user/login/ to the client and the login function cannot work. I tried to search for some documents and solutions to disable CSRF check (@csrf_exempt) but they are not working for me.I have added the CSRF_TRUSTED_ORIGINS in setting.py as the following(To be honest I don't know if these works or not): CSRF_TRUSTED_ORIGINS = [ 'http://localhost', 'http://*.127.0.0.1:*', 'http://10.0.2.2', 'http://127.0.0.1', 'https://127.0.0.1', 'https://127.0.0.1:*', 'https://127.0.0.1:', ] I have also tried to disable the middleware but not work. Is there any way that I can use ktor client to satisfy the CSRF thing from django?? Or what else should I do if that is not possible. Thank you for any answer. -
There is no cookie at all in my Next.Js frontend
I am super newbie on programming. I made Django Backend. and Next.js Frontend There is cookie which has _ga, csrftoken when I tested on local server 127.0.0.1 BUT, there is no cookie at all on my production. (production:which has different domain backend and frontend). I guessed that everything happened because I used different domain when production (just guess... I don't know it clear) here is some django settings.py i have ALLOWED_HOSTS = [ "127.0.0.1", "localhost", "BACKENDURL", "FRONTENDURL", "*.FRONTENDURL", ] CORS_ORIGIN_ALLOW_ALL = True CORS_ALLOW_CREDENTIALS = True CSRF_TRUSTED_ORIGINS = [ "http://127.0.0.1:3000", "http://localhost:3000", "https://*.frontendURL", "https://FRONTENDURL", ] CSRF_COOKIE_SECURE = True SESSION_COOKIE_SECURE = True I've searched all over the internet world. Please help me out from this hell... :-( -
Error "ImproperlyConfigured at /dj-rest-auth/login/" in use "dj_rest_auth"
I Want Use packeage 'dj_rest_auth' in django-rest-framework for login but get error: ImproperlyConfigured at /dj-rest-auth/login/ No default throttle rate set for 'dj_rest_auth' scope In setting.py File: INSTALLED_APPS = [ ... # 3rd Party 'rest_framework', 'rest_framework.authtoken', 'rest_framework_simplejwt', 'dj_rest_auth', # local ... ] REST_USE_JWT = True REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES':[ 'rest_framework_simplejwt.authentication.JWTAuthentication', 'dj_rest_auth.jwt_auth.JWTCookieAuthentication', ], 'DEFAULT_PERMISSION_CLASSES':[ 'rest_framework.permissions.AllowAny' ], 'DEFAULT_RENDERER_CLASSES':[ 'rest_framework.renderers.JSONRenderer' ], 'DEFAULT_THROTTLE_CLASSES':[ 'rest_framework.throttling.AnonRateThrottle', 'rest_framework.throttling.UserRateThrottle', 'rest_framework.throttling.ScopedRateThrottle', ], 'DEFAULT_THROTTLE_RATES':{ 'anon':'50/hour', 'user':'200/hour', 'register':'5/hour', 'ref_token':'5/minute', 'create_article':'5/minute', } } And url.py: urlpatterns = [ ... path('dj-rest-auth/',include('dj_rest_auth.urls')), ] -
Django Taggit Filtering Invalid for Icontains
I have a model that contains a tags field using the Django Taggit library. I am currently trying to use a search bar to see if any items contains the same tag such as "Savoury" "Sweet" etc. However i am getting the error "Related Field got invalid lookup: icontains" and im not sure why. I have doubled checked the value in the post request from the search bar and it matches so the problem lies in the filtering using icontains. Here is my code: models.py `class Food(models.Model): name = models.CharField(max_length=100) tags = TaggableManager()` views.py class SearchFood(TemplateView): ... def post(self, request): result = request.POST['search_result'] if Food.objects.filter(tags__icontains=result): object = Food.objects.filter(tags__icontains=result) ... Im not sure why this doesnt work as i have tried searching for the food name using icontains and it works perfectly. However doing it with Django Taggit i get errors. Any help would be appreciated. -
NoReverseMatch at / Reverse for 'post_detail' not found. 'post_detail' is not a valid view function or pattern name
I'm working on my Django blog. I was working on a registration form, everything it was working until I tested it and redirection was not working properly. Trying to fix errors, I got this message django.urls.exceptions.NoReverseMatch: Reverse for 'post_detail' not found. 'post_detail' is not a valid view function or pattern name. blog/urls.py from . import views from django.urls import path app_name = 'my_blog' urlpatterns = [ path('', views.home, name='home'), path('post/<slug:slug>/', views.post_detail, name='post_detail'), path('category/<slug:slug>/', views.category_detail, name='category_detail'), path('register/', views.register_request, name='register'), path('login/', views.login_request, name='login'), ] views.py def register_request(request): if request.method == "POST": form = NewUserForm(request.POST) if form.is_valid(): user = form.save() login(request, user) messages.success(request, "Registration successful." ) return redirect("my_blog:homepage") messages.error(request, "Unsuccessful registration. Invalid information.") form = NewUserForm() return render (request=request, template_name="register.html", context={"register_form":form}) def login_request(request): if request.method == "POST": form = AuthenticationForm(request, data=request.POST) if form.is_valid(): username = form.cleaned_data.get('username') password = form.cleaned_data.get('password') user = authenticate(username=username, password=password) if user is not None: login(request, user) messages.info(request, f"You are now logged in as {username}.") return redirect("my_blog:homepage") else: messages.error(request,"Invalid username or password.") else: messages.error(request,"Invalid username or password.") form = AuthenticationForm() return render(request=request, template_name="login.html", context={"login_form":form}) In home.html I used "{{ post.get_absolute_url }}", and now this is error when I try to reload page, I have no idea why this is happening. … -
Django postgres "No migrations to apply" troubleshoot
I had to modify the table of my app so I dropped it from postgres database (using objectname.objects.all().delete() in django python shell and with postgres at PGAdmin). I deleted the appname migrations folder. When I run python manage.py makemigrations appname, the folder migrations gets created with a 0001_initial.py creating the tables. When I run python manage.py migrate appname, nothing happens and I cannot see the tables in postgres PGAdmin. (website) C:\Users\Folder>python manage.py makemigrations appname Migrations for 'appname': food\migrations\0001_initial.py - Create model Table1 - Create model Table2 - Create index Table2_search__7dd784_gin on field(s) search_vector of model Table2 (website) C:\Users\Folder>python manage.py migrate Operations to perform: Apply all migrations: accounts, admin, auth, contenttypes, appname, sessions Running migrations: No migrations to apply. When I deleted the folder migrations I can see the migrations are gone with python manage.py showmigrations. I also tried python manage.py migrate --run-syncdb but still no result. (website) C:\Users\Folder>python manage.py migrate --run-syncdb Operations to perform: Synchronize unmigrated apps: messages, postgres, staticfiles Apply all migrations: accounts, admin, auth, contenttypes, appname, sessions Synchronizing apps without migrations: Creating tables... Running deferred SQL... Running migrations: No migrations to apply. Any other idea on what may be happening and how to get the tables in postgres … -
How to change representation while keeping field editable in DRF?
I have two classes: class ClassA(models.Model): name = models.Charfield(...) tags = models.ManyToManyField("TagClass", blank=True) class TagClass(models.Model): tag_name = models.Charfield(...) def __str__(self): return f"{self.tag_name}" And then I serialize like so: # serializers.py class ClassASerializer(serializers.ModelSerializer): class Meta: model = ClassA fields = "__all__" class TagClassSerializer(serializers.ModelSerializer): class Meta: model = TagClass fields = "__all__" So when I create a tag say "red", it has ID=1, and I link it to a ClassA object, in the ClassA's object representation it shows this : { "id": 1, "name": "Some name", "tags": [ 1 ], } Instead I'd like it to display like so : { "id": 1, "name": "Some name", "tags": [ "red", ], } I've seen the StringRelatedField but it makes editing the tags field disabled (read-only). Is there a way to proceed to have the String repr but staying editable? -
Django server unable to get data from react Axios
I'm not getting an error but when I saw the logs of my server it prints an empty object {} whenever I send a request to the sever from my react app using axios. I double checked everything every other request in another components of my app works fine, but only in this particular request the data is not being sent! I have no CORS issue! My react axios request // PrivateAxios instance to send api request const axiosPrivate = useAxiosPrivate(); const handleSearch = async () => { const data = JSON.stringify({ from_company: keyWord }); try { const response = await axiosPrivate.get(SEARCH_URL, data); console.log(response); setRecords(response?.data); } catch (err) { if (!err?.response) { console.log("NO SERVER RESPONSE"); } else { console.log("SOMETHING WRONG"); } } }; Server log {} <-- Prints the request.data as an empty object "GET /api/find_many/ HTTP/1.1" 200 6276 The django server responses with correct details when I send a request with Postman or Thunder Client. The server also prints the object that were sent with the Postman request. I don't know why the server is unable to get the object or data when I request from my react app. Request sent from Postman returns {'from_company': 'Jethmal Paliwal'} <-- Prints … -
djLint code H030 and H031 linter issue vscode
djLint (vscode) gives error in every html file which has html tag and I can't figure out the real problem or the solution. The error messages: Consider adding a meta description. (H030) Consider adding meta keywords. (H031) There is 3 example, but I do not understand that, why example_3 doesn't have any error. example_1 (linter on, with error): example_1 example_2 (linter off for H030 and 031): example_2 example_3 (linter on, but no error if a commented block inserted before the html): example_3 My settings.json: settings I've checked the djLint docs and googled it, but no luck. Already reinstalled extensions and packages. Any idea or solution? I'm new to HTML (and programming) so maybe I'm doing something wrong. -
Having trouble running django on Pycharm
I'm sure you guys have heard enough of these questions but I am a new programmer looking to start using Django. I have done pip install django and by the time it's almost done download I received a warning. WARNING: The script django-admin.exe is installed in 'C:\Users\bryan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. I have ignored this earlier and ran the command django-admin startproject and of course I receive another error. The term 'django-admin' is not recognized as the name of a cmdlet, function, script file, or operable program. Not quite what to do. I need your help. Or at least direct me to a post similar to this matter. Thank you! I have tried redirecting the PATH with pip install--install-option="--prefix=C:\Users\bryan\PycharmProjects\mySite" django I saw this on another post and thought it would help but nothing really worked. -
Beginner question. Started learning Django without knowing HTML, CSS and Javascript. is it possible? If not why?
Beginner question. Started learning Django without knowing HTML, CSS and Javascript. is it possible? If not why? Beginner question. Started learning Django without knowing HTML, CSS and Javascript. is it possible? If not why? -
How to create a single API which takes data of all Employees
I am new to django. I have a model like this: class Standup(models.Model): team = models.ForeignKey("Team", on_delete=models.CASCADE) standup_time = models.DateTimeField(auto_now_add=True) class StandupUpdate(models.Model): standup = models.ForeignKey("Standup", on_delete=models.CASCADE) employee = models.ForeignKey("Employee", on_delete=models.CASCADE) update_time = models.DateTimeField(auto_now_add=True) status = models.CharField(max_length=50) work_done_yesterday = models.TextField() work_to_do = models.TextField() blockers = models.TextField() If I write view for this model, every employee will have to hit API for his/her standup update. But I am supposed create a single API which takes updates of all the employees and saves it into database. In frontend, it will be something like this: Employee will select on a team as one employee can be a part of multiple teams. Then the employee will give his/her stadup updates. Then another employee will do the same thing and so on. At the end,by clicking on submit button, whole data will be saved together. Any guidance on how to do it? -
is there a way to make an infinite loop in django
I want to make a countdown for my website and I can't do it. Please help me I try with a tag "for" but you need the "while" loop which has no tag in django -
overriding validate_unique not raising a ValidationError
I am trying to override the validate_unique for on of my models to validate that a record doesn't exist with duplicate fields (labeler, date), but It's not raising any validation error when i enter duplicate (labeler, date). I've already looked through the issues here and here and constructed my view and model as follows: my view: class AttendanceCreateView(CreateView): model = Attendance template_name = "attendance/attendance_form.html" fields = [ "team_lead", "labeler", "attendance", ] def get_success_url(self): return reverse("attendance-home") my model: class Attendance(models.Model): id= models.AutoField(primary_key=True) attendance = models.IntegerField(blank=True, choices= CHOICES_ATTENDANCE, null=True) labeler = models.ForeignKey('Labelers', models.CASCADE, blank=True, null=True) team_lead = models.ForeignKey('TeamLeads', models.CASCADE, blank=True, null=True) date = models.DateField(auto_now_add=True, null=True) class Meta: managed = False db_table = "attendance" def validate_unique(self, *args, **kwargs): super().validate_unique(*args, **kwargs) if self.__class__.objects.filter(labeler= self.labeler, date= self.date).exists(): raise ValidationError(message='a already record exists for date and labeler',) any idea why my code is not behaving as expected ? thanks is advance. -
Django - stop logout with javascript pop-up confirm box
In my django site I have a logout button that redirects to the view logout. When the button is clicked it instantly logs the user out, but I would like a JS pop-up confirm box to appear then the logout button is clicked. When the user clicks 'Ok' OR 'Cancel' it logs the user out. How can i prevent the logout view being called when the user clicks 'Cancel'? views.py def logout(request): if "user_info" in request.session: del request.session["user_info"] #redirect to login so the user can log back in return redirect("login") script.js function logout_popup() { if (confirm("Are you sure?")) { window.location.reload() } } base.html <li onclick="logout_popup()" id="logout-tab"><a href="{% url 'logout' %}">Logout</a></li> -
Hi, I am using Django rest framework and when I want to encrypt my videos inside sections view I get error can someone help me
I am using Django rest framework and when I want to encrypt my videos inside sections view I get error and I installed cryptography package and I write the code for encrypting and decrypting but when I run the code it gives me error also I add encrypt key inside settings.py here is my code views.py `class ChapterSectionList(generics.ListAPIView): serializer_class=SectionSerializer def get_queryset(self): chapter_id=self.kwargs['chapter_id'] chapter=models.Chapter.objects.get(pk=chapter_id) l=[] for i in chapter_id: i['encrypt_key']=encrypt(i['chapter_id']) i['chapter_id']=i['chapter_id'] l.append(i) return models.Section.objects.filter(chapter=l) ` encryption_util.py `from cryptography.fernet import Fernet import base64 import logging import traceback from django.conf import settings def encrypt(text): try: txt = str(txt) cipher_suite = Fernet(settings.ENCRYPT_KEY) encrypted_text = cipher_suite.encrypt(txt.encode('ascii')) encrypted_text = base64.urlsafe_b64encode(encrypted_text).decode("ascii") return encrypted_text except Exception as e: print(e) logging.getLogger("error_logger").error(traceback.format_exc()) return None def decrypt(txt): try: txt = base64.urlsafe_b64encode(txt) cipher_suite = Fernet(settings.ENCRYPT_KEY) decoded_text = cipher_suite.decrypt(txt).decode("ascii") return decoded_text except Exception as e: logging.getLogger("error_logger").error(traceback.format_exc()) return None` urls.py path('chapter-section-list/<str:chapter_id>/', views.ChapterSectionList.as_view()), I want to get solution to my problem -
how can I get habit count by user in django orm
I would like to get num of habitlog by owner. so, coding api this is my models.py #Models.py class MakingHabit(SoftDeleteModelMixin, TimestampMixin): owner = models.ForeignKey( User, on_delete=models.CASCADE, related_name="making_habits" ) title = models.CharField(_("title"), max_length=255) method = models.CharField(_("method for recording"), max_length=255) class HabitLog(SoftDeleteModelMixin, TimestampMixin): habit = models.ForeignKey( MakingHabit, on_delete=models.CASCADE, related_name="logs" ) date = models.DateField(default=date.today) image = models.FileField(_("evidence image"), null=True, blank=True) this is viewsets.py @action(methods=["GET"], detail=False, url_path="habitrank", url_name="habitrank") def habitrank(self, request, *args, **kwargs): logs = HabitLog.objects.values('habit__owner').annotate(habit_count=Count('date')) for log in logs: print(log) this print enter image description here it's not working what i want. so, I coding different @action(methods=["GET"], detail=False, url_path="habitrank", url_name="habitrank") def habitrank(self, request, *args, **kwargs): logs = HabitLog.objects.values('date').annotate(habit_count=Count('habit__owner')) for log in logs: print(log) it work what i want this print enter image description here why the first query not working? -
Syntax for using {{ article.image }} inside {% static %} with django templates
Trying to display an image on a webpage with django templates {% for article in article_roll %} <li><div class="blog-post" id="blog{{ forloop.counter }}"> {% load static %} <img src="{% static '{{ article.image }}' %}" alt="{{ article.alt }}"> <div class="blog-post-preview"> <span class="blog-title">{{ article.image }} {{ article.title }}</span> <span class="blog-date">{{ article.date }}</span> </div> <span class="blog-text">{{ article.preview }}</span> </div></li> {% endfor %} This is the part that's giving me trouble <img src="{% static '{{ article.image }}' %}" alt="{{ article.alt }}"> {{ article.image }} is an ImageField in an SQLite Database setup with the default configurations django has. My main concern is loading up the correct image for each article as the for loop progresses, but I can't even get {{ article.image }} to evaluate to anything useful within the {% static %} braces. the static url comes out as <img src="/static/%7B%7B%20article.image%20%7D%7D" alt="image thing"> When what I'm trying to get is <img src="/static/value_of_{{article.image}}" alt="image thing"> I've tried escaping characters, avoiding using ' ', and rewriting the urls. I feel like I might be approaching this problem entirely wrong and there's a better way to do it, but I've been looking through the documentation and haven't seen anything obvious to me. -
Can You store a Django model in an ElasticSearch index?
Can I store a Django model in an ElasticSearch index? If yes, then how can I do that? -
Django how to have the command ./manage.py in Windows
I have saw a lot of posts regarding about how to do ./manage.py for windows and linux but i find the instructions unclear as a beginner. I have tried using "chmod +x manage.py" in my django project directory ("C:\Users\user\Django\Project") in windows command prompt and it does not work as it is not recognised by an internal or external command. So how would you be able to remove the keyword "Python" from "python manage.py" and run it as ./manage.py