Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
- 
        Which way shall I use foreign key in DjangoI have two models, Employee and Withdraw. Which way shall I do the referencing? Like this, as Employee have 0-many withdraws, class Withdraw(models.Model): amount = models.IntegerField(default=0) class Employee(models.Model): name = models.CharField(max_length=200) withdraw = models.ForeignKey(Withdraw, on_delete=models.CASCADE, null=True, blank=True) OR class Withdraw(models.Model): amount = models.IntegerField(default=0) employee = models.ForeignKey(Employee, on_delete=models.CASCADE) class Employee(models.Model): name = models.CharField(max_length=200) What are the pros/cons? Which would you use?
- 
        How to access media files uploaded via a Django form?I am accepting an image from the user in a form in Django. How do I access the uploaded image to show it in the web browser? This is what I have in settings.py MEDIA_ROOT = os.path.join(BASE_DIR,'media') MEDIA_URL = '/media/' This is in my models.py class Hotel(models.Model): name = models.CharField(max_length=50) image = models.ImageField(upload_to="images/") Also, I have added the if settings.DEBUG: urlpatterns +=static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT) in urls.py I tried to access the image as def image_view(request): if request.method=='POST': farm = hotelForm(); form = hotelForm(request.POST,request.FILES) if form.is_valid(): form.save() modelff = Hotel(name=request.POST['name'],image = request.FILES['image']) # print(modelff.image.url) return render(request,'djangoform.html',{"form":farm,"uploaded_data_url":modelff.image.url}) else: form = hotelForm() return render(request,'djangoform.html',{"form":form}) And in my template, I accessed the image as <img src="{{uploaded_data_url}}">. But the image does not show up and the console shows image not found. P.S. I have seen How to access media files in django How to access uploaded files in Django? https://docs.djangoproject.com/en/dev/howto/static-files/#serving-files-uploaded-by-a-user-during-development Django : accessing uploaded picture from ImageField But none of them seem to help me. I can't find how do I include the 'images/' in my path. My uploaded_data_url shows /media/Screenshot%202020-04-18%20at%206.39.24%20PM.png while I expect it to show /media/images/Screenshot%202020-04-18%20at%206.39.24%20PM.png Where is the problem? Also, if there can be something similar to How can I get …
- 
        How should I do a survey which shows a brownian motion which depends on the answer?I want to do a survey in which you write the amount you want to invest, then you see simulations (brownian motions) of different portfolios that you could choose, and then you answer which one you choose. I know how to use Python and Matplotlib, but I don't know how to use Django, which I guess that would be an option. I don't have any web development experience either. What do you thing that would be the easiest way to do it? Django with some webhost? I hope there is an easier solution. Thank you very much
- 
        How do you use the django rest framework serializer to populate a reverse relationship in a m2m mapping?Here's what I have class Component(models.Model): risks = models.ManyToManyField(Risk) ... class Risk(models.Model): label = models.TextField() ... class RiskSerializer(serializers.HyperlinkedModelSerializer): severity = serializers.SlugRelatedField(queryset=Severity.objects.all(), slug_field='label') class Meta: model = Risk fields = [ 'id', 'label', 'severity', ... ] def create(self, validated_data): print('foo', validated_data) instance = super().create(validated_data) if validated_data.get('component_id'): component = Component.objects.get(id=validated_data.get('component_id')) component.risks.add(instance) return instance What I'm trying to accomplish is I'm trying to create a new Risk using the serializer for an existing component object. Like so: risk = RiskSerializer(data={ 'label': 'foo bar' 'component_id': component.id ... }) risk.is_valid() risk = risk.save() The idea is that if I can pass the component_id then I could override the create method to somehow find and the component object, create it, and then add it to it. But unfortunately because the serializer validates the data and component_id isn't a field that should be there I can't do it this way, the create method won't ever find the component object. What's the correct way to populate Component's risk m2m field?
