Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django database data not showing in Templete
I have a class HardBook that inherits from Book: class Book(models.Model): title = models.CharField('Book Title', max_length=200) image = models.ImageField('Book Cover', upload_to='covers') description = models.CharField('Description', max_length= 350) class HardBook(Book): quantity = models.IntegerField('Quantity') I want to display the field data in a table, I want to show title, image and quantity. Everthing is displayed except quantity. {% for hardbook in hardbooks %} <tr> <td> <div class="cover-image" style="background-image:url({{hardbook.image.url}});"></div> </td> <td>{{hardbook.title}}</td> <td>{{hardbook.quantity}}</td> </tr> {% endfor %} -
dynamic form fields repeate the value of index[0]
'i have two table on different servers, both the table has same fields, i need to to compare the table in order to ensure that the data is synced and both the server has same data. in case of, mismatch will prepare a new table where i will endorsed the missing data. to clarify it further table1: emp_name , roll_no, (table on main server) table2: emp_name , roll_no. (table on standby server) i need output of the rcords that are in table1 but not in table2. and i will store the missing records in table3 like. missing_record_list: emp_name , roll_no. i will have almost 2 lakh records. i am writing this program in django. please reply with suitable solution. thanks -
Reverse for 'decrease-product-in-cart' with arguments '('',)' not found. 1 pattern(s) tried: ['cart\\/decrease\\/(?P<product_id>[^/]+)\\/$']
please help i am geting this error when i added quantity it is really frustrating because it has been 2 days and i am trying to solve it here is my html: {% extends "base.html" %} {% load static %} {% block content %} <div class="container my-4"> <h2 class="text-center my-4">Your Cart</h2> <table class="table"> {% if cart.products.exists %} <thead> <tr> <th scope="col">Product</th> <th scope="col">Quantity</th> <th scope="col">Price</th> <th scope="col" class="text-center">Amount</th> <th scope="col"></th> </tr> </thead> {% endif %} <tbody> {% for product in carts %} <tr> <td>{{ product.products.title }}</td> <td> <a href="{% url 'cart:decrease-product-in-cart' item.item.id %}"><span class="badge badge-dark mr-2"><i class="fas fa-minus"></i></span></a> <span>{{ product.items.quantity }}</span> <a href="{% url 'cart:increase-product-in-cart' item.item.id %}"><span class="badge badge-dark ml-2"><i class="fas fa-plus"></i></span></a> </td> <td>{{ item.item.price|floatformat:2 }} $</td> <td class="text-center">{{ item.get_total|floatformat:2 }} $</td> <td class="text-right"> <a class="btn btn-danger" href=""><i class="far fa-trash-alt"></i></a> </td> </tr> {% empty %} <div class="alert alert-info" role="alert"> The cart is empty </div> {% endfor %} {% if order.promo_code_applied %} <tr> <td colspan="3"></td> <td class="text-center text-success"> Discount: <span class="font-weight-bold">-{{ order.promo_code_discount|floatformat:2 }} $</span> </td> </tr> {% endif %} <tr> <td colspan="3"> <a class="btn btn-warning" href="{% url 'products:list' %}">Back to Home Page</a> </td> {% if order.items.all %} <td class="text-center"> Total: <span class="font-weight-bold ml-1">{{ order.get_total_amount|floatformat:2 }} $</span> </td> <td> <a class="btn btn-info … -
Cannot fetch API data after deploying application to Heroku (works perfectly locally)
I cannot fetch the data from my Django Rest API publicly after deploying to Heroku. It works perfectly locally. When I click on the heroku webpage -> Inspect -> Console, says "Failed to load resource: net::ERR_CONNECTION_REFUSED" & "Uncaught (in promise) TypeError: Failed to fetch". The API is located publicly on heroku and it CORRECTLY has all my data (https://xxxxxxxxxx.herokuapp.com/api). I'm using Django backend and ReactJS frontend. Settings.py import os from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False ALLOWED_HOSTS = ['xxxxxxxxxxxxx.herokuapp.com', '127.0.0.1'] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'backend', 'corsheaders', ] REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': [ 'rest_framework.permissions.AllowAny', ] } MIDDLEWARE = [ 'corsheaders.middleware.CorsMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', ] ROOT_URLCONF = 'xxxxxxxxxxxxx.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ os.path.join(BASE_DIR, 'reactapp/build'), ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'xxxxxxxxxxxxx.wsgi.application' # Database … -
Select a valid choice. That choice is not one of the available choices - Django
When i want to add new Question and Choices to this question i have this: Select a valid choice. That choice is not one of the available choices. Thats my models: class Question(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') def __str__(self): return self.question class Choice(models.Model): question = models.ForeignKey(Question, on_delete=models.CASCADE) choice = models.CharField(max_length=200) votes = models.IntegerField(default=0) def __str__(self): return self.choice Thats my Forms class ChoiceForm(ModelForm): class Meta: model = Choice fields = ('question',) widgets = {'question': forms.TextInput} Thats my views: def addPolling(request): ChoiceFormSet = inlineformset_factory(Question, Choice, fields=('choice',), extra=3, can_delete = False) formset = ChoiceFormSet() form = ChoiceForm() if request.method == 'POST': question = request.POST.get('question') form.fields['question'].choices = [(question, question)] form = ChoiceForm(request.POST) formset = ChoiceFormSet(request.POST) print(request.POST) if form.is_valid() and formset.is_valid(): print(request.POST) -
Unable to import model form model of another app
This is code of transactions.model here i am trying to import WalletUser model form WalletUser.models import uuid as uuid from django.db import models from walletApp.WalletUser.models import WalletUser class Transaction(models.Model): STATUS_TYPES = ( ('C', 'Compleat'), ('S', 'Success'), ('I', 'Incompleat'), ('A', 'aborted'), ) uuid = models.UUIDField(unique=True, default=uuid.uuid4, editable=False, db_index=True) status = models.CharField(choices=STATUS_TYPES, default='N', max_length=3) created_on = models.DateTimeField(auto_now_add=True, null=False) user = models.ForeignKey(WalletUser) amount = models.FloatField() def __str__(self): return self.uuid I am getting this error /Users/shoaib/Documents/walletTransactionSystem/walletApp/walletApp/settings.py changed, reloading. Watching for file changes with StatReloader Exception in thread django-main-thread: Traceback (most recent call last): File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 926, in _bootstrap_inner self.run() File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "/Users/shoaib/Documents/walletTransactionSystem/venv/lib/python3.7/site-packages/django/utils/autoreload.py", line 53, in wrapper fn(*args, **kwargs) File "/Users/shoaib/Documents/walletTransactionSystem/venv/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 110, in inner_run autoreload.raise_last_exception() File "/Users/shoaib/Documents/walletTransactionSystem/venv/lib/python3.7/site-packages/django/utils/autoreload.py", line 76, in raise_last_exception raise _exception[1] File "/Users/shoaib/Documents/walletTransactionSystem/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 357, in execute autoreload.check_errors(django.setup)() File "/Users/shoaib/Documents/walletTransactionSystem/venv/lib/python3.7/site-packages/django/utils/autoreload.py", line 53, in wrapper fn(*args, **kwargs) File "/Users/shoaib/Documents/walletTransactionSystem/venv/lib/python3.7/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/Users/shoaib/Documents/walletTransactionSystem/venv/lib/python3.7/site-packages/django/apps/registry.py", line 114, in populate app_config.import_models() File "/Users/shoaib/Documents/walletTransactionSystem/venv/lib/python3.7/site-packages/django/apps/config.py", line 211, in import_models self.models_module = import_module(models_module_name) File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/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 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line … -
HTML Script Function not returning List of Checked Items
I am using Django to receive Checked Items from HTML. Then, Django will run loop on array to delete all checked items from the list. Here is my code from HTML. It seems like HTML is not returning all checked ITEMS. SCRIPT <script> function MakeCheckList(){ checkedList = $('input:checkbox:checked[name="checkedbox"]').map(function() { return $(this).val(); }).get(); $('input#checklist').val(checkedList); } </script> HTML <div class="row"> <button class="taskDelete" name="taskDelete" formnovalidate="" type="submit" onclick=MakeCheckList();"><i class="fa fa-trash-o icon"></i>Delete</button> </div> <ul class="taskList"> {% for todo in todos %} <!-- django template lang - for loop --> <li class="taskItem"> <input type="checkbox" class="taskCheckbox" name="checkedbox" id="{{ todo.id }}" value="{{ todo.id }}"> </li> -
How to cache videos in Django?
How to cache videos in django? Like in youtube, preloading video while user watches it. I've searched on about this, google showed something about Redis, Memcached and etc. Can you provide some examples on how to do such thing? -
Django: form with fields for creating related objects
I have several models similar to these (example from Django docs): from django.db import models class Person(models.Model): name = models.CharField(max_length=128) def __str__(self): return self.name class Group(models.Model): name = models.CharField(max_length=128) members = models.ManyToManyField(Person, through='Membership') def __str__(self): return self.name class Membership(models.Model): person = models.ForeignKey(Person, on_delete=models.CASCADE) group = models.ForeignKey(Group, on_delete=models.CASCADE) date_joined = models.DateField() invite_reason = models.CharField(max_length=64) And there is a HTML form in which (if we continue the analogy with the example from the docs) there are three separate input fields: for entering the name of the Person; specifying the date_joined; specifying the invite_reason button to add a musician. When the user clicks the button, js-code is launched that adds hidden input fields to the page (so that all entered data will be included in the POST-request data) and a span element to render the entered data for the user. Now I see two ways to handle this situation on the Django side: put all the logic for working with memberships in the form: class MembershipForm(forms.ModelForm): class Meta: model = Membership fields = ('person', 'date_joined', 'invite_reason') class GroupForm(forms.ModelForm): class Meta: model = Recipe fields = ('name',) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.memberships = self.instance.membership_set.all() def clean(self): super().clean() self.memberships = [] memberships_data = … -
Unable to receive form data in AJAX POST Request
In my project i have a requirement to display data asynchronously using ajax, we have a backend django server running, from front end i am passing the AJAX post request to django route, that route process the request and give response, but while making a ajax request the form data i am unable to access in django views below is my code The form has one text area where user provide inputs i will take those one by one and send to django view which has one argument <script> document.getElementById("searchForm").onsubmit=(e)=>{ e.preventDefault(); var a=document.getElementById('a').value var b=document.getElementById('b').value var c=document.getElementById('c').value var d=document.getElementById('d').value var e=document.getElementById('e').value var arrayOfLines = $('#textarea').val().split('\n'); var csrf=document.getElementsByName('csrfmiddlewaretoken') console.log(csrf[0].value) var fd=new FormData() fd['csrfmiddlewaretoken']=csrf[0].value fd['a']=a fd['b']=b fd['c']=c fd['d']=d fd['e']=e let items=arrayOfLines for (var i = 0; i < items.length; i++){ $.ajax({ headers: { "X-CSRFToken": csrf[0].value }, type:'POST', url:'/django_view/'+items[i], async: true, data:fd, enctype:'multipart/form-data', success: function(response){ console.log(response) }, error:function(error){ console.log(error) }, cache:false, processData: false, contentType: false }) } } </script> in view def django_view(request,id): if request.method=='POST': data=request.POST.get('a') ...... in view i am not getting data, giving Internal Server Error 500 and i have checked in Network console Form data is showing 0 -
Argon2 in DJANGO and passwords in session variables
So far I used SHA256 to hash passwords (I know, terrible) and now I would like to switch to Argon2. My problem is that if I understand it correctly I am going to have to store the plain text password in a session variable now. Now I am storing the SHA256 hash in session variables, and I have a check_user function that check if the user is still logged in for most of my functions. def check_user(request): if 'email' not in request.session or not request.session['email']: return False if 'pw_hash' not in request.session or not request.session['pw_hash']: return False try: Clients.objects.get(pk=request.session['email']) except Clients.DoesNotExist: return False if request.session['pw_hash'] != Clients.objects.get(pk=request.session['email']).password: return False return True If I switch to Argon2, as far as I understand I ll have to store the plain password in the session variable to be able to use PasswordHasher().verify, which is IMO a bad practice. What is the recommended way for this problem? -
having problem with django static file set up
I can only and only set the static files in Django with this code In Installed Apps in settings.py '....', 'staticfiles', '.... In end of settings.py STATIC_URL = '/staic/' STATICFILE_DIRS = [ os.path.join(BASE_DIR, '/static') ] And It worked. At My First Time, I also tried this In urls.py #this way urlpatterns = [ ..., ..., ....., ] + static(STATIC_URL, document_root=STATIC_ROOT) #or urlpatterns += static(STATIC_URL, document_root=STATIC_ROOT) At the first time it worked but after that project this way didn't work I viewed thousands of websites. I did all the thing in the code like the youtube tutorial But the second code didn't work anymore. But I cannot use the development server in production. But the first code (which works for me) requires a development server. If Anyone knows please (if possible) give me the example code to try it, the possible answer, and all the websites where I can know more. It would be helpful. Thanks Very Much -
How to add dropzonejs drag and drop only on one field with django?
I am working on a project in django. In my template, I added the dropzonjs's css and js links. Then in my form I am having different fields. So when I added the class dropzone to the form tag, the drag and drop field is surrounding the entire form. I want it only as of the last field. This is my template 👇 {% extends 'supervisor_template/base_template.html' %} {% block page_title %} Raise Requisition {% endblock page_title %} {% block main_content %} <!-- Main content --> <section class="content"> <div class="container-fluid"> <div class="row"> <div class="col-md-12"> <!-- general form elements --> <div class="card card-primary"> <div class="card-header"> <h3 class="card-title">Raise Requisition</h3> </div> <!-- /.card-header --> <div class="card-body"> <div class="form-group"> {% if messages %} {% for message in messages %} {% if message.tags == 'error' %} <div class="alert alert-danger" style="margin-top:10px">{{ message }}</div> {% endif %} {% if message.tags == 'success' %} <div class="alert alert-success" style="margin-top:10px">{{ message }}</div> {% endif %} {% endfor %} {% endif %} </div> <!-- form start --> <form class="dropzone" action="{% url 'raise_requisition_save' %}" method="post"> {% csrf_token %} <div class="form-group"> <label>Position Required</label> <input class="form-control" type="text" name="position_required" required> </div> <div class="form-group"> <label>Requirement</label> <select name="requirement" class="form-control" aria-label="Requirement" required> <option value="new">New</option> <option value="backfill">Backfill</option> </select> </div> <div … -
Django media files not loading when debug is False on Cpanel
I am trying to show my media files for over a week and tried all stackoverflow solutions yet nothing. My project is hosted on Cpanel, i tried giving the media the absolute path, tried to put them on the public_html folder, nothing. Plus my static files are served without issue, but the media files doesn't even show in the source in developer tools (in normal case there should be one there), when debug is true it works perfectly fine but when debug is false it does not. Any ideas please? part of my settings.py import os from django.contrib.messages import constants as messages from decouple import config # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = config('SECRET_KEY') # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False CSRF_COOKIE_SECURE = config('CSRF_COOKIE_SECURE') SESSION_COOKIE_SECURE = config('SESSION_COOKIE_SECURE') MIDDLEWARE = [ 'debug_toolbar.middleware.DebugToolbarMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware' ] STATIC_URL = '/static/' STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage' STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static") ] STATIC_ROOT = os.path.join(BASE_DIR, 'assets') CKEDITOR_UPLOAD_PATH = 'uploads/' MEDIA_URL ='/media/' MEDIA_ROOT = … -
Python-Home not recognized by mod-wsgi using pyenv virtual env
Getting the below error when trying to configure mod-wsgi with Apache2 on a server. I've installed and setup mod-wsgi as per the docs in my virtual env, and then setup the apache2 site.conf, but am not able to get the server to respond. Checking the apache2/error.log I have a long list of the error shown below. not sure where to go or what to do as the configurations all look like they're supposed to according to what I've found to read. Current thread 0x00007f1b39a8cbc0 (most recent call first): <no Python frame> Python path configuration: PYTHONHOME = (not set) PYTHONPATH = (not set) program name = '/var/www/virtualenvs/something-serv-SrXEIUxH-py3.8/bin/python' isolated = 0 environment = 1 user site = 1 import site = 1 sys._base_executable = '/var/www/virtualenvs/something-serv-SrXEIUxH-py3.8/bin/python' sys.base_prefix = '/root/.pyenv/versions/3.8.8' sys.base_exec_prefix = '/root/.pyenv/versions/3.8.8' sys.executable = '/var/www/virtualenvs/something-serv-SrXEIUxH-py3.8/bin/python' sys.prefix = '/root/.pyenv/versions/3.8.8' sys.exec_prefix = '/root/.pyenv/versions/3.8.8' sys.path = [ '/root/.pyenv/versions/3.8.8/lib/python38.zip', '/root/.pyenv/versions/3.8.8/lib/python3.8', '/root/.pyenv/versions/3.8.8/lib/lib-dynload', ] Could not find platform independent libraries <prefix> Could not find platform dependent libraries <exec_prefix> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding Python runtime state: core initialized ModuleNotFoundError: No module named 'encodings' my site config is: <VirtualHost *:80> ServerAdmin webmaster@something.com ServerName something.com ServerAlias www.something.com … -
Django UUIDField vs Timeflake as primary key
I have an API written using Django Rest Framework and I'm using Postgres as my DB. I'm looking to convert my primary key to a more obscured format as I do expose them in external URLs. In my research, I came across this package called Timeflake and I couldn't find much out there on people's experiences with it and Django and how it compares to using a UUIDField with uuid4. In Timeflakes README, it says that uuid4 isn't suitable for clustered indexes and can cause performance degradation. As I understand it, Postgres indexes are heap-based and therefore wouldn't suffer from fragmentation like a clustered index if one used a uuid4 primary key. Aside from that are there any other reasons that someone might choose to use Timeflake primary keys over a uuid4 if they are using Postgres and their primary goal is it keep performance high and also have obscured ids in their URLs? Also, I did want to mention that I'm aware of the pattern of adding an external_id to your models and using that for external communication and the auto-incrementing pk for internal use. I certainly see the merits of this approach but my app is already pretty … -
Dependencybot or similar free tool on bitbucket
Anyone, who knows any online free tool like dependabot of Github for bibucket, whereby a bot can raise a Pull Request on bitbucket just incase if the dependency has an update? I want to use it on the Django project -
convert queryset(django _filters query result) to pdf Django xhtml2pdf
I know this is very silly question but I am new to django so I don't know how to do it. I want to crete a pdf of filtered result. I am working on a project and I have used django_filters to do queries on my data. I am getting the result in my html but the html is my dashboard . Now i want to provide a option to user that when he clicks on button export_pdf he will get the filtered output in pdf. views.py def index(request): order_list = Order.objects.all().order_by('-order_id') order_filter = OrderFilter(request.GET, queryset=order_list) # here in order_list I am getting the filtered data. order_list = order_filter.qs context = { 'order_filter': order_filter, 'order_list': order_list, } dashboard.html {% extends 'admin1/layout/master.html' %} {% block title %}Dashboard{% endblock %} {% block main %} <div> <div class="row d-flex justify-content-sm-center my-sm-3"> {% if request.user.role == 'Admin' %} <h1> Admin Dashboard </h1> {% endif %} {% if request.user.role == 'Designer' %} <h1> Designer Dashboard </h1> {% endif %} </div> <div class="container"> <div class="row"> <div class="col-lg-2"></div> <div class="col-lg-10"> <div class="row"> <form method="get"> <div class="card"> <div class="card-header"> <h4 class="card-title mt-sm-0">Filter Order</h4> </div> <div class="card-body"> <table class="table table-bordered border-secondary"> <tr> <th class="mx-sm-auto">{{order_filter.form.q_less_than.label }}</th> <td class="mx-sm-auto">{{order_filter.form.q_less_than }}</td> <th … -
I get this error and don't know what to do with it
This is a small one page site and it worked great before I decided to put it on a heroku. During the deployment process, there were problems and solving them I came to this error. I do not know what this error is connected with, but I have already spent a lot of time solving it. error: Traceback (most recent call last): File "E:\Programming\python\lib\threading.py", line 954, in _bootstrap_inner self.run() File "E:\Programming\python\lib\threading.py", line 892, in run self._target(*self._args, **self._kwargs) File "E:\Programming\python\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper fn(*args, **kwargs) File "E:\Programming\python\lib\site-packages\django\core\management\commands\runserver.py", line 138, in inner_run handler = self.get_handler(*args, **options) File "E:\Programming\python\lib\site-packages\django\contrib\staticfiles\management\commands\runserver.py", line 27, in get_handler handler = super().get_handler(*args, **options) File "E:\Programming\python\lib\site-packages\django\core\management\commands\runserver.py", line 65, in get_handler return get_internal_wsgi_application() File "E:\Programming\python\lib\site-packages\django\core\servers\basehttp.py", line 45, in get_internal_wsgi_application return import_string(app_path) File "E:\Programming\python\lib\site-packages\django\utils\module_loading.py", line 17, in import_string module = import_module(module_path) File "E:\Programming\python\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1030, in _gcd_import File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 790, in exec_module File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed File "E:\Programming\Projects\chuchman\chuchman\wsgi.py", line 16, in <module> application = get_wsgi_application() File "E:\Programming\python\lib\site-packages\django\core\wsgi.py", line 8, in get_wsgi_application return WSGIHandler() File … -
Can I specify HTTP method in Django generic ListCreateAPIView?
ListCreateAPIView in Django includes HEAD and OPTIONS methods. How can I get rid of them? -
The current path, accounts/signUp/signUp, didn't match any of these
hello im facing an issue when trying to make a sign up page in django when i submit in the html form a user should be created in the database but its not happening and it shows this message "The current path, accounts/signUp/signUp, didn't match any of these" and this in the terminal "Not Found: /accounts/signUp/signUp" views.py: from django.shortcuts import render,redirect from django.contrib.auth.models import User,auth # Create your views here. def signUp(request): if request.method=='post': first_name=request.POST['first_name'] last_name=request.POST['last_name'] username=request.POST['username'] password1=request.POST['password1'] rePassword=request.POST['repassword'] email=request.POST['email'] user = User.objects.create_user(username=username,password=password1,email=email,first_name=first_name,last_name=last_name) user.save(); else: return render(request,'signUp.html') signUp.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Sign Up</title> </head> <body> <form action="signUp" method="post"> {% csrf_token%} <input type="text" name="first_name" placeholder="First Name"><br> <input type="text" name="last_name" placeholder="Last Name"><br> <input type="text" name="username" placeholder="Username"><br> <input type="email" name="email" placeholder="email"><br> <input type="password" name="password" placeholder="Password"><br> <input type="password" name="rePassword" placeholder="Confirm Password"><br> <input type="submit"> </form> </body> </html> -
CKeditor 4.0.0 - Unable to scroll on mobile when editor is present
I am developing a form on Django that uses djangocms-text-ckeditor 4.0.0. The page has a few fields, and then a CKEditor textarea field. When the page loads, I am able to scroll with a mouse wheel just fine. However when using a Mobile device to scroll using a touch screen, it won't scroll unless you touch the text box for CKEditor and swipe up and down. Touching anywhere outside that box does not allow you to scroll at all. I searched online, but didn't find anything that seemed to work to resolve this issue. -
how to add login with phone number wihile using django allauth package
I am using Django all auth package (google) how can I set up login with phone number feature to it? can someone please guide me -
Saving ModelForm progress values to session in Django
I have flow where users can create (model) forms. If form is valid, object gets saved and flow continues, but selection is in multiple pages. I need to keep current state of created object, which cannot be saved before it's completely valid. One thing I can do is to always pass things around those views in the ModelForm to make sure, that user never loses data, but I also wanna make sure, that if he leaves the flow and comes back, he doesn't lose data, that he already entered previously. That's why I decided I wanna save all the fields to session. Is this correct approach? How would you do this? Where would you put this session logic? What's best way of getting the fields from incomplete form to be saved? -
Django : on_delete=models.SET.NULL gives error
Why attribute in my model class where class Tour_Cart: tours=models.ForeignKey(Tours,on_delete=models.SET.NULL,blank=True,null=True) Throws error: AttributeError: 'function' object has no attribute 'NULL' Why so? Any help will be appreciated?