Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Two types of users account in Django
I've form in HTML: <form action=""> <select> <option>Freelancer</option> <option>Employer</option> </select> <input type="text" placeholder="Name"> </form> When user will send the form I want check what account type user has selected. If user selected a Freelancer account I want save him to Freelancer model. If he selected Employer to Employer model. How to use this in forms.py when the class Meta would has two models? -
How to immediately return to my site after PayPal payment
I am creating a website through which people can buy tickets via paypal – I want to send a confirmation email once the payment is complete. So, I turned on auto return in paypal and set it up so that the email would be sent as soon as 'notify_url' was received. However, I only get this notification once it redirects from paypal to the website – I'm afraid that the users will click off the page before it is redirected and before the email is sent. Is there a way to make the process faster, i.e allow me to send the email as soon as the payment is confirmed? -
What could be causing this error in this file but not anywhere else?
I have an HTML file that serves as the layout and it's rendered with python. I keep getting the error 'str' object has no attribute 'field' And it says it comes from my tag, which works on every other page. This is not something I created but I'm rather learning to be able to use it as a newer web developer. My html file looks like this {% extends "ops/base.html" %} {% load core_tags %} {% block page_title %}Ops{% endblock %} {% block main %} <form id="create-w-form" action="{% url "ops:enter" %}" method="POST" class="form-horizontal"> {% csrf_token %} <div class="row"> <div class="form-group col-xs-12"> {% standard_input create_w_form.em_num %} </div> </div> <div class="row"> <div class="col-xs-12 text-right"> <div class="btn btn-primary ajax-submit-btn">Submit</div> </div> </div> </form> {% endblock main %} If I erase the line that contains {% standard_input create_w_form.em_num %} It will render the page, otherwise it won't and I'll get the error mentioned above. -
Django-rest , return customized Json
Hi i'm having this code for a backend query class HexList(generics.ListCreateAPIView): serializer_class = HexSerializer def get_queryset(self): hex_list = Hex.objects.filter(game_id=self.kwargs['pk']) return hex_list That returns this Json: [ { "id": 2, "game_id": 0, "position": 3, "resource": "NO", "token": 0 }, { "id": 3, "game_id": 0, "position": 5, "resource": "WO", "token": 0 }, { "id": 4, "game_id": 0, "position": 6, "resource": "BR", "token": 4 } ] What i would like it to return is the same data, but with in the shape of a Json like something like this: "hexes":[ { "id": 2, "game_id": 0, "position": 3, "resource": "NO", "token": 0 }, { "id": 3, "game_id": 0, "position": 5, "resource": "WO", "token": 0 }, { "id": 4, "game_id": 0, "position": 6, "resource": "BR", "token": 4 } ] } I've tried this : class HexList(generics.ListCreateAPIView): serializer_class = HexSerializer def get_queryset(self): hex_list = Hex.objects.filter(game_id=self.kwargs['pk']) return Response({'hexes': hex_list}) And i'm getting a ContentNotRenderedError Exception What should i do? Thanks in advance -
RuntimeWarning: DateTimeField received naive datetime while time zone support is active
pst = pytz.timezone('US/Pacific') start_time = pst.localize(datetime.strptime(data_post['startTime'], fmt)) if 'endTime' in data_post: end_time = pst.localize(datetime.strptime(data_post['endTime'], fmt)) I got the below Warning /venv/local/lib/python2.7/site-packages/django/db/models/fields/init.py:1393: RuntimeWarning: DateTimeField DashboardTestResult.start_time received a naive datetime (2019-09-27 00:00:00) while time zone support is active. RuntimeWarning) -
Sending api_key in header while url has parameters
For security reasons, I designed my django app to accept api_key in url header (in Authorization). So to call the service: curl -H "Authorization: 123456789ABC" http://127.0.0.1:8000/api:v1/live but I don't know how to send other url parameters: curl -H "Authorization: 123456789ABC" http://127.0.0.1:8000/api:v1/live?from=A&output=pdf it gets the api_key but not the parameters and gives this error in command prompt: {"api_key": "123456789ABC"}'output' is not recognized as an internal or external command, operable program or batch file. -
How to filter out profiles that have an appointment (foreign key relationship)?
I am attempting to retrieve all Profile objects that do not have an Appointment scheduled. An Appointment object may or may not have a Profile associated with it (either being an empty time slot or a booked appointment). I haven't tried anything yet, because I don't know where to start from here. users/models.py class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) phone = models.CharField(max_length=30) objects = managers.ProfileManager() booking/models.py class Appointment(models.Model): profile = models.ForeignKey( 'users.Profile', on_delete=models.PROTECT, unique=False, null=True, ) massage = models.CharField( default=None, max_length=2, choices=[ ('SW', 'Swedish'), ('DT', 'Deep Tissue'), ], null=True, ) date_start = models.DateTimeField() date_end = models.DateTimeField() black_out = models.BooleanField(default=False) date_created = models.DateTimeField(auto_now_add=True) date_updated = models.DateTimeField(auto_now=True) objects = AppointmentManager() users/managers.py def search_by_name(self, request): first_name = request.GET.get('first-name', '') last_name = request.GET.get('last-name', '') profiles = [] max_results = 5 if first_name == '' and last_name == '': return (True, {'profiles': profiles}) elif last_name == '': profiles = models.Profile.objects \ .filter(user__first_name__icontains=first_name)[:max_results] elif first_name == '': profiles = models.Profile.objects \ .filter(user__last_name__icontains=last_name)[:max_results] else: profiles = models.Profile.objects \ .filter(user__first_name__icontains=first_name) \ .filter(user__last_name__icontains=last_name)[:max_results] return (True, {'profiles': profiles}) The search_by_name function filters all Profile objects containing first and/or last names, including those with an Appointment scheduled (which I don't want). Any help is appreciated. -
Displaying Django inline formsets for different instances of parent model
I am new to Django and am trying to display an inline formset in my Django application to allow a user to add instances of a child model to its corresponding instance of the parent model. I feel like there is a simple answer but so far I haven't been able to think of or find a solution. My models: class ExerciseName(models.Model): name_of_exercise = models.CharField(max_length=100, default = 'Exercise name', unique=True) def __str__(self): return self.name_of_exercise class SetLogger(models.Model): weight = models.FloatField(default=0) reps = models.FloatField(default=0) date = models.DateField(auto_now=True) exercise_group = models.ForeignKey(ExerciseName, on_delete = models.CASCADE) My forms : class ExerciseNameForm(forms.ModelForm): class Meta: model = ExerciseName fields = ('name_of_exercise', ) Views: def name_list(request): exercise_name = ExerciseName.objects.all() sets = SetLogger.objects.all() exercisename = ExerciseName.objects.get(pk=1) SetLoggerFormSet = inlineformset_factory(ExerciseName, SetLogger, fields=('weight','reps',)) if request.method == 'POST': form = ExerciseNameForm(request.POST) formset = SetLoggerFormSet(request.POST, instance=exercisename) if form.is_valid(): form.save(commit=True) else: form = ExerciseNameForm() if formset.is_valid(): formset.save(commit=True) else: formset = SetLoggerFormSet() return render(request, 'gymloggerapp/name_list.html', {'exercise_name': exercise_name, 'form': ExerciseNameForm(), 'sets': sets, 'formset': formset}) So far, this has worked in allowing me to add weight and reps to the first instance of my ExerciseName model (with pk=1), by just displaying the formset in my template. However, I would like to create a formset in this way … -
Secure User Registration with ReactJS and Django REST
I am creating a project with React and Django REST framework, I want to know how can I register a user through React UI in a secure way. Do I send an HTTP request to Django with the clean password? this just seems very insecure and vulnerable -
Shoud we use NoSQL or SQL with Django
We aim to develop a platform to serve our customer SaaS in text analytics services. Our customers are financial institutions, mainly banks and each institution has ~1000 users on average. While we won't have an overload in our platform during the testing process with MVP(minimum viable product), our transition to customers after the testing process won't be soft. So we would like to take scalability, security, and performance into account. Platform, -Connects to various websites to collect customer reviews -Customers will be able to import call-center datasets and files such as CSV etc. -Performs analytics processes among text datasets such as classification and clustering. -Reports via visualizations and tables. -Customers can view the saved reports in mobile application. So, what would you recommend us to use as a database structure among Django Framework? Thanks in advance. -
django + ajax + dependent dropdown
I have implemented dependent dropdown input in Django (to allow the booking of different timeslots on different dates) using This tutorial. However, Django cannot process the POST request since the value is always 'none'. I am sure it has to do with AJAX (in the HTML file) and the function load_timeslots (in view.py): AJAX does not provide any information for the POST request. How would I implement this further? models.py class Day(models.Model): day = models.CharField(max_length=30) def __str__(self): return self.day class TimeSlot(models.Model): day = models.ForeignKey(Day, on_delete=models.CASCADE) timeslot = models.CharField(max_length=30) reserved = models.BooleanField(default=False) def __str__(self): return self.timeslot class Person(models.Model): name = models.CharField(max_length=100) email = models.EmailField() day = models.ForeignKey(Day, on_delete=models.SET_NULL, null=True) timeslot = models.ForeignKey(TimeSlot, on_delete=models.SET_NULL, null=True) def __str__(self): return self.name forms.py class TimeSlotForm(forms.ModelForm): class Meta: model = Person fields = ('name','email', 'day', 'timeslot') def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['timeslot'].queryset = TimeSlot.objects.none() views.py class ExpSignup(TemplateView): template_name = 'thesis_scheduler/index.html' def get(self,request): form = TimeSlotForm() return render(request, self.template_name, {'form':form}) def post(self,request): form = TimeSlotForm(request.POST) print(form ) if form.is_valid(): name = form.cleaned_data['name'] email = form.cleaned_data['email'] day = form.cleaned_data['day'] timeslot = form.cleaned_data['timeslot'] form.save() # Check if a given TimeSlot is still available if (len(TimeSlot.objects.filter(day=day_id, reserved=False, timeslot=timeslot)) != 0): # Deactive the TimeSlot temp= TimeSlot.objects.get(day=day_id, timeslot=timeslot) temp.reserved = … -
How to assign few objects to one user
I want to have template page with object(orders) list (another list, for another user). Like relations one to many. Where do i need to define that objects(order)(for exemple by id: order_id=1 and order_id=3) is assigned to user(driver) with id=1 etc? I was trying to create Driver class and than set atribute driver in order Class like this. #FORM.PY class OrderForm(forms.Form): telephone_regex = RegexValidator(regex=r'^\+?1?\d{9,15}$', message="Phone number must be entered in the format: '+999999999'.") airport = forms.ChoiceField(choices=AIRPORT_CHOICES) ### Jeśli lotnisko jest celem podróży direction = forms.ChoiceField(choices=DIRECTION_CHOICES) ## to pick_up < plane i odwrotnie!!! adress = forms.CharField() client = forms.CharField() telephone = forms.CharField(validators=[telephone_regex]) flight_number = forms.CharField() plane = forms.DateTimeField(input_formats=['%Y-%m-%d']) pick_up = forms.DateTimeField(input_formats=['%Y-%m-%d']) gate = forms.CharField() company = forms.ChoiceField(choices=COMPANY_CHOICES) driver = forms.ChoiceField(choices=DRIVER_CHOICES) #MODELS.PY class Driver(models.Model): name = models.CharField(max_length=30) tel = models.CharField(max_length=17) class Order(models.Model): telephone_regex = RegexValidator(regex=r'^\+?1?\d{9,15}$', message="Phone number must be entered in the format: '+999999999'.") airport = models.CharField(max_length=10, choices=AIRPORT_CHOICES) direction = models.CharField(max_length=7, choices=DIRECTION_CHOICES) adress = models.CharField(max_length=100, null=False, blank=False) client = models.CharField(max_length=50, null=False, blank=False) telephone = models.CharField(validators=[telephone_regex], max_length=17, blank=False) flight_number = models.CharField(max_length=7) plane = models.DateTimeField(null=True) pick_up = models.DateTimeField(null=True) gate = models.CharField(max_length=10, null=True, blank=True) comapny = models.CharField(max_length=50, choices=COMPANY_CHOICES) driver = models.ForeignKey(Driver, on_delete=models.CASCADE) # ORDER_LIST.HTML {% extends "base.html" %} {% block content %} {% if user.is_authenticated %} … -
What is the best way to convert a python ( Django + Wagtail ) website to an IOS app?
I built a website using Python ( Django + Wagtail ), and I need to convert it to an ios application. I have no prior experience on ios app development -
heroku logs --tail, unable to understand what follows
I am not being able to deploy my web app on Heroku. The error(I have listed them below) shows many things, of which I understand that psycopg2 = 2.7.2 and python 3.6 version is required. But in my requirement.txt file, when I pip freeze, psycopg2 = 2.8.3 comes, and for developing the web app I used python 3.7.4. Hence I enter python 3.7.4 version in the runtime.txt file. Now my question is, do the errors below suggest that I need to mention psycopg2=2.7.2 and python=3.6.(version)? But when I do that, psycopg2=2.7.2, and python=3.6.8, in the very first step, the push fails(git push Heroku master). What should I do? This my requirement.txt file Django==2.0.13 django-heroku==0.3.1 gunicorn==19.9.0 psycopg2==2.8.3 pytz==2019.2 whitenoise==4.1.4 This is my runtime.txt file python-3.7.4 This is my Procfile web: gunicorn mysite.wsgi --log-file - when I run heroku ps:scale web=1, it shows Scaling dynos... done, now running web at 1:Free but after runningheroku open, it shows errors. On getting the logs,heroku logs --tail`, when I follow the given link in the log history, I get the following errors. -----> Installing requirements with pip Collecting psycopg2==2.7.2 (from -r /tmp/build_323b8a662b13c10001fe839be236c115/requirements.txt (line 6)) Downloading https://files.pythonhosted.org/packages/d2/5a/6c2fe0b4671c81e7525c737d6600a5c82b7550a5f2dff8a01afb616dbbf4/psycopg2-2.7.2-cp36-cp36m-manylinux1_x86_64.whl (2.7MB) Installing collected packages: psycopg2 Found existing installation: psycopg2 … -
drango template webpage file utf-8 decoding error
bootstrap-examples-source-files have utf-8 decoding error in django render webpages. Internal Server Error: / Traceback (most recent call last): File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\exception.py", line 41, in inner response = get_response(request) File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\handlers\base.py", line 187, in _get_response .............. File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\codecs.py", line 321, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb7 in position 471: invalid start byte -
Django loaddata command from docker container
I have a django app that I put inside of a docker container for deployment. I have some initial data that I want to load into the database via the dumpdata and loaddata commands. The initial data lives on my local hard drive. I choose a very naive approach and simply copied the data_backup.json file to the server via scp. Now, I want to load the data_backup.json file (the file sits on the server not in the docker container) by executing: sudo docker-compose exec restapi python manage.py loaddata --settings=rest.settings.production ./data_backup_20191004.json But Django only searches the internal directories for fixtures. I am looking for a way to populate the database with the data_backup.json file inside the docker container. Can someone help? Ultimately, I am looking for a way to dump data directly to S3 and load it from there if needed (for db backups). If you have any tips on how to achieve that, this would also be super helpful - I don't seem to be able to find material on that. -
How to get data from one Django model to query another model within a template loop?
My Django application has two Models 'Items' & 'Colors' representing database tables 'items' and 'colors'. A Django template 'mytemplate.html' renders data gathered from the database with a 'for' loop, printing out a list of items with their properties. One of the fields of 'items' table is a numeric id that correspond to a text field in 'colors' table. Currently I can display all the items with their names and their color numeric id 'cid' (see code below). But I need to print the color name of an item instead of its 'cid'/'id' within the template loop. What is the most efficient way to achieve this? Do I need an intermediary data structure, alter my database to define a foreign key (items(cid) --> colors(id)), ... ? I'm not sure that I want to use a foreign key (items(cid) --> colors(id)) because at the time of first insertion of items 'cid' could be undefined (NULL). Table 'items' +------+------+------+ | id | cid | name | +------+------+------+ | 1 | 3 | barZ | | 2 | 3 | barC | | 3 | 1 | barE | | 3 | 2 | barD | | 4 | 1 | barA | +------+------+------+ … -
Django MultiWidget and field labels
I have a requirement for a Django form that contains 3 forms.Textarea which are compressed into a single models.TextField compatible value. For this, I've subclassed both forms.MultiValueField and forms.MultiWidget. My problem is in trying to identify where and how to add labels to the widget's textarea inputs. What I am currently doing is passing in the label value as an attr to the widget's subwidgets: class ContentWidget(forms.MultiWidget): template_name = 'content_widget.html' def __init__(self, attrs=None): widgets = ( forms.Textarea({'label': 'A'}), forms.Textarea({'label': 'B'}), forms.Textarea({'label': 'C'}), ) super().__init__(widgets, attrs) This lets me keep the content_widget.html pretty concise: {% for subwidget in widget.subwidgets %} <label for="{{ subwidget.attrs.id }}">{{ subwidget.attrs.label }}</label> {% include subwidget.template_name with widget=subwidget %} <br /> {% endfor %} But this also adds the label attr to each html element, which feels a bit hacky: <textarea name="content_0" cols="40" rows="10" label="A" required="" id="id_content_0"></textarea> Another option is to explicitly include it in a more long-form version of the template: <label for="{{ widget.subwidgets.0.attrs.id }}">A</label> {% include widget.subwidgets.0.template_name with widget=subwidget %} ... However, for form elements in general, the label is assigned to the field, but I can't find a way for the widget to access them from the MultiValueField instance if I define them there: class … -
Django manage.py outside of project
Is there a method of having manage.py outside of the Django project directory without having to change all the imports to from backend.<app>.<module> import ...? ├── project │ ├── api │ ├── frontend │ ├── project │ ├── manage.py │ ├── Pipfile │ ├── Pipfile.lock ├── project │ ├── backend │ │ ├── api │ │ ├── project │ │ ├── __init__.py │ ├── frontend │ ├── manage.py │ ├── Pipfile │ ├── Pipfile.lock As expected after moving the Django project into the backend directory and modifying manage.py with the line below there's a ModuleNotFoundError when trying to run the server. os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.project.settings') -
Django Project Template Error: django.template.exceptions.TemplateDoesNotExist
I tend to use the same project template for a majority of my Django projects. Till now, I have been using copy-paste to use the template in different projects. (Sorry! I was unware of --template option that comes with django-admin.) I got to know of --template option with django-admin a while back and I have a question regarding the same. The aforementioned template that I use for my projects has some common Django apps, namely, accounts to handle user authentication, pages to handle request to pages like 'About', 'Contact', etc and some generic Django templates like base.html, templates for account activation email and password reset email. Some of the generic Django templates (like the Sign In template) extend base.html in them. This is where the problem arises. I get an error django.template.exceptions.TemplateDoesNotExist: base.html when I try to use my project template with a new project. Traceback: $ django-admin startproject --template=/home/alfarhanzahedi/Projects/django-boilerplate/project_name --extension=py,html simpleqa Traceback (most recent call last): File "/home/alfarhanzahedi/Projects/temp/venv/bin/django-admin", line 10, in <module> sys.exit(execute_from_command_line()) File "/home/alfarhanzahedi/Projects/temp/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File "/home/alfarhanzahedi/Projects/temp/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/alfarhanzahedi/Projects/temp/venv/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv self.execute(*args, **cmd_options) File "/home/alfarhanzahedi/Projects/temp/venv/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute output = self.handle(*args, **options) File "/home/alfarhanzahedi/Projects/temp/venv/lib/python3.7/site-packages/django/core/management/commands/startproject.py", line 20, … -
Django test with setUpTestData doesn't keep changes between tests
classmethod TestCase.setUpTestData() The class-level atomic block described above allows the creation of initial data at the class level, once for the whole TestCase. [...] Be careful not to modify any objects created in setUpTestData() in your test methods. Modifications to in-memory objects from setup work done at the class level will persist between test methods. Cit. django.test.TestCase.setUpTestData Consider this example: class FoobarTest(TestCase): @classmethod def setUpTestData(cls): cls.post = Post() cls.post.stats = {} cls.post.save() def setUp(self): self.post.refresh_from_db() def test_foo(self): self.post.stats['foo'] = 1 self.post.save() self.assertEquals(self.post.stats, {'foo': 1}) # this should fail def test_bar(self): # this run first cause alphabetical order self.post.stats['bar'] = 1 self.post.save() self.assertEquals(self.post.stats, {'bar': 1}) Since Modifications to in-memory objects from setup work done at the class level will persist between test methods I expect one of the two test methods to fail cause the post object will have also a different property and the equality should fail. But this test pass without problem. If i force the execution order it actually behave like expected: class FoobarTest(TestCase): @classmethod def setUpTestData(cls): cls.post = Post() cls.post.stats = {} cls.post.save() def setUp(self): self.post.refresh_from_db() def _foo(self): self.post.stats['foo'] = 1 self.post.save() self.assertEquals(self.post.stats, {'foo': 1}) def _bar(self): self.post.stats['bar'] = 1 self.post.save() self.assertEquals(self.post.stats, {'bar': 1}) def test_foo_bar(self): self._foo() … -
POST list of dictionaries and update or create
Im trying to make my django-rest-framework to accept a list of dicts for updating or creating many objects in one api-call. My model: class Order(models.Model): internal_id = models.CharField(max_length=500, unique=True) external_id = models.CharField(max_length=500, blank=True, null=True, unique=True) status = models.CharField(max_length=500, verbose_name="Status", blank=True, null=True) My seriallizer: class SimpleOrderSerializer(serializers.ModelSerializer): class Meta: model = Order fields = '__all__' My view: class CreateListMixin(): def get_serializer(self, *args, **kwargs): if isinstance(kwargs.get('data', {}), list): kwargs['many'] = True return super().get_serializer(*args, **kwargs) class OrderViewSet(CreateListMixin, viewsets.ModelViewSet): queryset = Order.objects.all() serializer_class = SimpleOrderSerializer lookup_field = 'internal_id' When I try to pass a list with a value on internal_id that exists I want it to update the object. If the internal_id does not exists, I want to create a new objects. Is this possible with django rest framework? -
Django API: How to save/ save as project?
I am developing python backend for django web app. In the application when user clicks on Save or Save As button then I should give pop up for confirmation which can be handled by frontend. But in back end, when user opts to save the progress then I should save whatever progress they have made it on that application. Any ideas? -
How to implement Websockets on AWS using Django and boto3?
I'm planning to implement Websockets communication under Amazon Web Services for my Django project. The usual approach is to use Django Channels library but it's a bit tricky to implement on AWS. Recently it's been developed a native AWS WebSocket API. Python implementation for that is included in boto3 library. I suppose that the native AWS way is preferable but I'm not sure how. How to integrate AWS WebSocket API with a Django project using boto3? -
Migrate error after add new field use django-pgcrypto-fields
Migrate error after add new field use django-pgcrypto-fields My model (migrate okay in the first time) class Dkm(models.Model): name = fields.TextPGPSymmetricKeyField() value = fields.IntegerPGPSymmetricKeyField(default=0) I update model and migrate again: class Dkm(models.Model): name = fields.TextPGPSymmetricKeyField() value = fields.IntegerPGPSymmetricKeyField(default=0) value2 = fields.IntegerPGPSymmetricKeyField(default=0) Error occur Traceback (most recent call last): File "manage.py", line 21, in <module> main() File "manage.py", line 17, in main execute_from_command_line(sys.argv) File "C:\Users\vu.tran\Desktop\kona-server\env\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line utility.execute() File "C:\Users\vu.tran\Desktop\kona-server\env\lib\site-packages\django\core\management\__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Users\vu.tran\Desktop\kona-server\env\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv self.execute(*args, **cmd_options) File "C:\Users\vu.tran\Desktop\kona-server\env\lib\site-packages\django\core\management\base.py", line 364, in execute cursor.execute(sql, params) File "C:\Users\vu.tran\Desktop\kona-server\env\lib\site-packages\django\db\backends\utils.py", line 99, in execute return super().execute(sql, params) File "C:\Users\vu.tran\Desktop\kona-server\env\lib\site-packages\django\db\backends\utils.py", line 67, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "C:\Users\vu.tran\Desktop\kona-server\env\lib\site-packages\django\db\backends\utils.py", line 76, in _execute_with_wrappers return executor(sql, params, many, context) File "C:\Users\vu.tran\Desktop\kona-server\env\lib\site-packages\django\db\backends\utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "C:\Users\vu.tran\Desktop\kona-server\env\lib\site-packages\django\db\utils.py", line 89, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File "C:\Users\vu.tran\Desktop\kona-server\env\lib\site-packages\django\db\backends\utils.py", line 84, in _execute return self.cursor.execute(sql, params) django.db.utils.ProgrammingError: column "value3" is of type bytea but default expression is of type integer HINT: You will need to rewrite or cast the expression. The error will not occur if set null=True