Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django query parameter
I try to get a value as query parameter and I want to how can I optimize this code and don't use "" when user don't want to enter anything. author = request.GET.get('author','') name = request.GET.get('name','') -
DRF Get Request is always an empty object
I have a Django REST Framework setup, and I am only getting blank values. My serializer: class SettingsSerializer(serializers.Serializer): class Meta: model = Settings fields = fields = ["user_id","traditional","audio_download","show_read","show_pinyin","char_size","pinyin_size","start_date","end_date","speed","volume", "char_colors", "pinyin_colors", "global_dash"] My model: class Settings(models.Model): user = models.ForeignKey( User, on_delete=models.CASCADE) traditional = models.BooleanField() audio_download = models.BooleanField() show_read = models.BooleanField() show_pinyin = models.BooleanField() char_size = models.IntegerField() pinyin_size = models.IntegerField() start_date = models.DateField(null=True) end_date = models.DateField(null=True) speed = models.IntegerField() volume = models.IntegerField() char_colors = models.BooleanField() pinyin_colors = models.BooleanField() global_dash = models.BooleanField() class Meta: db_table = 'settings' My view: class SettingsRetrieveUpdateDestroyView(generics.RetrieveUpdateDestroyAPIView): queryset = Settings.objects.all() serializer_class = SettingsSerializer lookup_field = 'user_id' My url pattern: urlpatterns = [ path('settings/<int:user_id>/', SettingsRetrieveUpdateDestroyView.as_view()), ] My url: http://127.0.0.1:8000/api/v1/settings/87/ My response: {} And I can definitely confirm that there is a record for user_id = 87: Why is my response empty? -
django group by date without computing any metric
I have these two models and I am trying to build a django query such that given a Jobproject, I can get all the dates with events and which events they are...grouped by date. So basically, given a project having in return a dictionary that would look like this: { <10/10/21>:[Party,Meeting,DoctorAppointment]; <10/10/21>:[Game,Work]; <10/10/21>:[Dinner]; <10/10/21>:[Gym]; } Considering the below models, I though about building a query such as instance.jobproject_events.order_by('date') and then manipulate the result in python. But I was hoping Django had a way of doing it through a query using some sort of groupby. class EventName(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) name = models.CharField(max_length=30, null=True) def __str__(self): return self.name class Event(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) date = models.DateField(blank=True, null=True) event_name = models.ForeignKey(EventName, blank=True, on_delete=models.CASCADE, related_name='events', null=True) project = models.ForeignKey(JobProject, blank=True, on_delete=models.CASCADE, related_name='jobproject_events', null=True) def __str__(self): return self.project.title + ": "+ str(self.date.strftime("%m/%d/%Y")) + " - "+ str(self.event_name.name) #+ ": from " + str(self.date) #+ " to " + str(self.date_end) -
Guarantee that the results of a QuerySet are not all loaded in-memory
I have a query which will return a massive set of objects, but I just need to iterate over them once. Is calling .iterator() on the queryset enough to guarantee that they won't all be loaded into memory? -
DJango - handle form_invalid errors with ajax-submitted data
I'm looking for a way to keep all of django's builtin stuff for form errors with an ajax submission that returns a django form_invalid() "standard" response. For instance, with a non-ajax request: class SomeCreateView(LoginRequiredMixin, SideBarMixin, CreateView): def form_invalid(self): return self.render_to_response(self.get_context_data()) And then in the template: <div class="container-fluid"> <form action="" method="post" enctype='multipart/form-data'> {{ form.non_field_errors }} ... <div class="wide_items"> {{form.no_form.errors}} {{form.no_form.label_tag}} {{form.no_form}} </div> ... </form> ... I then get all the nice errors messages displayed in the relevent fields/or top of form for non_field_errors etc. However, using the following jquery ajax request: some_handler: function (e, clickedBtn) { // .... some logic to check what to do etc. .... $.ajax({ url: url, type: "POST", data: data, success: function (response) { if (response.status==1) { // form_valid() - reload current page, load some other alert(response.message); location.reload(true); if (response.next_url) { mainjs.open_new_window(response.next_url); } } else if (response.status==0) { // form_invalid - how to manage this? alert(response.message); } }, error: function (xhr, errmsg, err) { $('#results').html("<div class='alert-box alert radius' data-alert>Oops! We have encountered an error: " + errmsg + " <a href='#' class='close'>&times;</a></div>"); // add the error to the dom } }); }, In that second case, I'd like some way to directly the response from the regular … -
Django / Python Media rendering not working
Can anyone explain to me what is happening here? I am able to upload images from the admin panel, and the frontend to the 'media/company/logo1.png' folders. its working, and when I delete the folder it re-creates it, no issue. In development I am unable to render the image from the django admin panel, as clicking the image link to view returns "Not Found The requested resource was not found on this server." with the URL "http://13.59.234.9/media/company/mnmade-logo.png" # Settings.py import os STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, "static/") MEDIA_ROOT = os.path.join(BASE_DIR, 'media/') MEDIA_URL = '/media/' # Models.py class Company(models.Model): name=models.CharField(max_length=100, null=False, unique=True) image=models.ImageField(null=True, upload_to="company/") created_at=models.DateTimeField(auto_now_add=True) updated_at=models.DateTimeField(auto_now=True) objects = CompanyManager() # add for manager validator class Meta: ordering = ( 'id', 'name', 'image', 'created_at', 'updated_at' ) def __str__(self): return self.name # projects URLS.py from django.contrib import admin from django.urls import path, include from django.conf import settings from django.conf.urls.static import static urlpatterns = [ path('admin/', admin.site.urls), path('', include('frontend.urls')), path('reports/', include('reports.urls')), path('users/', include('users.urls')), path('company/', include('company.urls')), path('employees/', include('employees.urls')), ] urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # Views def manage_admin(request): if 'admin_id' not in request.session: return redirect('/signin-company-admin') company = Company.objects.get(admins=request.session['admin_id']) context = { 'admin': Admin.objects.get(id=request.session['admin_id']), 'all_admins': Admin.objects.filter(company=request.session['company_id']), 'company': company, 'locations': Location.objects.filter(company=company.id) } return render(request, … -
Django M2M / Many To Many Relationship to SELF with through table not adding symmetrical reverse
I'm trying to set a Many To Many relationship on a model to itself. I have read up on the whole Symmetrical=True/False settings. I do want the symmetry between the self related models, aka, if the locale1 of model Locale is related to another Locale, locale2, then locale2 should have a reference to get locale1. Below is how I have the models set up Locale and the Many To Many Model/Table RelatedLocale. When I set locale1.related_locales.set([locale2]) only 1 record is created and locale2 can not use 'related_locales' to access locale1. What am missing on the models? shell >>> locale1.related_locales.set([locale2]) >>> locale1.related_locales.all() <QuerySet [<Locale: Locale object (<locale2>)>]> >>> locale2.related_locales.all() <QuerySet []> Models: class Locale(models.Model): """Locale to be used for everything on the Aspiria Campus""" id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) ... related_locales = models.ManyToManyField( "Locale", through='RelatedLocale') class Meta: db_table = 'locale' class RelatedLocale(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) locale = models.ForeignKey( Locale, on_delete=models.CASCADE, db_column='locale_id') related_locale = models.ForeignKey( Locale, related_name="related_locale", on_delete=models.CASCADE, db_column='related_locale_id') is_parent = models.BooleanField(default=False) class Meta: db_table = "related_locale" def __str__(self): return "%s related" % self.locale.name -
Heroku Application Error (Django web App)
Hey, I am new in development and I don't understand all of this error please help me. how can I fix this? need help! -
Getting the whole linkvertise referrer address in django
I'm using linkvertise on my site and im trying to get the referrer with django, when i get redirected from linkvertise, request.META.get('HTTP_REFERER') returns https://linkvertise.com, not the whole link like linkvertise.com/code, is there anyway i can get the whole link to check if it's mine so people can't create fake links redirecting to my site? -
Django 3.2 base template fails with error: Invalid block tag on line 11: 'raw'. Did you forget to register or load this tag?
I searched the internet and they said to use {%block raw}. This fails with the error: only one raw block allowed. I also tried substituting {% verbatim %}. This also failed. Why does Django 3.2 fail with: Invalid block tag on line 11: 'raw'. Did you forget to register or load this tag? The template is: {{"{% extends 'webapp/base.html' "}}{{ "%" }}} {{"{% block content "}}{{ "%" }}} {{"{% if products "}}{{ "%" }}} <div class="row mx-2"> {{"{% for product in products "}}{{ "%" }}} <div class="col-12 col-sm-6 col-md-4 px-2 mb-3"> <div class="card"> <img src="{{product.image}}" class="img-fluid" style="padding: 30px" alt="{% raw %}{{product.title}}{% endraw %}" /> <div class="card-body"> <h5 class="card-title">{% raw %}{{product.title}}{% endraw %}</h5> <p class="card-text"> A beautiful {% raw %}{{product.title}} for ${{product.price}}{% endraw %}. </p> <a href="/" class="btn btn-primary">Buy Now</a> </div> </div> </div> {{"{% endfor "}}{{ "%" }}} </div> {{"{% else "}}{{ "%" }}} <p>No products available.</p> {{"{% endif "}}{{ "%" }}} {{ "{% endblock " }}{{ "%" }}} -
In Django Select2 how to exclude request user from search?
This method will exclude request user from many to many fields of users list to add requested user to forms forms.py from django_select2 import forms as s2forms class CoAuthorsWidget(s2forms.ModelSelect2MultipleWidget): search_fields = ["username__istartswith", "email__icontains"] class PostForm(forms.ModelForm): other_author = forms.ModelChoiceField( queryset=None, widget=CoAuthorsWidget( model=User, ) ) def __init__(self, user, *args, **kwargs): super(PostForm, self).__init__(*args, **kwargs) self.fields['other_author'].queryset = User.objects.exclude(id=user.id) class Meta: model = Post fields = 'other_author' widgets = { 'other_author': CoAuthorsWidget( attrs={ 'class': 'bg-olive-lite', 'style': 'width: 100%', } ) } views.py form = PostForm(user=request.user , data=request.POST, files=request.FILES) -
Ordering and ranking a QuerySet in Django based on existing model field data, limited to the first few rankings only?
I'm having some trouble with Window() expressions and Rank() for some multi-step rankings of QuerySets for a sports simulation I'm building. I have three core models: Team, Division and Conference. Here's a stripped down version of them to illustrate their relations to each other. class Conference(models.Model): name = models.CharField(max_length=200) class Division(models.Model): name = models.CharField(max_length=200) conference = models.ForeignKey( Conference, on_delete=models.CASCADE, related_name='divisions' ) class Team(models.Model): division = models.ForeignKey( Division, on_delete=models.CASCADE, related_name='teams', ) I'm creating rankings for each of the teams in their respective divisions and conferences based on their TeamStanding at the start of every week (wins, losses, etc.). The rankings will be saved in a TeamRanking instance (their numbered rank in their division 1-4, conference 1-16, and league-wide 1-32) which has a OneToOne relationship with TeamStanding (one of each per team, per week). Stripped down version of the above models as well: class TeamStanding(models.Model): team = models.ForeignKey( Team, on_delete=models.CASCADE, related_name='team_standings', ) # All the standing data fields class TeamRanking(models.Model): standing = models.OneToOneField( TeamStanding, related_name='ranking', on_delete=models.CASCADE, ) # All the rankings fields Here's how the division rankings are calculated currently: division_rank_qs = TeamStanding.objects.filter( team__division__exact=division ).annotate( rank=Window( expression=Rank(), order_by=[ F('wins').desc(), F('losses'), F('points_for').desc(), F('points_against') ], ) ) Then to access the ranks: for ranked_div_standing … -
django mysql dynamic table creation on a Model save
I would like to create additional tables when I call Model.save() (INSERT). But I keep getting this error: django.db.transaction.TransactionManagementError: Executing DDL statements while in a transaction on databases that can't perform a rollback is prohibited. I tried to create additional tables inside Model.save() and using a pre_save() signal, I get the same error. This is a pre_save solution attempt: from django.db.models.signals import pre_save from django.dispatch import receiver from django.db import connection @receiver(pre_save, sender=MyModel, dispatch_uid="create_tags") def create_tags(sender, instance, **kwargs): print("debug, signal pre_save works") try: # if obj exists in MyModel table, skip tag table creation existing_obj = MyModel.objects.get(name=instance.name) print("debug, obj exists") except MyModel.DoesNotExist: with connection.schema_editor() as schema_editor: schema_editor.create_model(MyModel2) Stack: Django, MySQL. What I wanted to implement is to create additional tables for the instance that is being inserted. -
DRF ManyToMany field seralize
I have the following model class Contact(models.Model): user = models.ForeignKey(CustomUser, on_delete=models.CASCADE, related_name='contacts') friends = models.ManyToManyField('self', blank=True) def __str__(self): return self.user.username When the user log-in, the client make a HTTP request to the following view to get user friends. class ContactAPIView(generics.RetrieveAPIView): queryset = Contact.objects.all() serializer_class = ContactSerializer lookup_field = 'user__username' The data returned: THE QUESTION IS: How can I serializer the 'friends' field in a way that I can get the id, user.id and user.username. -
By Convention, when creating an application in django is it more common to access the backend directly or use API's to make the CRUD?
I'm a beginner and now that I've done all the views and html, I'm in a connection phase with the backend, I would like to know what is most used, to do it correctly. PS: this will have a large number of users -
Inline CSS not following @media min-width and max-width properties
I am creating a pricing page in my Django app which has 3 columns. If the screen size is more than 768 pixels, I want it to show all 3 columns side-by-side. But if it's less 768 pixels, I want there to only be 1 column with the different pricing options on top of each other. For some reason, the @media properties are not being followed. It doesn't matter what the screen size is, the page is always showing 3 columns. The below screenshot should only have 1 column (like most mobile-friendly pages) Current page: Js Fiddle - LINK The strange thing is that in this JS Fiddle, it does seem to be following the @media screen and (max-width) properties. Code: <html> <head> <style> @import url(https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css); @import url(https://fonts.googleapis.com/css?family=Raleway:400,500,800); @import url(https://fonts.googleapis.com/css?family=Montserrat:800); /* MOBILE CUSTOMIZATIONS */ @media screen and (max-width: 767px) { .snip1214 .plan { width: 90%; margin: 0 auto; background-color: blue; } } @media screen and (min-width: 768px) { .snip1214 .plan { margin: 0; width: 25%; position: relative; float: left; background-color: #ffffff; border: 1px solid rgba(0, 0, 0, 0.1); } } html { height: 100%; } body { background-color: #212121; display: flex; justify-content: center; align-items: center; flex-flow: wrap; margin: 0; height: … -
Django filter statement error- invalid literal for int() with base 10:
I have 2 tables. I wanted to filter records from the second table based on filtered value from the first table. There is something wrong in my second filter statement. If anyone can help me to sort it out? report_table_data=report_table.objects.filter(cn_number=Master_table_data.cn_number)) My codes are as below. Models.py class Master_table(models.Model): sl_no = models.AutoField(primary_key=True) cn_number = models.CharField(max_length=10, null=False) class report_table( models.Model ): cn_number = models.ForeignKey(Master_table, on_delete=models.CASCADE) remarks = models.CharField( max_length=20, null=False ) Views.py def any_view(request): Master_table_data=Master_table.objects.get(sl_no=request.GET['key']) report_table_data=report_table.objects.filter(cn_number=Master_table_data.cn_number)) This throws below error. ValueError: invalid literal for int() with base 10: 'USS2000203' -
can't refresh the data in a DIV python Django nor the page after a jquery
Let me start by saying I have 2 variables in an HTML template(messages and users) and I have multiple buttons that when one of them is clicked it calls a jquery code that sends a post request to a Django server and it returns an update to a variable(messages) however, it's not updating the loop, I also tried to return a new HTML page that contains the new variable updated but the jquery is not updating the whole page with the new HTML if I can update the variable alone it would be better and if I can't do that how can I make jquery use the new HTML page the python code i used to return the update to the varialbe messages: if request.method == 'POST': send=Message.objects.filter(from_id=request.POST.get('userId'),to_id=2) rec=Message.objects.filter(from_id=2,to_id=request.POST.get('userId')) messages=sorted(chain(rec, send),key=lambda instance: instance.id,reverse=True) print(messages) return HttpResponse(list(messages)) and the code i used to return new HTML template: m = Message.objects.filter(to_id=2).order_by('-id') users = {} for i in m: if users.get(i.from_id.username) == None: users[i.from_id.username] = User.objects.get(id=i.from_id.id) users = list(users.values()) send=Message.objects.filter(from_id=users[0].id,to_id=2) rec=Message.objects.filter(from_id=2,to_id=users[0].id) messages=sorted(chain(rec, send),key=lambda instance: instance.id,reverse=True) if request.method == 'POST': send=Message.objects.filter(from_id=request.POST.get('userId'),to_id=2) rec=Message.objects.filter(from_id=2,to_id=request.POST.get('userId')) messages=sorted(chain(rec, send),key=lambda instance: instance.id,reverse=True) print(messages) return render(request,'psych.html',{"users":users, "messages":list(messages)}) return render(request,'psych.html',{"users":users, "messages":list(messages)}) the HTML code and jquery code that uses the variable and … -
password reset emails are coming to the host email
I'm making an e-commerce but it sends the password confirmation email to the host. I use django builtin password reset views so I have no idea path('password-reset/', PasswordResetView.as_view( ), name='password_reset'), path('password-reset/done/', auth_views.PasswordResetDoneView.as_view( ), name='password_reset_done'), path('password-reset-confirm/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view( ), name='password_reset_confirm'), path('password-reset-complete/', auth_views.PasswordResetCompleteView.as_view( ), name='password_reset_complete'), is there a way to edit the email that is sent to? -
Compare existing Django model's instances for matching fields?
I am working on a fairly difficult django query. The query needs to check against all of the Student model instances, and check if any 2 instances have 2+ matching database fields. I have this so far which works if I throw in a hard-coded search term or the value is grabbed from a form input value. Student.objects.annotate( match_count=Case(When(full_name='hardcodedvalue', then=1), default=0, output_field=IntegerField())).annotate( match_count=F('match_count') + Case(When(phone_number='hardcodedvalue', then=1), default=0, output_field=IntegerField())).annotate( match_count=F('match_count') + Case(When(student_email='hardcodedvalue', then=1), default=0, output_field=IntegerField()) ).filter(match_count__gt=1) This works great when compared to hardcoded value which is really a form input. If any 2 fields come back as a match, then it returns the correct result. Now I am struggling to run the query in a similar way, to query against items already existing in the database. I need to run a check that instead of checking against a form input, it checks all of the Student models fields. For example full name would have to check against... full_name=Student.objects.all().value('full_name') -
Azure pipeline not connecting to database service while running tests
I'm trying to run the tests of a Django application on azure with Azure pipelines. But every time I try to connect to the database I run with an error. The .yml file used for the pipeline is this: resources: containers: - container: pg12 image: postgres:12 env: POSTGRES_USER: beta POSTGRES_PASSWORD: beta POSTGRES_DB: beta ports: - 5432 # needed because the postgres container does not provide a healthcheck options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 variables: - name: DJANGO_SETTINGS_MODULE value: config.settings.production - name: DJANGO_SECRET_KEY value: <redacted> - name: DEBUG value: False - name: DATABASE_URL value: postgres://beta:beta@localhost:5432/beta trigger: - qa pool: vmImage: ubuntu-latest strategy: matrix: Python37: PYTHON_VERSION: '3.7' maxParallel: 3 services: postgres: postgres:12 steps: - script: printenv - task: UsePythonVersion@0 inputs: versionSpec: '$(PYTHON_VERSION)' architecture: 'x64' - script: | sudo apt install -y postgresql-client # sudo psql --host=postgres --username=postgres --command="SELECT 1;" - task: PythonScript@0 displayName: 'Export project path' inputs: scriptSource: 'inline' script: | """Search all subdirectories for `manage.py`.""" from glob import iglob from os import path # Python >= 3.5 manage_py = next(iglob(path.join('**', 'manage.py'), recursive=True), None) if not manage_py: raise SystemExit('Could not find a Django project') project_location = path.dirname(path.abspath(manage_py)) print('Found Django project in', project_location) print('##vso[task.setvariable variable=projectRoot]{}'.format(project_location)) - script: | python -m … -
Django FileNotFoundError: [Errno 2] No such file or directory: 'train_mean.joblib' after deployed in Ubuntu, but working in localhost
im deploying dajngi to ubuntu (apache), running fine on my local, but error when deployed on Ubuntu server. the error: [Fri Oct 01 16:59:25.938641 2021] [wsgi:error] [pid 58417:tid 140031275181824] [remote 140.213.196.122:39872] File "/home/ubuntu/prediction/predict/views.py", line 26, in __init__ [Fri Oct 01 16:59:25.938646 2021] [wsgi:error] [pid 58417:tid 140031275181824] [remote 140.213.196.122:39872] self.values_fill_missing = joblib.load("train_mean.joblib") [Fri Oct 01 16:59:25.938650 2021] [wsgi:error] [pid 58417:tid 140031275181824] [remote 140.213.196.122:39872] File "/home/ubuntu/prediction/venv/lib/python3.8/site-packages/joblib/numpy_pickle.py", line 577, in load [Fri Oct 01 16:59:25.938654 2021] [wsgi:error] [pid 58417:tid 140031275181824] [remote 140.213.196.122:39872] with open(filename, 'rb') as f: [Fri Oct 01 16:59:25.938658 2021] [wsgi:error] [pid 58417:tid 140031275181824] [remote 140.213.196.122:39872] FileNotFoundError: [Errno 2] No such file or directory: 'train_mean.joblib' views.py : from django.shortcuts import render from django.http import JsonResponse import joblib import pandas as pd import numpy as np import os class LogisticRegression: def __init__(self): path_to_artifacts = '' self.values_fill_missing = joblib.load(path_to_artifacts + 'train_mean.joblib') self.scaler = joblib.load(path_to_artifacts + 'min_max_scaler.joblib') self.model = joblib.load(path_to_artifacts + 'log_reg.joblib') The dir structure: -
How to avoid double saving after defining the `Save` method on the Model?
I have defined a Save method in my model for the order fields. Now, when I do some manipulations with the Order field in View and call save() - I save twice - in View save() and Model save(). Because of this, the problem! How to solve this problem? How to make Save work only when creating a model object? And don't work save when I save() in Views -
request.POST data field doesn't get to cleaned_data of form
In views.py I've got a method called signup: def signup(request): context = {} if request.method == 'POST': form = SignUpForm(request.POST) print("request", request.POST) if form.is_valid(): user = form.save(commit=False) login(request, user) return redirect('index') else: context['form'] = form else: # GET request form = SignUpForm() context['form'] = form return render(request, 'registration/signup.html', context) Request print gives me all the fields a user entered: request <QueryDict: {'csrfmiddlewaretoken': ['***'], 'username': ['12312312gdsgdsg'], 'email': ['123123fsdfesgf@gmail.com'], 'password1': ['123fhfhfh'], 'password2': ['989898gdfjgndf']}> When I call form.is_valid() it gets to clean data of my form of forms.py: class SignUpForm(UserCreationForm): username = forms.CharField( label="username", max_length=30, required=True, widget=forms.TextInput( attrs={ 'type': 'text', 'placeholder': 'Username', } ), ) email = forms.EmailField( label="email", max_length=60, required=True, widget=forms.TextInput( attrs={ 'type': 'text', 'placeholder': 'Email', } ), ) password1 = forms.CharField( label="password1", required=True, widget=forms.PasswordInput( attrs={ 'type': 'password', 'placeholder': 'Password', } ), ) password2 = forms.CharField( label="password2", required=True, widget=forms.PasswordInput( attrs={ 'type': 'password', 'placeholder': 'Confirm Password', } ), ) def clean(self): cleaned_data = super(SignUpForm, self).clean() print("cleaned data", cleaned_data) password = cleaned_data["password1"] confirm_password = cleaned_data["password2"] if password != confirm_password: self.add_error('confirm_password', "Password and confirm password do not match") return cleaned_data class Meta: model = ServiceUser fields = ('username', 'email', 'password1', 'password2') The form's cleaned data print returns me the same dictionary as the post, but … -
how to restore database 'postgres' from postgresql
I am using local postgresql and pgadmin 4. I dropped database 'postgres' and now pgadmin won't open. How can I restore 'postgres' or fix this issue?