Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
"127.0.0.1:8000 says Url failed with 404 /ad/1/favorite/" not able to favorite/unfavourite [closed]
I think this issue might be trivial, but, can someone please suggest to me an alternative for this code I did change the structure and wrote it as : I pretty much just changed the way the URL was written, and when I ran my code on localhost and clicked on the star, this is what I get...a prompt saying: 127.0.0.1:8000 says Url failed with 404 /ad/1/favorite/ Kindly tell me, is there anything wrong I'm doing? I'm sure the mistake is somewhere here, but, if not I can also upload code from the views.py and urls.py files... -
Django Best method to create different users
I am creating a School Management System where there should be 3 types of users (Student, Teacher, Authorities). Can anyone please help me in giving me a direction to proceed since I'm stuck in this. -
Why allauth EmailAddress matching query does not exist?
I am using dj-rest-auth packages for auth functionality for apis in my project. But with login endpoint I am getting this error. allauth.account.models.EmailAddress.DoesNotExist: EmailAddress matching query does not exist. When the user who get registered from the web can't login from api endpoint.Do I have to register the email into the allauth Emailaddress Table also if user gets created from web like this. django views def save_user(request): user = form.save() # then create this user email in all auth EmailAddress table ? EmailAddress.objects.create(email=user.email..) ?? rest settings ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_EMAIL_VERIFICATION = "mandatory" ACCOUNT_EMAIL_CONFIRMATION_EXPIRE_DAYS = 1 ACCOUNT_AUTHENTICATION_METHOD = "username" OR is there any settings available so that any active users from the system can login through api endpoint ? -
SMTPAuthenticationError on apache but not in the standard server. DJANGO and Apache2
When I am doing python manage.py runsever 0.0.0.0:8000 Everything is working correctly. I am just using django server by MY_ADRESS_IP:8000 When I am using apache2 on the Centos 7 I have an error when I want to send an email. My settings: EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp.gmail.com' EMAIL_USE_TLS = True EMAIL_PORT = 587 EMAIL_HOST_USER = 'MY_EMAIL_NAME' EMAIL_HOST_PASSWORD = 'MY_EMAIL_PASS' Do I need some special config in apache to let the gmail send emails? Here more error details: Django Version: 3.1.3 Python Version: 3.6.8 Installed Applications: ['sf_platform.apps.SfSplatformConfig', 'sf_users.apps.SfUsersConfig', 'sf_api.apps.SfApiConfig', 'crispy_forms', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware'] Traceback (most recent call last): File "/home/user_name/WEB-Platform/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/home/user_name/WEB-Platform/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 179, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/user_name/WEB-Platform/venv/lib/python3.6/site-packages/django/views/generic/base.py", line 70, in view return self.dispatch(request, *args, **kwargs) File "/home/user_name/WEB-Platform/venv/lib/python3.6/site-packages/django/utils/decorators.py", line 43, in _wrapper return bound_method(*args, **kwargs) File "/home/user_name/WEB-Platform/venv/lib/python3.6/site-packages/django/utils/decorators.py", line 130, in _wrapped_view response = view_func(request, *args, **kwargs) File "/home/user_name/WEB-Platform/venv/lib/python3.6/site-packages/django/contrib/auth/views.py", line 222, in dispatch return super().dispatch(*args, **kwargs) File "/home/user_name/WEB-Platform/venv/lib/python3.6/site-packages/django/views/generic/base.py", line 98, in dispatch return handler(request, *args, **kwargs) File "/home/user_name/WEB-Platform/venv/lib/python3.6/site-packages/django/views/generic/edit.py", line 142, in post return self.form_valid(form) File "/home/user_name/WEB-Platform/venv/lib/python3.6/site-packages/django/contrib/auth/views.py", line 235, in form_valid form.save(**opts) File "/home/user_name/WEB-Platform/venv/lib/python3.6/site-packages/django/contrib/auth/forms.py", line 325, in save … -
Web application could not be started by the Phusion Passenger application server, ModuleNotFoundError - Django [SOLVED]
when I install a third-site application from github with pip install -e git+https://github.com/breduin/das.git#egg=django_ajax_selects my site doesn't start and the following error raises: Web application could not be started by the Phusion Passenger application server. /usr/share/passenger/helper-scripts/wsgi-loader.py:26: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses import sys, os, re, imp, threading, signal, traceback, socket, select, struct, logging, errno Traceback (most recent call last): File "/usr/share/passenger/helper-scripts/wsgi-loader.py", line 369, in <module> app_module = load_app() File "/usr/share/passenger/helper-scripts/wsgi-loader.py", line 76, in load_app return imp.load_source('passenger_wsgi', startup_file) File "/opt/python/python-3.8.6/lib/python3.8/imp.py", line 171, in load_source module = _load(spec) File "<frozen importlib._bootstrap>", line 702, in _load File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 783, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/var/www/u1234567/data/www/mysite/passenger_wsgi.py", line 7, in <module> application = get_wsgi_application() File "/var/www/u1234567/data/env/lib/python3.8/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application django.setup(set_prefix=False) File "/var/www/u1234567/data/env/lib/python3.8/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/var/www/u1234567/data/env/lib/python3.8/site-packages/django/apps/registry.py", line 91, in populate app_config = AppConfig.create(entry) File "/var/www/u1234567/data/env/lib/python3.8/site-packages/django/apps/config.py", line 90, in create module = import_module(entry) File "/opt/python/python-3.8.6/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked ModuleNotFoundError: No module … -
Is there a way to preserve the original HTTP_REFERER when using Django's redirect?
I have a Django site and I'm using Google Analytics to keep track of where my traffic is coming from. I want to route traffic to various places depending on whether the user is signed in, or has done other stuff. So in my views.py, I have a function like this: def toDefaultLandingPage(request): # tell me who the referrer is # this is what I want to pass along in the request if I can print(request.META.get('HTTP_REFERER')) if request.user.is_authenticated: try: configuration = UserData.objects.get(user=request.user) return redirect('/home/') except: # user has not configured their profile yet return redirect('/user/') else: # promo page for non-logged in users return redirect('/about/') This works great, except that Google Analytics says that most of my traffic has no referrer. I know this is a lie, because the print statement in default landing page has either google or facebook in it about 70% of the time. Is there any way to pass the original referrer to the 3 different redirects I use? -
Replacing old file with a new file throws FileNotFound error Django
When I try to replace/upload a new image it calls the function delete_files_when_file_changed but it throws a FIleNotFound error. # Create your models here. def upload_to(instance, filename): now = timezone_now() base, extension = os.path.splitext(filename) extension = extension.lower() name = base + "_" + number_generator(3) instance = instance.shop_name + "_" + name return f"seller/{now:%Y/%m}/{instance}{extension}" """ Only delete the file if no other instances of that model are using it""" def delete_file_if_unused(model,instance,field,instance_file_field): dynamic_field = {} dynamic_field[field.name] = instance_file_field.name other_refs_exist = model.objects.filter(**dynamic_field).exclude(pk=instance.pk).exists() print("OTHER",other_refs_exist) if not other_refs_exist: instance_file_field.delete(False) class Seller(UrlBase): user = models.OneToOneField( User, related_name="sellers", on_delete=models.CASCADE ) token = models.UUIDField(max_length=36, unique=True, blank=True, primary_key=True) shop_name = models.CharField(max_length=256, blank=True, null=True) address_line_1 = models.CharField(max_length=255, blank=True) address_line_2 = models.CharField(max_length=255, blank=True) state = models.CharField(max_length=128, blank=True) city_village = models.CharField(max_length=255, blank=True) postal_code = models.CharField(max_length=20, blank=True) image = VersatileImageField(upload_to=upload_to, ppoi_field="ppoi", blank=True, null=True) ppoi = PPOIField() hero_image = VersatileImageField(upload_to=upload_to, ppoi_field="hero_image_ppoi", blank=True, null=True) hero_image_ppoi = PPOIField() banner_image_1 = VersatileImageField(upload_to=upload_to, ppoi_field="banner_ppoi_1", blank=True, null=True) banner_ppoi_1 = PPOIField() banner_image_2 = VersatileImageField(upload_to=upload_to, ppoi_field="banner_ppoi_2", blank=True, null=True) banner_ppoi_2 = PPOIField() lookup = models.CharField(max_length=120, blank=True, null=True, unique=True) is_verified = models.BooleanField(default=False) is_featured = models.BooleanField(default=False) def __str__(self): return str(self.user) def save(self, *args, **kwargs) -> None: if not self.token: self.token = str(uuid4()) if not self.lookup: self.lookup = ((self.user.first_name + self.user.last_name + self.shop_name).replace(" ", "_")).lower() … -
I am using django for a project and i got this error
I am doing a project in Django and i got this error.How is this occurs? NoReverseMatch at / Reverse for 'create_order' with no arguments not found. 1 pattern(s) tried: ['create_order/(?P[^/]+)/$'] urls.py from django.urls import path from accounts import views urlpatterns = [ path('',views.home, name="home"), path('product/',views.products, name="product"), path('customer/<str:pkid>/',views.customer, name="customer"), path('create_order/<str:pk>/',views.createOrder, name="create_order"), path('update_order/<str:pk>/',views.updateOrder, name="update_order"), path('delete_order/<str:pk>/',views.deleteOrder, name="delete_order"), ] views.py def createOrder(request, pk): customer = Customer.objects.get(id=pk) form = OrderForm(initial={'customer':customer}) if request.method == 'POST': form = OrderForm(request.POST) if form.is_valid: form.save() return redirect('/') context = {'form':form} return render(request, 'accounts/order_form.html', context) order_form.html {% extends 'accounts/main.html' %} {% load static %} {% block content %} <form action="" method="POST"> {% csrf_token %} {{ form }} <input type="submit" name="Submit"> </form> {% endblock %} -
Where can I store the refresh and access token in django
I'm using django and trying to integrate it with quickbooks online through python-quickbooks package and already did so and it works fine, but the problem is I don't want to store the tokens in the request session because I'm trying to access them outside the views, to be exact I'm trying to send an invoice each time an invoice(invoice model from django) object was made I want to send one to quickbooks and I'm doing this through django signals but I can't access the session from the signals so where is the best place to store them on the server side? thanks in advance. -
Can't find static image. Trying to use a tag in a html for loop
so I was trying to use a webp image converter and the template usage is very simple, the example says: <img src="{% static_webp 'img/hello.jpg' %}">` Ok now my problem is that I show my images using a for like this {% for product_object in products_slider %} <div class="banner banner-1"> <img src="{{ product.image.url }}"> </div>{% endfor %} My question is how I can use te static_webp tag and pass the image url of every product on the for?? I tried this but it didn't work :( <img src="{% static_webp 'media/{{ product.image }}'%}"> <!--FAIL--> -
How do I filter values according to logged in user in Django forms?
I have Rank, UserProfile and Company models. These classes are connected with foreign keys. A user with Rank "Lead" can create new users from his dashboard. I want to filter Rank models according to UserProfile's company. In the sign up form there will be dropdown list to choose Rank for new user. There should only be ranks that belong to UserProfile's company. These are my models: class CompanyProfile(models.Model): comp_id = models.UUIDField(default=uuid.uuid4, editable=False, unique=True) comp_name = models.CharField(max_length=200) country = models.CharField(max_length=200, default='') def __str__(self): return self.comp_name class Rank(models.Model): rank_name = models.CharField(max_length=200) company = models.ForeignKey(CompanyProfile, on_delete=models.CASCADE, null=True, unique=False) def __str__(self): return self.rank_name class UserProfile(AbstractUser): company = models.ForeignKey(CompanyProfile, on_delete=models.CASCADE, null=True, unique=False) user_id = models.UUIDField(default=uuid.uuid4(), editable=False, unique=True) username = models.CharField(max_length=500, unique=True) first_name = models.CharField(max_length=200) last_name = models.CharField(max_length=200) password = models.CharField(max_length=250) email = models.EmailField(max_length=254) rank = models.ForeignKey(Rank, on_delete=models.CASCADE, null=True, unique=False) image = models.ImageField(upload_to='profile_image', blank=True, null= True, default='profile.png') def __str__(self): return self.username This is my form: class SignUpForm(forms.ModelForm): password1 = forms.CharField(max_length=250) password2 = forms.CharField(max_length=250) class Meta: model = UserProfile fields = ( 'username', 'first_name', 'last_name', 'email', 'password1', 'password2','rank', 'image') And this is views.py: @user_passes_test(is_lead) @login_required def signup(request): form_class = SignUpForm if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid() : user = form.save() user.refresh_from_db() # load the … -
ValueError: Field 'id' expected a number but got 'favicon.ico'
I am building a BlogApp and I was working on a Feature and Suddenly i saw an Error while server is running. It shows below ↓ Error when i open something in browser. Everything is Working Fine BUT this is keep showing in every Click i do. ValueError: Field 'id' expected a number but got 'favicon.ico'. views.py def detail_view(request,id): data = get_object_or_404(Post,id=id) comments = data.comments.order_by('-created_at') new_comment = None comment_form = CommentForm(data=request.POST) post = get_object_or_404(Post,id=id) if post.allow_comments == True : if request.method == 'POST': if comment_form.is_valid(): comment_form.instance.post_by = data comment_form.instance.commented_by = request.user comment_form.instance.active = True new_comment = comment_form.save() return redirect('detail_view',id=id) else: comment_form = CommentForm() context = {'counts':data.likes.count,'post':post,'data':data,'comments':comments,'new_comment':new_comment,'comment_form':comment_form} return render(request, 'show_more.html', context ) urls.py path('<id>',views.detail_view,name='detail_view'), When i check this Error in Browser, it is showing data = get_object_or_404(Post,id=id) IT MEANS that the error is in this line in Views.py. I don't know what's wrong in this. Any help would be appreciated. Thank You in Advance. -
Change Shape of JSON Serialized Object Django REST Framework
I'm trying to change the structure of my serialized JSON in Django. Currently it looks like this: { "id": 1, "dates": [ { "date": "2021-02-03", "entry_id": 1, "indicator": "D" }, { "date": "2021-02-04", "entry_id": 1, "indicator": "D" }, { "date": "2021-02-05", "entry_id": 1, "indicator": "2" } ], }, { "id": 2, "dates": [ { "date": "2021-02-09", "entry_id": 2, "indicator": "K" }, { "date": "2021-01-10", "entry_id": 2, "indicator": "K" }, { "date": "2021-01-11", "entry_id": 2, "indicator": "K" }, { "date": "2021-01-18", "entry_id": 2, "indicator": "K" } ] } However I am aiming for a response that is structured like this: { "id": 1, "dates": { "20210203": "D", "20210204": "D", "20210205": "2" } }, { "id": 2, "dates": { "20210209": "K", "20210110": "K", "20210111": "K", "20210118": "K" } } Currently my simplified models+serializers like this: class Dates(models.Model): date: date = models.DateField(verbose_name='Datum') indicator: str = models.CharField(max_length=1, null=True, default=None, blank=True, verbose_name='Indikator') entry: Entry = models.ForeignKey(Entry, on_delete=models.PROTECT, related_name='bookings') class Entry(models.Model): pass class EntrySerializer(serializers.ModelSerializer): dates = DateSerializer(many=True) class Meta: model = Entry fields = ('id', 'dates',) read_only_fields = ('id',) class DatesSerializer(serializers.ModelSerializer): entry_id = serializers.PrimaryKeyRelatedField(queryset=Dates.objects.all(), source='entry.id') class Meta: #depth = 1 model = Dates fields = ( 'date', 'entry_id', 'indicator' ) read_only_fields = ('date', 'entry_id') def create(self, … -
Django get form errors after redirect
I have a page that shows the details of a person. On the same page it also shows the many friends that the person has. I have a button that lets me add a friend to the person, when I click on it, a bootstrap modal shows. /person/10 (this is the person's page) /person/10/add-friend (this is the POST endpoint to add a friend) If the form data is valid, the new friend is added to the person and is redirected back to the person details page. The problem is, if the data is invalid, I can't seem to get the form errors after the redirect. def add_friend(request, id=None): person = get_object_or_404(Person, pk=id) form = FriendForm(request.POST) if form.is_valid(): # code to save the friend to the person #here I want to send the form errors if the form failed, but don't think we can send context with redirect return redirect('person_detail', id=person.pk) Many say that I should render the persons detail page and send the form as context if the form validation fails, but the problem is, the URL will be /person/10/add-friend instead of /person/10 Am coming from PHP/Laravel, doing something like what I want above is just too simple/basic, but can't … -
DRF order by custom field (non-model) in serializers
I am trying to sort objects based on custom field but cannot find how to do it. The queryset must include car objects sorted by number of ratings. For instance, car1 has 3 rates, car2 has 1 rate, so car1 should be a first in the queryset. models.py from django.db import models class Car(models.Model): make_name = models.CharField(max_length=255) model_name = models.CharField(max_length=255) def __str__(self): return f"{self.make_name}-{self.model_name}" class Rate(models.Model): car = models.ForeignKey('Car', on_delete=models.CASCADE, related_name='car') rate = models.IntegerField() def __str__(self): return self.car.model_name serializers.py class PopularCarSerializer(serializers.ModelSerializer): class Meta: model = Car fields = ('make_name', 'model_name',) read_only_fields = ('id',) views.py class PopularCarViewSet(viewsets.GenericViewSet,generics.ListAPIView): serializer_class = serializers.PopularCarSerializer def get_queryset(self): # How to order cars based on number of rates? ordered_queryset = Rate.objects.values('car').annotate(total_rates=Count('car')).order_by('-total_rates') Currently the ordered_queryset returns the result below: <QuerySet [{'car': 3, 'total_rates': 5}, {'car': 1, 'total_rates': 4}, {'car': 2, 'total_rates': 1}]> Once I return it the Django throws an error that fields are not matching. I understand it, but how I can make a sorted query based on number of rates that will get fields of car model? Thanks for any help. -
Return JSON for objects related with ManyToManyField
I have built an API for my portfolio site with the Django REST Framework. I want to show the stack I used for each project so I made a Skill model for things like Python, Javascript etc.. My Project model has a ManyToManyField for choosing each technology I used. This works great however I want the JSON I get back to contain the whole object for each Skill. Currently I just get an array of the ids. Here are my models class Skill(models.Model): title = models.CharField(max_length=255) image = models.FileField(upload_to="skills/", validators=[FileExtensionValidator(['svg'])]) def __str__(self): return self.title class Project(models.Model): project_image = models.ImageField(upload_to="projects/") project_title = models.CharField(max_length=50) project_stack = models.ManyToManyField(Skill, blank=True) def __str__(self): return self.project_title My endpoint returns the following JSON for each project: { "id": 1, "project_image": "/media/projects/161044437967.png", "project_title": "Example Project", "project_stack": [ 1, 4, 14 ] } I'd like project_stack to return the entire object rather than the ids. Desired output { "id": 1, "project_image": "/media/projects/161044437967.png", "project_title": "Example Project", "project_stack": [ {"id": 1, "title": "Python", "image": "/media/skills/161044437967.png"}, {"id": 4, "title": "Javascript", "image": "/media/skills/160444437964.png"}, {"id": 14, "title": "CSS", "image": "/media/skills/161044422965.png"}, ] } serializers.py class ProjectSerializer(serializers.ModelSerializer): class Meta: model = Project fields = '__all__' views.py @api_view(['GET']) def project_detail(request, slug): project = get_object_or_404(Project, project_slug=slug) serializer = … -
Get element id from django queryList in template using ajax
I'm getting queryList in django and want to add it to 'table' in template using ajax (hope that i do and understand all correct, as I'm new in jquery & ajax). in table i see all needed info except record's ID. instead id it shows 'undefined'. What's going wrong? template.html table id="list_data" data-toggle="table" url = "{% url 'data_a:listing' %}" thead tr th id /th ... /tr /thead tbody id="listing" /tbody /table GetDAta.js: function putTableData(result) { let row; let dd; if(result["results"].length > 0){ $("#no_results").hide(); $("#list_data").show(); $("#listing").html(""); $.each(result["results"], function (a, b) { row = "<tr> <td>" + b.id + "</td>" + "<td>" + b.title + "</td>" + "<td>" + b.text + "</td>" + "<td>" + b.comment + "</td>" + "<td>" + b.create_date + "</td></tr>" $("#listing").append(row); }); } } template table: id | title | text |... undefined | a | a_text |... undefined | aw | aw_text |... undefined | qqa | qqa_text |... -
Django returns SQL Syntax Error when using ExpressionWrapper and F expressions - what I do wrong?
So, I encountered interesing problem, I write booking/reservation system with API and wanted to check if reservation exists, because I want to exclude them from response - I want to return only available reservation slots in specific intervals. For example, global interval is 15 minutes, when somebody place reservation of service at 8:05 to 8:20, reservation slots 8:00-8:15 and 8:15-8:30 are excluded from 'AvailableReservationsTerms' view response. I wrote this code to check for reserved slots: duration_expression = ExpressionWrapper( datetime.timedelta(minutes=1) * F('duration'), output_field=DurationField()) booking_end = ExpressionWrapper( F('booking_dt') + duration_expression, output_field=DateTimeField()) booking_qs.annotate( booking_end=booking_end).get( Q(Q(booking_dt__lte=first_interval), Q(booking_dt__gte=next_interval)) | Q(Q(booking_end__lte=first_interval), Q(booking_end__gte=next_interval))) Not really sure if I should use python logic instead of ORM, but ORM seems to be faster to implement despite I probably send many queries for checking every internal and I hit the database. Anyway... I get this error: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* `carwashes_carwashbooking`.`duration`) MICROSECOND) AS `booking_end` FROM `car' at line 1") SQL query that is sent to db: ('SELECT `carwashes_carwashbooking`.`id`, ' '`carwashes_carwashbooking`.`carwash_id`, ' '`carwashes_carwashbooking`.`created_dt`, ' '`carwashes_carwashbooking`.`booking_dt`, ' '`carwashes_carwashbooking`.`duration`, `carwashes_carwashbooking`.`car_id`, ' '`carwashes_carwashbooking`.`car_name`, `carwashes_carwashbooking`.`plate`, ' '`carwashes_carwashbooking`.`status`, `carwashes_carwashbooking`.`driver_id`, ' '`carwashes_carwashbooking`.`phone_number`, ' '`carwashes_carwashbooking`.`service_id`, … -
Cron job in linux is setup using django but not working
I scheduled cron job using django it is showing in logs but it is not working code: settings.py: INSTALLED_APPS = [ 'django_crontab', 'django_apscheduler', ] CRONJOBS = [ ('*/1 * * * *', 'allActivitiesApp.cron.sendNotification', '>> /path/to/log/file.log'), ] allActivitiesApp->cron.py: from .models import * def sendNotification(): # notificationList = dateBasedNotificaton.objects.filter(scheduleDate = date.today()) obj = test(name="working") obj.save() obj.refresh_from_db() # print("sending notifications/messages") return "success" I dont think there is any problem in code I think the problem is in operating system. when I check the scheduled jobs using crontab -e, it is showing: the 2nd part was added by me when I was trying to debug it. crontab -l is showing scheduled tasks: (env) karanyogi@karanyogi:~/E-Mango/Jan27New/eMango$ crontab -l MAILTO = "karankota01@gmail.com" */1 * * * * /home/karanyogi/E-Mango/env/bin/python /home/karanyogi/E-Mango/Jan27New/eMango/manage.py crontab run 60a198cfdc0c719d07735a708d42bafb >> /path/to/log/file.log # django-cronjobs for iStudyMain MAILTO = "karankota01@gmail.com" */1 * * * * /home/karanyogi/E-Mango/env/bin/python /home/karanyogi/E-Mango/Jan27New/eMango/manage.py sendNotification --settings=iStudyMain.settings.development when I checked system's logs I get this: the highlighted line is showing that job is running but why it is not performing task...?????? I wasted 4-5 days in trying to figuring out what is wrong, but I can't. Someone please help. -
Django/SCSS: missing staticfiles manifest
I try to use SCSS in my Django project using django_compressor et django libsass stack: Django/Nginx/Postgresql/Docker I have configured 2 environment of development: dev and preprod I got an error: valueerror: missing staticfiles manifest entry for 'theme.scss' I did not understand because it has worked bt I've tryed to delete container/images/volumes and rebuild all my project and got this error I've tryed DEBUG = True, STATIC_ROOT = 'static'... but nothing works logs only raise this error settings -> preprod.py - app - core - static - bootstrap - css - js - theme.scss - nginx DEBUG = False STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, "static") STATICFILES_FINDERS = [ 'compressor.finders.CompressorFinder', ] COMPRESS_PRECOMPILERS = ( ('text/x-scss', 'django_libsass.SassCompiler'), COMPRESS_ENABLED = True COMPRESS_OFFLINE = True LIBSASS_OUTPUT_STYLE = 'compressed' STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage' ) entrypoint.preprod.sh python manage.py collectstatic --no-input python manage.py compress --force docker-compose.preprod.yml version: '3.7' services: web: restart: always container_name: web build: context: ./app dockerfile: Dockerfile.preprod restart: always command: gunicorn core.wsgi:application --bind 0.0.0.0:8000 volumes: - app_volume:/usr/src/app - static_volume:/usr/src/app/static - media_volume:/usr/src/app/media expose: - 8000 env_file: - ./.env.preprod depends_on: - db - redis healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8000/"] interval: 30s timeout: 10s retries: 50 redis: container_name: redis image: "redis:alpine" celery: container_name: celery build: context: ./app dockerfile: … -
social_auth for django tenant schemas
I'm new to using django tenant schemas and social auth. Is there any documentation regarding logging into tenant schemas using social_auth(Google authentication). Please point me to the link if there are any.Thanks -
Django sum of objects filtered by date view
I want to get sum of items i get by using generic date view. Example views.py class OrderDayArchiveView(LoginRequiredMixin, generic.dates.DayArchiveView): queryset = Order.objects.all() date_field = 'date_ordered' template_name = 'ordersys/manager/archive_page.html' Example template: {% for order in object_list %} <li class="bg-light"> {{ order.id }}: {{order.print_ordered_items_products_amounts}} (${{order.create_cost}}) </li> {% endfor %} Example path in urls.py: path('<int:year>/<int:month>/<int:day>/', views.OrderDayArchiveView.as_view(month_format='%m'), name="archive_day"), I want to get sum of all 'order.create_cost' sent to template, is it possible to get filtered queryset in this view? If not, how can i sum it in the template. -
Read SAML User ID after login from Okta using django,python
I have used the django-saml2-auth - https://pypi.org/project/django-saml2-auth/ library to login into my django application from Okta. Post successful login into okta, when I click on my application's tab I even get redirected to my application's login page. I want to read the User name using which the user logged into Okta and validate it and redirect the user to my home page and not login screen. The issue is I'm not able to retrieve the user name for Okta Login. I have also installed SAML Tracer in Firefox and there I am able to see Username. I don't know how to fetch it in python. -
How do I add a Django project to process manager (PM2)?
I have got a Django project and I wanna add it to PM2. How can I do that? -
slatejs don't work after npm run build in react and collectstatic in django
I have a django+reactjs app and I link them using npm run build and './manage.py collectstatic and it works very well. However, when I use slatejs after i ran './manage.py collectstatic I got this error 0 static files copied to '/Users/apple/Desktop/docs_editor-social_site/staticfiles', 176 unmodified, 400 post-processed. I got the following error Failed to load resource: the server responded with a status of 404 (Not Found) after I ran ./manage.py runserver while I got no errors with npm start