Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Not Able to load my static files after connecting Gcloud bucket with Django App
I have a Django App on which i have set the default file storage to my bucket in my google cloud console and also set the other required environment variables in my settings.py like this DEFAULT_FILE_STORAGE = 'storages.backends.gcloud.GoogleCloudStorage' GS_BUCKET_NAME = 'agevent-269406.appspot.com' STATICFILES_STORAGE = 'storages.backends.gcloud.GoogleCloudStorage' GS_ACCESS_KEY_ID = 'GOOG1EZ5NIIEKVXTIEUN44APX3R5RQZBKPCY2QZLKNVVWO4CXKS4CUBGNDJCI' GS_SECRET_ACCESS_KEY = 'u92B3tGHGgul8sOzkQ40hIgKBsVAZw7N5UxlrsRP' GS_CREDENTIALS = service_account.Credentials.from_service_account_file( "agevent-518288d70053.json" ) And i have also manually uploaded my static folder (inlcluding all files) to my bucket. Currently im using these variables in my settings.py for static files STATIC_URL = 'https://storage.googleapis.com/agevent-269406.appspot.com/face_detector/static/' STATIC_ROOT = 'static' and in my app.yaml im using these values for static - url: /static static_dir: https://storage.googleapis.com/agevent-269406.appspot.com/face_detector/static/ But the problem is when my django app loads on the GAE server, my static files do not load neither the images nor the styling files. I am quite a rookie in python and gae so please suggest me some basic answers for all those steps i have done, i followed the following link https://django-storages.readthedocs.io/en/latest/backends/gcloud.html#installation -
Django MongoDB SQLDecodeError at /admin
I'm getting SQLDecodeError in Django admin panel when I'm trying to view any model or trying to create document in the collection. I'm using - MongoDB - v3.6.3 django - v3.0.4 djongo - v1.3.1 sqlparse - v0.3.1 I have tried different versions of sqlparse but nothing seemed to work. How can i make this work ? -
How to communicate with an external server using django application?
Currently I have a requirement,I need to communicate with external server using django application. The server is already up,Next section is the data transfer. I need some time samples and values from server and I need to send responses back to server. How django port can listen to external server.? How it can response back continuosly? -
django rest, forbidden 403 error in ajax call
I am going to post data via ajax but it returns an error with 403 status code. i am using rest api for this My Create View class CityCreateAPIView(generics.CreateAPIView): queryset = models.City.objects.all() serializer_class = serializers.CitySerializer In template <form action="" method="post"> {% csrf_token %} <div class="modal-header"> <h5 class="modal-title" id="exampleModalLongTitle">Modal title</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">&times;</span> </button> </div> <div class="modal-body"> <div class="form-group"> <label for="">name (en)</label> <input id="name_en" type="text" name="name_ru" class="form-control"> </div> <div class="form-group"> <label for="">name (ru)</label> <input id="name_ru" type="text" name="name_ru" class="form-control"> </div> </div> <div class="modal-footer"> <button id="saveButton" data-api="{% url 'city-create-api' %}" type="button" class="btn btn-primary">Save changes </button> </div> </form> JavaScript $("#saveButton").click(function (event) { event.preventDefault(); let cityFormData = new FormData(); cityFormData.append(`name_en`, $('#name_en').val()); cityFormData.append(`name_ru`, $('#name_ru').val()); $.ajax({ url: $(this).data('api'), data: cityFormData, processData: false, contentType: false, type: "POST", success: function (data) { }, error: function (data) { } }); }); Here i have tried so far but again I am taking an error. How can i solve this issue? Thanks in advance! P.S I looked at possible solutions and tried some of them but they did not help me -
mysql not connecting into django
I am working on django. it is working good. but now i have to connect mysql database into django. in local system i install all things realted packages. but in virtual enviornment I am getting so much error. I am working on django. it is working good. but now i have to connect mysql database into django. in local system i install all things realted packages. but in virtual enviornment I am getting so much error. I used this command and getting same errors. pip install mysqlclient pip3 install mysqlclient can you suggest me how can i fixed this errors. (venv) palwesh@wg-palwesh:~/Workplace/learn/task2$ pip3 install mysqlclient Collecting mysqlclient Using cached mysqlclient-1.4.6.tar.gz (85 kB) Building wheels for collected packages: mysqlclient Building wheel for mysqlclient (setup.py) ... error ERROR: Command errored out with exit status 1: command: /home/webgen-palwesh/Workplace/learn/venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xd1syfgb/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xd1syfgb/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-la3lzm0o cwd: /tmp/pip-install-xd1syfgb/mysqlclient/ Complete output (31 lines): running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-3.6 creating build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.6/MySQLdb copying MySQLdb/release.py -> build/lib.linux-x86_64-3.6/MySQLdb copying … -
AttributeError: 'NoneType' object has no attribute 'find' - Apache Django
I am trying to run a django framework application from apache but getting the error AttributeError: 'NoneType' object has no attribute 'find' The connection is working fine from virtual environment but from apache there is intermittent db connection issue File "/TomCatWeb/app/projects/GDM/customer/db.py", line 13, in connection [Thu Mar 05 06:45:12.194252 2020] [wsgi:error] [pid 68520] try: [Thu Mar 05 06:45:12.194258 2020] [wsgi:error] [pid 68520] AttributeError: 'NoneType' object has no attribute 'find' below is the code for db connection import logging import os import cx_Oracle logging.basicConfig(filename='/TomCatWeb/app/projects/GDM/customer/db.log', filemode='w', format='%(asctime)s - %(message)s', level=logging.DEBUG) os.environ['GDM_CUSTOMERS']="<host details>" def connection(): try: host = os.getenv('GDM_CUSTOMERS') con = cx_Oracle.connect(host) driver = con.cursor() return driver except cx_Oracle.DatabaseError as e: logging.debug(e) return 0 -
Get functionality of form in include tag of django template
I have been trying to render the a form in multiple templates. In one of my trials I used include tag to render the form. Below is my function for the form- It sends a mail once the form is submitted. views.py def myformfunction(request): if request.method == 'GET': form = myform() else: form = myform(request.POST) if form.is_valid(): subject='form Details' mobile = form.cleaned_data['mobile'] email = form.cleaned_data['email'] dummy = '\nMobile: '+mobile+'\nEmail: '+email' try: send_mail(subject, dummy, 'dummy@gmail.com', ['dummy1@gmail.com', 'dummy2@gmail.com']) messages.success( request, " Thank you !! For contacting.') except BadHeaderError: return HttpResponse('Invalid header found.') return redirect('email') return render(request, "my_app/email.html", {'form': form}) In one of my templates I am calling the the above as include tag. Below is the code. template1.html <form method="post" action="{% url 'frform' %}"> #if I am not adding the action, I am unable to finish the action of sending the mail {% include 'my_app/email.html' %} </form> email.html <div class="p-4 shadow-lg rounded-lg bg-white"> {% if messages %} <ul class="messages"> {% for message in messages %} {% if message.tags %} <script>alert("{{ message }}")</script> <a href="{{request.META.HTTP_REFERER|escape}}">Back</a>{% endif %} {% endfor %} </ul> {% else %} <h5 class="h6 mb-4">Create test Form</h5> <form method="post" action="{% url 'frform' %}"> {% csrf_token %} {{ form }} <button type="submit" … -
Django Routing caused Module not found error
While defining path from Django project (eitan) to Djnago app (users_and_auth) I get this below mentioned error. app/eitan/__init__.py changed, reloading. eitan-application_1 | Watching for file changes with StatReloader eitan-application_1 | Performing system checks... eitan-application_1 | eitan-application_1 | Exception in thread django-main-thread: eitan-application_1 | Traceback (most recent call last): eitan-application_1 | File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner eitan-application_1 | self.run() eitan-application_1 | File "/usr/local/lib/python3.7/threading.py", line 870, in run eitan-application_1 | self._target(*self._args, **self._kwargs) eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/utils/autoreload.py", line 53, in wrapper eitan-application_1 | fn(*args, **kwargs) eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run eitan-application_1 | self.check(display_num_errors=True) eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 395, in check eitan-application_1 | include_deployment_checks=include_deployment_checks, eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 382, in _run_checks eitan-application_1 | return checks.run_checks(**kwargs) eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/core/checks/registry.py", line 72, in run_checks eitan-application_1 | new_errors = check(app_configs=app_configs) eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/core/checks/urls.py", line 13, in check_url_config eitan-application_1 | return check_resolver(resolver) eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/core/checks/urls.py", line 23, in check_resolver eitan-application_1 | return check_method() eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/urls/resolvers.py", line 406, in check eitan-application_1 | for pattern in self.url_patterns: eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/utils/functional.py", line 48, in __get__ eitan-application_1 | res = instance.__dict__[self.name] = self.func(instance) eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/urls/resolvers.py", line 587, in url_patterns eitan-application_1 | patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) eitan-application_1 | … -
Django: how to show name as per user_id?
class Order_ListAPIView(APIView): def get(self,request,format=None): totalData=[] if request.method == 'GET': cur,conn = connection() order_query = ''' SELECT * FROM orders ''' order_detail_query = ''' SELECT * FROM order_details ''' user_query = ''' SELECT * FROM users ''' with conn.cursor(MySQLdb.cursors.DictCursor) as cursor: cursor.execute(order_detail_query) order_detail_result = cursor.fetchall() order_detail_data = list(order_detail_result) # print(order_detail_data) cursor.execute(order_query) order_result = cursor.fetchall() order_data = list(order_result) cursor.execute(user_query) user_result = cursor.fetchall() user_data = list(user_result) dic = {} def merge_order_data_and_detail(order_data, order_detail_data): for d in order_detail_data: if d['order_id'] not in dic: dic[d['order_id']] = [] dic[d['order_id']].append(d) for o in order_data: if o['order_id'] in dic: o['order_detail_data'] = dic[o['order_id']] merge_order_data_and_detail(order_data, order_detail_data) # totalData.append({"order_data":order_data, }) return Response({"order_data":order_data, "user_data":user_data},status=status.HTTP_200_OK) else: return Response(status=status.HTTP_400_BAD_REQUEST) Output: { "order_data": [ { "order_id": 1, "payment_method_id": 1, "delivery_id": 2, "user_id": 3, "txnid": "584ffb7fd622eca10a6d", "order_no": "1-1583152683-0005", "order_total": 1.0, "payment_status": "Paid", "payuMoneyId": "306043618", "mihpayid": "9956109007", "order_detail_data": [ { "order_detail_id": 1, "order_id": 1, "user_id": 3, "qty": 1, "product_price": 1.0, "order_item_status": "Placed", "feedback": "" } ] }, { "order_id": 2, "payment_method_id": 2, "delivery_id": 2, "user_id": 2, "txnid": "", "order_no": "1-1583152785-0010", "order_total": 1.0, "payment_status": "Unpaid", "payuMoneyId": "", "mihpayid": "", "order_detail_data": [ { "order_detail_id": 2, "order_id": 2, "user_id": 2, "qty": 1, "product_price": 1.0, "order_item_status": "Cancelled", "feedback": "0" } ] }, { "order_id": 3, "payment_method_id": 1, "delivery_id": 2, "user_id": 1, "txnid": … -
GeoDjango field in admin not show the street name, how to enable it?
I am integration the map display into django admin by using GeoDjango plugin. model.py class Listing(gismodels.Model): #... geolocation = gismodels.PointField() Latitude = models.DecimalField(max_digits=10, decimal_places=6, default=11.5627939) Longitude = models.DecimalField(max_digits=10, decimal_places=6, default=104.9210989) objects = GeoManager() admin.py class ListingAdmin(admin.GeoModelAdmin): list_display = ('id', 'title', 'is_published', 'price', 'list_date', 'realtor') list_display_links = ('id', 'title') list_filter = ('realtor',) list_editable = ('is_published',) search_fields = ('title', 'description', 'address', 'city', 'state', 'zipcode', 'price') list_per_page = 25 default_lon = 104.9210989 default_lat = 11.5627939 default_zoom = 13 readonly_fields = ('Latitude', 'Longitude') admin.site.register(Listing, ListingAdmin) But I got the output like this (no street or address name in the mape) : -
Scope of returned resource highly depandant on user role encoded in JWT token - is it RESTful?
I'm working on API that tries to stay in RESTful principles, although one requirement keeps bugging me. We use JWT based authentication. Inside JWT claims we store roles of the user. Now our main GET endpoint (let's call it ListAllOffers for simplicity) behaves differently depending on what role the user have: if API recognizes admin via JWT it responds with full list of Offers if API recognizes ordinary user via JWT it responds with narrowed list of Offers (depending on relation in DB) My concerns is: is it ok according to REST principles or any unwritten REST practices? I am used to modify response object according to argument from url, params from querystring or alternatively via header values. Altering JSON response basing JWT seems not explicit enough that is feels some kinda strange. Bonus question: is it against any of REST principles how should this requirement be implemented. -
Which is good? django-tenants vs django-tenant-schemas
Hey guys I just came up with 2 different tenant management libs in Django https://github.com/bernardopires/django-tenant-schemas and https://github.com/tomturner/django-tenants. Which one will be better? Is any other libs better than these two? -
countdown in django using keith wood countdown timer
I am using keith wood countdown, How do i set the default countdown to (14 days) and it will start when after the user login to their profile, and the countdown will still continue even if the user logout or leave the page? <div id="defaultCountdown"></div> <script> $(function () { var austDay = new Date(); austDay = new Date(austDay.getFullYear() + 1, 1 - 1, 26); $('#defaultCountdown').countdown({until: austDay}); $('#year').text(austDay.getFullYear()); }); </script> -
How to pass request to a Field Serializer in Rest Framework?
Hi I am using a Field Serializer to be able to serialize a PK field then deserialize it as object. Inside the serializer is a SerializerMethodField to build a custom url. It works when I use the itself from serializing its own record. However when I use it to a different serializer as a FieldSerializer, the request object is not passed. class TelemetryFileSerializer(serializers.ModelSerializer): telemetry_type = serializers.SlugRelatedField( slug_field='name', queryset=TelemetryFileType.objects.all()) receiving_station = serializers.SlugRelatedField( required=False, slug_field='name', queryset=ReceivingStation.objects.all()) link = serializers.SerializerMethodField() class Meta: model = TelemetryFile fields = '__all__' def get_link(self, object): request = self.context.get('request') print(self.context) # request is not passed here from RawImageSerializer/TelemetryFileField return request.build_absolute_uri('/data_management/telemetry_files/{}'.format(object.id)) class TelemetryFileField(serializers.PrimaryKeyRelatedField): def to_representation(self, value): pk = super(TelemetryFileField, self).to_representation(value) item = TelemetryFile.objects.get(pk=pk) serializer = TelemetryFileSerializer(item) return serializer.data class RawImageSerializer(serializers.ModelSerializer): from_telemetry_file = TelemetryFileField(queryset=TelemetryFile.objects.all()) link = serializers.SerializerMethodField() I want to pass a request of itself to be able to create a url of it. This is the returned when I use the RawImageSerializer: AttributeError: 'NoneType' object has no attribute 'build_absolute_uri' -
group by integer range Django & posgres
i have a table which i would like to group by integer range (ages). table for example: Name Age John 21 Steve 24 Dan 29 Mike 31 my expected result is to group the name by age ranges for example [21-28] [29-33] so what i'll get is the following result: [21-28] [29-33] John Dan Steve Mike i was playing around with the annotate function of Django but couldn't figure it out so far. any suggestions? -
Django valudation email restriction
How to restrict to certain emails so that only they can register within my web? Taking all lists such as gmat, yahoo etc is lengthy. Any thought? -
how i can dynamically select page/product on form django
hello i want to save on data base where the form is comming from from any page (the page is product page) i want create ecomerce website(cash on delivery) and i have truble to now any the product is ordered on this form ,the form is work i need just this last field the product id the problem i think is there on the views to see all fiels scroll down : form = Modelform(request.POST) Modelform.Product.filter(id=p_id) if form.is_valid(): post = form.save(commit=False) #p_id =Product.objects.filter( id=p_id) #Modelform(initial={'p_id':p_id}) post.save() form = Modelform() the models: from django.db import models class Product(models.Model): title = models.CharField(max_length=50 , default='product title') price = models.CharField(max_length=10 , default= int('0')) delPrice = models.CharField(max_length=10, default=int('0')) img1 = models.ImageField(upload_to='product_gallry',default='img') img2 = models.ImageField(upload_to='product_gallry',default='img') img3 = models.ImageField(upload_to='product_gallry',default='img') description = models.TextField(max_length=5000 , default='description') Video_Link = models.TextField(max_length=5000 , default='Video_Link') def __unicode__(self): return u'%d' % self.id class Form (models.Model): Product = models.ForeignKey(Product,null=True, blank=True,on_delete=models.SET_NULL) name = models.CharField(max_length= 100 , default=None) number = models.CharField(max_length=13,default=None) adresse = models.CharField(max_length=500,default=None) city = models.CharField(max_length=20, default=None) the views: from .form import Modelform from .models import Product , Form from django.shortcuts import render from django.shortcuts import get_object_or_404 from django.utils import timezone def p_page(request,p_id): obj = Product.objects.all() template = "index.html" product = get_object_or_404(obj,id=p_id) if request.method =='POST': form … -
Wagtail large files 403 when serve
In my Wagtail project I use custom document model with specified file upload path. I'm able to upload large files to specified directory, but, when I try do serve them,there is nginx 403 forbidden error. Tried a lot of different solutions from similar questions, but nothing helped :( -
django - database - from sqlite to postgres, not fully migrated, lacking language support?
I just deployed my very first django project, and I am trying to use pgloader v3.5 to migrate some important data from sqlite3 to postgres. It's successful, well, semi-successful since the data written in English are migrated whereas the data written in Russian (Cyrillic) aren't. Tried: Then, I tried a generic way - dump a datadump.json file of db.sqlite3 and python manage.py loaddata datadump.json, then the error: django.db.utils.DataError: Problem installing fixture '/home/user/project/datadump.json': Could not load boutique.Category(pk=1): character with byte sequence 0xd0 0x90 in encoding "UTF8" has no equivalent in encoding "LATIN1" datadump.json Then, I checked the datadump.json file: [{"model": "boutique.category", "pk": 1, "fields": {"gender": 1, "name": "\u0410\u043a\u0441\u0435\u0441\u0441\u0443\u0430\u0440\u044b", "description": "", "uploaded_date": "2020-03-02T08:20:49.786Z"}}, ... checked I checked the data in db.sqlite3 is intact, and data (mainly strings) in Russian aren't transferred in the new postgres database. system Ubuntu 18, bionic django 3.0.3 Question: I think the question is how to load/convert non-English json data? Not sure where to start to solve the problem. Thanks in advance! -
Django Heroku Scheduler once a week
I've set up a Heroku Scheduler for my Django app and it works great as a daily process. This is the command I insert in the scheduler to run the job: $ python manage.py update_db I want it to run only once a week. I researched and found a bunch of posts including - How can I schedule a 'weekly' job on Heroku? if [ "$(date +%u)" = 1 ]; then MY_COMMAND; fi How do I combine MY_COMMAND with my command above? I tried replacing it directly but it doesn't work. The job is run daily, but the function is not executed. Thanks -
How to create multidimensional array in python from list?
I have a list containing elements like list1 = [['Test Name', 'Results', 'Units', 'Bio. Ref. Interval'], ['Cholesterol, Total', '243.00', 'mg/dL', '<200.00'], ['Triglycerides', '365.00', 'mg/dL', '<150.00'], ['HDL Cholesterol', '48.56', 'mg/dL', '>50.00'], ['LDL Cholesterol, Calculated', '121.44', 'mg/dL', '<100.00'], ['VLDL Cholesterol, Calculated *', '73.00', 'mg/dL', '<30.00'], ['Non-HDL Cholesterol', '194', 'mg/dL', '<130']] I want to use list1[0] that is, ['Test Name', 'Results', 'Units', 'Bio. Ref. Interval'] to make it as key and want output something like the following multidimensional dictionary. { Testname : 'Cholesterol, Total' { Result : '243.00', Units : 'mg/dL', Bio. Ref. Interval : '<200.00' },.... .... { Testname : 'Non-HDL Cholesterol' { Result : '194', Units : 'mg/dL', Bio. Ref. Interval : '<130'}} } I'm newbie to python. Help out please. -
pythonanywhere refused to connect while serving PDFs
enter image description here When I am serving pdfs through my backend written in Django pythonanywhere to my frontend website written in react, I am getting this error yashshah2820.pythonanywhere.com refused to connect. code in models.py name = models.CharField(max_length=20, blank=True) pdf = models.FileField(upload_to="pdfs", blank=True) def __str__(self): return self.name code in settings.py STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') STATIC_URL = '/static/' # for media under development MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') -
django data in form only appear after refresh
I am using custom user authentication for verifying user. I have table named voter and I am tacking username and password via from and matching that with username and password of table if it match user will be logged in and allowed them to pass to next page which contain form. In that form I initiated data but it will not appear automatically it will appear only when i refresh the page code of my files is bellow (for some big file only relevant code is included that's why it is partial) model.py (partial) class Voter(models.Model): serial_voter_id = models.AutoField(primary_key=True) voter_id = models.CharField(unique=True, max_length=10) voter_name = models.CharField(max_length=255) voter_constituency = models.ForeignKey(Constituency, models.DO_NOTHING, blank=True, null=True) username = models.CharField(unique=True, max_length=32) password = models.TextField() voter_address = models.CharField(max_length=255, blank=True, null=True) area = models.CharField(max_length=10, blank=True, null=True) city = models.CharField(max_length=10, blank=True, null=True) pincode = models.IntegerField(blank=True, null=True) adhar_no = models.BigIntegerField(unique=True) birth_date = models.DateField() age = models.IntegerField() fingerprint = models.TextField(blank=True, null=True) authenticity = models.CharField(max_length=3, blank=True, null=True) wallet_id = models.TextField() class Meta: managed = False db_table = 'voter' forms.py from django import forms from .models import Voter class VoterForm(forms.ModelForm): class Meta: model = Voter fields = [ 'serial_voter_id', 'voter_id', 'voter_name', 'voter_constituency', 'username', 'voter_address', 'area', 'city', 'pincode', 'adhar_no', 'birth_date', 'age', 'authenticity', 'wallet_id' … -
Translate this linux script command to windows commands
I need to create a .bat file script to run python manage.py collectstatic --noinput Below is the bash script.. i need to to work on windows.. it cd in folder named chefables, portal is application name #! /bin/bash cd chefables rm -rf static/ rm -rf assets/portal/ python manage.py assets build cp -R ./assets/portal/* ./portal/static/portal/ python manage.py collectstatic --noinput -
users.models.Profile.user.RelatedObjectDoesNotExist: Profile has no user
I am designing a website to take in and store a users information under a profile. The main issue I am running into seems to be between the profile and user relationship. When I try and delete empty profiles from the admin page it gives me this error: (py3) (base) Ethans-MBP-2:opinions_app ethanjay$ python manage.py runserver Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). March 05, 2020 - 00:09:33 Django version 2.2.10, using settings 'django_project.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C. [05/Mar/2020 00:09:42] "GET / HTTP/1.1" 200 3142 Not Found: /favicon.ico [05/Mar/2020 00:09:42] "GET /favicon.ico HTTP/1.1" 404 4608 [05/Mar/2020 00:09:46] "GET /admin/ HTTP/1.1" 200 8342 [05/Mar/2020 00:09:47] "GET /admin/ HTTP/1.1" 200 8342 [05/Mar/2020 00:09:50] "GET /admin/users/profile/ HTTP/1.1" 200 6300 [05/Mar/2020 00:09:50] "GET /admin/jsi18n/ HTTP/1.1" 200 3223 Internal Server Error: /admin/users/profile/ Traceback (most recent call last): File "/Users/ethanjay/Enviroments/py3/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/Users/ethanjay/Enviroments/py3/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "/Users/ethanjay/Enviroments/py3/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/Users/ethanjay/Enviroments/py3/lib/python3.7/site-packages/django/contrib/admin/options.py", line 606, in wrapper return self.admin_site.admin_view(view)(*args, **kwargs) File "/Users/ethanjay/Enviroments/py3/lib/python3.7/site-packages/django/utils/decorators.py", line 142, in _wrapped_view response = view_func(request, *args, **kwargs) File "/Users/ethanjay/Enviroments/py3/lib/python3.7/site-packages/django/views/decorators/cache.py", line 44, …