Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
add dynamic field to serializer class
In my serializer class, i have defined two properties, and third property could be derived from those two properties. Please see the code below class ItemNameSerializer(NestedCreateUpdateMixin, ModelSerializer): nested_child_field_name = 'attribute_names' nested_child_serializer = AttributeNameSerializer attribute_names = AttributeNameSerializer(many=True) class Meta: model = ItemName fields = '__all__' from the above code we can see that attribute_names = AttributeNameSerializer(many=True) can be derived by [nested_child_field_name] = nested_child_serializer(many=true) So my question is can i add add dynamic field which will derived from other fields (to avoid writing redundant code) ? if yes then how ? the possible solutions can be of two types A. overriding some ModelSerializer method. B. generalised solution for any python class. please try to provide both type of solutions (if possible)(and may be of some another type ?) -
Django Styling a UserCreationForm with css
I a trying to add some style to the UserCreationForm, I cannot user Bootstrap for this project so need to modify its html and css directly. I have not been able to find anything in its documentation the allows me to do this. I added a email field to my UserCreationForm field by adding this snippet of code to models.py class CreateUserForm(UserCreationForm): class Meta: model = User fields = ['username', 'email', 'password1', 'password2'] and I pass the form as context to my template in views.py def register(request): if request.method == 'GET': if request.user.is_authenticated: return redirect('news') else: form = CreateUserForm() context = {'form': form} return render(request, 'base1.html', context) if request.method =='POST': form = UserCreationForm(request.POST) if form.is_valid(): form.save() user = form.cleaned_data.get('username') messages.success(request, 'Account was created for ' + user) return redirect('login') return render(request, 'registration.html', context) this is how I have manage to display it inside my HTML5 template <form action="" method="post"> {% csrf_token %} <h1 class="t34"> Register </h1> <div class="t34">{{form.username.label}}</div> {{form.username}} {{form.email.label}}{{form.email}} {{form.password1.label}}{{form.password1}} {{form.password2.label}}{{form.password2}} <input type="submit" name="Create User"> </form> More over I have looked at several tutorials and did not find what I was looking for as well as an Stackoverflow where this answers seem to help but since they are years … -
Django 'django-admin' command not found. django version : 2.2
I'm trying to use the django-admin but sadly its not working correctly and I must use python -m django how can i fix it the commandline exception that it gives: django-admin : The term 'django-admin' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + django-admin version + ~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (django-admin:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException -
When calling a specific url, do not give full media url in django rest framework
After changing image to url, I am giving it to API. However, even though serialization has been carried out through the same serializer, when a request is sent to a particular url, it is transferred in the form of media/image_name instead of 127.0.0.1:8000/media/image_name. I can't find the cause of this. Can you help me find the cause by looking at my code? feed\serializers.py class PostSerializer (serializers.ModelSerializer) : owner = userProfileSerializer(read_only=True) like_count = serializers.ReadOnlyField() comment_count = serializers.ReadOnlyField() images = ImageSerializer(read_only=True, many=True) liked_people = LikeSerializer(many=True, read_only=True) tag = serializers.ListField(child=serializers.CharField(), allow_null=True, required=False) comments = CommentSerializer(many=True, read_only=True) class Meta : model = Post fields = ('id', 'owner', 'title', 'content', 'view_count', 'images', 'like_count', 'comment_count', 'liked_people', 'tag', 'created_at', 'comments') def create (self, validated_data) : images_data = self.context['request'].FILES post = Post.objects.create(**validated_data, created_at=str(datetime.now().astimezone().replace(microsecond=0).isoformat())) for i in range(1, 6) : image_data = images_data.get(F'image{i}') if image_data is None : break Image.objects.create(post=post, image=image_data) return post def to_representation (self, instance) : data = super().to_representation(instance) images = data.pop('images') liked_people = data.pop('liked_people') comments = data.pop('comments') images_array = [image.get('image') for image in images] liked_people_array = [liked_person.get('liked_people') for liked_person in liked_people] comments_array = [comment for comment in comments] if comments_array != [] : if len(comments_array) == 1 or len(comments_array) == 2: data.update({'image_urls': images_array, 'liked_people': liked_people_array, 'comment_preview': … -
django: [WinError 2] The system cannot find the file specified
I am working on a Django project where the user enters a file in pdf, doc, pptx or text (any document) that processed further and show some results as a plagiarism report. But I am getting error and unable to resolve it. I am a newbie to Django. someone, please help me out. this is full traceback. Environment: Request Method: POST Request URL: http://127.0.0.1:8000/index-trial/ Django Version: 3.1.2 Python Version: 3.7.4 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'main'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware'] Traceback (most recent call last): File "C:\Users\Farhana Noureen\AppData\Local\Programs\Python\Python37\lib\site- packages\django\core\handlers\exception.py", line 47, in inner response = get_response(request) File "C:\Users\Farhana Noureen\AppData\Local\Programs\Python\Python37\lib\site- packages\django\core\handlers\base.py", line 179, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\Farhana Noureen\AppData\Local\Programs\Python\Python37\lib\site- packages\django\views\generic\base.py", line 70, in view return self.dispatch(request, *args, **kwargs) File "C:\Users\Farhana Noureen\AppData\Local\Programs\Python\Python37\lib\site- packages\django\views\generic\base.py", line 98, in dispatch return handler(request, *args, **kwargs) File "C:\Users\Farhana Noureen\plagtrap\main\views.py", line 302, in post results = process_homepage_trial(request) File "C:\Users\Farhana Noureen\plagtrap\main\services.py", line 435, in process_homepage_trial queries = pdf.get_queries(filename) File "C:\Users\Farhana Noureen\plagtrap\util\getqueriespertype\pdf.py", line 17, in get_queries pdf_to_text_output = subprocess.check_output([settings.PDF_TO_TEXT, "-layout", absolute_file_path, "- "]) File "C:\Users\Farhana Noureen\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 395, in check_output **kwargs).stdout File "C:\Users\Farhana Noureen\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 472, in run with Popen(*popenargs, **kwargs) as process: File "C:\Users\Farhana Noureen\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 775, … -
Saving bound result to the database instead of actuall value
This is my first time working on Django, Python and MSSQL. I am creating a simple webpage where I take a name of an application and store it to the database using forms. Here is the classes: models.py from django.db import models from django.forms import forms, ModelForm # Create your models here. class Application(models.Model): name = models.CharField(max_length=100) forms.py from django import forms from .models import Application # define the class of a form class ApplicationForm(forms.ModelForm): class Meta: # write the name of models for which the form is made model = Application # Custom fields fields = ['name'] views.py from django.shortcuts import render from .forms import ApplicationForm def add_application_view(request): form = ApplicationForm(request.POST or None) if form.is_valid(): print('Form = ', form) # it shows the html code for debugging purpose print('cleaned = ', form.cleaned_data['name']) # it shows <bound method Field.clean of <django.forms.fields.CharField object at 0x7fcdd56c3910>> print(form['name'].value()) # it shows the correct value I entered print(form.data['name']) # it shows the correct value I entered form.save() form = ApplicationForm() context = { 'form': form } return render(request, 'application/add_application.html', context) whenever I test the page and enter any value as the name of the application, it stores the below value in the database as … -
a syntax error is showing in the code i don't know but its happen while building a web app with pyton and django
error wihile developing a web app with python and django PLS HELp -
Django - Unable to remove objects in the database through Full Calendar
I've been trying to implement Full Calendar in Django and I'am following this question FullCalendar in Django. I have successfully rendered the data in my database in Full Calendar but failed to implement a "remove/delete" function because of an error. The error generated None Internal Server Error: /scheduler/remove/ Traceback (most recent call last): File "C:\Users\Emman\Anaconda3\envs\elxr\lib\site-packages\django\core\handlers\exception.py", line 34, in inner response = get_response(request) File "C:\Users\Emman\Anaconda3\envs\elxr\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "C:\Users\Emman\Anaconda3\envs\elxr\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\Emman\Desktop\elxr\elxr\scheduler\views.py", line 42, in remove event = Appointment.objects.get(id=id) File "C:\Users\Emman\Anaconda3\envs\elxr\lib\site-packages\django\db\models\manager.py", line 82, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "C:\Users\Emman\Anaconda3\envs\elxr\lib\site-packages\django\db\models\query.py", line 417, in get self.model._meta.object_name scheduler.models.Appointment.DoesNotExist: Appointment matching query does not exist. [02/Nov/2020 18:15:52] "GET /scheduler/remove/ HTTP/1.1" 500 80403 This is my models.py class Appointment(models.Model): author = models.ForeignKey(User, on_delete=models.CASCADE, related_name='scheduler_appointments') id = models.AutoField(primary_key=True) client_name = models.CharField(max_length=50,null=True,blank=True) start_date = models.DateTimeField(null=True,blank=True) end_date = models.DateTimeField(null=True,blank=True) appointment_type = models.CharField(max_length=250,null=True,blank=True) client_sessions = models.IntegerField(null=True, blank=True) objects = models.Manager() def __str__(self): return 'ID : {0} Client Name : {1}'.format(self.id, self.client_name) my views.py excluding the calendar function because I think the problem is in this function def remove(request): id = request.GET.get("id", None) print(id) # prints None event = Appointment.objects.get(id=id) event.delete() data = {} return … -
Mezzanine Multi-lingual forms: is django-modeltranslation necessary?
I just inherited a project that has had many hands running through it. I have never used Mezzanine before. I see in settings.py that USE_MODELTRANSLATION = False, but django-modeltranslation is not part of the requirements.txt in the first place, so it seems like someone originally wanted to get set up with django-modeltranslation and then changed their mind. Some parts of forms are not being translated correctly, and some are. Is there a way to localise Mezzanine form elements without having to go through with downloading and setting up django-modeltranslation? -
django: access dictionnary key inside of request session object
How is it possible to access a key from a dictionnary in a django view. I am banging my head off the wall with many errors and no solutions. I access a dictionnary in a view as such: def generate_pdf_assembly(request): data = request.session['sale'] print(data) ...attempts... #total_ht = request.session['sale'].get('NetAmount') #total_ht = request.session['NetAmount'] #total_ht = data.get('NetAmount') #print('total_ht', total_ht) my_company = MyCompany.objects.get(id = 1) context = {'data' : data, 'my_company' : my_company} print(context) return render(request, 'pdf/invoice_generator_assembly.html', context) Important to mention that data output exactly what I need it to, which is: [{'Id': '100121', 'Date': datetime.date(2020, 8, 10), 'Quantity': 1.0, 'NetAmount': 1.0, 'customer_name': <Customer_base: Customer_base object (unknown)>, 'id': None}] I want to access the 'NetAmount' key. Please send some help! thanks -
Relative Module Import In Python/Django Not Working
I am creating an api with the rest_framework but anytime i do a relative import for a module it doesn't work even though they are in the same directory Here is my directory structure DjangoReact / HouseRentalSystem / __init__.py admin.py apps.py models.py serializer.py tests.py urls.py views.py Below Is The Code Inside My Views.py from rest_framework.decorators import APIView from .serializer import HouseApiSerializer class HouseApiHomeView(APIView,View): pass Below Is The Error I Am Getting Unable to import 'house_api.serializer'pylint(import-error) -
How to link checkbox value to a model's attribute?
The idea is to have something like this: template.html {% for item in items %} <input type="checkbox" checked= {{ item.status }}> {% endfor %} views.py def index(request): context = { 'items' : Item.objects.all() } return render(request, 'template.html', context) But the status by design isn't simply True or False: models.py class Item(models.Model): class Status(models.TextChoices): ON = 1 OFF = 0 status = models.IntegerField(choices=Status.choices) # other attributes.. How will I link these two values so that they're two-way connected? (Loading template.html yields the checkbox's checked-ness based on the retrieved item.status (checked for ON, unchecked for OFF, while checking or unchecking the checkboxes will change the related item.status value?) The only thing I've seen closest to my problem is this, but it's not the same at all. Mine is a single binary attribute but has different kinds of values. -
I want to upload a set of multiple files with one submit button using django
I want to upload a set of multiple files with one submit button using django. The issue I am facing is that the uploaded files does not get saved anywhere in my local machine. Can anyone please help me here. My codes are: urls.py from django.urls import path from django.conf import settings from django.conf.urls.static import static from . import views urlpatterns = [ path('', views.home, name='home'), path('majorheads/', views.display_majorheads, name='majorheads'), path('upload/', views.display_uploadpage, name='displayupload'), ] if settings.DEBUG: urlpatterns + static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT) views.py from django.shortcuts import render from django.http import HttpResponse from django.core.files.storage import FileSystemStorage def display_uploadpage(request): return render(request, 'website/upload.html' ) if request.method == 'POST': uploaded_file = request.FILES['files'] fs = FileSystemStorage() fs.save(uploaded_file.name, uploaded_file) return render(request, 'upload.html') settings.py MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') upload.html <form method="post" enctype="multipart/form-data"> {% csrf_token %} <div class="form-group"> <div class="container"> <div class="row"> <div class="col"> <label>Select AG Data...</label> <input type="file" id="files" name="files" multiple="multiple"> </div> <div class="col"> <label>Select fin year</label> <input type="text" id="datepicker"/> </div> </div> </div> </div> </form> -
Order by in Django [closed]
I want to calculate the difference of Eye2Nose each entities and sort them. I don't want to add other attribute to the Dog model because it keeps changing. However I have no idea how to do that using Order By ... class Dog(models.Model): Name=models.CharField(max_length=20) Breed=models.CharField(max_length=20) Sex=models.CharField(max_length=20,null=True) Color=models.CharField(max_length=20,null=True) LostNoticeNum=models.ForeignKey(LostNotice, on_delete = models.CASCADE,null=True) FindNoticeNum=models.ForeignKey(FindNotice, on_delete = models.CASCADE,null=True) Eye2Nose = models.FloatField(max_length=20,null=True) Eye2Ears = models.FloatField(max_length=20,null=True) thank you:) Every comments are welcomed!!! -
Show the table name in database regarding the model in django
I have to find the database table name of resoective model in my project how can i do it . I previously tried the python class Meta: db_table = 'tablenameIWant' but how can I see the table name ? -
Django permissions via related objects permissions
I am relatively new to Django and I'm looking for some guidance in how to setup permissions in a certain way. Basically I have an app that consists of a couple of models similar to this: class Project(models.Model): name = models.CharField(max_length=100) users = models.ManyToManyField(CustomUser, related_name="projects") class Task(models.Model): name = models.CharField(max_length=100) project = models.ForeignKey(Project, on_delete=models.CASCADE, related_name="tasks") class Asset(models.Model): name = models.CharField(max_length=100) project = models.ForeignKey(Project, on_delete=models.CASCADE, related_name="assets") My idea is that if a user is "assigned" to a project (via M2M field), that user will have access to all assets and tasks that are related to that Project. I have looked into django-guardian for per-object permissions and I think that could be the way to go, but to me it seems like I then would have to setup those permissions on each model..? It feels like this should be a pretty common way of setting up permissions for any project-based app but I have a hard time finding similar examples and starting to wonder if I'm overthinking this or looking in the wrong direction? Thank you, Jonas -
Segmentation fault django celery Redis
When starting celery with following command - celery -A name_analytics worker --loglevel=info, I am getting Segmentation fault, broker is Redis. Ubuntu 16.4 OpenNvz. Note. If I remove redis, it works just fine -
Apache with django and wordpress, wsgi error loading wordpress
I have two sites, site-one is a django app and site-two is a wordpress site. I have two .conf files inside /etc/apache2/sites-available: site-one.com.conf <VirtualHost *:80> ServerAdmin adminmail@gmail.com ServerName site-one.com ServerAlias www.site-one.com DocumentRoot /var/www/site-one.com/public_html ErrorLog ${APACHE_LOG_DIR}/site-one.com.error.log CustomLog ${APACHE_LOG_DIR}/site-one.com.access.log combined Alias /static /var/www/site-one.com/public_html/static <Directory /var/www/site-one.com/public_html/static> Require all granted </Directory> <Directory /var/www/site-one.com/public_html/MyApp> <Files wsgi.py> Require all granted </Files> </Directory> WSGIScriptAlias / /var/www/site-one.com/public_html/MyApp/wsgi.py WSGIDaemonProcess django_app python-path=/var/www/site-one.com/public_html WSGIProcessGroup django_app </VirtualHost> site-two.com.conf <VirtualHost *:80> ServerAdmin adminmail@gmail.com ServerName site-two.com ServerAlias www.site-two.com DocumentRoot /var/www/site-two.com/public_html ErrorLog ${APACHE_LOG_DIR}/site-two.com.error.log CustomLog ${APACHE_LOG_DIR}/site-two.com.access.log combined </VirtualHost> The site-one.com is 100% working but when I load site-two.com I get this error: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. The site-two.com.error.log shows this: [Mon Nov 02 09:09:48.629460 2020] [wsgi:error] [pid 2396] [remote 151.49.10.216:63056] mod_wsgi (pid=2396): Failed to exec Python script file '/var/www/site-one.com/public_html/MyApp/wsgi.py'. [Mon Nov 02 09:09:48.631915 2020] [wsgi:error] [pid 2396] [remote 151.49.10.216:63056] mod_wsgi (pid=2396): Exception occurred processing WSGI script '/var/www/site-one.com/public_html/MyApp/wsgi.py'. [Mon Nov 02 09:09:48.632702 2020] [wsgi:error] [pid 2396] [remote 151.49.10.216:63056] Traceback (most recent call last): [Mon Nov 02 09:09:48.632776 2020] [wsgi:error] [pid 2396] [remote 151.49.10.216:63056] File "/var/www/site-one.com/public_html/MyApp/wsgi.py", line 16, in <module> [Mon Nov 02 09:09:48.632784 2020] [wsgi:error] [pid 2396] [remote 151.49.10.216:63056] application = get_wsgi_application() [Mon … -
Reserved fields of Django model
I'd like to have a Django model with a reserved field, so that no one can set it directly but its value it's generated at saving time. This is useful for example to generate user tokens and I want to prevent developers to directly set a value for the token key. At the same time I would like to be able to treat that field as I do with others, so using __ for fields lookup in queries, or be able to retrieve tokens as: token = Token.objects.get(key='c331054c00494f6a22f0ebde7a32bf9d4619b988') So in my mind doing something like: Token.key = 'my-token-key' should fail, and even instantiation should fail: token = Token(key='my-token-key') So far I came up with this solution, but I'm a bit concerned my changes could break some Django workflow since I'm not sure what my changes will affect: import binascii import datetime import os from django.contrib.auth import get_user_model from django.db import models class Token(models.Model): """ An access token that is associated with a user. """ id = models.AutoField(primary_key=True) # By default `get_attname` returns the field `name`, # but in my case the attribute name is different _key = models.CharField(max_length=40, unique=True, name='key', db_column='key') _key.get_attname = lambda: '_key' name = models.CharField(max_length=255) user = … -
How do I implement a form submission if the form is in my base template file?
I have a base template file that holds the form for the users to subscribe to the email newsletter. All of my templates inherit from the base template file, as I'd like to display this form on every web page. I don't know how do I make the form submit the data the user inputs into the database. So far, I dealt with views and each view was specific to a URL, so it's not really obvious to me how do I do this for all URLs, since the base template is present on all URLs. base.html (the base template file): {% load static %} <html> <head> <title>{% block title %}{% endblock %}</title> </head> <body> <a href="{% url 'employers:list_joblistings' %}"> Homepage </a> <a href="{% url 'employers:submit_job_listing' %}"> Post a job </a> {% block content %}{% endblock %} <p> Subscribe to new jobs: </p> <form method="post"> <p> Email: <input type="email" name="email" /> </p> <p> First name: <input type="text" name="first_name" /> </p> <p> Last name: <input type="text" name="last_name" /> </p> <input type="submit" value= "Submit"> </form> </body> </html> I also made a form in my forms.py file which constructs the form from my email subscriber model, but I don't use it anywhere so … -
How to develop appointment system with start time end time and duration using Django? [closed]
What I want? I am trying to develop appointment API with using DRF(Django Rest Framework). Users can add available times with related to date. For example users can add availabilities like this: 22 March 2021, 10:30AM - 11:30PM, available for 30 minute meetings. Then it means user can book for appointment between; 10:30AM to 11:00AM or 10:40AM to 11:10AM or 10:50AM to 11:20AM or 11:00AM to 11:30AM. It should work like Calendly. What I tried? I tried to get date, start time, end time and duration from user. For creating slots like mentioned above in quote; I found 2 option: Create object for every duration in a loop(i.e. obj1(date:... start_time:10.30AM, end_time:11:00AM) obj2(date:... start_time:10.40AM, end_time:11:10AM)...). Create object without splitting(i.e. obj(date:..., star_time:10:30AM, end_time:11:30, duration: 30min)) and when requested split to slots like given quote above. The Question Is there any better way to do this or what is the better way? How to do the operation? -
I try to save a mp3 file on s3 space with python but got empty file
Hi I come here after few days of research on the subject, I have a django class : Question, the admin can create question : he has to input a "title" and some "items" + True or False for each item. I want to get the "title" of the question as mp3 file so I use gTTS (google text to speech) and it works as well while I use it locally ! if(sender == Question and kwargs['update_fields'] == None): myQuestion = kwargs['instance'] output = gTTS(myQuestion.title, lang="fr") mySound = './media/questionsSound/Question'+str(myQuestion.id)+'.mp3' output.save(mySound) Now I want to save these mp3 files on a s3 space because I have many applications which will call them. So in a first time I just tried to replace the path of mySound by the path of my bucket but I got this error message : [Errno 22] Invalid argument: 'https://[mySpaceName].fra1.digitaloceanspaces.com/[myBucketName]/questionSound/Question95.mp3' This is the first problem which have no sense for me, because the url exists I tried it with files which I dragged and dropped. So I tried to find a workaround and I decided to save the file in the original folder ./media/questionsSoud... then to upload it on the s3 space : import boto3 from boto3 … -
I want to build custom login registration withour using any built in system
I am creating a website where i want to add login registration. But Djnago has built in login registration system.But I want build a system where user can register and login actually it will be on my own.But I am really confused about this matter can someone give me an example of this topic? it will be very helpful for me.Cz I am stuck here :( -
OperationError Django Foreign Key Mismatch
class User(models.Model): username = models.CharField(max_length=200, primary_key=True) name = models.CharField(max_length=200) password = models.CharField(max_length=200) number = models.CharField(max_length=200) email = models.EmailField() USERNAME_FIELD = 'username' def __str__(self): return self.username class Car(models.Model): carid = models.CharField(max_length=200, primary_key=True, default='') carplate = models.CharField(max_length=200, null=True) license = models.CharField(max_length=200) username = models.ForeignKey(User, on_delete = models.CASCADE, default = "") def __str__(self): return self.carid class Ride(models.Model): carid = models.OneToOneField(Car, default = '', on_delete=models.CASCADE) rideid = models.CharField(max_length=200, primary_key=True) location = models.CharField(max_length=200) destination = models.CharField(max_length=200) date = models.DateField(auto_now_add=True) time = models.TimeField(auto_now_add=True) price = models.DecimalField(max_digits = 10, decimal_places = 2) def __str__(self): return self.rideid class Bid(models.Model): STATUS = ( ('Pending', 'Pending'), ('Accepted', 'Accepted'), ('Rejected', 'Rejected') ) bid_amt = models.DecimalField(max_digits = 10, decimal_places = 2) username = models.OneToOneField(User, on_delete = models.CASCADE) rideid = models.OneToOneField(Ride, on_delete = models.CASCADE) status = models.CharField(max_length=200, choices=STATUS, default='Pending') def __str__(self): return self.bid_amt I'm getting error django.db.utils.OperationalError: no such columns: users car.username_id and i am unable to migrate my new alterations to the models as i get another error: django.db.utils.OperationalError: foreign key mismatch - "users_ride" referencing "users_car" I'm really new to django and i hope someone can help me identify my mistake here! I am trying to make a carpooling website where users can either have cars or not have cars, those with … -
Makemessages marking my entry as obsolete. What am I doing wrong?
As my title says, I have the exact same content in both my .po file and in the html file, however the makemessages command just comments it out in the .po file. The other translations on the site work just fine, using the exact same format, so I'm not sure why this one in particular would be marked as obsolete. Any help would be greatly appreciated. django.po #: frontend_theme/templates/accounts/account_signup.html:10 #, python-format msgid "" "<p>En validant votre inscription vous consentez au traitement suivant de vos données.</p>" "<p>Les informations recueillies sur ce formulaire sont indispensables pour la création du compte personnel de l’Enquêteur." "Conformément au règlement européen (UE) 2016/679 du 27 avril 2016 relatif à la protection des personnes physiques à l’égard du traitement des données à caractère personnel, et à la loi “Informatique, fichiers et libertés” n° 78-17 du 6 janvier 1978 modifiée" "Elles sont enregistrées dans un fichier informatisé par l’unité de recherche Linguistique, langues,Parole de l'ABCDEFG pour la gestion de la plateforme et sont conservées pendant la durée d’inscription del’enquêteur à celle-ci." "Vous pourrez retirer votre consentement à tout moment.</p>" "<p>Vous pouvez accéder à vos données via votre profil utilisateur. Vous pouvez également les faire rectifier ou les faire …