- 
        Using custom querysets in deep foreignkey Django FiltersI have a model called Users, it derives from a SoftDelete model I've developed. That model has additional querysets defined using models.Manager. This allows me to query the Users model in teh following manner: Users.objects.all() # just the non-deleted objects Users.objects_with_deleted.all() # fetch all, including the deleted. Now let's assume I have a model called Service. It has a manager, expressed with a foreign key to User. manager = models.ForeignKey(User, db_index=True, null=True, on_delete=models.PROTECT) I have an issue running queries like this: services = Service.objects.filter(manager__style="micromanagement") It will return Service objects referencing a soft-deleted User records. It's as if it's not using the default objects queryset I defined for the Users model, prohibiting the fetching of soft-deleted records. Is there a way to instruct filter to use a particular queryset when looking at User records in the deep __style= query? Other than explicitly specifying all the fields that are considered in the custom objects queryset I defined for Users model. It seems counter-intuitive and wasteful, not to mention error-prone and dangerous to re-specify the details of the default objects queryset already override for the Users model into every single query in every single file that tries to deep-filter by it.
- 
        Link to a module member in SpinxI have a file named models.py which contains a list named CC_TYPES. This exists outside any other class in this file: ... CC_TYPES = ( ('VIS', 'Visa'), ('MAS', 'Master Card'), ('AMX', 'American Express'), ('DIS', 'Discover') ) """Types of credit cards accepted""" class Address(models.Model): """Address information for the 50 US states and Washington DC. **Referenced BY:** :class:`Organization`, :class:`User`""" ... I have CC_TYPES referenced in the Sphinx docs and it is rendering correctly: .. automodule:: eBiz.common.models :members: CC_TYPES What I can't figure out how to do is link from docstring to the CC_TYPES section. I have tried: """Credit Card Type Used. Valid values are listed in `eBiz.common.models.CC_TYPES`_ """ But this gives WARNING: Unknown target name
- 
        In Django, how can I delete object inside template by clicking link?I made a notification system. When "B" user comments at "A" user's post, notification sends to A. This is my part of my code. models.py from django.db import models from freeboard.models import FreeBoardComment from users.models import CustomUser class Notification(models.Model): TYPE_CHOCIES = ( ("FreeBoardComment", "FreeBoardComment"), ) creator = models.ForeignKey(CustomUser, on_delete=models.CASCADE, null=True, related_name="creator") to = models.ForeignKey(CustomUser, on_delete=models.CASCADE, null=True, related_name="to") notification_type = models.CharField(max_length=50, choices=TYPE_CHOCIES) comment = models.CharField(max_length=1000, blank=True, null=True) post_id = models.IntegerField(null=True) class Meta: ordering = ["-pk"] def __str__(self): return "From: {} - To: {}".format(self.creator, self.to) notification/views.py from django.views.generic import ListView from .models import Notification def create_notification(creator, to, notification_type, comment, post_id): if creator.email != to.email: notification = Notification.objects.create( creator=creator, to=to, notification_type=notification_type, comment=comment, post_id=post_id, ) notification.save() class NotificationView(ListView): model = Notification template_name = "notification/notification.html" freeboard/views.py ... @login_required def comment_write(request, pk): post = get_object_or_404(FreeBoardPost, pk=pk) if request.method == 'POST': form = CreateFreeBoardComment(request.POST) if form.is_valid(): comment = form.save(commit=False) comment.comment_writer = request.user comment.post = post comment.save() # 포인트 award_points(request.user, 1) ### NOTIFICATION PART!!!! ### create_notification(request.user, post.author, "FreeBoardComment", comment.comment_text, post.pk) ### NOTIFICATION PART !!! ### return redirect("freeboard_detail", pk=post.id) else: form = CreateFreeBoardComment() return render(request, "bbs/freeboard/free_board_comment.html", {"form": form}) notification.html {% extends "base.html" %} {% block css_file %} <link href="/static/css/notification/notification.css" rel="stylesheet"> {% endblock %} {% block content %} <ul class="list-group"> …
