Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
django.core.exceptions.ImproperlyConfigured: The included URLconf 'api.urls' does not appear to have any patterns in it
Having a hard time understanding why I am receiving this error. If I just leave the api/user/ path it works fine but when I try to add api/user/date_counter/ path I get this error. Using Django 3. Any help would be appreciated. date_counter/urls.py from django.urls import path from date_counter import views app_name = 'date_counter' urlpatterns = [ path('date_counter/', views.DateCounterViewSet.as_view(), name='date_counter'), ] date_counter/views.py from django.shortcuts import render from date_counter.models import Date_Counter from date_counter.serializers import DateCounterSerializer class DateCounterViewSet(viewsets.ModelViewSet): queryset = Date_Counter.objects.all() serializer_class = DateCounterSerializer date_counter/serializers.py from date_counter.models import Date_Counter from rest_framework import serializers class DateCounterSerializer(serializers.ModelSerializer): class meta: model = Date_Counter fields = ['user', 'date', 'count'] date_counter/models.py from django.db import models from user.models import User class Date_Counter(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) date = models.DateField(auto_now=True) count = models.IntegerField(default=0) api/urls.py from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('api/user/', include('user.urls')), path('api/user/date_counter/', include('date_counter.urls')), ] api/settings.py INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'knox', 'user', 'date_counter', ] Stack Trace Exception in thread django-main-thread: Traceback (most recent call last): File "/Users/francisco_navarro/.local/share/virtualenvs/pomodoro_tracker-2HYScThJ/lib/python3.6/site-packages/django/urls/resolvers.py", line 590, in url_patterns iter(patterns) TypeError: 'module' object is not iterable During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 916, … -
Deploy django app on linux shared hosting
I've made a django app and I'm ready to deploy it to a live server with my custom domain. The problem I'm facing is my I'm using a shared hosting and the terminal access is disabled by the administrator. SO is there any way to deploy django app successfully from cpanel. Thanks in advance. -
Django - oscar show a field in dashboard
from oscar.apps.catalogue.abstract_models import AbstractProduct from oscar.core.compat import AUTH_USER_MODEL from django.db import models class Product(AbstractProduct): seller = models.ForeignKey( AUTH_USER_MODEL, on_delete=models.CASCADE, null=True) from oscar.apps.catalogue.models import * I added this code to forked catalog model > I want to show it in the dashboard,Image of dashboard and dropdown box I tried admin.site.register but it is not working. -
I am trying to use a locally hosted Django webserver's HTML button to execute a python script that's on my local machine and I'm stumped
So, I'm pretty new to Django, python, and javascript. I have a partially functional Django webserver that, while developing it, I host locally on my machine. I've made a button with HTML which I've figured out can be tied to a javascript script. The next step for me was to make this button "execute" a python script that's sitting on my machine, particularly on the /desktop directory. I can of course move the script though, but the important part is that I want that python script (let's call it django_test_script.py) to open its own window on my machine. It's just a file that says "hi" in stdout, then closes after 5 seconds, but due to the plan for this whole project, I want that to happen. I want to have my website open on my machine, click that button, then have the script's console pop up on my desktop and run/finish. The eventual goal is to control an LED strip that's plugged into my raspberry pi. I want colored buttons on the website that, when clicked, run appropriate python scripts that turn the lights to that color. It wouldn't take me long to write up the python scripts themselves that … -
Django - Customizing admin form element: modifying change_form to add jquery plugin
I appear to have a valid output when I view the page source on my customized django admin page. But I'm trying to add a jquery datetimepicker to the "Timeslot start" form element, and nothing happens when I click on it. No javascript error, nothing. Debug is True on my settings.py and there are no errors. change_form.html changes: {% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}"> <link rel="stylesheet" type="text/css" href="{% static 'css/schedule/jquery.datetimepicker.css' %}"/ > {% endblock %} . . . {% block admin_change_form_document_ready %} {{ block.super }} <script src="{% static 'js/jquery-3.2.1.min.js' %}"></script> <script src="{% static 'js/schedule/jquery.datetimepicker.full.min.js' %}"></script> <script type="text/javascript" id="django-admin-form-add-constants" src="{% static 'admin/js/change_form.js' %}" {% if adminform and add %} data-model-name="{{ opts.model_name }}" {% endif %}> jQuery(document).ready(function () { jQuery('#DTPicker').datetimepicker(); }); </script> {% endblock %} This is the page with the datetimepicker instructions, which I think I have followed correctly in this case. admin.py class TeacherAvailabilityAdmin(admin.ModelAdmin): form = TeacherAvailabilityAdminForm list_display = ('teacher_id', 'student_id', 'timeslot_start',) forms.py class TeacherAvailabilityAdminForm(forms.ModelForm): TEACHER_CHOICES_QUERYSET = TeacherProfile.objects.available_teachers() STUDENT_CHOICES_QUERYSET = StudentProfile.objects.active_students() teacher = forms.ModelChoiceField( queryset=TEACHER_CHOICES_QUERYSET, empty_label="Select One", to_field_name="id") student = forms.ModelChoiceField( queryset=STUDENT_CHOICES_QUERYSET, empty_label="Select One", to_field_name="id") timeslot_start = forms.DateTimeField(widget=forms.DateTimeInput(attrs={'id': 'DTPicker'}), required=True) class Meta: model = TeacherAvailability fields = ('teacher', 'student', 'timeslot_start') -
Need help to mash this code. I'm trying to copy a media file from someone and the DIR is messed up
I have media player I need to put on a site but, I don't know how to combine all this code in settings.py its throwing unrelated errors. STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'firegod/static') ] STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_URL = '/static/' PROJECT_DIR = os.path.dirname(os.path.abspath(__file__)) STATIC_ROOT = os.path.join(PROJECT_DIR, 'static') PROJECT_ROOT = os.path.normpath(os.path.dirname(__file__)) STATICFILES_DIRS = ( os.path.join(PROJECT_ROOT, '..', 'static'), ) MEDIA_URL = 'media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media/') -
Using opencv to read a video file in Django, yet the cam won't open?
I am getting a video file from the user and storing it in the media folder. Then I pass a path to the file to a function, but when I use opencv to open the file, the cam won't open. start = time.time() cam = cv2.VideoCapture(video_name) fr = cam.get(cv2.CAP_PROP_FPS) The video_name is of the form /media/video_name.mp4 The error report is the following [ERROR:0] global C:\projects\opencv-python\opencv\modules\videoio\src\cap.cpp (116) cv::VideoCapture::open VIDEOIO(CV_IMAGES): raised OpenCV exception: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\videoio\src\cap_images.cpp:235: error: (-5:Bad argument) CAP_IMAGES: error, expected '0?[1-9][du]' pattern, got: /media/video_name.mp4 in function 'cv::icvExtractPattern' -
Pulling changed data from heroku
I have deployed a Django app in Heroku. I want the updated SQLite file to be reflected in my local repository. Is there any way I can do this. -
How to calculate total price using django?
I have simple django code, but it doesn't work. The code works to calculate total price from price and qty of the item purchased, then save it into the database. Here the code class Items(models.Model): items_name = models.CharField(max_length=50) harga = models.PositiveIntegerField() def __str__(self): return self.items_name class Transaction (models.Model): items = models.ForeignKey(Items, on_delete=models.CASCADE) qty = models.PositiveIntegerField() def total_price(self): total = self.qty * self.items.harga return total total_price = models.PositiveIntegerField(total_price) -
Django - makemigrations - No changes detected/Apps could not be found
I was trying to create migrations within an existing app using the makemigrations command but it outputs "No changes detected" The code I used for that is `python3 manage.py makemigrations` I tried python3 manage.py makemigrations polls and it shows "App 'polls' could not be found. Is it in INSTALLED_APPS?" Here is my INSTALLED_APPS of the settings.py file INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'polls.apps.PollsConfig', ] I know some people simply put 'polls', it doesn't work either Here is my folder structure: File structure Here is my apps.py from django.apps import AppConfig class PollsConfig(AppConfig): name = 'polls I am using django2.1 and python3.8 -
Custom metrics from celery workers into prometheus
I have a few celery workers running in containers under kubernetes. They are not auto-scaled by celery and each run in a single process (i.e. no multiprocessing). I would like to get a bunch of different metrics from them into prometheus. I've looked at celery-prometheus-exporter (unmaintained) and celery-exporter but they are focused on metrics at celery level rather than app metrics inside of the celery workers. It looks like two options would be either to find some hacky way to get app level metrics to celery-prometheus-exporter which then would make them available to prometheus OR to use pushgateway. Which is better, or maybe there's another option I missed? -
Website not opening without www but opens with it
I am trying to deploy my website. It works fine with www but I get apache default page when I enter the website without www. I don't understand where the problem comes from, I have already set an Alias as you can see here. <VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port t> # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. ServerName foot-bet.com ServerAlias www.foot-bet.com ServerAdmin webmaster@localhost DocumentRoot /var/www/html # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # … -
Does the following model design have optimization space?
Should port fields be of integer or string type? Should port fields use Boolean or enumeration types? (I'm not sure Django supports enumeration types yet) Or do you have any better suggestions? I would appreciate it if you could write specific code! from django.db import models class Proxy(models.Model) ip = models.GenericIPAddressField(protocol='IPv4') port = models.IntegerField() status = models.BooleanField() -
existe t'il une autre facon d'installer les requirement.txt dans un projets sans qu'il n'y ait pas d'erreur [closed]
je viens de cloner l'api d'un projet. J'ai bien suivit le fichier .README mais à chaque fois que je met pip install -r requirements.txt j'ai cette erreure suivanteenter image description here -
showing random users while excluding copies of the same user
I'm trying to display 3 random users on my home page. How would I go about doing that? I can get the users to display, but sometimes there are two of the same user that are showing. I want to make sure every time there are 3 unique users showing. views.py def home(request): random_profile1 = (Profile.objects.exclude(id=request.user.id).order_by('?')[0]) random_profile2 = (Profile.objects.exclude(id=request.user.id).order_by('?')[0]) random_profile3 = (Profile.objects.exclude(id=request.user.id).order_by('?')[0]) context = dict(random_profile1 = random_profile1, random_profile2 = random_profile2, random_profile3 = random_profile3) return render(request, 'dating_app/home.html',context) -
views still firing old function in django
Why is it everytime i fire the url for my logout view it still rendering the old function? but when i create one like example logout_test its rendering correct, is the browser cached my function in django? here is my urls.py: urlpatterns = [ path('', LoginView.as_view(), name = 'login'), path('logout/', logout, name = 'logout'), path('signup/', signup, name = 'signup'), ] here is my views.py: def logout(request): return test I put intentionally test in return so that i will expect an error, but still its rendering the old function which is: def logout(request): response = redirect(reverse_lazy('login:login')) return response -
pyodbc error: using django in docker container
I am using a docker container running django application. i get the below error whenever i try to run function that manipulates data on 2 separate databases error: [Microsoft][ODBC Driver 17 for SQL Server]SSL Provider: [error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol] (-1) (SQLDriverConnect)') this is the function i run def preStepBtn3(request): sourcePE = request.GET.get('sourcePE') targetPE = request.GET.get('targetPE') inputFTID = request.session['username'] datetime_object = datetime.datetime.now() step_name = "preStepBtn3" table_name = "null" Action_taken = "change router status to MIG" MassivePortalSessionID = request.session['MassivePortalSessionID'] try: with connections['DataAdmin'].cursor() as cursor: sql = """DECLARE @out nvarchar(max); exec DTA.mig_sop_ce_status2mig_django 0, %s, @param_out = @out OUTPUT; SELECT @out AS the_output; """ params = [sourcePE] cursor.execute(sql, params) rows = cursor.fetchall() result = [] result.append(rows) logDB_sql(MassivePortalSessionID, inputFTID, sourcePE, targetPE, table_name, step_name, datetime_object, Action_taken) print("data inserted in log DB") while rows: print(rows) if cursor.nextset(): result.append(cursor.fetchall()) else: print(result) return JsonResponse(result, safe=False) except Exception as ex: error = ex print(error) context = {'text': error} logDB_sql(MassivePortalSessionID, inputFTID, sourcePE, targetPE, table_name, step_name, datetime_object, Action_taken) print("data inserted in log DB during exception") return render(request, 'posts/textArea.html', context) whenever i remove the logDB_sql it works perfectly this is code for logDB_sql def logDB_sql(MassivePortalSessionID, inputFTID, sourcePE, targetPE, table_name, step_name, datetime_object, Action_taken): params = [MassivePortalSessionID, inputFTID, sourcePE, targetPE, table_name, step_name, datetime_object, Action_taken] print(targetPE) print(sourcePE) … -
Django keeps using wrong storage backend when trying to upload static files to S3
I have been using S3 as a storage service for other Django apps, however for a new project, Django refuses to pick up the correct backend and keeps putting the files on my local filesystem instead of upload. To be exact, after I install boto3 and adjust settings.py, then run python manage.py collectstatic, that command keeps moving the static files to <my_project_path>/staticfiles instead of starting the upload to S3. This is the output of python manage.py collectstatic: You have requested to collect static files at the destination location as specified in your settings: /Users/simon/projects/farmtokitchen/farmtokitchen/staticfiles This will overwrite existing files! Are you sure you want to do this? Type 'yes' to continue, or 'no' to cancel: My settings: INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.sites', # Vendor 'storages', 'allauth', 'allauth.account', 'allauth.socialaccount', 'sass_processor', 'crispy_forms', [..] ] # static & media files USE_S3 = config('USE_S3', cast=bool, default=True) AWS_ACCESS_KEY_ID = config('AWS_ACCESS_KEY_ID') AWS_SECRET_ACCESS_KEY = config('AWS_SECRET_ACCESS_KEY') AWS_DEFAULT_ACL = None AWS_STORAGE_BUCKET_NAME = config('AWS_STORAGE_BUCKET') AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME AWS_S3_OBJECT_PARAMETERS = { 'CacheControl': 'max-age=86400', } AWS_LOCATION = 'static' STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') MEDIA_ROOT = os.path.join(BASE_DIR, 'media') if USE_S3: MEDIA_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, 'media') DEFAULT_FILE_STORAGE = 'farmtokitchen.storage_backends.MediaStorage' STATIC_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, AWS_LOCATION) STATICFILES_STORAGE = … -
In Django how can I filter objects in a QuerySet based on a many to many relationship?
So I have a user Profile model with a data attribute which is a many to many field representing a Profile "friending" another Profile like on Facebook. Here's the code for that: friends = models.ManyToManyField("self") What kind of query can I do to write a method that gets me all the Profiles that are friends with a current Profile? friends = Profile.objects.filter(friends=self.pk) This seems to give an empty QuerySet when I test it. -
Cant pip-install mysql into venv on Mac OS Catalina for Django framework
Dears, I can not install mysql or mysqlclient into my venv. Everytime I try, I am getting this errors: However, I managed to brew-install it locally by using these steps: https://ruddra.com/posts/install-mysqlclient-macos/ It worked locally, but still, I can not create a proper venv with mysql or mysqlclient. I am using Django and PyCharm. Everytime I want to manage.py runserver, it asks me for mysqlclient. Error when trying to pip install mysql into my venv: Processing /Users/michaltarasiewicz/Library/Caches/pip/wheels/3e/4a/d0/506edab38d1bdf574b02c24805fcf7348a327297fcc285431d/mysql-0.0.2-py3-none-any.whl 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: /Users/michaltarasiewicz/Projects/Venvs/Django/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/v5/rxvfdtj967bcph1hj69s0k8m0000gn/T/pip-install-v6y4fnwu/mysqlclient/setup.py'"'"'; __file__='"'"'/private/var/folders/v5/rxvfdtj967bcph1hj69s0k8m0000gn/T/pip-install-v6y4fnwu/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 /private/var/folders/v5/rxvfdtj967bcph1hj69s0k8m0000gn/T/pip-wheel-8ds4c5v5 cwd: /private/var/folders/v5/rxvfdtj967bcph1hj69s0k8m0000gn/T/pip-install-v6y4fnwu/mysqlclient/ Complete output (30 lines): running bdist_wheel running build running build_py creating build creating build/lib.macosx-10.9-x86_64-3.8 creating build/lib.macosx-10.9-x86_64-3.8/MySQLdb copying MySQLdb/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb copying MySQLdb/_exceptions.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb copying MySQLdb/compat.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb copying MySQLdb/connections.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb copying MySQLdb/converters.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb copying MySQLdb/cursors.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb copying MySQLdb/release.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb copying MySQLdb/times.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb creating build/lib.macosx-10.9-x86_64-3.8/MySQLdb/constants copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb/constants copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb/constants copying MySQLdb/constants/CR.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb/constants copying MySQLdb/constants/ER.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb/constants copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb/constants copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-x86_64-3.8/MySQLdb/constants … -
How can a django developer tell which code is the better one to use
I must say, I am really loving django and how the framework handles a lot of things, but sometimes, it just seems like there are way too many ways to do the same thing, that sometimes one just wants to know if a particular way is best. I have a filtering line of code that I initially wrote like this.. Post.objects.filter(author=user).filter(approved=True).order_by('-date_posted') I was going through my codes and just thought to change this line to Post.objects.filter(author=user, approved=True).order_by('-date_posted') I knew it would still work, but was still surprised it did the exact same thing. So, my question is, in a situation like this, how would one know which is the better implementation here? Cos both lines of code do filtering on the database level. -
Issue with Django interaction between user input + View + Html response
I am having an issue in my django project with the following logic: A user enters a value in a search bar (form ) that renders data on the same html page. He then can click on a data point that redirect the user on a new page where there is a table containing data regarding the value that he has originally entered. I am having a problem with the view that redirect the user from the original value entered, pass it in the table and shows him the data in the new html page. I don't know what is wrong with it. I hope someone can see where i am mistaken! view.py class PostSupplierData(APIView): def get(self, request): query = request.GET.get('search_ress', None) context = {} if query and request.method == 'GET': queryset = Item.objects.filter(fournisseur = query) table = SupplierData(queryset) context.update({'table' : table}) return render(request, 'SupplierData.html', context) table.py class SupplierData(tables.Table): class Meta: model = Item template_name = "django_tables2/bootstrap4.html" error: AssertionError at /SupplierData.html Expected a `Response`, `HttpResponse` or `HttpStreamingResponse` to be returned from the view, but received a `<class 'NoneType'>` I get that the error means that I am not actually rendering anything but I am not sure why that is. Please … -
Pandas Read CSV Byte Array from Multipart Request is altered
So i am trying to build a web time series analysis app for uni and i am stuck on a problem. The app is split in two services, a kotlin web service that will recieve a csv file from a client, encrypt and compress it (using GZIP, if it has any relevance) then storing the file into DB. When the client requests analysis on that specific file, it is retrieved from DB,decompressed and decrypted and sent to the python service via REST Multipart request as a byte stream to be consumed as a CSV. All good until there, when i look at the string representation of the file inside debug in the python service it seems good but somehow on the course the file has been altered and i cant find out why and where (because dataFrame.to_json() spits different results for the transferred file vs the original one). I can't find what i am doing wrong, should i Base64 encode the file before storing it to DB/sending it via REST? Thank you in advance! -
Django Markdownx Trouble
I am having trouble with markdown on my Django application. I am writing a blog from a tutorial, and want markdown in my posts. I installed Markdownx for Django, and it almost works. I have issues when it comes to code blocks. The markdown looks different in the admin page than it does in the rendering of the html page. I would like my code blocks to appear as they do on stackoverflow and github. Instead, when I do the code block formatting with the three ```, I get red text. Below are my files for the application I am asking about: project/urls.py from django.contrib import admin from django.urls import path, include from django.conf.urls.static import static from django.conf import settings urlpatterns = [ path('admin/', admin.site.urls), path('projects/', include('projects.urls')), path('blog/', include('blog.urls')), path('markdownx/', include('markdownx.urls')), ] urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) project/settings.py ... INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'projects', 'blog', 'markdownx', ] ... app/models.py from django.db import models from markdownx.models import MarkdownxField from markdownx.utils import markdownify class Projects(models.Model): title = models.CharField(max_length=100) short_description = models.TextField() long_description = MarkdownxField() project_link = models.URLField(max_length=250) def formatted_markdown(self): return markdownify(self.long_description) app/admin.py from django.contrib import admin from projects.models import Projects from markdownx.admin import MarkdownxModelAdmin class ProjectsAdmin(admin.ModelAdmin): pass admin.site.register(Projects, … -
'Profile object is not iterable'
So I'm having some difficulty here. I am attempting to match two users by checking if the user that the current user is voting on ALSO voted true to them. Now, it runs all way until it has to query the Profile objects, which is my user model since I created a custom user model. Now I'm stuck here because request.user should serve the Profile object, and it works in other parts of my code, but it's not working here. Furthermore, the code does create a 'vote' object regardless of wether or not the users get matched and put into my matches database. And the error only occurs if the other use has voted True on the current user, so that part is working, it's just not iterating through Profile objects. error error is at 'npm = Profile.objects.get(request.user)' traceback Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view return view_func(request, *args, **kwargs) File "/Users/papichulo/Documents/DatingAppCustom/dating_app/views.py", line 134, in nice return create_vote(request, profile_id, True) File "/Users/papichulo/Documents/DatingAppCustom/dating_app/views.py", line 157, in create_vote …