Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django ImageField Uploaded to Different Path than Reported by url property?
I'd like to allow users to upload profile pictures and then to display them. Here's my model.py: from django.db.models import CharField, ImageField, Model class Eater(Model): name = CharField(max_length = 30) image = ImageField(upload_to = 'images/eaters/') def __str__(self): return str(self.name) Here's my urls.py: from django.conf import settings # settings is an object, not a module, so you can't import from it. :( from django.conf.urls.static import static from django.urls import path from .views import EaterView, IndexView, post, sudo app_name = 'socialfeedia' urlpatterns = [ path('', IndexView.as_view(), name = 'index') ] + static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT) # Static returns a list of path, not a path itself. This is at the end of my settings.py: MEDIA_URL = '/media/' MEDIA_ROOT = BASE_DIR.joinpath('media/') Here's a line out of my index.html: <img class="post-profile-picture" src="{{ post.eater.image.url }}" alt="?"/> I successfully uploaded a file into this field - it got stored at: mysite/media/images/eaters/test_picture_64.jpg The image loads successfully if I visit it here: http://127.0.0.1:8000/socialfeedia/media/images/eaters/test_picture_64.jpg However, the img that shows up in my generated file is this: <img class="post-profile-picture" src="/media/images/eaters/test_picture_64.jpg" alt="?"> This file doesn't resolve - I just see a ? (the alt) instead. Should I be using something else to get the correct path to the file instead? Something … -
mailgun account disabled after deply app on heroku
I use heroku for deploying my django app. I used mailgun for email smtp. before deploying on heroku my mailgun smtp works correctly but after deploying,My accunt became disabled and I got the below message: Your account is temporarily disabled. ( exposed account credentials ) Please contact support to resolve. What shold I do? -
Django with Apache problem with virtual host configuration
I a new to Django. I am trying to deploy Django project on Linux using Apache virtual hosts. My project directory looks like below. Virtual host configuration is as follows: ServerAdmin webmaster@localhost ServerName ........... ServerAlias ........... DocumentRoot /var/www/djangotest1 ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined Alias /static /var/www/djangotest1/static <Directory /var/www/djangotest1/static> Require all granted </Directory> <Directory /var/www/djangotest1/djtest1> <Files wsgi.py> Require all granted </Files> </Directory> WSGIDaemonProcess djangotest1 python-path=/var/www/djangotest1 python-home=/var/www/djangotest1/djenv WSGIProcessGroup djangotest1 WSGIScriptAlias / /var/www/djangotest1/djtest1/wsgi.py When trying to get the page I get following error: Fatal Python error: Py_Initialize: Unable to get the locale encoding Thanks for any help. -
django rest framework serializer doesn't return field when empty
I have a model with JsonField field that represented in a serializer. I want that field to always return all fields in response, even when empty, while listField should return as empty list in that case. In the way I created it, the None fields (allow_null=True) always return, even when empty, but the listField (default=list) doesn't return when it's empty. How can I make it also return in the response as empty list? I have this model (partial)- class MyModel(models.Model): objects_list = JSONField(default=dict) And this view - class MyModelViewSet(mixins.UpdateModelMixin, mixins.RetrieveModelMixin): serializer_class = ObjectsListSerializer This is the serializer - class ObjectsListSerializer(serializers.Serializer): days = serializers.IntegerField(allow_null=True, source='objects_list.days') user_list = serializers.ListField(child=serializers.CharField(), default=list, allow_empty=True, required=False, source='objects_list.user_list') manager = serializers.CharField(allow_null=True, source='objects_list.manager') def update(instance, validated_data): ....... -
NoReverseMatch at / Reverse for
this error is killing me please help I sat on in like for 3 hours and I couldn't even know why is the error happening I will give all the information needed , btw I am new to Django so please explain if you can Thank You, Error: NoReverseMatch at / Reverse for 'change_friends' with keyword arguments '{'operation': 'add', 'pk': 2}' not found. 1 pattern(s) tried: ['connect/(P.+)/(P\d+)/'] Here is my views.py from django.views.generic import TemplateView from django.shortcuts import render, redirect from django.contrib.auth.models import User from home.forms import HomeForm from home.models import Post, Friend class HomeView(TemplateView): template_name = 'home/home.html' def get(self, request): form = HomeForm() posts = Post.objects.all().order_by('-created') users = User.objects.exclude(id=request.user.id) try: friend = Friend.objects.get(current_user=request.user) friends = Friend.users.all() except Friend.DoesNotExist: friends = None args = { 'form': form, 'posts': posts, 'users': users, 'friends': friends } return render(request, self.template_name, args) def post(self, request): form = HomeForm(request.POST) if form.is_valid(): post = form.save(commit=False) post.user = request.user post.save() text = form.cleaned_data['post'] form = HomeForm() return redirect('home:home') args = {'form': form, 'text': text} return render(request, self.template_name, args) def change_friends(request, operation, pk): friend = User.objects.get(pk=pk) if operation == 'add': Friend.make_friend(request.user, friend) elif operation == 'remove': Friend.lose_friend(request.user, friend) return redirect('home:home') Models.py from django.db import models from django.contrib.auth.models import … -
Django creating an instance of a model, negative number turns positive
I'm creating a new instance of a Referral_Commision and it's for a chargeback so I added a - sign in front of the 2 fields to make the variables negative. When it saves it's always positive when I check in the admin panel. I tried replacing the variable with an integer so it said =-20 and that worked fine when I checked in the admin panel. The transaction instance works fine and is negative when I check in the admin panel, so I'm really not sure why this happens. I even added a Decimal() cast to see if that works but it's still positive Models.py class Referral_Commision(models.Model): conversion_amount = models.DecimalField(max_digits=9,decimal_places=2) commision = models.DecimalField(max_digits=9,decimal_places=2) Signals.py Referral_Commision.objects.create(transaction=instance, referral_code=referrer.referral_code, user_referred=instance.user.referral, conversion_amount=-Decimal(instance.payout_coins), commision_percentage=referrer.referral_code.commision_percentage, commision=-Decimal(Decimal(instance.payout_coins)*referrer.referral_code.commision_percentage/100), chargeback=1) -
Accessing fields in a Queryset from a ManytoManyFIeld
Pretty new to Django and models and I am trying to make a wishlist where people can add to the wishlist an then view what is in their wishlist by clicking on the link to wishlist. I created a separate model for the wishlist that has a foreignfield of the user and then a many to many field for the items they want to add to the wish list. For right now i am trying to view the wishlist that i created for the user using the admin view in Django. The problem that i am having is that when I try to print their wishlist to the template the below comes up on the page. <QuerySet [<listings: item: Nimbus, description:this is the nimbus something at a price of 300 and url optional(https://www.google.com/ with a category of )>, <listings: item: broom, description:this is a broom stick at a price of 223 and url optional(www.youtube.com with a category of broom)>, <listings: item: wand, description:this is a wand at a price of 3020 and url optional(www.twitter.com with a category of sales)>]> What i ideally want is the query set to be split such that the two listings and their information would be … -
Dockerizing a Python Django Web Application, Nginx and Gunicorn
I'm trying to connect Gunicorn to my Django application, by Docker, to serve it as an HTTP server. The build was successful, with no errors. My problem starts in the race. That's the kind of message I get: [2020-10-01 12:55:18 +0000] [9] [INFO] Starting gunicorn 20.0.4 [2020-10-01 12:55:18 +0000] [9] [INFO] Listening at: http://0.0.0.0:8010 (9) [2020-10-01 12:55:18 +0000] [9] [INFO] Using worker: sync [2020-10-01 12:55:18 +0000] [13] [INFO] Booting worker with pid: 13 [2020-10-01 12:55:18 +0000] [13] [ERROR] Exception in worker process Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker worker.init_process() File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 119, in init_process self.load_wsgi() File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi self.wsgi = self.app.wsgi() File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi self.callable = self.load() File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load return self.load_wsgiapp() File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp return util.import_app(self.app_uri) File "/usr/local/lib/python3.7/site-packages/gunicorn/util.py", line 358, in import_app mod = importlib.import_module(module) File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked ModuleNotFoundError: No module named 'wsgi' [2020-10-01 12:55:18 +0000] [13] [INFO] Worker exiting (pid: 13) [2020-10-01 12:55:18 +0000] [9] [INFO] Shutting down: Master [2020-10-01 12:55:18 +0000] … -
Unable to parse the date in the url Django
I have a url like this http://localhost:8000/getup/downloadrange/ef46219d-7b33-4bdc-aab1-c3bf073dca0e/datebottom=2019-10-10&datetop=2020-10-01/ My urls.py is like this path( "downloadrange/<uuid:id>/(?P<datebottom>\d{4}-\d{2}-\d{2})&(?P<datetop>\d{4}-\d{2}-\d{2})/$", views.getup, name="getup", ), The url pattern is not found for this. Kindly help me in this regard -
display login form errors with ajax without page refresh in django
i want to use ajax in my django login form that is in a bootstrap modal to display if there are errors such as wrong password or wrong email without the page being refreshed or the modal being closed NB: i'm new to django and especially ajax in my views.py if request.method == "POST": if 'signin_form' in request.POST: signin_form = SigninForm(request.POST) if signin_form.is_valid(): email = request.POST['email'] password = request.POST['password'] user = authenticate(email=email, password=password) if user: login(request, user) elif user is None: messages.error(request, 'ُEmail or password is incorrect') in my forms.py class SigninForm(forms.ModelForm): class Meta: model = User fields = ('email', 'password') widgets = { 'email': forms.EmailInput(attrs={'placeholder': 'Email', 'class': 'form-control','id':'signin_email'}), 'password': forms.PasswordInput(attrs={'placeholder': 'Password', 'class': 'form-control','id':'signin_password'}), } def clean(self): if self.is_valid(): email = self.cleaned_data['email'] password = self.cleaned_data['password'] in the template <form action="" method="POST" id="form_signin"> {% csrf_token %} {{signin_form.email}} {{signin_form.password}} <button type="submit" name="signin_form">Sign in</button> <hr> {% for message in messages %} <div class="alert alert-danger"> {{ message }} </div> {% endfor %} </form> -
How to index formset input fields with list elements
How can I use elements from a list as formset indexes instead of the generic 0,1,2 etc? Right now I have something like: Sizes = ["XS", "S", "M","L", "XL"] SizesFormSet = formset_factory(SizesForm, extra=len(Sizes)) And my formset input fields are indexed as 0,1,2... and I'd like to index them as "XS", "S", "M" etc The django documentation deals with renaming a formset input field prefix, but it doesn't deal with indexing. Thanks in advance for the help! -
Django-allauth creating custom registration form
I want to create a signup form with additional fields. I am using django-allauth. When I try to signup as a normal user I get this errror: [01/Oct/2020 12:28:15] "GET /accounts/signup/ HTTP/1.1" 200 438 Internal Server Error: /accounts/signup/ Traceback (most recent call last): File "/Users/home/Library/Python/3.7/lib/python/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/Users/home/Library/Python/3.7/lib/python/site-packages/django/core/handlers/base.py", line 179, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/Users/home/Library/Python/3.7/lib/python/site-packages/django/views/generic/base.py", line 70, in view return self.dispatch(request, *args, **kwargs) File "/Users/home/Library/Python/3.7/lib/python/site-packages/django/utils/decorators.py", line 43, in _wrapper return bound_method(*args, **kwargs) File "/Users/home/Library/Python/3.7/lib/python/site-packages/django/views/decorators/debug.py", line 89, in sensitive_post_parameters_wrapper return view(request, *args, **kwargs) File "/Users/home/Library/Python/3.7/lib/python/site-packages/allauth/account/views.py", line 215, in dispatch return super(SignupView, self).dispatch(request, *args, **kwargs) File "/Users/home/Library/Python/3.7/lib/python/site-packages/allauth/account/views.py", line 81, in dispatch **kwargs) File "/Users/home/Library/Python/3.7/lib/python/site-packages/allauth/account/views.py", line 193, in dispatch **kwargs) File "/Users/home/Library/Python/3.7/lib/python/site-packages/django/views/generic/base.py", line 98, in dispatch return handler(request, *args, **kwargs) File "/Users/home/Library/Python/3.7/lib/python/site-packages/allauth/account/views.py", line 104, in post response = self.form_valid(form) File "/Users/home/Library/Python/3.7/lib/python/site-packages/allauth/account/views.py", line 231, in form_valid self.user = form.save(self.request) AttributeError: 'CustomSignupForm' object has no attribute 'save' [01/Oct/2020 12:28:24] "POST /accounts/signup/ HTTP/1.1" 500 13665 I can create superuser. When creating superuser, it demands email but when logging in, it demands username. But I can enter email as username and log in successfully. forms.py: class CustomSignupForm(forms.Form): first_name = forms.CharField(max_length=30, label='First name') last_name = forms.CharField(max_length=30, label='Last name') … -
active button click in Django Javascript
This is my html file , i want to active button when click and colorized , i am using Django , but i think Javascript is good idea for this task. can any one help? html file <div class="menu_tabs"> <div class="menu_tabs_title"> </div> <a href="/aries" class="btn-skin ">Daily</a> <a href="/aries/love" class="btn-skin ">Loves</a> <a href="aries/finance" class="btn-skin ">Financial</a> <a href="aries/gambling" class="btn-skin ">Gambling</a> <a href="aries/sex" class="btn-skin ">Sexy</a> <a href="aries/pets" class="btn-skin ">Pets</a> css.file .btn-skin { border-radius: 2px; box-shadow: 1px 2px 5px rgba(0, 0, 0, .15); background: #4CAF50; color: #fff; width: auto; padding: 15px; transition: background-color 300ms linear; font-family: proxima-nova, sans-serif; font-size: 1rem; cursor: pointer; display: inline-block; margin: 8px 5px 5px 0; font-size: 20px; font-family: font2 } .active, .btn-skin:hover { background-color: #666; color: white; } -
i want to set null true when saving image in django rest api with base64
my models is class Profile(models.Model): store_picture1 = models.ImageField(null=True, blank=True) store_picture2 = models.ImageField(null=True, blank=True) store_picture3 = models.ImageField(null=True, blank=True) store_picture4 = models.ImageField(null=True, blank=True) store_picture5 = models.ImageField(null=True, blank=True) store_picture6 = models.ImageField(null=True, blank=True) def save(self,*args, **kwargs): if self.user_picture: im = Image.open(self.user_picture) output = BytesIO() im = im.resize((740, 610)) im.save(output, format='JPEG', quality=120) im.save(output, format='PNG', quality=120) output.seek(0) self.user_picture = InMemoryUploadedFile(output, 'ImageField', "%s.jpg" % self.user_picture.name.split('.')[0], 'image/jpeg',sys.getsizeof(output), None) self.user_picture = InMemoryUploadedFile(output, 'ImageField', "%s.png" % self.user_picture.name.split('.')[0], 'image/png',sys.getsizeof(output), None) self.user_picture = InMemoryUploadedFile(output, 'ImageField', "%s.jpg" % self.user_picture.name.split('.')[0], 'image/jpeg',sys.getsizeof(output), None) self.user_picture = InMemoryUploadedFile(output, 'ImageField', "%s.png" % self.user_picture.name.split('.')[0], 'image/png',sys.getsizeof(output), None) and this is my serializers.py class: class ProfileUpateSerializer(ModelSerializer): user_picture = Base64ImageField( max_length=None, use_url=True, ) store_picture1 = Base64ImageField( max_length=None, use_url=True, ) store_picture2 = Base64ImageField( max_length=None, use_url=True, ) store_picture3 = Base64ImageField( max_length=None, use_url=True, ) store_picture4 = Base64ImageField( max_length=None, use_url=True, ) store_picture5 = Base64ImageField( max_length=None, use_url=True, ) store_picture6 = Base64ImageField( max_length=None, use_url=True, ) class Meta: model = Profile fields ='__all__' i did set null=true and blan=true in my models.py for imageField but when i whant sent with image base64 with api notifies that it needs this field how cat in set null and blank true in my serializer class -
While saving data by overriding django admin's model forms save method, my code runs twice
While saving data by overriding Django admin's model form save method, in few cases my code runs twice causing few dependent actions to create multiple entries in DB and two success messages. I am unable to find why it is happening. This is hampering my usual workflow creating several bugs. Any help would be appreciated. -
Errno - 13 Permission denied: '/media/ - Django
I am using Django 3.1 in ubuntu, I got an error while uploading media files PermissionError at /admin/main/artist/1/change/ [Errno 13] Permission denied: '/media/artists' Exception Type: PermissionError Exception Value: [Errno 13] Permission denied: '/media/artists' Exception Location: /usr/lib/python3.8/os.py, line 223, in makedirs Python Executable: /home/rahul/.local/share/virtualenvs/music-69qL54Ia/bin/python This code works in windows, but not in ubuntu Settings.py STATIC_URL = '/static/' STATICFILES_DIRS = [BASE_DIR / 'static'] MEDIA_URL = '/media/' MEDIA_ROOT = BASE_DIR / '/media/' Models.py class Artist(models.Model): image = models.ImageField(upload_to='artists/%Y/%m/%d/', default='demo-artist.jpg', null=True, blank=True) I tried this but didn't work https://stackoverflow.com/questions/21797372/django-errno-13-permission-denied-var-www-media-animals-user-uploads -
How to Remove single Inverted comma from array in python?
i am new in python.I have array like this a =['1','2'] i want to convert this array into below formet a=[1,2] How to do that? -
Reverse for 'equipment_categories' with arguments '('',)' not found. 1 pattern(s) tried: ['equipments/equipment_categories/$']
I am trying to make a website that sorts equipment based on their category and i am getting the reverse match error when i link the urls on the webpage. Please i need advice on how i can properly pull this off. Thanks in advance. urls.py from django.urls import path from . import views app_name = 'equipments_catalogue' urlpatterns = [ path('equipment_list/', views.EquipmentListView.as_view(), name='equipment_list'), path('equipment_categories/', views.EquipmentCategoryView.as_view(), name='equipment_categories'), path('equipment_by_category/<str:cats>/', views.EquipmentListByCategory, name='equipment_by_category') ] views.py from django.shortcuts import render from django.views.generic import ListView from . import models # Create your views here. class EquipmentCategoryView(ListView): model = models.Category template_name = 'equipment_categories.html' def EquipmentListByCategory(request, cats): equipment_category = models.Equipment.objects.filter(category=cats) return render(request, 'equipment_by_category.html', {'cats': cats , 'equipment_category': equipment_category}) class EquipmentListView(ListView): model = models.Equipment template_name = 'equipment_list.html' template {% extends 'base.html' %} {% load static %} {% block title %}Home{% endblock %} {% block content %} <h1>Welcome to JPI Equipment Categories Page</h1> {% for category in object_list %} <a href="{% url 'equipments_catalogue:equipment_categories' equipment_by_category.category %}">{{ category.name }}</a><br><br> {% endfor %} {% endblock %} -
What is the equivalent of the Django {% block %} and {% extends %} tags in Next.js?
I am modernizing the code of my Django web application by re-creating its frontend in a separate Next.js application. I am having problems finding the equivalent of the Django {% block %} tag in Next.js. Concretely, all pages across my app share the following HTML skeleton: a navbar at the top, and a mainbar and a sidebar below it. In Django, I achieved this using a base.html file containing the navbar, a {% block mainbar %} tag, and {% block sidebar %} tag and then extended this template from other child templates using {% extends "base.html %}. Here is my Django base.html: <body> <!-- Navbar --> <header id="navbar"> ... </header> <!-- Body --> <div id="body"> <!-- Mainbar --> <main id="mainbar"> {% block mainbar %} {% endblock %} </main> <!-- Sidebar --> <aside id="sidebar"> {% block sidebar %} {% endblock %} </aside> </div> </body> How can I recreate the concept of a {% block %} and {% extends %} tags in Next.js? Or, how can I recreate a template inheritance structure similar to the one above? -
Django forms serialize to JSON for angular API
I need to serialize Django form to json to use API for front on Angular. Dont know how to properly make this. My form: class BSForm(forms.ModelForm): class Meta: model = BS fields =[ 'c','b_input', ] widgets = { 'c': forms.TextInput( attrs={ 'class': 'form-control' } ), 'benchmark_input': forms.Textarea( attrs={ 'class': 'form-control' } ), } labels = { "c": "C Name", "b_input" : "Provide Input to add", } My view: class BSView_API(APIView): def get(self, request, *args, **kwargs): my_form = BSForm() return JsonResponse({"form": my_form}) def post(self, request, *args, **kwargs): if request.method == "POST": my_form = BSForm(request.POST) context = { "form": my_form } if my_form.is_valid(): my_form.save() my_form = BSForm() messages.success(request, 'success!') else: print("An error occurred") print(my_form.errors) messages.error(request, 'Something went wrong: %s ' % my_form.errors.as_data()) return JsonResponse({'nbar': 'benchmark', 'bbar': 'home'}) What's the proper way to serialize such froms for API? I've tried to use list(my_form.__dict__) but the I'm loosing form data. -
Django REST Framework: Posting to URL with ID in URL
Given the following contrived example, how can I POST to a URL with an ID in path and have it resolve the model instance instead of including the model instance in the POST body itself? urls.py path("api/schools/<int:pk>/student/", views.CreateStudentView.as_view(), name="createStudent") models.py class School(models.Model): name = models.CharField(default="", max_length=128) address = models.CharField(default="", max_length=128) mascot = models.CharField(default="", max_length=128) class StudentModel(models.Model): first_name = models.CharField(default="", max_length=128) last_name = models.CharField(default="", max_length=128) notes = models.CharField(default="", max_length=512) school = models.ForeignKey(School, on_delete=models.CASCADE) serializers.py class CreateStudentSerializer(serializers.ModelSerializer): class Meta: model = Student fields = ("first_name", "last_name") views.py class CreateStudentView(generics.CreateAPIView): serializer_class = CreateStudentSerializer queryset = Student.objects.all() I want to be able to POST just the new student's first name and last name to the URL to create a new student in my database. However, because I don't provide a School object in the body of my POST I get an error. I was hoping it would be possible for my code to resolve which school I want to add the student to because the URL contains the ID. I get an error when I POST the following body to /api/schools/1/student/. The school with an ID of 1 does exist in the database. { "first_name": "John", "last_name": "Smith" } IntegrityError at /api/schools/1/student/ NOT NULL … -
Django reverse lookup on multilevel models
I am trying to query for storetypes at a location without success. I can however query for locations in a city using the models shown.I want to use the querysets in a menu with a submenu with another submenu at the root url of the project. Please help. #models class Supplier(): shopping_center = models.ForeignKey('Shopping_center') storetype = models.ForeignKey('Storetype') class City(models.Model): name = models.CharField() class Location(models.Model): city = models.ForeignKey('City') class Shopping_Center(models.Model): location = models.ForeignKey('Location') class Storetype(models.Model): title = models.CharField() -
How do I structure a project which uses django and ebay python sdk?
I am completely new to django and making non-static websites, so I'm sorry if this is a stupid question, but I couldn't find info anywhere on how to actually structure files for a django project. I built a program that scrapes data from one online store, formats the data, and then adds the item to eBay via ebay python sdk. For this, I wrote three .py files - one that uses the requests library to get product data, one that formats the data into the correct structure to feed into the api, and finally the file that makes the api call. The way I understand eBay SDK, these files all have to be in the ebaysdk directory in order to work (at least, the one that makes the api call has to be in there). My problem is that I now want to make a simple django website, which takes a product url from the user from that store, and then automatically uploads the product. I am confused about how to make my three .py files work with a django website? Do I have to restructure the whole thing and put them into my views.py file as functions? But then, … -
Django allauth signup view not working coorecly
I have a problem signup allauth. I am tryin add new account but when try it i get this error. Other functions(login, logout and other password works) are working. Other view is working but singup not working, when i want to add new user, i got this problem. Internal Server Error: /accounts/signup/ Traceback (most recent call last): File "/root/PycharmProjects/essahmi/venv/lib/python3.8/site- packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/root/PycharmProjects/essahmi/venv/lib/python3.8/site- packages/django/core/handlers/base.py", line 179, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/root/PycharmProjects/essahmi/venv/lib/python3.8/site- packages/django/views/generic/base.py", line 70, in view . . . return super(CloseableSignupMixin, self).dispatch(request, File "/root/PycharmProjects/essahmi/venv/lib/python3.8/site- packages/django/views/generic/base.py", line 98, in dispatch return handler(request, *args, **kwargs) File "/root/PycharmProjects/essahmi/venv/lib/python3.8/site-packport_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked ModuleNotFoundError: No module named 'some' I have not written any code yet baceuse i … -
cannot parse {{post.content}} inside if condition
I made a blog website and I am trying to render all my posts. I have truncated my posts whose content was greater than 500 alphabets and I added a read more anchor tag. I want that read more anchor tag to come only if my content is greater than 500 works I wrote this line but it didn't work: {% if len({{post.content}}) >500 %} can someone help me with what I should use in place of this code?