- 
        How to login to a user already created without password?I have a web page developed in django that uses the django authentication system. To log in to a user, I need their username and password, but I would like to create a login that allows me to enter only by entering the username without the need to use a password, is this possible? Django View class LoginView(SuccessURLAllowedHostsMixin, FormView): """ Display the login form and handle the login action. """ form_class = AuthenticationForm authentication_form = None redirect_field_name = REDIRECT_FIELD_NAME template_name = 'registration/login.html' redirect_authenticated_user = False extra_context = None @method_decorator(sensitive_post_parameters()) @method_decorator(csrf_protect) @method_decorator(never_cache) def dispatch(self, request, *args, **kwargs): if self.redirect_authenticated_user and self.request.user.is_authenticated: redirect_to = self.get_success_url() if redirect_to == self.request.path: raise ValueError( "Redirection loop for authenticated user detected. Check that " "your LOGIN_REDIRECT_URL doesn't point to a login page." ) return HttpResponseRedirect(redirect_to) return super().dispatch(request, *args, **kwargs) def get_success_url(self): url = self.get_redirect_url() return url or resolve_url(settings.LOGIN_REDIRECT_URL) def get_redirect_url(self): """Return the user-originating redirect URL if it's safe.""" redirect_to = self.request.POST.get( self.redirect_field_name, self.request.GET.get(self.redirect_field_name, '') ) url_is_safe = is_safe_url( url=redirect_to, allowed_hosts=self.get_success_url_allowed_hosts(), require_https=self.request.is_secure(), ) return redirect_to if url_is_safe else '' def get_form_class(self): return self.authentication_form or self.form_class def get_form_kwargs(self): kwargs = super().get_form_kwargs() kwargs['request'] = self.request return kwargs def form_valid(self, form): """Security check complete. Log the user in.""" auth_login(self.request, form.get_user()) …
- 
        Django 3 . Save Pillow Image to ImageFieldI am migrating some code to python 3 and django 3. The image that is being saved is doesn't work, this is the error: Error interpreting JPEG image file (Not a JPEG file: starts with 0x78 0x73) This is the code: import requests from io import StringIO, BytesIO from PIL import Image r = requests.get(img_url) image = Image.open(BytesIO(r.content)) img_file = ContentFile(image.tobytes(), slugify("0_" + card.nombre)) card.image_base.save("0_" + carta_obj.nombre, img_file, save=True) card.image_base is a ImageField. Is there a standard process for this? Pillow + BytesIO + Django?
- 
        'EquipmentOrder' object has no attribute 'equipments'I am trying to add a new e-commerce feature to my python/django project and i keep on getting an error when i use the add to cart button. I am really frustrated because i have been battling it out for weeks now i really need help. Thanks in advance. here is the EquipmentOrder model class EquipmentOrder(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) equipment = models.ManyToManyField(EquipmentOrderItem) start_date = models.DateTimeField(auto_now_add=True) ordered_date = models.DateTimeField() ordered = models.BooleanField(default=False) objects = models.Manager() def __str__(self): return self.user.username here is the add to cart view def add_to_cart(request, slug): equipment = get_object_or_404(models.Equipment, slug=slug) equipment_order_item, created = models.EquipmentOrderItem.objects.get_or_create( equipment=equipment, user=request.user, ordered=False ) equipment_order_qs = models.EquipmentOrder.objects.filter(user=request.user, ordered=False) if equipment_order_qs.exists(): equipment_order = equipment_order_qs[0] # check if equipment order item is in order if equipment_order.equipment.filter(equipment__slug=equipment.slug).exists(): equipment_order_item.quantity += 1 equipment_order_item.save() messages.info(request, "This item quantity was updated.") else: messages.info(request, "This item was added to your cart.") equipment_order.equipments.add(equipment_order_item) else: ordered_date = timezone.now() equipment_order = models.EquipmentOrder.objects.create(user=request.user, ordered_date=ordered_date) equipment_order.equipments.add(equipment_order_item) messages.info(request, "This item was added to your cart.") return redirect("create:equipment_detail", slug=slug)
- 
        StreamingHttpResponse: return database connection to poolIf you have a StreamingHttpResponse returned from a Django view, when does it return any database connection to the pool? If by default it does it once the StreamingHttpResponse has completed, is there a way to make return the connection earlier? def my_view(request): # Some database queries using the Django ORM def yield_data(): # A generator, and # no database queries using the Django ORM return StreamingHttpResponse( yield_data(), status=200 )
- 
        validation on createview djangoI am using generic create view to create a product , the code below creates a product, but how can I raise an error if a product name is duplicated in DB, or product already exist . in model product name is required =True class ProductBaseView(generic.CreateView): model = Product fields = ['ProductName'] template_name = "products.html" def form_valid(self, form): form.instance.user = self.request.user return super().form_valid(form)
