Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Creating Django model instance on form submission
I have am trying to create a "stats" app in my project that keeps track of all the leads my site generates. When a user submit the "request info" form a message is automatically sent to the business associated with that product. Simultaneously I would like a model instance to be created in one of the models in the Stats app (different app then we are working in). The Stats works in the background simply collecting info view model instance for certain things. Here is the code breakdown: The view: def ListingView(request,name_initials,l_slug): listing = get_object_or_404(Listing,l_slug=l_slug) images = ListingImage.objects.filter(property=listing) form = ContactPropertyForm(request.POST or None) context = { 'listing':listing, 'images':images, 'form':form, } if form.is_valid(): name = form.cleaned_data.get('name') phone = form.cleaned_data.get('phone') email = form.cleaned_data.get('email') party_size = form.cleaned_data.get('party_size') form_message = form.cleaned_data.get('message') listing_address = listing.address message = name + " " + phone + " " + email + " " + party_size + " " + listing_address to_email = ['email here'] html_message = "<b>Name: </b>" + name + "<br>" + "<b>Phone: </b>" + phone + "<br>" + "<b>Email: </b>" + email + "<br>" + "<b>Group Size: </b>" + party_size + "<br>" + "<b>Property: </b>" + listing_address send_mail('New Lead', message, 'from email', ['To email'], fail_silently=False, … -
Django rest framework storing byte string for image
So what i am doing is to store byte string. And from my understanding, i am using byteio to convert the byte string i store and output it into image. Although i have not read about how ByteIO works so im going to research it later. Maybe im wrong but please give correct me if it is. But i have no idea on using what field for it. I tried using BinaryField for it but got error for its editable=False, setting it to true doesnt fix anything. So do i use CharField to store the byte string or ImageField/FileField works for it too ? -
Django: Submit multi-level form data
I have three models A, B, & C. B has a foreignkey to A while C has a foreignkey to B. I want to create A instance with multiple B and multiple C. E.g A -----B1 -----C11, C12, C13 -----B2 -----C22, C22, C23 -----B3 -----C31, C32, C33 but when I submit the form, I get something like this instead: A -----B1 -----C11, C12, C13 -----B2 -----B3 How do I fix it? models class A(models.Model): a_text = ... created_by = models.Foreignkey(User) class B(models.Model): a = models.ForeignKey(A, on_delete=models.CASCADE) b_text = ... created_by = models.Foreignkey(User) class C(models.Model): b = models.ForeignKey(B, on_delete=models.CASCADE) c_text = .... forms class AForm(forms.ModelForm): class Meta: model = A fields = ['a_text',] class BForm(forms.ModelForm): class Meta: model = B fields = ['a', 'b_text',] class CForm(forms.ModelForm): class Meta: model = C fields = ['b', 'c_text',] B_FormSet = forms.inlineformset_factory(A, B, form=BForm, can_delete=False, extra=3) C_FormSet = forms.inlineformset_factory(B, C, form=CForm, can_delete=False, extra=3) views @login_required def create_A_object(request, *args, **kwargs): if request.method != 'POST': A_form = AForm(prefix='a') B_forms = B_FormSet(prefix='b') C_forms = C_FormSet(prefix='c') else: A_form = BaForm(request.POST, request.FILES, prefix='a') B_forms = CaFormSet(request.POST, request.FILES, prefix='b') C_forms = ChFormSet(request.POST, request.FILES, prefix='c') A_valid = A_form.is_valid() B_valid = B_forms.is_valid() C_valid = C_forms.is_valid() if A_valid and B_valid and C_valid: a = … -
WSGI Error deploying Pythong to Heroku
If i run heroku local web my application runs as expected. But when I git push heroku master and go to my herokuapp, I get a server error and my heroku logs give me this: 2018-01-03T02:39:35.291600+00:00 app[web.1]: self.wsgi = self.app.wsgi() 2018-01-03T02:39:35.291602+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load 2018-01-03T02:39:35.291603+00:00 app[web.1]: return self.load_wsgiapp() 2018-01-03T02:39:35.291601+00:00 app[web.1]: self.callable = self.load() 2018-01-03T02:39:35.291603+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp 2018-01-03T02:39:35.291604+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 352, in import_app 2018-01-03T02:39:35.291605+00:00 app[web.1]: __import__(module) 2018-01-03T02:39:35.291611+00:00 app[web.1]: ModuleNotFoundError: No module named 'myNewApp' 2018-01-03T02:39:35.291604+00:00 app[web.1]: return util.import_app(self.app_uri) 2018-01-03T02:39:35.291802+00:00 app[web.1]: [2018-01-03 02:39:35 +0000] [9] [INFO] Worker exiting (pid: 9) 2018-01-03T02:39:37.490787+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=myNewApp.herokuapp.com request_id=68ae4976-dfd3-4201-9401-c7caf7189f66 fwd="24.5.227.25" dyno= connect= service= status=503 bytes= protocol=https help please? I'm not sure if I need to add any settings informaiton on here, but I can if needed... -
can not login with Extended AbstractBaseUser model
I'm using Django 2.0 I have extended the AbstractBaseUser to make some modification to the email and use email as username class UserManager(BaseUserManager): def create_user(self, email, password=None, is_staff=False, is_superuser=False): if not email: raise ValueError('User must have an email address') if not password: raise ValueError('User must have a password') user = self.model( email=self.normalize_email(email) ) user.is_staff = is_staff user.is_superuser = is_superuser user.set_password(password) user.save(using=self._db) return user def create_staffuser(self, email, password=None): return self.create_user( email, password=password, is_staff=True ) def create_superuser(self, email, password=None): return self.create_user( email, password=password, is_staff=True, is_superuser=True ) class User(AbstractBaseUser): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) email = models.EmailField(max_length=250, blank=False, unique=True) first_name = models.CharField(max_length=150, blank=True) last_name = models.CharField(max_length=150, blank=True) is_staff = models.BooleanField(default=False) is_active = models.BooleanField(default=False) is_superuser = models.BooleanField(default=False) groups = models.ManyToManyField(Group, blank=True) last_login = models.DateTimeField(auto_now=True) date_joined = models.DateTimeField(auto_now_add=True) USERNAME_FIELD = 'email' objects = UserManager() @property def staff(self): return self.is_staff @property def active(self): return self.is_active @property def superuser(self): return self.is_superuser def __str__(self): if self.first_name is not None: return self.get_full_name() return self.email def get_full_name(self): if self.last_name is not None: return self.first_name + ' ' + self.last_name return self.get_short_name() def get_short_name(self): return self.first_name I have then run python manage.py makemigrations python manage.py migrate and created superadmin using python manage.py createsuperuser The superuser is created successfully. But when I … -
Form is not shown in html correctly
Form is not shown in html correctly.I wrote in search.html, {% load static %} <form action='/search/' method='POST> <table> {{ form.as_table }} </table> <input name="submit" type="Search" /> {% csrf_token %} </form> in views.py def search(request): form = SearchForm() if request.method == 'GET': return render_to_response( 'search.html', {'form': form}, RequestContext(request)) elif request.method == 'POST': form = SearchForm(request.POST) search_result = POST.objects.all() if form.is_valid(): result = search_result.filter(Q(title__contains=form.cleaned_data['keyword'])) return render_to_response('search.html',{'form':form, 'result':result}) When I access search method,search.html is shown as strings like now search.html It is not From,so I really cannot understand why such a thing happens.No error happens but UserWarning: A {% csrf_token %} was used in a template, but the context did not provide the value. This is usually caused by not using RequestContext. "A {% csrf_token %} was used in a template, but the context " is shown in terminal.How should I fix this?What is wrong in my code? -
Sending confirmation email from inherited allauth class view
I am inheriting the allauth class view SignupView (from allauth.account.views import SignupView) I am using my own custom view and custom forms.py. Here's what I have: views.py class RegisterView(SignupView): form_class = RegisterForm template_name = 'oauth/auth_form.html' def form_valid(self, form): user = form.save(commit=False) # Do not save to table yet username = form.cleaned_data['username'] password = form.cleaned_data['password'] try: validate_password(password, user) except ValidationError as e: form.add_error('password', e) # to be displayed with the field's errors return render(self.request, self.template_name, {'form': form}) user.set_password(password) user.save() login(self.request, user) return redirect('profiles:Index', slug=username) forms.py class RegisterForm(forms.ModelForm): class Meta: model = User fields = ['username', 'email', 'password'] username = forms.CharField(label='Username', widget=forms.TextInput(attrs={'placeholder': 'Username:'})) email = forms.EmailField(label='Email', widget=forms.EmailInput(attrs={'placeholder': 'Email:'})) password = forms.CharField(label='Password', widget=forms.PasswordInput(attrs={'placeholder': 'Password:'})) My view is successfully showing up and when I click sign up it signs me up and redirects me. However, in the default allauth sign up view, it sends you a confirmation email. With my custom view it doesn't for some reason. What do I have to do in order for my form to be able to send a confirmation email to the user? I am using: this as my reference -
Is it possible to add non model field to method body in Django?
Is it possible to add non model field for instance to PATCH body? Let's take as an example that I would like to change password of the user. In my model I have only field password however in PATCH I would like to add old_password to authenticate user and then update password from password field from body. Any ideas? I found SerializerMethodField but I am not sure whether it is possible to do what I have described above -
Django - Questions around how to validate current environment and how to run in production
my apologies, for what might be a rather simple and amateur set of questions. I recently was voluntold (more like told) to absorb a django/python project that was developed by someone else. That someone else has left, and now I have to pick this up and run with it as there is no other backup. Being a university student (intern at work for another 12 mos), I don't think this experience will go to waste AT ALL so I'm happy to be involved, but because this is production and in use today I need to ramp up rather quickly. // sordid_tale I am new to Python, Django, Anaconda, PostGreSQL and the world. I know some coding from my first two years, and I've been reading through books to get up to speed. Current scenario: Project deployed in production server (windows 2012) project has an open connection to postgresql and publishes a website used by multiple people across the firm to upload math analytics for reporting. i started the project up using the python manage.py runserver 123.123.22.22:8000 which started the DEVELOPMENT server and sent me a big ol' warning sign saying don't do this in production. so i took it down … -
django test urls status code
hello i create some test for my project mainly to enrich my knowledge. and I have some questions. simple test code : test.py from django.test import Client, TestCase class User_Form_Test(TestCase): def test_logged_user_get_dataset(self): response = self.client.get('/details/', follow=True) self.assertEqual(response.status_code, 200) def test_logged_user_get_disasters_projects(self): response = self.client.get('/details-images/', follow=True) self.assertEqual(response.status_code, 200) urls.py url(r'^details/(?P<id>\d+)/$', views.details, name='details'), url(r'^details-images/(?P<slug>[^\.]+)/$', views.details_images, name='details_images') all this code work fine I take passed messages in this two test. my question is how to can test like this example all possible regex from id in first case and second slug in second case automate ? -
Serving protected files in Django without AWS S3
How to serve a protected files like picture, mp3, videos without amazon s3 in Django with Nginx and Digital Ocean? I am gonna use to Digital Ocean Droplet and want to configure it for serving protected files like pictures,mp3 and videos with Nginx. How can I implement it? Is it like I serve my file as FileSystemStorage on my local computer? With setting up all permissions related thing? from django.core.files.storage import FileSystemStorage class ProductFile(models.Model): file = models.FileField( upload_to=uploade_protected_file, storage=FileSystemStorage(location=settings.PROTECTED_ROOT) ) In my local environment, I serve my files in this way. And its work well. So same type of setup will work in Digital Ocean also? Thanks for help. -
Django private posts and public post example?
I am developing a django application that has private section and public section. How can I develop such app with django? I have tried having Model Manager and also template tags but neither make a user's post private. the following is my PostModelManager: class PostManager(models.Manager): def public_post(self, *args, **kwargs): # Post.objects.all() = super(PostManager, self).all() return super( PostManager, self).filter(public=True) def private_post(self, *args, **kwargs): # Post.objects.all() = super(PostManager, self).all() return super( PostManager, self).filter(public=False) -
Apache ImportError: No module named 'django'
Using django (I have tried many versions 1.8.7, 1.11.X, 2.0.1) python3.5 amd wsgi 4.5.24 compiled from source making sure that the python path set correctly /usr/bin/python3.5 I have an apache file with several wsgi sript aliases, all of which work except for the django script alias, which only failed when parsing the wsgi.py file because it can't import django. So first is the error from apache: [Tue Jan 02 18:46:32.247088 2018] [wsgi:error] [pid 2475:tid 139822294771456] [remote 192.168.254.101:2418] mod_wsgi (pid=2475): Target WSGI script '/var/www/protectionprofiles/protectionprofiles/wsgi.py' cannot be loaded as Python module. [Tue Jan 02 18:46:32.247260 2018] [wsgi:error] [pid 2475:tid 139822294771456] [remote 192.168.254.101:2418] mod_wsgi (pid=2475): Exception occurred processing WSGI script '/var/www/protectionprofiles/protectionprofiles/wsgi.py'. [Tue Jan 02 18:46:32.247523 2018] [wsgi:error] [pid 2475:tid 139822294771456] [remote 192.168.254.101:2418] Traceback (most recent call last): [Tue Jan 02 18:46:32.247637 2018] [wsgi:error] [pid 2475:tid 139822294771456] [remote 192.168.254.101:2418] File "/var/www/protectionprofiles/protectionprofiles/wsgi.py", line 12, in <module> [Tue Jan 02 18:46:32.247699 2018] [wsgi:error] [pid 2475:tid 139822294771456] [remote 192.168.254.101:2418] from django.core.wsgi import get_wsgi_application [Tue Jan 02 18:46:32.247772 2018] [wsgi:error] [pid 2475:tid 139822294771456] [remote 192.168.254.101:2418] ImportError: No module named 'django' and my apache config: <VirtualHost *:80> WSGIScriptAlias /certs /var/www/scripts/CavsCertSearch/CavsCertSearch/certstrip.wsgi WSGIScriptAlias /testcerts /var/www/scripts/CavsCertSearchTest/CavsCertSearch/certstriptest.wsgi WSGIScriptAlias /debug /var/www/scripts/debug/debug.wsgi WSGIDaemonProcess protectionprofiles python-path=/var/www/protectionprofiles WSGIProcessGroup protectionprofiles WSGIApplicationGroup %{GLOBAL} WSGIScriptAlias /pp /var/www/protectionprofiles/protectionprofiles/wsgi.py process-group=protectionprofiles <Directory /var/www/protectionprofiles/protectionprofiles> … -
Django shared db with restricted views per user
I have a db that is to be shared. Where if a object has a certain value I need specific users to be able to see and edit it. No other users can see or edit these objects. I am trying to understand what way one should do this. I don't know django very well. I am currently looking at conditionals for views. Not sure if that is even possible given i don't know if conditionals on views can filter objects from models. If anyone could point me in the right direction I would greatly appreciate it. -
Django Client().login() creates Anonymous user even when returning True
I am writing Django tests for views and have run into a problem where Client().login(...) returns True but creates AnonymousUsers, which have no attributes. First, I create the user in a test mixin class like : @classmethod def setUpTestData(cls): super(BareSetupClass, cls).setUpTestData() cls.regular_user = User.objects.create(email='test_user@test.com', first_name='test', last_name='user', confirmed_email=True ) cls.regular_user.set_password("password") cls.regular_user.save() Then I login in the test class like so: class UserGroupViewTestSuite(BareSetupClass): @classmethod def setUpTestData(cls): super(UserGroupViewTestSuite, cls).setUpTestData() cls.user = Client() cls.user.login(username="test_user@test.com", password="password") I have checked the value returned by calling login and it is True but the user I get from Client is still AnonymousUser, which inhibits my views from functioning properly. Thank you ahead of time! -
How to select unique records with minimum value of specific field in django?
I have a following model: class Product_shipment(models.Model): product_dscr = models.ForeignKey(Product_dscr, related_name='product_dscr', on_delete=models.CASCADE) import_date = models.DateTimeField(auto_now=True) stock = models.PositiveIntegerField() price = models.DecimalField(max_digits=10, decimal_places=2) I need to create an object with unique product_dscr. Duplicates should be chosen based on the minimal value of import_date. Following SQL code works fine: select id, import_date, stock, product_dscr_id from shop_product_shipment where import_date = ( select min(import_date) from shop_product_shipment as s where s.product_dscr_id = shop_product_shipment.product_dscr_id); Can anyone gimme a tip how to translate in Django? -
Updating a model from a dictionary object efficiently
I have a simple model: class A(models.Model): status=models.CharField() and I have a list of dictionary items in this way: data=[ {'id':1, 'status':'moved'}, {'id':2, 'status':'sized'} ] the id and status keys are related to the model fields. Currently, I am updating them by looping the data and it was ok. But the web service sent a long list the other day and it got me thinking, what if they don't send for days and when they send, it can be a big list. Since i don't have control over the data passed to me, what would be the most efficient way to make the updates? Currently: for i in range(len(data)): record=A.objects.get(pk=data[i]['id']) record.status=data[i]['status'] record.save() I am looking for something like .filter().update(....) but with status that can apply differently to each record. Any one? -
Django Set Form Field Value In Post Request
I am trying to set a form field value in views.py inside the Post request using data from request.session and then save that data to the db. However, I am having trouble figuring out how to do that. Here is what I've tried: if self.form.is_valid(): #attempt 1 request.POST._mutable = True self.form.data['field'] = request.session['key'] #attempt 2 self.form.fields['field'] = request.session['key'] #attempt 3 self.form.cleaned_data['field'] = request.session['key'] self.object = self.form.save() Is there a way to do this? -
List in template tag used in javascript file
As title say I want to use list from views.py to javascript file. I read this topic, but in my case it doesn't work: link My views.py: ... arr = ['first', 'second', 'third'] return render(request, "something.html",{"array": arr}) ... something.html: ... <script> array_js = eval("{{ array|escapejs }}"); </script> <script src="{% whatever.js %}"></script> ... I am using array_js in whatever.js file. It's works fine, but I am using eval function. I don't want to use it, but I don't know how to make it work without eval function. I am beginner, so please be patient. Thank You -
Django access the uploaded file from a model form
I am currently learning to use Django to create web apps and have problem with the admin site of Django. I created a model named AccountList and registered it in admin site, then I am able to add an account or modify one. Now, I want to make the administrator could add multiple accounts by upload a file. Here is what I have already done: I create a modelform in forms.py called AccountForm, add a new filefield called extra_file, which is used to upload the file containing accounts. class AccountForm(forms.ModelForm): extra_file = forms.FileField() def save(self, commit): ``` Some work here ``` pass class Meta: model = AccountList fields = ['game_id'] Then in admin.py, I override the get_form method so when i click add button, it would let me to upload a file rather than fill in every fieldsite manully. class UploadAccount(admin.ModelAdmin): list_display = ('game_id' , 'account_id' , 'name_list' , 'type_list') def get_form(self, request, obj=None, **kwargs): if obj: return super(UploadAccount, self).get_form(request, obj, **kwargs) else: return AccountForm Now, when I click the add button at admin site , the view looks like this, result I suppose the uploaded file should be handled in AccountForm.save() method, like loading each line and save it … -
Django rest framework and Cloudinary
Can someone help me to understand why I got this error response: [02/Jan/2018 22:05:11] "POST /api/v1/images/ HTTP/1.1" 400 43 when I try to upload a new image. { "error": "Not a valid string." } I completely new in Django world and a try to follow a tutorial but for some reason, my code didn't work and I try to debug my code but I can't understand why is not work for me. I hope someone can orientate me to go a good way. This my model from django.db import models from core.models import TimestampedModel class Image(TimestampedModel): image = models.CharField(max_length=350) def __str__(self): return self.image this my view from random import randint from rest_framework.response import Response from rest_framework.views import APIView from rest_framework import status from rest_framework.parsers import MultiPartParser, FormParser from cloudinary.templatetags import cloudinary from .serializers import ImageSerializer from .models import Image class ImageCloud(APIView): parser_classes = (MultiPartParser, FormParser,) serializer_class = ImageSerializer def get(self, request, format=None): images = Image.objects.all() serializer = ImageSerializer(images, many=True) return Response ({'images': serializer.data}, status=status.HTTP_200_OK) def upload_image_cloudinary(self, request, image_name): cloudinary.uploader.upload( request.FILES['image'], public_id=image_name, crop='limit', width='2000', height='2000', eager=[ {'width': 200, 'height': 200, 'crop': 'thumb', 'gravity ': 'auto', 'radius': 20, 'effect': 'sepia'}, {'width': 100, 'height': 150, 'crop': 'fit', 'format ': 'png'} ], tags=['image_ad', 'NAPI'] … -
Django: Referencing objects within a model - best practise
I'm currently going around in a bit of a "QuerySet' object has no attribute '' <> app.models.DoesNotExist: Messages matching query does not exist loop. Essentially, I'm trying to define "last_activity" on a Room model that is referencing the time at which the last Message associated to that room was sent. This is my attempt: class Room(models.Model): """ This model class sets up the room that people can chat within - much like a forum topic. """ title = models.CharField(max_length=255) staff = models.BooleanField(default=False) slug = models.SlugField(max_length=250, default='') banner = models.ImageField(storage=USER_UPLOAD_LOC, null=True, blank=True) def last_activity(self): last_persisted_message = Messages.objects.filter(where=self.title).order_by('-sent_at')[:1] return last_persisted_message.sent_at class Messages(models.Model): room = models.ForeignKey(Room, on_delete=models.CASCADE) where = models.CharField(max_length=255) message = models.TextField(default='') user = models.ForeignKey(settings.AUTH_USER_MODEL) username_from = models.CharField(max_length=255) username_to = models.CharField(max_length=255, default='all') sent_at = models.DateTimeField(default=datetime.datetime.now) I've tried so many things now and referenced the query set documentation and nothing seems to be working. I can also confirm that the "where" field for the Messages model is populated when a message is created by {{ room.title }}. I'm using a web socket connection on the client side to pass a "message" back to the websocket consumer.py which then persists the message to the DB). -
How to pass Django Context dict to Angular JS
I am pretty new to Angular and learned only so much to help with the project i am working on. I have a scenario where i want to pass context dictionary from Django view to imported Angular JS file. I was able to read properly to JS as jdata but unable to pass same data to Angular js js/main.js file . I tried following did not work. <html ng-app="plunker"> <head> <meta charset="utf-8" /> <title>Welcome to My Site!</title> <script data-require="angular.js@1.4.x" src="https://code.angularjs.org/1.4.0- rc.0/angular.js" data-semver="1.4.0-rc.0"></script> <script type="text/javascript"> var jdata = "{{ data | safe }}"; console.log(jdata); </script> <script src="{% static "js/main.js" %}"></script> </head> <body ng-controller="MainCtrl" > {% verbatim %} <div ng-init="weights={{ data }}"> </div> {% endverbatim %} <div ng-repeat="weight in weights"> {% verbatim %} <input type="radio" ng-model="selectedValue.name" ng-value="weight.name" ng-change="changeValue(weight.name)"> <label for="{{ weight.name }}">{{ weight.name }} </label> {% endverbatim %} </div> <div ng-repeat="weight in weights" ng-if="weight.name === selectedValue.name"> {% verbatim %} <label ng-repeat="wei in weight.values"> <input type="checkbox" ng-click="checkBoxChange(wei)" ng-value="wei" /> {{wei}} {% endverbatim %} </label> </div> {% verbatim %} <div>Selected object : {{selectedValue}}</div> {% endverbatim %} </body> </html> cs/main.js file app.controller('MainCtrl', function($scope, $window) { //$scope.weights = data; $scope.weights = [ { name: 'class1', values: ['1','2','3'] }, { name: 'class2', values: ['4','5','6'] }, { name: … -
Django ORM: Extremely slow response when no record exists
There are about 10 million records in the PostgreSQL table described by the following Django (1.11) model: class Tweet(models.Model): id = models.BigIntegerField(primary_key=True) user_id = models.BigIntegerField(db_index=True) text = models.TextField() created = models.DateTimeField(db_index=True) meta = JSONField(blank=True, null=True) To find the last Tweet by a user, I execute the following query: Tweet.objects.filter(user_id=user.id).order_by('-created').first() If the user has tweets in the db, it returns the last tweet instantly. However, if the user.id does not exist, it takes minutes to return a None. Even more strangely, when I run the generated queries directly on Postgres console, they both execute very fast. I've found a solution to check if any record exists first with .exists(): Tweet.objects.filter(user_id=user.id).exists() and then check for the last record. Now the total query times are reasonable but it doesn't feel right and there seems to be something wrong with Django ORM layer's interpretation of this case. Any ideas? -
How can I edit the urls.py of allauth?
I want to edit the urls.py of allauth by removing the links to the change email and password reset pages. Is there a way I can edit the urls.py in order for these pages to not display and return a 404 when the user tries to access them?