Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django Wagtail: migrating from MySQL to Postgresql
I'm trying to migrate a Django project from using MySQL to Postgresql. The project contains a Puput blog. Puput is blog implemented with Wagtail. I've followed the following tutorial. When I reach step three python manage.py migrate --database postgres I get the following error: Apply all migrations: account, admin, app, auth, contenttypes, puput, sessions, sites, taggit, wagtailadmin, wagtailcore, wagtaildocs, wagtailembeds, wagtailforms, wagtailimages, wagtailredirects, wagtailsearch, wagtailusers Running migrations: Applying contenttypes.0001_initial... OK Applying contenttypes.0002_remove_content_type_name... OK Applying auth.0001_initial... OK Applying auth.0002_alter_permission_name_max_length... OK Applying auth.0003_alter_user_email_max_length... OK Applying auth.0004_alter_user_username_opts... OK Applying auth.0005_alter_user_last_login_null... OK Applying auth.0006_require_contenttypes_0002... OK Applying auth.0007_alter_validators_add_error_messages... OK Applying auth.0008_alter_user_username_max_length... OK Applying app.0001_initial... OK Applying account.0001_initial... OK Applying account.0002_fix_str... OK Applying account.0003_passwordexpiry_passwordhistory... OK Applying account.0004_auto_20170416_1821... OK Applying admin.0001_initial... OK Applying admin.0002_logentry_remove_auto_add... OK Applying app.0002_marketnotification_pricechangenotification... OK Applying app.0003_auto_20170812_0920... OK Applying app.0004_auto_20170813_0949... OK Applying app.0005_auto_20170816_2141... OK Applying app.0006_auto_20170816_2149... OK Applying app.0007_auto_20170816_2230... OK Applying app.0008_auto_20170816_2239... OK Applying app.0009_auto_20170817_2036... OK Applying app.0010_auto_20170817_2045... OK Applying app.0011_auto_20170817_2048... OK Applying app.0012_auto_20170817_2113... OK Applying app.0013_auto_20170817_2114... OK Applying app.0014_auto_20170817_2115... OK Applying app.0015_auto_20170818_2317... OK Applying app.0016_auto_20170818_2334... OK Applying app.0017_auto_20170819_1500... OK Applying app.0018_auto_20170819_1948... OK Applying app.0019_auto_20170819_2032... OK Applying app.0020_auto_20170819_2054... OK Applying app.0021_auto_20170820_1129... OK Applying app.0022_auto_20170820_1218... OK Applying app.0023_auto_20170820_2140... OK Applying app.0024_auto_20170820_2314... OK Applying app.0025_auto_20170821_1931... OK Applying app.0025_auto_20170821_1923... OK Applying app.0026_merge_20170821_1936... OK Applying app.0024_auto_20170821_1949... OK Applying … -
Django url with anchor
I am using Django 1.11 and have troubles using urls with anchor. They work well intrapage, but when a url points to a specific anchor on another page it doesn't work at all. This is my url schema: url(r'^(?P<slug>[-_\w]+)/$', CategoryListView.as_view(), name='category_detail', ), And this is how the url is constructed: <a href="{{cat.get_absolute_url}}#someAnchor">BlaBla</a> Which results in a url that looks like this: mydomain.com/category/#venus As said once I get to the url at mydomain.com/category/ and reload retry (click again from a sidebar, no reload triggered) the page the anchor works, but when I am going from another location it doesn't point to the anchor and I end up on top of the page. Any ideas how to fix this? Thanks for any input. -
what is best secure way database design for holding credit?
I want to create web site with django that managers can payed their employees salary ,in this method mangers should first pay in my site and i increase their balance after their payed and then i payed to their employees i want to know best way database design for holding balance that cant be hacked and how to hold transactions data in django here is the few models i have tanks all class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) employees = models.ManyToManyField(User, blank=True, null=True, related_name='boss') FatherName = models.CharField(max_length=20,default='',blank=True) NationalCode = models.CharField(max_length=20, default='') birth_date = jmodels.jDateField(null=True, blank=True) PhoneNumber = models.CharField(max_length=20,default='') email_confirmed = models.BooleanField(default=False) phone_confirmed = models.BooleanField(default=False) profile_confirmed = models.BooleanField(default=False) DebitCardNumber = models.CharField(max_length=16, default='') balance = models.DecimalField(max_digits=6, decimal_places=2 , default=0) class Transaction(models.Model): FromUser = models.ForeignKey(Profile, related_name='+') ToUser = models.ForeignKey(Profile, related_name='+') TransactionDate = models.DateField() Amount = models.DecimalField(max_digits=6, decimal_places=2) transaction_type = models.BooleanField() -
Django-Allauth does not offer posts extracts from profile
I am trying since weeks to get the users complete profile and posts for my NLP analysis. I have tried many libraries for that purpose and found Django-alluth a bit useful for authentication. But it does not satisfy my requirements including displaying the profile image, posts, about the user, etc. Inshort most part of the complete profiles on my website and then the analysis part using the posts text. I have gone through many libraries among which is Authomatic, django-allauth and many other. But they are useless in my case. I want to know how I can achieve this task in Django. I do not mean to use the JS-SDK of facebook, as it might reveal the program logic on the front. Kindly, suggest me. If anyone have better option for the achieving the task of my experiment. -
Implement Facebook Log In with Django
Hi I would really appreciate if somebody could please paste there code here for there Facebook login created for their Django project, whether it is a separate app or not, with a couple of explanations. Pulling User Name, Email and profile pic. Thank you -
I cannot read matplotlib graph by using shell
I cannot read matplotlib graph by using shell. I wrote in views.py from pylab import figure, axes, pie, title from matplotlib.backends.backend_agg import FigureCanvasAgg import numpy as np import matplotlib.pyplot as plt def graph1(): left = np.array([1, 2, 3, 4, 5]) height = np.array([100, 200, 300, 400, 500]) plt.bar(left, height) graph1() I wrote commands in terminal like python manage.py shell from accounts import views views.graph1() but no graph is shown. I think matplotlib graph can be read by using shell,but do I misunderstand? or am i wrong to write the way of code? How can I do it? -
how to import a variable from some python file to views.py django
How to import a variable from some python file to views.py django. Getting error in urls.py, views.py, xyz.py while doing normal import in django environment in views.py. For example: from xyz import x; # gives error while running project -
Not able to access the gravatar URL using Django-AllAuth
I am trying to access the profile picture with django-allauth plugin, but I am getting error while accessing it. I am using the following code: import allauth.socialaccount.providers.facebook.provider as fb def fb_personality_traits(request): # logger.debug('FB Page Loaded') print fb.FacebookAccount.get_avatar_url(user) return render(request, 'home/facebook_personality_traits.html') I have got the following error: Please let me know what to do to improve it. Here is the reference: get_avatar_url -
Invalid syntax: from django import forms
I wrote the following code in forms.py. I can't understand what is wrong with this. This gives invalid syntex form django import forms class contactForm(forms.Forms): name=forms.CharField(required=False,max_length=100,help_text='100 characters max.') email=forms.EmailField(required=True) comment=forms.CharField(required=True,widget=forms.Textarea) -
Django doesn't see some static files in development
I am having issues with django not serving some static assets during development. It's a really strange issue. This is how the pertinent part of my static directory is right now: site_media └── static ├── css │ ├── public.css │ ├── site-ada8eab0af.css Now that is my staticfiles directory, and things are correctly imported there from my static directory when I run manage.py collectstatic. I have two lines in my template: <link href="{% static 'css/site-ada8eab0af.css' %}" rel='stylesheet' /> <link href="{% static 'css/public.css' %}" rel="stylesheet" /> These produce these two lines in the rendered output: <link href="/site_media/static/css/site-ada8eab0af.css" rel='stylesheet' /> <link href="/site_media/static/css/public.css" rel="stylesheet" /> When I go to the first link, it works fine. When I go to the public.css link though, I get a 404 error that says 'css/public.css' could not be found. The complete link I use is http://localhost:8000/site_media/static/css/public.css What could possibly make it able to serve one of these files, but not the other? -
Django - Allauth - How to add additional API parameters to registration
I'm using Django all-auth through Django rest-auth and I'd like to extend the registratino functionality to match my custom user object. Given the user model below: class Profile(AbstractUser): email = models.EmailField(unique=True) username = models.CharField(max_length=40, unique=True, blank=True) first_name = models.CharField(max_length=40, blank=True) last_name = models.CharField(max_length=40, blank=True) How can I enable allauth to receive those as parameters via an API call to then clean/store them. In other words, what I want to be able to do, is call the /rest-auth/registration/ endpoint with a body like such; { "username": "foo", "email": "bar@mail.com", "password1": "fooBar!@", "password2": "fooBar!@", "first_name": "first", "last_name": "last" } and have first_name and last_name stored as a Profile object. Again, I want to be able to do this via the API and not via a form. Environment details: Django==1.11.3 django-allauth==0.33.0 django-environ==0.4.4 django-rest-auth==0.9.1 django-storages==1.6.5 django-taggit==0.22.1 djangorestframework==3.6.4 ... $ python --version Python 2.7.11 -
Can't convert string from 'UTF-8' to native encoding for pysvn export
I was running pysvn's export of a repo with file names with french letters like "Français" or "Spécifications du produit". When the export runs, the following error is returned Can't convert string from 'UTF-8' to native encoding I found this http://refactor.se/2007/08/13/svn-fix-cant-convert-string-from-utf-8-to-native-encoding/ and Can't convert string from 'UTF-8' to native encoding indicating something about setting the local language but I couldn't find this in pysvn. Is it possible to set this when initializing a pysvn Client? EDIT: Forgot to mention i'm doing this on django 1.7 Thanks -
deploying a django app on osx
I am using OS X El Capitan with server app v 5.1. I created a simple app using Django in \Library\Server\Web\Data\WebApps. The app is called mysite (actually it is an empty app created with django). Can anyone help me with the deployment of this app? I cannot seem to find any documentation or tutorial on how to do this. Is there a way to add it to the server appp^ and which .conf or .wsgi or com.something should I change. Any help is really appreciated. Thank you -
Permission denied for relation django_migrations using Heroku
While attempting to migrate database changes using django on Heroku, I get: psycopg2.ProgrammingError: permission denied for relation django_migrations Other people have been able to resolve this issue by granting the appropriate privileges (e.g., Permission denied for relation). Unfortunately, I can't grant permissions or create a new user on the Heroku hobby tier. I was able to rolling back some migrations, but eventually I got: django.db.utils.ProgrammingError: table "labs_branch_tests" does not exist and could not migrate back to newer migrations. Full traceback for permission denied for relation django_migrations File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv self.execute(*args, **cmd_options) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute output = self.handle(*args, **options) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 204, in handle fake_initial=fake_initial, File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/executor.py", line 115, in migrate state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/executor.py", line 250, in apply_migration self.recorder.record_applied(migration.app_label, migration.name) File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 73, in record_applied self.migration_qs.create(app=app, name=name) File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/query.py", line 394, in create obj.save(force_insert=True, using=self.db) File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/base.py", line 807, in save force_update=force_update, update_fields=update_fields) File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/base.py", line 837, in save_base updated = self._save_table(raw, cls, force_insert, … -
Video not playing in production. Django backend
I'm trying to understand how I can have my website properly display - specifically a banner video. I think the issue relates to Mimetype - It works from my computer but not when served from a server. This is the website https://consultingpage.herokuapp.com/ . I assume that the issue is within my settings.py or urls.py - I'll put them below. Urls.py """ The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.11/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.conf.urls import url, include 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ from django.conf import settings from django.conf.urls import url from django.contrib import admin from django.conf.urls.static import static from profiles import views as profiles_views urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^$', profiles_views.base, name='base'), ] if settings.DEBUG: urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) and Settings.py """ Django settings for alex1 project. Generated by 'django-admin startproject' using Django 1.11.4. For more information on this file, see https://docs.djangoproject.com/en/1.11/topics/settings/ For … -
Why is my form creating a new model object instead of modifying one?
I am working on a Django view which allows the user to modify an existing model object. However, when the form is submitted it creates a new object instead of modifying the existing object. I have read the Django docs on the save() function, forms, queries, etc. but haven't been able to understand what is happening. The docs say that .save() should translate into an UPDATE statement on the database side. I have looked into other solutions here, such as this one. My original view updated the model based on the contents of a form. As part of my troubleshooting, I replaced that part of the code with the lines that update each field individually. def modify(request, auditID): this_audit = Audit.objects.get(id=auditID) form = auditForm(instance=this_audit) if form.is_valid(): this_audit.project_number = request.POST.get('project_number',) this_audit.title = request.POST.get('title',) this_audit.title_short = request.POST.get('title_short',) this_audit.status = request.POST.get('status') this_audit.save() return redirect('index') -
Passwords cannot be typed in form
Passwords cannot be typed in form. Im making user regist web site. I wrote in views.py def regist(request): form = RegisterForm(request.POST or None) context = { 'form': form, } return render(request, 'registration/regist.html', context) in forms.py class RegisterForm(UserCreationForm): class Meta: model = User fields = ('username', 'email',) def __init__(self, *args, **kwargs): super(RegisterForm, self).__init__(*args, **kwargs) self.fields['username'].widget.attrs['class'] = 'form-control' self.fields['email'].widget.attrs['class'] = 'form-control' self.fields['password1'].widget.attrs['class'] = 'form-control' self.fields['password2'].widget.attrs['class'] = 'form-control' in regist.html <main> <div class="container"> <div class="heading col-lg-6 col-md-12"> <h1>WEB SITE</h1> </div> <div class="heading col-lg-6 col-md-12"> <h2>NEW REGISTRATION</h2> <form class="form-horizontal" method="POST"> <div class="form-group-lg"> <label for="id_username">USER NAME</label> {{ regist_form.username }} </div> <div class="form-group-lg"> <label for="id_email">EMAIL</label> {{ regist_form.email }} </div> <div class="form-group-lg"> <label for="id_password">PASSWORD</label> {{ regist_form.password1 }} </div> <div class="form-group-lg"> <label for="id_password">PASSWORD(CONFROMATION)</label> {{ regist_form.password2 }} <p class="help-block">{{ regist_form.password2.help_text }}</p> </div> <div class="form-group-lg"> <div class="col-xs-offset-2"> <button type="submit" class="btn btn-primary btn-lg">SUBMIT</button> <input name="next" type="hidden"/> </div> </div> {% csrf_token %} </form> </div> </div> </main> I really cannot understand why only passwords cannot be typed in form.Username&Email can be typed.Because I cannot type passwords,so I cannot put SEND button.How should I fix this? -
Django - Customising Modelform
Ive tried to add the following to my form: class ReadOnlyFormMixin(forms.ModelForm): def __init__(self, editable=False, *args, **kwargs): super(forms.ModelForm, self).__init__(*args, **kwargs) if editable==False: for key in self.fields.keys(): self.fields[key].disabled = True and then make my form like this: class UserForm(ReadOnlyFormMixin): """ Edit a User """ class Meta: model = User fields = ('first_name','last_name', 'email') However my code then never passes .is_valid() ~How should I make my form read only, via a URL flag. (e.g. im trying to do) urlpatterns = [ url(r'^$', index, name='index'), url(r'^profile/$', profileView.as_view(), name='profile'), url(r'^profile/edit/$', profileView.as_view(), {'edit': True}, name='profile_edit'), ] -
Migrating django models in Postgres/PostGIS not reflecting
I successfully imported my Geojson data using ogr2ogr to PostGIS. I run the following command: python manage.py inspectdb class Route(models.Model): ogc_fid = models.AutoField(primary_key=True) distance = models.FloatField(blank=True, null=True) route_type = models.CharField(max_length=-1, blank=True, null=True) route_long = models.CharField(max_length=-1, blank=True, null=True) route_name = models.CharField(max_length=-1, blank=True, null=True) agency_id = models.ForeignKey(max_length=-1, blank=True, null=True) route_id = models.CharField(max_length=-1, blank=True, null=True) route_url = models.CharField(max_length=-1, blank=True, null=True) route_desc = models.CharField(max_length=500, blank=True, null=True) duration = models.FloatField(blank=True, null=True) shape_id = models.IntegerField(blank=True, null=True) route_tcolor = models.CharField(max_length=-1, blank=True, null=True) route_color = models.CharField(max_length=-1, blank=True, null=True) wkb_geometry = models.LineStringField(blank=True, null=True) class Meta: managed = False db_table = 'network_route' Ofcourse I had to modify the max_length to a positive integer and set manage to True so I did. I also added an additional column, created_at and updated_at. Resulting to the following final model: class Route(models.Model): ogc_fid = models.AutoField(primary_key=True) distance = models.FloatField(blank=True, null=True) route_type = models.CharField(max_length=100, blank=True, null=True) route_long = models.CharField(max_length=200, blank=True, null=True) route_name = models.CharField(max_length=100, blank=True, null=True) agency_id = models.ForeignKey(Agency, on_delete=models.CASCADE) route_id = models.CharField(max_length=100, blank=True, null=True) route_url = models.CharField(max_length=300, blank=True, null=True) route_desc = models.CharField(max_length=500, blank=True, null=True) duration = models.FloatField(blank=True, null=True) shape_id = models.IntegerField(blank=True, null=True) route_tcolor = models.CharField(max_length=100, blank=True, null=True) route_color = models.CharField(max_length=100, blank=True, null=True) wkb_geometry = models.LineStringField(blank=True, null=True) created_at = models.DateTimeField(default=timezone.now(),editable=False) updated_at = models.DateTimeField(blank=True, null=True) objects = … -
ajax like button is updating all the product with weird values
I try to implemented ajax like button in my django project. I wanted like button to work in the list of company(list view) and detail view. But in list view, when I hit the like button, the like is shown 201 when it should be only 2 and when unlike it shows 200 something like that instead of 0. Also it is updating all the companies like value instead of specific company whose like button is clicked. What might be wrong in my code? Here is the code url(r'^like/company$', views.CompanyLikesAPIView.as_view(), name="like-company"), class CompanyLikesAPIView(APIView): permission_classes = (permissions.IsAuthenticated, ) def post(self, request, slug=None, format=None): company_id = request.data.get('id') print('company_id', company_id) action = request.data.get('action') if company_id and action: try: company = Company.objects.get(id=company_id) if action == "like": company.likes.add(request.user) else: company.likes.remove(request.user) return Response({'status': 'ok'}) except: pass return Response({'status': 'ko'}) {% block pagecontent %} <div class="container"> {% for company in companies %} {% with total_likes=company.likes.count users_like=company.likes.all %} {% if forloop.first %}<div class="row">{% endif %} <div class="col-md-4"> <div class="card-body text-center"> <h3 class="card-title text-center">{{ company.name }}</h3> <a href="{{ company.get_absolute_url }}" class="btn btn-link">View Detail</a> <span class="count"> <span class="total">{{ total_likes }}</span> like{{ total_likes|pluralize }} </span> <a href="#" data-id="{{ company.id }}" data-action="{% if request.user in users_like %}un{% endif %}like" class="company-like like-{{ company.id}} … -
Deploying Django and Angular 2 on Heroku
I am at a bit of a roadblock. Under one GitHub repository, I have two services. A Django API, and an Angular 2 application (forgive me if any of my vocabulary isn't aaccurate). I am trying to use Heroku to accomplish hosting this. My current Procfile looks like so: web: node frontend/server.js api: gunicorn platform/Minieco/wsgi.py However, when I build through Heroku's website, I get the following output: -----> Python app detected -----> Installing requirements with pip -----> Discovering process types Procfile declares types -> api, web -----> Compressing... Done: 47.2M -----> Launching... Released v7 https://minieco.herokuapp.com/ deployed to Heroku It detects the app as Python, when really only the API is. Maybe this isn't the issue, but it stood out to me. Either way, I get an Application Error when I visit the website, what are the correct steps to take in order to run both of these services side-by-side? -
How to connect an Arduino by ethernet shield to a raspberry pi 3
I have a Django Application running on my raspberry pi, this application shows the temperature of many temperature sensors (LM35DZ) connected to an arduino. When I was in the debug environment I connected the arduino to the LAN, then it does the requests to the Raspberry. Now in production environment is required to be connected directly to the Raspberry. How may I do this? -
Django : Object has no attribute _set'
I have this code in a project with django: def all_songs(request, filter_by): if not request.user.is_authenticated(): return render(request, 'music/login.html') else: try: song_ids = [] for album in Album.objects.all(): for song in album.song_set.all(): song_ids.append(song.pk) users_songs = Song.objects.filter(pk__in=song_ids) for album in GenericAlbum.objects.all(): for song in album.genericsong_set.all(): song_ids.append(song.pk) generic_songs = GenericSong.objects.filter(pk__in=song_ids) except Album.DoesNotExist: users_songs = [] except GenericAlbum.DoesNotExist: generic_songs = [] return render(request, 'music/songs.html', { 'song_list_all': users_songs, 'generic_song_list': generic_songs, 'filter_by': filter_by, }) When I go to the allSong page, I get this error : AttributeError: 'NoneType' object has no attribute 'split' I think a variable allows a None value, but I don't know witch one, I tried 'em all and still same problem. -
Django RestFramework Serializer request.data with array object
i need you help ! i have this situation, i received by POST this data: {'fields':[{'key':'comment', 'value':'something', 'data_type':'string'}, {'key':'days', 'value':'2', 'data_type':'int'}]} My serializers class FieldSerializer(serializers.Serializer): value = serializers.CharField(max_length=200) data_type = serializers.CharField(max_length=200) key = serializers.CharField(max_length=200) class FieldsSerializer(serializers.Serializer): fields = FieldSerializer(many=True) In my view pass request.data to FieldsSerializer() serializer = FieldsSerializer(data=request.data, many=True) serializer.is_valid() raise Exception(serializer.data, serializer.errors) //output: Exception: (ReturnDict([('fields', [])]), ReturnDict()) i use versions Django==1.8.15 and djangorestframework==3.0 -
Using logging in python and django to record user interactions with a website
I'm currently working on helping with the development of a website. Someone this past weekend attempted to hack into the website, but failed. However, since the entire site was rewritten this last summer, there was no way to store their movements within the site and to catch the user's IP before they gave up. Is there a way to track a users actions (such as which links they visit) while in a website and store it into a file (the website is small) in order to make sure we have a record of the actions, if anyone ever attempts to hack it again? To see if I could do this, I started using logging, but ran into issues with how exactly I am supposed to record the users actions with logging. My setup is below, and it works, I just don't know what to put in place of the string currently inside of logging.info() to record the movements of the user. Thanks in advance for any help you can provide. from ipware.ip import get_ip import logging def IPCatcher(request): ip = get_ip(request) if ip is not None: print("We have an IP address for user") print(ip) logging.basicConfig(filename='log_recording.txt', level=logging.DEBUG,format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p') …