- 
        Updating django database with paypal transaction detailsI have a django project that takes payments and I need to update my database with a new owed balance of 0 after the paypal transaction is complete. I'm a newbie to javascript and the paypal docs aren't being helpful. here's my code: I need to create a new payment from this and update the invoice with the correct amount owed. This is the payment page where the payment happens, make_payment.html. Payments go through successfully. {% extends "base.html" %} {% load crispy_forms_tags %} {% block content %} <div class="card card-primary"> <div class="card-header"> <h2>Make a Payment</h2> </div> <div class="float-right list-group-item"> <p class="font-weight-bold float-left p-0 m-0">Invoice Number</p> <p class="font-weight-bold float-right p-0 m-0">{{ object.pk }}</p> </div> <div class="float-right list-group-item"> <p class="font-weight-bold float-left p-0 m-0">Amount Billed</p> <p class="font-weight-bold float-right p-0 m-0">${{ object.amount_billed }}</p> </div> <div class="float-right list-group-item"> <p class="font-weight-bold float-left p-0 m-0">Amount Owed</p> <p class="font-weight-bold float-right p-0 m-0">${{ object.amount_owed }}</p> </div> <div class="float-right list-group-item"> <!-- Set up a container element for the button --> <div id="paypal-button-container"></div> </div> <div class="float-right list-group-item"> <a href="{% url 'invoice-list'%}"><button type="button" class="btn btn-primary float-right">Go back</button></a> </div> </div> <!-- Include the PayPal JavaScript SDK --> <script src="https://www.paypal.com/sdk/js?client-id=AeFSJDq8sonOdMT62SM-B040Eo4YWi6IS6xsPqDe-eamtEbGs9Jtbf5AbtwjnPC45LjFPOCa4sNoHEIt&currency=USD&disable-funding=credit&commit=false"></script> <script> // Render the PayPal button into #paypal-button-container paypal.Buttons({ // Set up the transaction …
- 
        How to style a Django ModelFormDoes someone know how to style this form with bootstrap? from django.forms import ModelForm from .models import * from django import forms class OrderForm(ModelForm): class Meta: model = Order fields = ('__all__') ** ^ forms.py ^** class Order(models.Model): customer = models.ForeignKey(Customer, null=True, on_delete= models.SET_NULL) product = models.ForeignKey(Product, null=True, on_delete= models.SET_NULL) date_created = models.DateTimeField(auto_now_add=True, null=True) status = models.CharField(max_length=200, null=True, choices=STATUS) def __str__(self): return self.product.name This is the model where the form is about
- 
        1 form, 1 class based view, 2 models, how?I'm new to Django so explain it like I'm 5 I've been racking my brain(and the internet), not even sure its actually possible. I've tried a lot of different links/guides but either the concept is not going in or I'm trying to do something that isn't possible. My Idea is to have: Parent/Child Model, Class Based View, one form in the template. I'm open to any suggestion and I KNOW inline-formset is probably the right answer but every example I've found is years old, the Django documentation(v3.0) doesn't seem to differ from examples. The closest I've so far managed to come is having the template show the children, I can get the parent in the same template but it isn't the same form. Where am I going wrong or what base knowledge do I need to understand this? please don't just link me to the Django docs for inline-formset with no explanation Many thanks
