Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django won't add the default language prefix in URL at startup
This is my first question here after 3 years of programming with Django, during which i always did all i could to solve problems by doing research. This time i'm really stuck... My issue is with a recent Django website ( url: h t t p s : // bucegipark. ro ) that should automatically add the language prefix when you access it (like for example going to this link), but it suddenly STOPPED doing that around a month ago and really cannot find the issue. I reset all language internalization settings twice. I should mention that with debug set to True it redirects to url with language prefix just fine, the issue comes up in production. When no prefix is shown after the url, database info is not either loaded. After starting the website, if i choose a language using the dropdown list i built, it redirects to that url with chosen language prefix. It does the same when i click the brand logo which has the {% url 'home' %} url attached to it and redirects to the homepage with the language prefix just fine. So theoretically, the urls.py code works fine i guess, the problem lies in … -
Trying to make an icon work while modifying a django template
How can make this icon show in my modified django template: I tried using font awesome link but it did not work the template was downloaded online and i am currently modfying it hence me encountering this issue. i triend downloading other fonts online but then none is the same as this -
Cannot translate only a model label in Django Admin
I'm trying to translate the entire Django Admin from English to French. This is my django-project below. *I use Django 4.2.1: django-project |-core | |-settings.py | └-urls.py |-my_app1 | |-models.py | |-admin.py | └-apps.py |-my_app2 └-locale └-fr └-LC_MESSAGES |-django.po └-django.mo And, this is core/settings.py below: # "core/settings.py" MIDDLEWARE = [ ... 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', ... ] LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_TZ = True from django.utils.translation import gettext_lazy as _ LANGUAGES = ( ('en', _('English')), ('fr', _('French')) ) And, this is core/urls.py below: # "core/urls.py" from django.contrib import admin from django.urls import path from django.conf.urls.i18n import i18n_patterns urlpatterns = i18n_patterns( path('admin/', admin.site.urls) ) And, this is my_app1/models.py below: # "my_app1/models.py" from django.db import models from django.utils.translation import gettext_lazy as _ class Person(models.Model): name = models.CharField(max_length=20, verbose_name=_("name")) class Meta: verbose_name = _('person') verbose_name_plural = _('persons') And, this is my_app1/apps.py below: # "my_app1/apps.py" from django.apps import AppConfig from django.utils.translation import gettext_lazy as _ class MyApp1Config(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'my_app1' verbose_name = _('my_app1') And, this is locale/fr/LC_MESSAGES/django.po below: # "locale/fr/LC_MESSAGES/django.po" ... #: .\core\settings.py:140 msgid "English" msgstr "Anglais" #: .\core\settings.py:141 msgid "French" msgstr "Français" ... #: .\my_app1\apps.py:7 msgid "my_app1" msgstr "mon_app1" #: .\my_app1\models.py:6 msgid "name" msgstr "nom" #: … -
how can I create an E-commerce CART system using python Django
I am developing an E-commerce website and encountering difficulties in implementing a cart system. please, Can anyone guide me through the process of implementing a cart system or provide some helpful resources? Thank you. -
python/django - convert 2 unequal querysets into "context" dictionary for passing on to template rendering in detail view
new to python/django framework. have got 2 querysets ('a' and 'b') using ldid=3 a=Ld.objects.filter(id=ldid).values() b=Ld.objects.get(id=ldid).ldref.all().values() Result: type of a and b is <class 'django.db.models.query.QuerySet'> a is <QuerySet [{'id': 3, 'docref': '228689', 'deno': 'ESGF387054', 'dedt': '20200905', 'bjno': 'ESGF387054', 'bjdt': '20200905', 'ccode_id': 3, 'gcode_id': 6, 'smcd_id': 3, 'cmcd_id': 1, 'schmcd_id': 6, 'invno': '2015407629', 'invdt': '20200905', 'item': 'MOBILE', 'brnd': 'VIVO', 'pref1': 'X50 KC472228', 'pref2': '', 'invamt': '34990', 'intper': '0', 'intamt': '0', 'emitot': '18', 'emiamt': '1944', 'emiano': '6', 'emiaamt': '11664', 'lnamt': '23327', 'lnbal': '23328', 'ddt': '20201010', 'cldt': '', 'szdt': '', 'szrem': '', 'lstatus': '', 'ndeno': '462DDFGF387054', 'ntdue': '23328', 'ntrcpt': '21384', 'nbal': '1944'}]> b is <QuerySet [{'id': 3, 'rtref': '2196146', 'ldref_id': 3, 'rtno': 'E504744', 'rtdt': '20210605', 'emi': '1944', 'pen': '0', 'remlt': 'false'}, {'id': 4, 'rtref': '2196147', 'ldref_id': 3, 'rtno': 'E504745', 'rtdt': '20210605', 'emi': '1333', 'pen': '0', 'remlt': 'false'}, {'id': 5, 'rtref': '2196148', 'ldref_id': 3, 'rtno': 'E504746', 'rtdt': '20210605', 'emi': '1545', 'pen': '0', 'remlt': 'false'}]> need to convert them to single dictionary, introducing a new key 1,2,3,4 etc. and values the dictionaries from the queryset. something like `context = { 1 : {'id': 3, 'docref': '228689', etc.,}, --> from a 2 : {{'id': 3, 'rtref': '2196146', 'ldref_id': 3, 'rtno': 'E504744', etc.,}, ` for use as context … -
Migration failed in Wagtail 5.0.1 on MSSQL
after install wagtail, i have some problems how to use mssql in wagtail cms? i have error when migration wagtail when use mssql, im use wagtail v5 and django v4.2.2 its error log django.db.utils.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The index 'content_object_idx' is dependent on column 'content_type_id'. (5074) (SQLExecDirectW); [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]ALTER TABLE ALTER COLUMN content_type_id failed because one or more objects access this column. (4922)") is it possible use mssql for wagtail cms database? how to Solve migration to MSSQL on wagtail cms ? -
deciding a sofware stack angular+django+vite? [closed]
I work for a firm that gave me the task to select a software stack that suits our needs i already have some idea of what it is going to be but i am the only technical people in the firm so i need advice. I just got out of school so its kinda overwelming. What we need -One MPA (so ssr and seo) -Two SPA on the same domain as the MPA -A backend that works with mssql and the frontend Because it is a pretty big enterprise project and my devs are in inda and familiar with angular i want to use angular with primeNG on top. For the backend i think django will be my choice becauce it works with our database and the build in functionalities seem very nice. I would also like to use vite for faster developing time but i am not sure if it will suit my needs. The main question is can i use angular for the MPA so ssr and angular for the SPA's on the same domain, it opens a new tab when a link is clicked to the SPA. I need to hydrate some parts of pages of the … -
Django: request.POST contains only the last form in my formset
When I run pprint(request.POST), it only returns the data of the last form of my formset. Why is this happening? Here is my code. My models.py: class Order(models.Model): date = models.DateField(unique=True, blank=True, null=True) first_course = models.CharField(null=True, blank=True, unique=False, max_length=30) first_course_quantity = models.IntegerField() second_course = models.CharField(null=True, blank=True, unique=False, max_length=30) second_course_quantity = models.IntegerField() dessert = models.CharField(null=True, blank=True, unique=False, max_length=30) dessert_quantity = models.IntegerField() drink = models.CharField(null=True, blank=True, unique=False, max_length=30) drink_quantity = models.IntegerField() def __str__(self): return f"Date of order: {self.date}" My forms.py: class DisabledOptionWidget(forms.Select): def render(self, name, value, attrs=None, renderer=None): html_code = super(DisabledOptionWidget, self).render(name, value, attrs, renderer) html_code = html_code.replace(f'<option value=""', f'<option value="" disabled') return html_code class OrderForm(forms.ModelForm): first_course = forms.ChoiceField(choices=[("", 'Select a dish')] + [(f"{item}", item) for item in list( Menu.objects.values_list("first_course", flat=True))], widget=DisabledOptionWidget, required=False) first_course_quantity = forms.IntegerField(min_value=0) second_course = forms.ChoiceField(choices=[("", 'Select a dish')] + [(f"{item}", item) for item in list( Menu.objects.values_list("second_course", flat=True))], widget=DisabledOptionWidget, required=False) second_course_quantity = forms.IntegerField(min_value=0) dessert = forms.ChoiceField(choices=[("", 'Select a dish')] + [(f"{item}", item) for item in list( Menu.objects.values_list("dessert", flat=True))], widget=DisabledOptionWidget, required=False) dessert_quantity = forms.IntegerField(min_value=0) drink = forms.ChoiceField(choices=[("", 'Select a dish')] + [(f"{item}", item) for item in list( Menu.objects.values_list("drink", flat=True))], widget=DisabledOptionWidget, required=False) drink_quantity = forms.IntegerField(min_value=0) date = forms.DateField(required=False) class Meta: model = Order fields = "__all__" def save(self, commit=True): if commit: … -
Django issue with validating data in form
So I've been working my way through this tutorial, and I've run into a problem I can't figure out. I'm hoping someone can show me the way. I have a new user registration form I'm working on, and I can't get the data to validate with form.is_valid(). In views.py, the if form.is_valid() is supposed to validate the data inputted into the form, but instead it returns "Invalid" no matter what. I'm relatively new to Python and Django, so any assistance would be appreciated. views.py: # main/views.py from django.http import HttpResponse from django.contrib.auth import login from django.shortcuts import redirect, render from django.urls import reverse from main.forms import CustomUserCreationForm # Create your views here. def main(request): return render(request, 'main.html', {}) def dashboard(request): return render(request, 'users/dashboard.html') def admin(request): return render(request, 'admin') def login(request): return render(request, 'registration/login.html') def register(request): if request.method == 'GET': return render( request, 'users/register.html', {'form': CustomUserCreationForm} ) elif request.method == 'POST': form = CustomUserCreationForm(request.POST) if form.is_valid(): user = form.save() login(request, user) return HttpResponse('<h1>Validated!</h1>') # return render(redirect(reverse('dashboard'))) else: return HttpResponse('<h1>Invalid</h1>') forms.py: # main/forms.py from django import forms from django.contrib.auth.forms import UserCreationForm class CustomUserCreationForm(UserCreationForm): class Meta(UserCreationForm.Meta): fields = UserCreationForm.Meta.fields + ('email',) register.html: <!-- main/templates/users/register.html --> {% extends 'main.html' %} {% block content %} … -
friends help me my login system doesnt function doesnt redirect to dashboards and there is no detected errors, below are codes
please help login system doesnt function i cant login in my django system class User(AbstractBaseUser, PermissionsMixin): email = models.EmailField(unique=True) first_name = models.CharField(max_length=150) last_name = models.CharField(max_length=150) username = models.CharField(max_length=150, unique=True, null=True, blank=True) is_staff = models.BooleanField(default=False) is_active = models.BooleanField(default=True) -
django messages wont show up in template
Okey this has been asked aloooot but no answer has helped, tried tutorials and asked my student collegues for help but no one can answer why. They have looked and says it looks fine, that it could be something wrong with my django itself. I'm trying to just show a successful logged in message on my django app. I can't make it work. Please bare with me, my first django project and im a student that suffers real bad from imposter syndrome, play nice :) My folder setup home <--app projectfolder media static with images and css folder users <-- app So to start off i use djangos built in auth system. Works great on the site. Using djangos own form for login and logout. Whats really weird is that the div dosent even show up when i render the page and check inspect, nothing in console either. views.py in users from django.contrib import messages from django.contrib.auth import authenticate, login, logout from django.shortcuts import render, redirect def login_user(request): """ Login form and messages """ if request.method == "POST": username = request.POST['username'] password = request.POST['password'] user = authenticate(request, username=username, password=password) if user is not None: login(request, user) messages.success(request, "You have been … -
Django socket communication
I have a Django server with a list of devices and their corresponding MAC addresses. I have also created firmware for these devices, and I want to license them using my Django webserver in order to prevent the firmware from being copied onto other chips. The problem I'm facing is that the data will be sent to my web backend every 10 minutes (which could be reduced to 1 minute in the future). Additionally, I want the communication between the devices and the web server to be two-way, so that I can disable the devices at any time by sending a message. I'm unsure of how to handle this situation. Would Django channels be a useful solution in this case, and if so, how can I implement them? The firmware is written in C++. -
How can I edit the contents of a datalist element based on a selection made in another dropdown
I'm writing a section of a Django template file for inputting multiple fields using dropdown menus. Two of the sections are 'State' and 'County'; currently the county dropdown list is just a datalist of all the counties in the entire country, but I would like to use some Javascript to rewrite the datalist whenever a selection is made in the State dropdown option to show only the counties in that particular state. Any suggestions are appreciated! -
Overidding dj-rest-auth Registration Serializer
I am trying to override the register serializer, I want to add a name field but the default view still shows this is my configuration in settings.py ACCOUNT_USERNAME_REQUIRED = False ACCOUNT_EMAIL_VERIFICATION = 'none' REST_AUTH_REGISTER_SERIALIZERS = { 'REGISTER_SERIALIZER': 'accounts.serializers.CustomRegisterSerializer' } my url looks like this urlpatterns = [ path('', include('dj_rest_auth.urls')), path('registration/', include('dj_rest_auth.registration.urls')), ] while my serializer from dj_rest_auth.registration.serializers import RegisterSerializer class CustomRegisterSerializer(RegisterSerializer): name = serializers.CharField(max_length=100) email = serializers.EmailField() class Meta: model = get_user_model() fields = [ 'name', 'email' ] -
How to type hint self.client.patch in django.test.TestCase?
I am wondering what type hint to use as the output of _request in the following Django test case: from django.test import TestCase class SomeTestCase(TestCase): def _request(self, id: int, update_data: dict[str, Any]) -> ?: url = reverse('path', kwargs={'id': id}) return self.client.patch(url, update_data) ... -
Django-Rest - How to create URL & View to extract "GET" query parameters in different formats?
I have an application that is sending a GET request in the form of /myapi/details/?id="myid". Currently my Django-Rest server is setup to receive requests as follows: urls.py urlpatterns = [ path('/details/<str:id>/', views.details.as_view()), ] views.py class details(APIView): def get(self, request, id): //id contains the data This works fine when sending a GET request as /myapi/details/"myid". To try and also receive requests with /?id="myid" I added path('/details/?id=<str:id>/', views.details.as_view()), to urlpatterns, but sending the request still hits the other URL regardless of the order. What would be the correct way to go about this? Ideally, I would like to accept both /"myid" and /?id=<str:id> formats. -
How to filter table with class name in html?
If class = "node focused" , how can i filter the data with its id in table table-bordered table-sm table-active in base.html i want to see deatils only selected node in my table. {d.1} = div id <div id="TEM01" data-parent="ATK" class="node focused"><div class="title" style="width:200px"><i class="oci oci-leader symbol"></i>ATK</div> <div id="TEM02" data-parent="ATK" class="node"><div class="title" style="width:200px"><i class="oci oci-leader symbol"></i>ATK</div> chart.js below nodeClickHandler: function (event) { this.$chart.find('.focused').removeClass('focused'); $(event.delegateTarget).addClass('focused'); }, css below .orgchart .node.focused { background-color: rgba(217, 83, 79, 0.8); } base.html below. <body> <div id="chart-container"></div> {% block content %} {% endblock %} <script type="text/javascript" src="{% static 'js/jquery.js' %}"></script> <script type="text/javascript" src="{% static 'js/jquery.orgchart.js' %}"></script> <script src="{% static 'js/bootstrap.js' %}"></script> <div id=" row justify-content-md-center"> <div class="col-sm"> <h5 align="center"><i><span style="background-color: #262626" class=" badge badge-info">Node Information </span></i> </h5> <table class="table table-bordered table-sm table-active"> <tr> <th>DVS</th> <th>DWH</th> <th>AO_Trap</th> <th>BO_Trap</th> <th>Info</th> </tr> <tr> <tbody> {% for d in alltables %} <tr> <td>{{d.1}}</td> <td>{{d.1}}</td> <td>{{d.2}}</td> <td>{{d.3}}</td> </tr> {% endfor %} </tbody> </tr> </table> -
Django rest framework and fetch don't work
I am trying to make a simple api where a user writes something in an input, presses a button and a new instance is added in a database. To do this I am using react and django rest framework. App.js function handleClick() { fetch("http://127.0.0.1:8000/post", { method: "POST", body: { title: name, name:name } }) } return ( <> <form> <input type='text' value={name} onChange={handleChange} /> <button onClick={handleClick}>OK</button> </form> </> ); views.py @api_view(['POST']) def home2(request): serializer = ItemSerializer(data=request.data) if serializer.is_valid(): serializer.save() return Response() But when I press the button I get manifest.json:1 GET http://127.0.0.1:8000/manifest.json 404 (Not Found) and manifest.json:1 Manifest: Line: 1, column: 1, Syntax error. in javascript. In django I get manifest.json:1 Manifest: Line: 1, column: 1, Syntax error. Also I am using npm run build for javascript and manifest.json is in public folder. -
Django reflexive relationship
I am working with MongoDB v6.0.6 and Django v4.1.9. I have a reflexive relationship in one of my models: class Learner(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) supervisor = models.ForeignKey('self', null=True, blank=True, on_delete=models.SET_NULL, related_name='learner_supervisor') profile = models.ForeignKey(Profile, on_delete=models.CASCADE, related_name="learner_profile") company = models.ForeignKey(Company, on_delete=models.CASCADE, related_name="learner_company") When I try to create an object in the Django admin, I encounter an issue with the error message: No exception message supplied A screenshot of the error message is available below: I'm not sure what the cause of this issue is. Can someone provide guidance on how I can solve it? Thank you. -
How Can I check image size and resize it in Django
I am working on a Django project where I want to check uploaded image size if it is more than 14kb, and resize it to be less than or equal to 14kb. My code below does the other checks but doesn't work on reducing the image size to be less than or equal to 14kb. So the image is been uploaded with the original size. Someone help with the best way using my code below. Understand that using django-imagekit could help me with all I needed while processing the image because of the implementation process. def clean_image(self): image = self.cleaned_data.get('image') if image: # Check if the image size exceeds 14kb if image.size > 14 * 1024: # 14kb in bytes # Open the image using Pillow with Image.open(image) as img: # Resize the image while preserving the aspect ratio max_size = (img.width, img.height) img.thumbnail(max_size) # Rotate the image if it's originally landscape if img.width > img.height: img = img.transpose(Image.ROTATE_90) # Convert the image to RGB mode img = img.convert('RGB') # Save the modified image to a BytesIO object buffer = BytesIO() img.save(buffer, format='JPEG') # Create a new InMemoryUploadedFile object with the modified image data modified_image = InMemoryUploadedFile( buffer, None, 'modified.jpg', … -
NameError: name 'Include' is not defined
I'm currently developing a Mobile Application with Django as Backend (I'm a beginner), but I have a problem with Python:Since I created my App I can't run % python manage.py makemigrations and got error line 8, in path('', Include('api.urls')), NameError: name 'Include' is not defined Am using Python -v 4.2 I tried % python manage.py makemigrations And expected Migration for "school": school\migration\0001_initial.py Create model Article -
Django Rest Framework POST not saving to database
@api_view(['POST']) def addProduct(request): serializer = ProductSerializer(data = request.data) if serializer.is_valid(): print("valid!!!") serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) Above is my views.py for adding a product Below is my serializers.py from rest_framework import serializers from django.contrib.auth.models import User from products.models import Product from userProfile.serializers import UserSerializer class ProductSerializer(serializers.ModelSerializer): user = UserSerializer() class Meta: model = Product fields = "__all__" Below is my Product model: class Product(models.Model): uuid = models.CharField(max_length=100) product_name = models.CharField(max_length=50) model = models.CharField(max_length=30) date_of_purchase = models.DateField() description = models.TextField() user = models.ForeignKey(User, on_delete=models.CASCADE) defects = models.CharField(max_length=500) price = models.IntegerField(default=100) slug = models.SlugField(max_length=200) def save(self, *args, **kwargs): self.slug = slugify(self.uuid) super(Product, self).save(*args, **kwargs) def __str__(self): return f"{self.product_name}" UserSerializer used in ProductSerializer from rest_framework import serializers from django.contrib.auth.models import User class UserSerializer(serializers.ModelSerializer): class Meta: model = User fields = ['username','first_name', 'last_name','email','date_joined','is_staff','is_active'] My input: { "id": 4, "user": { "username": "Anirudh", "first_name": "", "last_name": "", "email": "email@email.com", "date_joined": "2023-06-15T15:15:57.138400Z", "is_staff": true, "is_active": true }, "uuid": "qwerty", "product_name": "Phone", "model": "iPhone 12 mini 64GB", "date_of_purchase": "2021-08-15", "description": "Working condition, no dents. all buttons work. Upgrading to new phone so I am selling", "defects": "None", "price": 20000, "slug": "qwerty" } I am getting an error stating that user already exists with this username … -
Django model-field-choices became fields in table and cause not-null error
The choices of a multiselectfield seem to have become fields in my table. I cannot give them a value, but I get an error that they violate the non-null constaint. (I anonimised some of the code) My model.py class Plate(models.Model): Other irrelevant model fields here ------------------------ PR_MDPH = 'PR-variable1' PR_MDM = 'PR-variable2' PR_AL = 'PR-variable3' PR_LE = 'PR-variable4' PR_FB = 'PR-variable5' PR_DB = 'PR-variable6' PR_DFR = 'PR-variable7' PR_BDG = 'PR-variable8' PR_ME = 'PR-variable9' PR_NO = 'None' DEFECT_PR_CHOICES = ( (PR_MDPH, 'PR-variable1'), (PR_MDM, 'PR-variable2'), (PR_AL, 'PR-variable3'), (PR_LE, 'PR-variable4'), (PR_FB, 'PR-variable5'), (PR_DB, 'PR-variable6'), (PR_DFR, 'PR-variable7'), (PR_BDG, 'PR-variable8'), (PR_ME, 'PR-variable9'), (PR_NO, 'None'), ) AR_MDPH = 'AR-variable1' AR_MDM = 'AR-variable2' AR_AL = 'AR-variable3' AR_LE = 'AR-variable4' AR_FB = 'AR-variable5' AR_DB = 'AR-variable6' AR_DFR = 'AR-variable7' AR_BDG = 'AR-variable8' AR_ME = 'AR-variable9' AR_BO = 'AR-variable10' AR_GL = 'AR-variable11' AR_BW = 'AR-variable12' AR_NO = 'None' DEFECT_AR_CHOICES = ( (AR_MDPH, 'AR-variable1'), (AR_MDM, 'AR-variable'), (AR_AL, 'AR-variable'), (AR_LE, 'AR-variable'), (AR_FB, 'AR-variable'), (AR_DB, 'AR-variable'), (AR_DFR, 'AR-variable'), (AR_BDG, 'AR-variable'), (AR_ME, 'AR-variable'), (AR_BO, 'AR-variable'), (AR_GL, 'AR-variable'), (AR_BW, 'AR-variable'), (AR_NO, 'None'), ) PR_defect = MultiSelectField(choices=DEFECT_PR_CHOICES, default=PR_NO) AR_defect = MultiSelectField(choices=DEFECT_AR_CHOICES, default=AR_NO) When I look in my local pgAdmin database, I now have the following: randomField text blabla moreFields boolean NOT NULL "AR_defect" character varying(29) … -
How to define a model one-to-many relationship using a foreign key
I am trying to connect to tables using a foreign key in the following code: models.py class DailyTestDraft(models.Model): index = models.AutoField(db_column='Index', primary_key=True) # Field name made lowercase. gantry = models.IntegerField(db_column='Gantry', null=True) '.....' class DailyTestInput(models.Model): index = models.AutoField(db_column='Index', primary_key=True) # Field name made lowercase. energyID = models.IntegerField(db_column='energyID',null=True) '.......' indexid = models.ForeignKey(DailyTestDraft, on_delete=models.CASCADE, null=True, blank=True, default=None) # Field name made lowercase. views.py: form = DailyTestDraft(gantry=3) form.save() form2 = DailyTestInput(indexid=form) form2.save() I would like the table DailyTestInput to save the primary key of DailyTestDraft (which is index) into its foreign key variable which is indexid. However, I get the error "(1054, "Unknown column 'indexid_id' in 'field list'")" and when I change it to form2 = DailyTestInput(indexid_id=form) I get the error "Field 'index' expected a number but got <DailyTestDraft: 58>.". But when I change it to form2 = DailyTestInput(indexid_id=form.index) then I get the same error 1054. If I put form2 = DailyTestInput(indexid=form.index) then I get the error "Cannot assign "58": "DailyTestInput.indexid" must be a "DailyTestDraft" instance." Sorry for all the options, but I've been trying to make it work in many ways and I am a bit lost as to how it should be implemented. Thanks in advance for your help! -
Postgresql id conflict when migrated old db to new one
I migrated some data from my old db to new one with pk(id). What should I do in order to my new db continue from last id of migrated data. I encounter no problem while migrating but when project is running, there is problem while adding new object to the db. Project is done in django