Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
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 -
Payment redirect not working correctly when the user clicks submit button
I'm building an ecommerce store with Django and I want that when the user selects a payment, he gets redirected to that specific payment option. Meaning that when someone clicks Stripe, it should go to the Stripe's checkout and when he clicks Paypal, it should direct them tothat option. But as for now, when the user clicks the button to proceed it does nothing. I've alread made all the form validations and the payment_option's so that it redirects correctly. views.py: class CheckoutView(View): def get(self, *args, **kwargs): try: order = Order.objects.get(user=self.request.user, ordered=False) form = checkoutForm() context = { 'form': form, 'order': order, } shipping_address_qs = Address.objects.filter( user=self.request.user, address_type='S', default=True ) if shipping_address_qs.exists(): context.update( {'default_shipping_address': shipping_address_qs[0]}) except ObjectDoesNotExist: messages.info(self.request, "You do not have an active order") return redirect("core:checkout") return render(self.request, "ecommerceapp/checkout.html", context) def post(self, *args, **kwargs): form = checkoutForm(self.request.POST or None) try: order = Order.objects.get(user=self.request.user, ordered=False) if form.is_valid(): use_default_shipping = form.cleaned_data.get( 'use_default_shipping') if use_default_shipping: print("Using the defualt shipping address") address_qs = Address.objects.filter( user=self.request.user, address_type='S', default=True ) if address_qs.exists(): shipping_address = address_qs[0] order.shipping_address = shipping_address order.save() else: messages.info( self.request, "No default shipping address available") return redirect('core:checkout') else: print("User is entering a new shipping address") street_address = form.cleaned_data.get( 'street_address') appartment_suite = form.cleaned_data.get( 'appartment_suite') town_city … -
Save data into Model and get data from Model
Hi I'm building a Webshop with a cart and checkout function. Now I'm trying to save the cart data in a Django Model so I can retrieve it. Now my question is how could I do that? and how can I get the data from an model? Here are my models: This is the model I want to save the data in: class MessageItem(models.Model): customer = models.ForeignKey(Customer, on_delete=models.SET_NULL, blank=True, null=True) mItem = models.CharField(max_length=255, null=True) mQuantity = models.CharField(max_length=255, null=True) # Could also be an Integer! mOrderItem = models.CharField(max_length=255, null=True) Here are my other models: class Customer(models.Model): user = models.OneToOneField(User, null=True, blank=True, on_delete=models.CASCADE) name = models.CharField(max_length=200, null=True) email = models.CharField(max_length=200) class Product(models.Model): name = models.CharField(max_length=200, null=True) price = models.FloatField() digital = models.BooleanField(default=False, null=True, blank=False) # Nicht nötig image = models.ImageField(null=True, blank=True) class Order(models.Model): customer = models.ForeignKey(Customer, on_delete=models.SET_NULL, blank=True, null=True) date_ordered = models.DateTimeField(auto_now_add=True) complete = models.BooleanField(default=False, null=True, blank=False) transaction_id = models.CharField(max_length=200, null=True) class OrderItem(models.Model): product = models.ForeignKey(Product, on_delete=models.SET_NULL, null=True) order = models.ForeignKey(Order, on_delete=models.SET_NULL, null=True) quantity = models.IntegerField(default=0, null=True, blank=True) date_added = models.DateTimeField(auto_now_add=True) Here is my View: I Want to save: item.product.name, item.quantity and items into the model. @login_required(login_url='login') def cart(request): # If user logged in or not (Handling orders in cart) if request.user.is_authenticated: … -
Display posts made by a user one by one in django
I am making this simple blog site in django. My friend working on the frontend made a user profile page which shows all the posts made by the user. My problem is that I know how to render out all the posts using {% for bl in blog %} but this lists down all the posts made by the user together but the user profile page is such that it creates these small boxes in which I wish to show only one post title and a read more to open the post but I am not able to show single posts. I want other posts to be in their respecitve boxes. Is there any way to show single posts without using the for loop. Here is the views.py num_post = BlogPost.objects.filter(author=request.user.id).count() blogs = BlogPost.objects.filter(author=request.user.id).order_by('-time') return render(request, "user_blog.html", {'blog': blogs, 'user':user }) Here is the model: author = models.ForeignKey(User, default=None, on_delete=models.CASCADE) title = models.CharField(max_length=30) editor = RichTextField() topic = models.CharField(max_length=25) time = models.DateField(default=now) Here is the block in html where I am trying to show the data. <div class="card2"> <img src="{% static 'images/2.jpg' %}" alt="Avatar" style="width:100%"> <div class="container"> <h4>Blog author: {{ blog.author }}</h4> <h4><b>Blog Heading: {{ blog.title }}</b></h4> <p>Some intro of … -
Django Microsoft AD Authentication
I noticed that this question was repeated few times, but still, from all the resources, I couldn't manage to make it work properly. I'm simply trying to use Azure Active Directory authentication with my Django app. I am using this module, and I configured everything as noted in the docs. The thing is - I can't figure out where should user enter the credentials - since the module has only one url ('auth-callback/'). I can't find out how to jump to Microsoft login html page. Should I use my login.html or? Also, I guess that 'auth-callback/' url is obviously a callback URL, which comes after the login page. In terms of Redirect URI's I configured redirect URI to match directly the 'http://localhost:8000/microsoft/auth-callback/' url, which is also how it needs to be I guess. Main problem is - where can I enter the credentials for login? :) Also, when I try this - I get invalid credentials error on my Admin login page : Start site and go to /admin and logout if you are logged in. Login as Microsoft/Office 365/Xbox Live user. It will fail. This will automatically create your new user. Login as a Password user with access to … -
www.name.co and name.co redirects to different pages. Using Django, Heroku, and got the domain from GoDaddy
sorry if I'm writing this in a wrong way but this is my first time writing on stackoveflow. I am building a website on django/heroku and I bought the domain from godaddy. Works perfectly locally and works perfectly on www.name.co, but it takes me to the godaddy 'This Web page is parked FREE, courtesy of GoDaddy.' when i go to name.co Can be seen on the screenshot provided here. https://i.stack.imgur.com/oI05H.jpg I've added www.name.co, *.name.co, and name.co on the domains panel on heroku And I've put the DNS Target of *.name.co on GoDaddy's CNAME. Allowed hosts on my settings.py are like this ALLOWED_HOSTS = ['star (can't put it here for somer eason','name.herokuapp.com','127.0.0.1','0.0.0.0', '*.name.co', 'www.name.co','name.co'] Am I doing something wrong? -
Jquery paginator
I have a table and a jquery paginator linked to it. How can I add a second table with a separate paginator linked to it? I tried using different class names but that didn't work. I highly appreciate any assistance scripts: <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/jquery.jold.paginator/jquery.jold.paginator.min.js"></script> html table: <div class="card-body"> <div class="items-container"> {% for key, value in bing.iterrows %} <div class="item item-visible"><a href="{{bing.link}}" target="_blank"> <small class="text-muted">source/{{ bing.source }} : </small>{{ bing.title }} </a></div> {% endfor %} </div> </div> <ul class="pagination-container" ></ul> plugin script: (function($){ var paginator = new $('.items-container').joldPaginator({ 'perPage': 4, 'items': '.item', 'paginator': '.pagination-container', 'indicator': { 'selector': '.pagination-indicator', 'text': 'Showing items {start}-{end} of {total}', } }); })(jQuery); -
How can i make a GET request and return a response to iframe using Django
I have created already a HTML form <form action = "defaut" method = "GET"> Number: <input type="text" name="number" id="number" value=""> Input: <input type="text" name="input" id="input"> newRequest: <input type="text" name="date" id="date" value="0 or 1"> <input type="submit" value="Go" name="go" id="go"> </form> # Views.py def home(request): return render(request, 'myproject/home.html') def defaut(request): message = int(request.GET["input"]) msisdn = int(request.GET["number"]) msc = millis newRequest = int(request.GET["date"]) payloads = dict(input=input, number=number, newRequest=newRequest) res = requests.get("xxxxxx?", params=payloads) print(res.url) return HttpResponse('<h2>asdafasafas </h2>') # from url.py from django.contrib import admin from django.urls import path from qaprojects import views from django.conf import settings from django.conf.urls.static import static urlpatterns = [ path('home.html', views.home), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) my issue is that i am getting: sing the URLconf defined in localtool.urls, Django tried these URL patterns, in this order: home.html ^static/(?P.*)$ The current path, default, didn't match any of these. -
TranslatablePage matching query does not exist wagtail custom menu issue
when i am creating wagatil menu translatable page does not exist error display {% load wagtailimages_tags cms_tags %} {% get_menu "main" None request.user.is_authenticated as navigation %} <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="navbar-nav ml-auto mr-5"> {% for item in navigation %} {% get_menu item.slug item.page request.user.is_authenticated as submenu %} <li class="{% if submenu %}dropdown {% endif %}p-2"> <div class="dropdown show"> <a href="{{ item.url }}" {% if submenu %} class="menuitem dropdown-toggle {% if item.icon %}menuicon{% endif %}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" {% else %} data-toggle="tooltip" title="{{ item.title }}" class="menuitem" {% endif %} > {% if item.icon %} {% image item.icon fill-30x30 class="image-menu" %} {% else %} {{ item.title }} {% endif %} </a> {% if submenu %} <div class="dropdown-menu"> {% for subitem in submenu %} <a href="{{ subitem.url }}" class="dropdown-item menuitem p-2 {% if subitem.icon %}menuicon{% endif %}"> {% if subitem.icon %} {% image subitem.icon fill-30x30 class="image-menu" %} {% else %} {{ subitem.title }} {% endif %} </a> {% endfor %} </div> {% endif %} </div> </li> {% endfor %} </ul> </div> -
ERROR H10 App crashed on HEROKU (Django application)
Pls Can someone guide me to solve this error, I want to host my application on Heroku but I'm getting this error. I'm new to this field. I'm getting this error. 2021-02-04T01:05:38.874590+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=grouppublishingindiastore.herokuapp.com request_id=8c528157-dd3c-498a-a86b-a5aabe7796ed fwd="103.252.25.21" dyno= connect= service= status=503 bytes= protocol=https 2021-02-04T01:05:39.670246+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=grouppublishingindiastore.herokuapp.com request_id=3a0b8aa0-94cf-443b-b6b5-a7fab4140f81 fwd="103.252.25.21" dyno= connect= service= status=503 bytes= protocol=https This is my Procfile: web: gunicorn grouppublishingindia:Inventory