- 
        Why is not `url` showing up in the DRF ResponseI can't get url to be returned when I use it in a HyperlinkedModelSerializer. # model.py class Promotion(TimeStampedMixin, models.Model): name = models.CharField(max_length=300) # ... # views.py class PromotionViewSet(viewsets.ModelViewSet): serializer_class = PromotionSerializer queryset = Promotion.objects.all() def retrieve(self, request, *args, **kwargs): instance = self.get_object() serializer = self.get_serializer(instance, context={'request': request}) return Response(serializer.data) # serializers.py class PromotionSerializer(serializers.HyperlinkedModelSerializer): url = serializers.HyperlinkedRelatedField( view_name="campaigns:promotion-detail", read_only=True ) class Meta: model = Promotion fields = ( "url", "id", "name", ) The JSON output I receive when querying curl -X GET http://localhost/api/promotion/2/: {"id":2,"name":"My promotion"} If I use reverse to check if the view_name in the HyperlinkedRelatedField exists, it prints the correct URL. My question is: why doesn't the url show up in the response? It works any all my other views (comparing code with classes that works hasn't helped). Read the DRF documentation but I see nothing new (using version 3.11.0)
- 
        linking search results to a its own detail pageThis is a django related question: I am doing an assignment where we are playing around making a search bar then afterwards letting each individual search result linked to its own page with more details. In this context we are doing a job search engine and I need assistance in when you click each jobs posting, it takes you to a separate page with more info about the job. We already made templates for all the pages. I understand that we have to make a request to the api again after doing it for the view function in the search bar and also use templating got fill up out the detailed search results.Im just not sure how would I apply these concepts to the html file that w ehave. here's the code View function code import requests from django.shortcuts import render def home(request): context = { 'example_context_variable': 'Change me.', } return render(request, 'pages/home.html', context) def search_results(request): search_query = request.GET['searchterm'] context = { 'result_count': 0, 'search_term': search_query, } context['results_count'] = 0 url = 'https://jobs.github.com/positions.json?location=bay+area&description=' url += search_query response = requests.get(url) results_data = response.json() job_list =[] for result in results_data: job_list.append(result) context['job_results'] = job_list return render(request, 'pages/search_results.html', context) **detailed Search Results Html …
- 
        django 1.2 (jinja) form that takes in information and emails itI would like to add a small form on an already existing html template. When the information is filled in and sent to the backend, i would like it to them be emailed to a specific email address. I am not sure how to do this. So far i have the route Route(r'/educationEmail', 'handlers.site_handlers.EducationEmailHandler', name='education_email'), I have the class set up: class EducationEmailHandler: template_filename = 'education_email' def get(self): pass def put(self): pass I have the form <form methos="POST" action="/educationEmail"> Name: <input type="text" name="fname" required><br> Email: <input type="text" name="email" required><br> <input type="submit" value="Submit"> </form> How can i put this together to make it function how i want it to? Thanks
- 
        How do I add a custom filter in a django child model?I'm pretty new to django and I'm working on an existing app that I did not write. The app handles some document management activities and whenever a document thumbnail is displayed, it currently displays all associated metadata. In my case, some of the metadata rows are unwanted (guid's are not very human friendly) and I therefore want to exclude some of the metadata. There are principally three tables, one for Documents, One for Metadata types, and a join table that ties them together. The guts of the join table are like so: class DocumentMetadata(models.Model): document = models.ForeignKey( on_delete=models.CASCADE, related_name='metadata', to=Document, verbose_name=_('Document') ) metadata_type = models.ForeignKey( on_delete=models.CASCADE, to=MetadataType, verbose_name=_('Type') ) value = models.CharField( blank=True, db_index=True, ), max_length=255, null=True, verbose_name=_('Value') ) The current code does this as it builds the thumbnail: queryset=context['object'].metadata.all() I've got a test version like so: context['object'].metadata.exclude(name__endswith='_Id') I have a convention where the guid metadata field name ends in _Id, and this filter works fine and does what I want it to do right now. I don't like it though. In future, I want to add a human_readable boolean field to the metadata type table and there are other places in the code base where I'll want to sift …
- 
        JavaScript dropdown hidden in a css grid columnI have an admin header from Django which is divided in 2 columns with css grid. I included a JavaScript dropdown effect on the user icon to show other elements like "Change Password" and "Log Out" but the problem is that dropdown stays hidden inside the column, doesn't show outside. How can I fix this? Thanks in advance, A newbie in web development Images attached will show exactly the situation described above: Forced height of header to show the dropdown: Below you can find partial Django code: {% load i18n static %}<!DOCTYPE html> {% get_current_language as LANGUAGE_CODE %}{% get_current_language_bidi as LANGUAGE_BIDI %} <html lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}> <head> <title>{% block title %}{% endblock %}</title> <link rel="stylesheet" type="text/css" href="{% block stylesheet %}{% static "admin/css/base.css" %}{% endblock %}"> {% block extrastyle %}{% endblock %} {% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% block stylesheet_rtl %}{% static "admin/css/rtl.css" %}{% endblock %}">{% endif %} {% block extrahead %} {{ block.super }} <script> /* When the user clicks on the button, toggle between hiding and showing the dropdown content */ function openDropdown() { document.getElementById("myDropdown").classList.toggle("show"); } // Close the dropdown if the user clicks outside of it window.onclick = function(event) { if …
- 
        Save a list of strings in django sql-lite database from viewI want to save a list of strings in django sql-lite database from view. Here is my piece of code def home(request): if request.method=='POST': tags=request.POST['tag'] tweets=scrape(tags) tweets=preprocessing(tweets) tweet=Tweet() tweet.text='save the tweet' tweet.save() return render(request,'home.html',{"tweet":tweets}) else: all_tweets=Tweet.objects.all return render(request,'home.html',{"old_tweet":all_tweets}) The following three-line can save a single string (tweet) in my database tweet=Tweet() tweet.text='save the tweet' tweet.save() But I have a list of strings (tweets) that I want to save in the database. I want to save the output of preprocessing(tweets) which is a list in my database. If I use a loop, I think it makes the process too much slow. So is there any efficient way. Thanks
- 
        How do I insert multiple blocks into the base.html in Django?Possibly I'm misunderstanding the inheritance of templates in Django, but why doesn't the below code work? Both child templates are inheriting from the parent template with different block names. base.html: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <h1>test</h1> {% block index %}{% endblock %} {% block nav %}{% endblock %} </body> </html> index.html {% extends 'blog/base.html' %} {% block index %} <h1>This is the index.html page</h1> {% endblock %} nav.html {% extends 'blog/base.html' %} {% block nav %} <h1>This is the nav.html</h1> {% endblock %} I'm trying to grasp the concept of using multiple blocks so that I can place them on the templates that I need.
- 
        django-ckeditor jquery call to display real-time editingI am creating a django app that uses a RichTextField from django-ckeditor. I'm displaying a side-by-side of what the form will look like once submitted by using jQuery for my input fields. When transitioning from a TextField to RichTextField my jQuery function stopped working. // project.js // old keyup function for TextField var textInput = $('#id_text'); function setText(value) { $('#preview-text').text(value) } setText(textInput.val()) textInput.keyup(function () { var newText = $(this).val() setText(newText) } I have attempted this: // project.js // new jQuery function var textInput = CKEDITOR.instances['id_text'].getData(); function setText(value) { $('#preview-text').text(value) } setText(textInput) // removed .val() as this caused a TypeError: textInput.val is not a function textInput.keyup(function () { var newText = $(this).val() setText(newText) } This gives me TypeError: textInput.keyup is not a function. I would like to continue using the .keyup() function as a prompt for updating the side-by-side preview, but it appears it will need to be reworked. // project.js var textInput = $('textarea#id_text'); // specifying textarea yields [object Object] in HTML function setText(value) { $('#preview-text').text(value) } setText(textInput) textInput.keyup(function () { var newText = $(this).val() setText(newText) } The above function yields [object Object] in the <span id='preview-text'></span>. Previous post I used for the CKEDITOR.instance[].getData() call here. Any insights into how …
- 
        How save selected option in django template?After submitting the form, I can't save selected choice. Please help. <select id="category" class="form-control" name="category"> {% for option in categories %} <option value="{{option.name}}" {% if option.name == 'I don't know what's dynamic value write here(or how get value of POST-parameter' %}selected{% endif %}> {{ option.name }} </option> {% endfor %} </select>
- 
        Catch post_save signalDjango 3.0.5. apps.py from django.apps import AppConfig from django.db.models.signals import post_save from django.dispatch import receiver class NewsConfig(AppConfig): name = 'news' def ready(self): from .models import News # Breakpoint 0 @receiver(post_save, sender=News) def handle_news_save(sender, **kwargs): print("Working") a = 0 # Breakpoint 1 models.py class News(models.Model): news_text = models.TextField() settings.py INSTALLED_APPS = [ ... 'news.apps.NewsConfig', ] The problem At Breakpoint 0 the interpreter stops when I run the application. That is at the next line Django gets to know that I'm catching the signal. But when I save an instance of News in admin site, at Breakpoint 1 the interpreter doesn't stop. And, of course, no printing happens. Could you help me catch the signal?