Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
local 'variable' referenced before assignment
I wrote a signal that changes a field inside user model. it works fine but when a user registers for the first time it gives me this error: UnboundLocalError: local variable 'scientific' referenced before assignment this is my signal: @receiver(pre_save, sender=User, dispatch_uid='progress_change') def progress(sender, instance, **kwargs): user = instance if ScientificInfo.objects.filter(user=user).exists(): scientific = ScientificInfo.objects.get(user=user) if ReligiousInfo.objects.filter(user=user).exists(): religious = ReligiousInfo.objects.get(user=user) if PsychologicInfo.objects.filter(user=user).exists(): psychological = PsychologicInfo.objects.get(user=user) if InvestigationInfo.objects.filter(user=user).exists(): investigation = InvestigationInfo.objects.get(user=user) if scientific.is_interviewed == False and religious.is_interviewed == False and psychological.is_interviewed == False and investigation.is_interviewed == False: user.progress_level = USER_PROGRESS_LEVELS[1][0] if scientific.is_interviewed == True and religious.is_interviewed == False and psychological.is_interviewed == False and investigation.is_interviewed == False: user.progress_level = USER_PROGRESS_LEVELS[2][0] if scientific.is_interviewed == True and religious.is_interviewed == True and psychological.is_interviewed == False and investigation.is_interviewed == False: user.progress_level = USER_PROGRESS_LEVELS[3][0] if scientific.is_interviewed == True and religious.is_interviewed == True and psychological.is_interviewed == True and investigation.is_interviewed == False: user.progress_level = USER_PROGRESS_LEVELS[4][0] if scientific.is_interviewed == True and religious.is_interviewed == True and psychological.is_interviewed == True and investigation.is_interviewed == True: user.progress_level = USER_PROGRESS_LEVELS[5][0] I think the pre_save is causing the issue because when I change it to post_save users can register but the signal wont work then. what should I do to fix this problem? -
Account activation using Django on newest Safari not working
I have run into a weird issue using Djoser for account activation. My web app successfully allows you to sign up for an account and sends you an activation email for your account. However, when entering the activation link sent to my email in Safari I receive a 401 (unauthorized). When entering the activation link in Chrome, it successfully activates the account. Why might this be occurring? It should also be noted that I have everything Dockerized and running through NGINX. If I locally run my React app using npm start, and then add :3000 to the activation URL I receive, also works successfully to activate the account in Safari. For example, if I receive http://localhost/activate/xyz/abcdef as an activation email, editing it to http://localhost:3000/activate/xyz/abcdef and entering that URL into Safari while the React app is running locally it successfully activates the account. My settings.py has this configuration for Djoser: DJOSER = { "USER_ID_FIELD": "username", "LOGIN_FIELD": "email", "SEND_ACTIVATION_EMAIL": True, "ACTIVATION_URL": "activate/{uid}/{token}", "PASSWORD_RESET_CONFIRM_URL": "reset_password/{uid}/{token}", 'SERIALIZERS': { 'token_create': 'apps.accounts.serializers.CustomTokenCreateSerializer', }, } PROTOCOL = "http" DOMAIN = "localhost" if not DEBUG: PROTOCOL = "https" DOMAIN = "domain.com" EMAIL_HOST = 'smtp.gmail.com' DEFAULT_FROM_EMAIL = 'Don\'t Reply <do_not_reply@' + DOMAIN + '.com>' EMAIL_HOST_USER = 'xyz@gmail.com' EMAIL_HOST_PASSWORD = … -
chat database structure and perform sided deletion in drf
I have researched and was not able to find the correct answer I decided to ask questions here. I have a chat application in Django Rest the structure is as follows: Chat Table this is both for Group and Private. It contains from_user, to_user columns for private chats. title column for group chats Chat Member Table in this table group, chat users are saved at last Message Table my first question is that is it a good structure for the whole chat app? what do I need to do to perform one-sided deletion? for example, if user A deletes a message or chat, user B or remained chat users should be able to see the message or chat Can anybody give me advice, please? -
How to Convert Api view class to CreateModelMixin
class Add_Product(APIView): def post(self,request,*args, **kwargs): user=request.user if user.is_authenticated: data=request.data date=datetime.now().date() slug=user.username+"-"f'{int(time())}' print(data) serializer=ProductSerializer(data=data,many=True) if serializer.is_valid(): print(serializer.data) serializer.save(user=request.user,slug=slug) return Response("Your product is added") return Response(serializer.errors) return Response("Login First") I want to convert this to CreateModelMixin But i don't know how to pass values like request.user and slug in create method. class Product_List(GenericAPIView,CreateModelMixin): queryset = Product.objects.all() serializer_class = ProductSerializer def post(self,request,*args, **kwargs): return self.create(request,*args,**kwargs) -
graphene-django full text search
I'm struggling with implementing full text search with graphene-django module. Is there a way to do this? (I'm using relays). I want to pass search string to my get query as an additional field. Which search engine to use is not important. Haven't found any useful information -
How can I solve this KeyError
How to solve this?? Is anything wrong there?? I'm new to Django... Thanks in advance -
Django View that shows related model context
I'm learning and I'm struggling to create a Django view that displays a Company Detail model, but also can show the associated location names that are located in child FK models to the Company. What I've tried includes these models: class Company(models.Model): company_name = models.CharField(max_length=100, unique=True) street = models.CharField('Street', max_length=100, null=True, blank=True) city = models.CharField('City', max_length=100, null=True, blank=True) province = models.CharField('Province/State', max_length=100, null=True, blank=True) code = models.CharField('Postal/Zip Code', max_length=100, null=True, blank=True) company_comments = models.TextField('Comments', max_length=350, null=True, blank=True) class Region(models.Model): company = models.ForeignKey(Company, on_delete=models.CASCADE) region_name = models.CharField(max_length=100) description = models.TextField(blank=True) def __str__(self): return self.region_name class District(models.Model): region = models.ForeignKey(Region, on_delete=models.CASCADE) district_name = models.CharField(max_length=100) description = models.TextField(blank=True) dictrict_ops_leadership = models.CharField(max_length=100, blank=True) def __str__(self): return self.district_name My view looks like: class CompanyDetailView(DetailView): model = Company template_name = 'main/company_detail.html' def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['region'] = Region.objects.all() context['district'] = District.objects.all() return context I want to call **all instances of Region and District** for the **single instance of Company.** With my HTML tags as : <p>{{ region }}{{ district }}</p> It just returns a list of query's of all Region and District instances: <QuerySet [<Region: RegionA>, <Region: RegionB>]> <QuerySet [<District: DistrictA>, <District: DistrictB>]> Any help would be GREATLY appreciated. Thanks -
Django ignores second value of input form field
When I submit a form, one of the inputs has multiple values, but Django ignores the values and just takes the first one. request.POST: <QueryDict: {'csrfmiddlewaretoken': ['2hM...truncated'], 'project_code': ['123'], 'project_manager': ['Michael Jackson', 'Hulk Hogan'], note': ['']}> So, I would like to have in my db for the column project_manager the value Michal Jackson,Hulk Hogan but instead I'm only getting Michael Jackson. models.py: class Project(models.Model): project_code = models.CharField(max_length=250, null=False, blank=False) project_manager = models.CharField(max_length=250, null=True, blank=True) note = models.CharField(max_length=2000, null=True, blank=True) forms.py: class CreateNewProjectForm(ModelForm): class Meta: model = Project fields = '__all__' -
400 Bad Request error from amazon S3 uploading
I am uploading the file to S3 pucket with this library django-s3direct https://github.com/bradleyg/django-s3direct I am trying to do the example of this library $ git clone git@github.com:bradleyg/django-s3direct.git $ cd django-s3direct $ python setup.py install $ cd example # Add config to your environment export AWS_ACCESS_KEY_ID='…' export AWS_SECRET_ACCESS_KEY='…' export AWS_STORAGE_BUCKET_NAME='…' export AWS_S3_REGION_NAME='…' export AWS_S3_ENDPOINT_URL='…' $ python manage.py migrate $ python manage.py createsuperuser $ python manage.py runserver When uploading the file,In my chrome console. there is 400 Bad Request. amazon s3 public access, Iam policy is set and S3 CORS is set. From this log, it looks authentification is finished??? Where should I check ? Starting myarshe.jpg reason: first file index.js:43 index.js:43 initiate getPayloadSha256Content: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 index.js:43 initiate V4 CanonicalRequest: POST /vr-dev-my-resource-bucket/myarshe.jpg uploads= content-type:image/jpeg host:s3.ap-northeast-1.amazonaws.com x-amz-acl:public-read x-amz-date:20220126T044825Z content-type;host;x-amz-acl;x-amz-date e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 index.js:43 V4 stringToSign: AWS4-HMAC-SHA256 20220126T044825Z 20220126/ap-northeast-1/s3/aws4_request 491645163177dd5166cf240fe4ad71a12424b2f358b7f453371d6c921d882d1f index.js:43 initiate signature: 61ac2bd7b3c323fd134e09f187921a2acdeadf6c722d9f1c43421d37ec7e482c index.js:43 initiate getPayloadSha256Content: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 s3.ap-northeast-1.amazonaws.com/vr-dev-my-resource-bucket/myarshe.jpg?uploads:1 POST https://s3.ap-northeast-1.amazonaws.com/vr-dev-my-resource-bucket/myarshe.jpg?uploads 400 (Bad Request) -
Django module autocomplete not working in VSCode
I am learning Django. While creating a class that extends CreateView, I found that the module was not autocompleted in the VSCode environment. In case of HttpResponseRedirect, it is automatically completed as follows. enter image description here I get "from django.contrib.auth.models import User " is required, but does not appear in the autocomplete list. enter image description here I've been working on this issue for 3 hours now. Any help would be greatly appreciated. -
Django Template Aren't Loading
I'm trying to load different html files into the base.html and they're not showing. Any ideas? <body class="bg"> <main class='text'> {% block carousel %} {% endblock %} {% block info%} {% endblock %} {% block content %} {% endblock %} {% block mobile %} {% endblock %} </main> </body> -
Using Primary Key To Index HTML Template Django
Bit confused on how I would index a list I have based on the primary key in the HTML template? Here is my views page: def current_game_table(request): items = list(Nbav8.objects.using('totals').all()) return render(request, 'home/testing.html', {'items': items}) def current_games(request, pk): item = Nbav8.objects.using('totals').get(pk=pk) items2 = list(CurrentDayStats.objects.using('totals').values_list('home_team_over_under_field', flat=True)) return render(request, 'home/testing2.html', {'item': item, 'uuup':items2}) Here is my testing1.html: Hello World {{ items }} {% for item in items %} <a href="{% url 'current_games' item.pk %}">{{ item.home_team_field }}</a> {% endfor %} Here is my testing2.html: <p>The price of this item is: {{ item }}</p> Where is it?!!? {{ item.uuup }} My pages display fine testing1 shows my pages as I want for testing purposes, my problem is this. On my testing2.html page that displays, I have a list "uuup", my problem is, I only want to show uuup.0 on page 1, uuup.1 on page 2, uuup.2 on page 3, etc. I can't seem to figure out how to use the pk as an index? I set a diff variable in my views page and set it to int(item) and printed it out on each page to confirm that each subpage showed it as 1/2/3/4/etc so I am unsure how to call it to use … -
Heroku - Server Error (500) - Not Static - DEBUG = False
On my Django website, I am working on getting the final bugs out and I am running into an error. I finally got my static files to host using Whitenoise and they are hosting fine on the local server when DEBUG = True or False and they are hosting fine on in production on Heroku when DEBUG = True. I know that you can get a lot of the same 500 errors when static files are being hosted locally but I don't believe that I am getting these 500 errors from my static files anymore. I have been looking at the Heroku logs after the 500 errors come up and I haven't been able to narrow down the problem. I am hoping that someone can help me answer the following question. Why am I receiving Server Error (500) in Heroku when DEBUG = False. Thanks in advance!! settings.py: import django_heroku from pathlib import Path import os from django_quill import quill from inspect_list.security import * # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ROOT_DIR = os.path.dirname(BASE_DIR) TEMPLATE_DIR = os.path.join(BASE_DIR, 'templates') #MEDIA_ROOT = os.path.join(BAS_DIR, 'media') TIME_INPUT_FORMATS = ['%I:%M %p',] #Media_URL = '/signup/front_page/sheets/' # Quick-start development settings … -
origin 'http://localhost' has been blocked by CORS policy on amazon-s3
I am trying to upload the data to S3 but CORS error occurs. https://s3.ap-northeast-1.amazonaws.com/my-dev-bot-resource-bucket/4252342.jpg?uploads' from origin 'http://localhost:8005' has been blocked by CORS policy CORS token is set in html <input type="hidden" name="csrfmiddlewaretoken" value="Zo84NgB4sm97d5NVtSXufVq7FpZmaiermOe96GSZgU4Mon8qaYbZsb9siW7gqBLg"> and I set CORS header [ { "AllowedHeaders": [ "*" ], "AllowedMethods": [ "GET", "HEAD", "PUT", "DELETE" ], "AllowedOrigins": [ "*" ], "ExposeHeaders": [] } ] Is there anything I need to check?? -
autoselect multiple select values when receiving data from database
I have a bootstrap-select with the attribute multiple data-max-options="2", let's use some example from the official docs <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <!-- CSS only --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"> <!-- JavaScript Bundle with Popper --> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/css/bootstrap-select.min.css"> <!-- Latest compiled and minified JavaScript --> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.14.0-beta2/js/bootstrap-select.min.js"></script> <select class="selectpicker" multiple data-max-options="2"> <option>Mustard</option> <option>Ketchup</option> <option>Relish</option> </select> Generally speaking, what I would do with single selects is: <select class="selectpicker" multiple data-max-options="2"> {% if meal.sauce == "Mustard" %} <option value="Mustard" selected>Mustard</option> <option value="Ketchup">Ketchup</option> <option value="Relish">Relish</option> {% elif meal.sauce == "Ketchup"%} <option value="Mustard">Mustard</option> <option value="Ketchup" selected>Ketchup</option> <option value="Relish">Relish</option> {% else %} <option value="Mustard">Mustard</option> <option value="Ketchup">Ketchup</option> <option value="Relish" selected>Relish</option> {% endif %} </select> In this way, depending on what we have in the database when we want to edit the select, it will be autoselected with the result of the database. The problem comes when we select more than one sauce and then we want to edit in another page. With a simple sauce, the edit is simple: meal.sauce == "Mustard" or whatever. With multiple select, I don't know how to implement the logic: meal.sauce == "Ketchup, Mustard" ? -
How to hide the icon from folium.Marker django
I am working on a map with folium. I have the HeatMap I want thanks to the code below. I want to add some metadata when the mouse hover over the place but the only way I have found is with the folium.Marker function but it also display a huge marker I would like to hide (it's ruining my HeatMap ...). m = folium.Map(location=[-17.4889,-149.90017], zoom_start=4, tiles='CartoDB Dark_Matter', control_scale=(True)) data_popup = SigCoord.objects.values_list('longitude', 'latitude', 'ile', 'site', 'programme', 'terme') for i in range(len(data_popup)) : m.add_child(folium.Marker(location = (data_filter[i][0], data_filter[i][1]), tooltip = "Ile : " + str(data_popup[i][2]) + '<br>' + "Site : " + str(data_popup[i][3]) + '<br>' + "Programme : " + str(data_popup[i][4]) + '<br>' + "Nombre de données sur ce site : " + str(data_popup[i][5]), icon = folium.Icon(icon='cloud', color='red'))) plugins.HeatMap(data_filter).add_to(m) folium.LayerControl().add_to(m) m = m._repr_html_() Do you have any idea of how can I do that or if there is another function I can use instead ? Thank you ! -
404 error when looking for page on Django site
I'm trying to create a media page on my site through Django. I'm following a course and I'm pretty stumped. I'm following exactly what the guy is doing but I keep getting the following error: Error: Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/ Using the URLconf defined in portfolio.urls, Django tried these URL patterns, in this order: admin/ ^media/(?P<path>.*)$ My settings.py: MEDIA_ROOT = BASE_DIR/'media' MEDIA_URL = '/media/' urls.py: from django.contrib import admin from django.urls import path from django.conf import settings from django.conf.urls.static import static urlpatterns = [ path('admin/', admin.site.urls), ] + static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT) The problem arises as soon as I enter this line: + static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT) I haven't written anything in the views.py folders yet because the course hasn't required me to on this project so far. I'm just a newbie so I don't really have any clue what's happening when the code looks correct but I'm still running into the issue. Any help is appreciated. -
Django signals how to notify user on new reply?
Right now my author get notification through signals if anyone replied or comment. Let explain you this line of code little bit if instance.user.id != instance.blog.author.id: only triggering signals if user is not blog author. here is my code: models.py class BlogComment(models.Model): blog = models.ForeignKey(Blog,on_delete=models.CASCADE,blank=True,null=True) user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE,blank=True,null=True) @receiver(post_save,sender=BlogComment) def NotiFicationSignals(instance,created,**kwargs): if created: if instance.user.id != instance.blog.author.id: #notifiy author noti_to_author = Notifications.objects.create(duplicate_value="author",sender=instance.user,receiver=instance.blog.author,text_preview=f"Recived new comment from {instance.user}") Now I want to create notifications object for commenter if any reply added on his comment. -
Cannot assign object must be of instance
I have these Models: class InvestorProfile(SealableModel): investor_type = models.CharField(max_length=200, choices=investor_type_choices) account = models.ForeignKey('app.Account', related_name='add_account_investorprofile', blank=False, null=False, on_delete=models.CASCADE) class Account(SealableModel): contact = models.OneToOneField('app.Contact', on_delete=models.CASCADE) class Contact(SealableModel): firstname = models.CharField(max_length=200) lastname = models.CharField(max_length=200, blank=True, null=True) email = models.EmailField(max_length=200) and I want to add a Contact, Account, and an InvestorProfile respectively when importing InvestorProfile using django-import-export. The way I'm doing it is with django-import-export's after_import_instance. def after_import_instance(self, instance, new, row_number=None, **kwargs): """ Create any missing Contact, Account, and Profile entries prior to importing rows. """ try: # check if the investor type is company, ind, etc. # retrieve the correct object depending on the investor type # do the logic below if self.investorprofile__add_associated_account__contact__email: # create contact first contact, created = Contact.objects.seal().get_or_create(email=self.investorprofile__add_associated_account__contact__email) # add firstname and lastname contact.firstname = self.investorprofile__add_associated_account__contact__firstname contact.lastname = self.investorprofile__add_associated_account__contact__lastname # save contact.save() # # check if account exists account, created = Account.objects.seal().get_or_create(contact=contact) # # check if investorprofile exists investorprofile, created = InvestorProfile.objects.seal().get_or_create(add_associated_account=account, investor_type=self.investorprofile__investor_type) instance.investorprofile = investorprofile except Exception as e: print(e, file=sys.stderr) Everything looks fine until I encounter this in the error message view: INVESTORPROFILE__ADD_ASSOCIATED_ACCOUNT Cannot assign "'sample@email.com'": "InvestorProfile.add_associated_account" must be a "Account" instance. which is confusing since this line returns an account object. # # check if account exists … -
How django forms works?
I'm using CreateForm like below. I expect it makes error but It works well. I don't understand why It works. Django User dosen't have email2 fields. class CreateForm(UserCreationForm): email2 = forms.EmailField(label = 'email2') def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) for field in self.fields: self.fields[field].widget.attrs.update({'class': 'form-control', 'ALIGN': 'center'}) self.fields[field].help_text = '' self.fields[field].error_messages = '' class Meta: model=User fields=("username","email","email2", "last_name","password1","password2") labels = { 'username' : 'id', 'last_name' : 'name', 'email' : 'certification email', } Before __init__, Dose form add Meta email2? what is sequence of this form? -
How do I uninstall django from windows? I get permission error like the pic. Also I get these import errors and exceptions in Pycharm using django. I
PermissionError: [WinError 5] Access is denied: 'c:\program files\python310\lib\site-packages\django-3.0.14.dist-info\AUTHORS' ![1]: https://i.stack.imgur.com/E4Tfk.png -
Django Gunicorn restart updating fields
I've noticed strange behavior whenever I upload to the server with local changes I have. The database for Django takes all my objects and sets the "updated_by" and "update" fields to the time that I updated the server... Maybe I'm not correctly uploading changes to my server. What I'm using: Ubuntu 18.04.6 Nginx Gunicorn Mysql Python 3.6.12 Django 3.2.9 I generally run: git pull pipenv run python3 manage.py migrate sudo systemctl restart gunicorn sudo systemctl restart nginx I don't run pipenv run python3 manage.py migrate unless I have migrations to run, doesn't affect outcome. Here's the field on my model associated with the weird updating: updated = models.DateTimeField(auto_now=True) updated_by = models.ForeignKey( User, on_delete=models.CASCADE, related_name='updated_by', verbose_name='Last edited by') Any ideas on what I may be doing wrong, or what might be causing this? -
Django dynamic URL in template not working
I have a table where I'd like each row to link to a different "view" page. Essentially the final url should look something like: siteurl.com/view/<campaign_id>/<user_emp_id>/ I've tried doing href={% url 'view/'|add:'{{campaign.id}}'|add:'/'|add:'{{user.pid}}'|add:'/' %} with no luck. I've also attempted other variations of this with no success as well. The error I receive is: Reverse for 'view/{{campaign.campaign.id}}/{{user.pid}}/' not found. 'view/{{campaign.campaign.id}}/{{user.pid}}/' is not a valid view function or pattern name. The url in urls.py is defined as re_path(r'^view/(?P<campaign_id>\w+)/(?P<user_pid>\w+)/$', views.view, name='view') This works just fine when typing it in manually but I'm having a lot of trouble trying to link to it in the template itself Any ideas on how I could accomplish this? -
How to make always active session for postgresql?
Previously, I had a django application/database on the same server. Now I have made one server with application, one server with database(Debian 11; Postgresql 12.9 (Install via Homebrew)) Problem: after a few hours there are problems with connecting to the database... postgres log: 2022-01-24 23:27:00.315 UTC [9982] LOG: received smart shutdown request 2022-01-24 23:27:00.323 UTC [9982] LOG: background worker "logical replication launcher" (PID 9996) exited with exit code 1 2022-01-24 23:27:00.324 UTC [9991] LOG: shutting down 2022-01-24 23:27:00.344 UTC [9982] LOG: database system is shut down /var/log/syslog: Jan 24 23:27:00 d systemd[1]: Stopping User Manager for UID 1000... Jan 24 23:27:00 d systemd[8909]: Stopped target Main User Target. Jan 24 23:27:00 d systemd[8909]: Stopping D-Bus User Message Bus... Jan 24 23:27:00 d systemd[8909]: Stopping Homebrew generated unit for postgresql@12... Jan 24 23:27:00 d systemd[8909]: dbus.service: Succeeded. Jan 24 23:27:00 d systemd[8909]: Stopped D-Bus User Message Bus. Jan 24 23:27:00 d systemd[8909]: homebrew.postgresql@12.service: Succeeded. Jan 24 23:27:00 d systemd[8909]: Stopped Homebrew generated unit for postgresql@12. Jan 24 23:27:00 d systemd[8909]: homebrew.postgresql@12.service: Consumed 1min 22.614s CPU time. Jan 24 23:27:00 d systemd[8909]: Removed slice app-homebrew.postgresql.slice. Jan 24 23:27:00 d systemd[8909]: app-homebrew.postgresql.slice: Consumed 1min 22.614s CPU time. Jan 24 23:27:00 d systemd[8909]: Stopped … -
Why am I not getting any feedback as to whether my form is completed correctly or incorrectly? Python, Django
I'm working in Django with Python, and here are is my views.py def register(request): if request.method == "POST": form = NewUserForm(request.POST) if form.is_valid(): user = form.save() auth_login(request, user) print("success") return render(request, 'Upload.html', {}) # messages.success(request, "Regisration successful.") # print("hello") return render(request, "Home.html") else: print(form.errors) return render(request, 'Register.html', {'form': form}) form = NewUserForm() return render(request, 'Register.html', context={"form":form}) This is my HTML {% extends 'base.html' %} {% load static %} {% block css %} <link rel="stylesheet" href=" {% static 'website/Register.css' %} " media="screen"> {% endblock %} {% block content %} <section class="u-align-center u-clearfix u-section-1" id="sec-6951"> <div class="u-clearfix u-sheet u-sheet-1"> <div class="u-align-center u-form u-form-1"> <form action="#" method="POST" class="u-clearfix u-form-spacing-10 u-form-vertical u-inner-form" source="custom" name="form" style="padding: 10px;"> {% csrf_token %} <div class="u-form-email u-form-group"> <label for="email-87f0" class="u-label">Email</label> <input type="email" placeholder="Enter a valid email address" id="email-87f0" name="email" class="u-border-1 u-border-grey-30 u-input u-input-rectangle u-white" required=""> </div> <div class="u-form-group u-form-name"> <label for="name-87f0" class="u-label">Username</label> <input type="text" placeholder="Create a username" id="name-87f0" name="username" class="u-border-1 u-border-grey-30 u-input u-input-rectangle u-white" required=""> </div> <div class="u-form-group u-form-name u-form-group-3"> <label for="name-12e6" class="u-label">Password</label> <input type="text" placeholder="Create a password" id="name-12e6" name="password1" class="u-border-1 u-border-grey-30 u-input u-input-rectangle u-white" required=""> </div> <div class="u-form-group u-form-name u-form-group-4"> <label for="name-12e6" class="u-label">Verify Password</label> <input type="text" placeholder="Verify your password" id="name-12e6" name="password2" class="u-border-1 u-border-grey-30 u-input u-input-rectangle u-white" required=""> </div> …