Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Web Scraping in Django: running scraper every day to update database or running a specific scraper for every user?
I have a project idea: a website where a user could enter search details (city, keywords, etc.) and then receive periodical job offer emails. I would like to hear your opinion on how the scraper part should work: Should I run a scraper every day? It would go through the pages of the website, building a database. Then filter the database specifically for the user and send an email with the result. Or should I build a specific scraper for every user? Every scraper would only take the information that is needed for a particular user from the website. As far as I understand django-dynamic-scraper package would fit, but it does not support the newest django version. What are your thoughts on this? Maybe there are simpler ways to implement this project? -
Unable to content Django form with extended user model
Trying to connect Django form and extended user model, but struggling to get the form to save. Basically, I'm able to authenticate user, but not save information to the CustomUser model or "profile" model for the user. I feel like I fundamentally don't understand how to extend the user model, so if you have some advice to that affect that would be very helpful. #views.py def registration(request): if request.method == "POST": form = CustomUserCreationForm(request.POST) if form.is_valid(): custom = form.save(commit=False) user = request.user custom = user.profile() custom.key = "".join(random.choice(string.digits) for i in range(20)) custom.save() username = form.cleaned_data['username'] password = form.cleaned_data['password2'] user = authenticate(request, username=username, password=password) messages.success(request, f'Your account has been created! Please proceed to agreements and payment.') return redirect('other_page') else: form = CustomUserCreationForm(request.POST) return render(request, 'registration.html', {'form': form}) Here is my models.py class CustomUser(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) key = models.CharField(max_length=25, null=True, blank=True) first_name = models.CharField(max_length=25) last_name = models.CharField(max_length=25) username = models.CharField(max_length=25) password1 = models.CharField(max_length=25) password2 = models.CharField(max_length=25) @receiver(post_save, sender=User) def create_custom_user(sender, omstamce, created, **kwargs): if created: CustomUser.objects.create(user=instance) @receiver(post_save, sender=User) def save_user_profile(sender, instance, **kwargs): if instance.CustomUser.save() def __str__(self): return f'{self.first_name} ({self.last_name})' In settings.py I added "AUTH_PROFILE_MODULE = 'app.CustomUser'". However, I'm getting this error: AttributeError: 'User' object has no attribute 'profile' -
Django datatable error - DataTables warning: table id=datatable - Ajax error
I am using datatables in Django. But when i include related data in my datatable, search function display a pop error "DataTables warning: table id=datatable - Ajax error." At the same time i also receive this error in terminal "File "C:\Dev\virenvmt\lib\site-packages\django\db\models\sql\query.py", line 1107, in build_lookup raise FieldError('Related Field got invalid lookup: {}'.format(lookup_name)) " My model is class Location(models.Model): name = models.CharField (max_length=50, null=False, blank=False, unique= True) status = models.IntegerField(blank=False, default='1') created_date = models.DateTimeField(default=datetime.now, blank=False) created_by = models.IntegerField(blank=False) updated_date = models.DateTimeField(blank=True) update_by = models.IntegerField(blank=True) def __str__(self): return self.name class Devices(models.Model): name = models.CharField (max_length=50, null=False, blank=False, unique= True) phone_number = models.CharField (max_length=20, blank=True, unique=True) location = models.ForeignKey(Location, on_delete=models.DO_NOTHING, null=False, blank=False) status = models.IntegerField(blank=False, default='1') ip_address = models.CharField(max_length=15, null=False, blank=False, unique=True) power_status = models.IntegerField(blank=True, default='0') created_date = models.DateTimeField(default=datetime.now, blank=False) created_by = models.IntegerField(blank=False) updated_date = models.DateTimeField(blank=True) update_by = models.IntegerField(blank=True) My Javascript file is $(document).ready(function() { var dt_table = $('#datatable').dataTable({ columns: [ {"dt_table": "name"}, {"dt_table": "location"}, {"dt_table": "phone_number"}, {"dt_table": "ip_address"}, {"dt_table": "power_status", "render": function (data, type, row) { return (data === '1') ? '<span class= "badge badge-success icon-flash_on r-20">&nbsp;On</span>' : '<span class="badge badge-danger icon-flash_off blink r-20">&nbsp;Off</span>';} }, { "dt_table": "id", "orderable": false, // "defaultContent": "<a class=\"btn-fab btn-fab-sm btn-primary shadow text-white\"><i class=\"icon-pencil\"></i></a>", "targets": -1, 'render': … -
DJANGO - Static files are being collected, but they don't want to work on local server
as a newbie in Django I'm struggling with the staticfiles within my project. Whenever I take some prepared bootstrap template something is not working, same when I try to add some javascript - and have no idea why. I tried to find the answer before, but in theory, everything should work - would be awesome if someone could guide me, cuz I feel completely lost now. Everything works fine until I want to use some advanced js/css animations. It looks like in the image - the main background doesn't load, the navibar is shattered as well... My settings I think look fine - Django collect all the static files, but they don't want to work on the local server. Everything is rooted in views.py/urls.py (settings.py) STATIC_URL = '/static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static") ] STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') `<!DOCTYPE html> {% load static %} <html lang="en"> <head> <meta charset="utf-8"> <title>BizPage Bootstrap Template</title> <meta content="width=device-width, initial-scale=1.0" name="viewport"> <meta content="" name="keywords"> <meta content="" name="description"> <!-- Bootstrap CSS File --> <link href="{% static 'lib/bootstrap/css/bootstrap.min.css' %}" rel="stylesheet"> <!-- Libraries CSS Files --> <link href="{% static 'lib/font-awesome/css/font-awesome.min.css' %}" rel="stylesheet"> <link href="{% static 'lib/animate/animate.min.css' %}" rel="stylesheet"> <link href="{% static 'lib/ionicons/css/ionicons.min.css' %}" rel="stylesheet"> <link href="{% static 'lib/owlcarousel/assets/owl.carousel.min.css' … -
How to show assigned members its balance in html page?
I have assigned some random numbers as a balance to every user who sign up but I am not able to show them in html page. How to do it? Maybe I have made some mistakes in python files also. I have added those numbers(balance) in my database. So please let me know and correct my mistake. models.py class Payment(models.Model): payment_numbers = models.CharField(max_length=100) owner = models.ForeignKey(User, on_delete=models.CASCADE) views.py def payment(request): receiving1 = Payment.objects.filter(owner=request.user) for field in receiving1: field.payment_numbers context = { 'receiving1': receiving1 } return render(request, 'index.html', context) HTML page {% for numbers1 in receiving1 %} {% if numbers1 %} <li style="float: right;">Your Balance: Rs. {{numbers1.payment_numbers}}</li> {% endif %} {% endfor %} -
ImportError: Couldnt import Django ... Did you forget to activate a virtual environment?
I know there are several questions/answers about this but I cant figure out what I should do. So I wanted to get started with Django and installed it with pip install and added Python37 and Python37-32 to my enviromental variables and it I guess it worked because I can run several python commands in my shell. But everytime I try to python manage.py runserver it gives me an Error. I also set up my virtual environment and activated it but I think theres a problem with Django. But because I installed it with pip install django I know its there and I can use commands like django-admin startapp ... So I guess Django is working. I dont rlly know what PYTHONPATH means and where to find it. Would be pretty nice if anybody could take a look at my error. Here you can see that Django is installed : # **C:\Users\Kampet\Desktop\Python-Django\mysite>pip install django Requirement already satisfied: django in c:\users\kampet\appdata\local\programs\ python\python37-32\lib\site-packages (2.2.4) Requirement already satisfied: pytz in c:\users\kampet\appdata\local\programs\py thon\python37-32\lib\site-packages (from django) (2019.2) Requirement already satisfied: sqlparse in c:\users\kampet\appdata\local\program s\python\python37-32\lib\site-packages (from django) (0.3.0)** # And thats my error **C:\Users\Kampet\Desktop\Python-Django\mysite>python manage.py runserver Traceback (most recent call last): File "manage.py", line 10, in main … -
Why does my django pagination keeps returning the same items infinitely?
I am using django and ajax to create a infinite scroll on my website. I would like it to load more items from the database (that are in the next page) when the user scrolls to the bottom of the page. Everything is working perfectly except that it keeps returning the first page's items infinitely. For example if a user scrolls down to the end of a page instead of adding page 2's elements it just add the same elements from the first page to the bottom again. I am very sure this issue is from my views.py. I can't seem to figure out what's wrong. def feed(request): queryset2 = Store_detail.objects.filter(store_lat__gte=lat1, store_lat__lte=lat2)\ .filter(store_lng__gte=lng1, store_lng__lte=lng2) queryset3 = Paginator(queryset2, 4) page = request.GET.get('page',1) try: queryset = queryset3.page(1) except PageNotAnInteger: queryset = queryset3.page(page) except EmptyPage: queryset = "" context = { "location":location, "queryset":queryset, } # return HttpResponse(template.render(context,request)) return render(request, 'main/feed.html', {'queryset': queryset, 'location':location,}) So basically I would like to load the next page when a user scrolls to the end of the screen and if there are no more items in the next page or the next page does not exist then stop adding items. -
Converting to and from CamelCase within DRF
I am making a SOAP post request which returns data in CamelCase. I need to refactor the response back from SOAP request into snake_case. Then again I receive a request from a Restful API in snake case which I need to convert into CamelCase and then send a SOAP request. I have a mini serializer which I wrote to convert between the two, i.e. extended the to_representation method and then returned the respective CamelCase or snake_case, however I'm not sure if this mini serializer is a good way of doing it, should maybe be a helper function than serializer? Here is the serializer converting a list of objects containing name and attribute_given keys into CamelCase. class ToCamelCase(serializers.Serializer): name = serializers.CharField() attribute_given = serializers.CharField() def to_representation(self, value): data = [] for x in range(len(value)): data.append({ 'Name': value['name'], 'AttributeGiven': value['attribute_given'], }) return data I'm just looking for the best approaching solving this. Is solving this by extending the to_representation and returning custom key name at serializer level a good way or shall I write a helper function for it? -
Unable to create the django_migrations table with DateTime Field
I was migrating my Django app from local system to production server. Configurations on local server are as below: Django2.2 MySQL 5.7.27-0ubuntu0.16.04.1 mysqlclient-1.4.2.post1 sqlparse-0.3.0 On production server, configurations are as below: Django2.2 MySQL 5.5.53 mysqlclient-1.4.2.post1 sqlparse-0.3.0 Only difference between local and production configurations is of MySQL server version. There is a model with below code: class Tracking404Model(models.Model): url = models.CharField(max_length=512, null=False, blank=False) timestamp = models.DateTimeField(null=False, blank=False) After running migration, I ran the commnd python manage.py sqlmigrate app-name migration-file-number to check MySQL syntax generated, which is as below: CREATE TABLE `404_tracking` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `url` varchar(512) NOT NULL, `timestamp` datetime(6) NOT NULL); Show create table statement output on Local: mysql> show create table 404_tracking\G *************************** 1. row *************************** Table: 404_tracking Create Table: CREATE TABLE `404_tracking` ( `id` int(11) NOT NULL AUTO_INCREMENT, `url` varchar(512) NOT NULL, `timestamp` datetime(6) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 1 row in set (0.00 sec) Migrations ran just fine on local, tables were created and I was able to perform all mysql operations. Basically everything was just fine. When running migrations on production, I am getting below error: raise MigrationSchemaMissing("Unable to create the django_migrations table (%s)" % exc) django.db.migrations.exceptions.MigrationSchemaMissing: Unable … -
How to send signal from django to java script trigger
I want create a signal in my django and javascript can find out this signal and do specific action. -
html data is not rendering property in html using python django
i could not display the html data sent from python in the html page. when i open the html in view source mode, it thing data is rendered as messed html code <table border="1"> <tr> <th>servername</th> <th>cpu</th> <th>memory</th> <th>cdrivespace</th> <th>ddrivespace</th> <th>fdrivespace</th> <th>gdrivespace</th> <th>pdrivespace</th> <th>kdrivespace</th> {{ data }} </table> python view data = callFileReaderMain( form.cleaned_data['session_key'] ) return render(request,'marketplace_output.html',{'data' : data }) view source code <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title>marketplace output server details</title> </head> <body> <table border="1"> <tr> <th>servername</th> <th>cpu</th> <th>memory</th> <th>cdrivespace</th> <th>ddrivespace</th> <th>fdrivespace</th> <th>gdrivespace</th> <th>pdrivespace</th> <th>kdrivespace</th> &lt;tr&gt;&lt;td&gt;W01GCTIAPP01A&lt;/td&gt;&lt;td&gt;3.0&lt;/td&gt;&lt;td&gt;93.0&lt;/td&gt;&lt;td&gt;42.0&lt;/td&gt;&lt;td&gt;40.0&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;/tr&gt; </table> </body> </html> -
import django.http from HttpResponse ^ SyntaxError: invalid syntax
I am trying to run this but getting syntax error import django.http from HttpResponse ^ SyntaxError: invalid syntax import django.http from HttpResponse def index(request): return HttpResponse("Hello") -
Efficient replacement of source urls with django static urls
In django when we load image we use tag something like this: <img alt="background" src="{% static "img/inner-6.jpg" %}" /> and I use templates and build backend to those templates to learn django (for now) so when I start project all the images source urls and css file urls and javascript urls are given like : <img alt="background" src="img/inner-6.jpg" /> so I have to replace all of them with the above one which is time consuming and non-productive. Can someone please tell me the efficient way to do this (like notepad text replacement system or something like that). How do experience django developers deal with this kind of problems? Thanks in advance. (I have searched a lot about it before asking on stackoverflow but couldn't find anything) -
Django is complex select query possible for this?
I have the following model used to store a bidirectional relationship between two users. The records are always inserted where the smaller user id is user_a while the larger user id is user_b. Is there a way to retrieve all records belonging to a reference user and the correct value of the status based on whether the reference user id is larger or smaller than the other user id? Perhaps two separate queries, one where reference user = user_a and another where reference user = user_b, followed by a join? class Relationship(models.Model): RELATIONSHIP_CHOICES = ( (0, 'Blocked'), (1, 'Allowed'), (-2, 'Pending_A'), (2, 'Pending_B'), (-3, 'Blocked_A'), (3, 'Blocked_B'), ) user_a = models.ForeignKey(CustomUser, on_delete=models.SET_NULL, related_name='user_a',null=True) user_b = models.ForeignKey(CustomUser, on_delete=models.SET_NULL, related_name='user_b',null=True) relationship_type = models.SmallIntegerField(choices=RELATIONSHIP_CHOICES, default=0) -
How to fetch the selected dropdown values in the editable form in the dropdown using django
Dropdown value is stored in separate table,how to retrieve the dropdown value in the editable form views.py def edit(request, id): form = DeptForm(request.POST) form1 = DesigForm(request.POST) dt = Department.objects.all() dg = Designation.objects.all() dept = request.POST.get("depart") Department.id = dt desig = request.POST.get("design") Designation.id = dg print(Designation) edit_record = Emp_Profile.objects.get(pk=id) print(edit_record) context = { 'edit_record': edit_record } print(context) print(edit_record.department) return render(request, 'registration/register_edit.html', context,{'form' : form, 'form1' : form1}) def update(request, id): form = DeptForm(request.POST) form1 = DesigForm(request.POST) dt = Department.objects.all() dg = Designation.objects.all() if request.method == "POST": First_name = request.POST['First_name'] lname = request.POST['lname'] depart = request.POST.get("depart") Department.id = dt print(depart) uname = request.POST['uname'] design = request.POST.get("design") Designation.id = dg print("design") print(design) mnumber = request.POST['mnumber'] Emp_Profile.objects.filter(pk=id).update( first_name=First_name, last_name=lname, Mobile_Number=mnumber, username=uname, ) return redirect('/accounts/profile/') return render(request,'register_edit.html',{'form':form, 'form1':form1}) In this department and designation is two separate table,while storing it is stored in another table called "Emp_Profile".while editing,the selected value of department and designation should come with dropdown. -
How to retrieve the save checkbox value in the editable form in django
Data is save to DB, Retrieve the data in enabled checkbox. How can I write code for edit the form in views.py file In models username field is the foreign key of Emp_Profile model and Process is the foreign key of Client_Process table Models.py class Emp_Process(models.Model): username = models.ForeignKey(Emp_Profile, on_delete=models.CASCADE) process = models.ForeignKey(Client_Process, on_delete=models.CASCADE) class Meta: db_table : 'emp_process' html file {% extends 'client_pannel.html' %} {% block content %} <br><br> <br><br> <div class="data-table-area mg-b-15"> <div class="container-fluid"> <div class="row"> <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"> <div class="sparkline13-list"> <div class="sparkline13-hd"> <div class="main-sparkline13-hd"> <label>{{ emp.first_name }} {{ emp.last_name }} - {{ emp.designation }}</label> </div> </div> <div class="sparkline13-graph"> <div class="datatable-dashv1-list custom-datatable-overright"> <table id="table" data-toggle="table" data-pagination="true" data-search="true" data-show-columns="true" data-show-pagination-switch="true" data-show-refresh="true" data-key-events="true" data-show-toggle="true" data-resizable="true" data-cookie="true" data-cookie-id-table="saveId" data-show-export="true" data-click-to-select="true" data-toolbar="#toolbar"> <thead> <tr> <th >Client</th> <th>Process</th> </tr> </thead> <tbody> {% for client in form %} <tr> <td> <input type="checkbox" name="cname[]" value="{{ client.id }}"> {{ client.Name }} </td> <td> {% for process in client.clients %} <input type="checkbox" name="process[]" value="{{ process.id }}"> {{ process.process }}<br /> {% endfor %} </td> </tr> {% endfor %} </tbody> </table> </div> </div> </div> </div> </div> </div> </div> {% endblock %} -
How to solve the datetime.datetime issue after running migrate in django?
Whenever I run python manage.py migrate, I get following error. How to resolve this issue? I am not understanding. Error value = self.get_prep_value(value) File "C:\Users\Bilal\Envs\trial\lib\site-packages\django\db\models\fields\__init__.py", line 966, in get_prep_value return int(value) TypeError: int() argument must be a string, a bytes-like object or a number, not 'datetime.datetime' __init__.py def get_prep_value(self, value): from django.db.models.expressions import OuterRef value = super().get_prep_value(value) if value is None or isinstance(value, OuterRef): return value return int(value) -
unable to install Django 2.2.4 for python3.7.4 on Linux mint 19.1
I want to install Django web framework version 2.2.4 on the Linux.I'm using Linux mint 19.1 with python2(default), python3.6.8(default) and python3.7.4(sudo installed from source). I am using command 'pipenv --python3.7 install django==2.2' to install but it's not working. I tried this tutorial to install Django- link to the youtube tutorial $ python3.7 -V Python 3.7.4 $ pip3 -V pip 19.2.1 from /usr/local/lib/python3.7/site-packages/pip (python 3.7) ~ dev/try_django$ pipenv --python3.7 install django==2.2.4 Usage: pipenv [OPTIONS] COMMAND [ARGS]... Try "pipenv -h" for help. Error: no such option: --python3.7 -
Django taking image from Python program
I have previously written some python code which takes some information, and presents it into a chart. An example is in the link below. The python program creates the chart, then places the numbers in the chart in the relevent location. There is some randomness as to where they are placed in the smaller squares. My question is I would like to implement this in Django. Being new to Django, my thought process is I should be calling the Python code, which would create the image from the Django database, and then displaying it. I have worked out how to call the code, however there is little information about how to do so on the click of a button. This has made me question if calling the Python code is the correct way to do this? -
How to fetch id from bottom-up approach in django ORM
How to fetch id of Process and Client model in Emp_Process using Client_Process Models.py class Process(models.Model): Name = models.CharField(max_length=50) def __str__(self): return self.Name class Meta: db_table : 'process' class Client(models.Model): Name = models.CharField(max_length=50, unique=True) def __str__(self): return self.Name class Meta: db_table : 'client' class Client_Process(models.Model): process = models.ForeignKey(Process, on_delete=models.CASCADE) client = models.ForeignKey(Client, on_delete=models.CASCADE) class Meta: db_table : 'client_process' class Emp_Process(models.Model): username = models.ForeignKey(Emp_Profile, on_delete=models.CASCADE) process = models.ForeignKey(Client_Process, on_delete=models.CASCADE) class Meta: db_table : 'emp_process' -
How to avoid path django.urls.path() funtion interpreting ? in url?
I want to set an optional request parameter in my view. But ? interprets to %3F. I have tried the following code: app_name = "account" urlpatterns = [ ... path('profile/<int:user_id>/', UserProfileManager.as_view(), name='user_profile'), path('profile/<int:user_id>/?edit=<str:edit>', UserProfileManager.as_view(), name='user_profile'), ... ] <a href="{% url 'account:user_profile' member.id 'true' %}"> Edit your profile </a> -
How to upload audio recorded by recorder.js to django backend for some analysis
This is the javascript file of the recorder.js to record and upload the audio to server how to extract that audio in django backend i want that audio file to be used in librosa library to extract some features function createDownloadLink(blob) { var url = URL.createObjectURL(blob); var au = document.createElement('audio'); var li = document.createElement('li'); var link = document.createElement('a'); //name of .wav file to use during upload and download (without extendion) var filename = new Date().toISOString(); //add controls to the <audio> element au.controls = true; au.src = url; //save to disk link link.href = url; link.download = filename+".wav"; //download forces the browser to donwload the file using the filename link.innerHTML = "Save to disk"; //add the new audio element to li li.appendChild(au); //add the filename to the li li.appendChild(document.createTextNode(filename+".wav ")) //add the save to disk link to li li.appendChild(link); //upload link var upload = document.createElement('a'); upload.href="/show/"; upload.innerHTML = "Upload"; upload.addEventListener("click", function(event){ var xhr=new XMLHttpRequest(); xhr.onload=function(e) { if(this.readyState === 4) { console.log("Server returned: ",e.target.responseText); } }; var fd=new FormData(); fd.append("audio_data",blob, filename); xhr.open("POST","show/",true); xhr.send(fd); }) li.appendChild(document.createTextNode (" "))//add a space in between li.appendChild(upload)//add the upload link to li //add the li element to the ol recordingsList.appendChild(li); } -
Create a function that identifiies object type and passes form depending on what type the object is
I have a model named product, and depending on the type of product I would like to pass a form. So, for example, if the product type is "Clothing", then render a form to select a size (S, M, L, etc...) I've tried creating a view that passes the product to a template, and then made a function within the view called is_clothing that says product type is clothing. # models.py PRODUCT_TYPE = [ ('C', 'Clothing'), ('A', 'Accessory'), ('F', 'Furniture'), ] class Product(models.Model): ... type = models.Charfield(blank=True, choices=PRODUCT_TYPE) # views.py def product_view(request, slug): productvariant = get_object_or_404(ProductVariants, slug=slug) form = ProductSizeForm # Function that defines whether product type is clothing def is_clothing(): product.type == "Clothing" context = { 'product' : productvariant, 'form' : form } return render(request, "products/product-page.html", context) <!--TEMPLATE--> {% if product.is_clothing %} {{ form }} {% endif %} As I said I was hoping to render the sizes form if the product type is clothing, but I'm not getting any results. Any ideas? -
Facing trouble in running python manage.py runserver
I am trying to run python manage.py runserver and till today I never faced any issues. Whenever I run python manage.py runserver I get this- $ python manage.py runserver Performing system checks... System check identified no issues (0 silenced). August 11, 2019 - 05:34:42 Django version 2.1.5, using settings 'try_django.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C. Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f0b20e6d6a8> Traceback (most recent call last): File "/home/user/anaconda3/lib/python3.7/site-packages/django/utils/module_loading.py", line 13, in import_string module_path, class_name = dotted_path.rsplit('.', 1) ValueError: not enough values to unpack (expected 2, got 1) The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/user/anaconda3/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 45, in get_internal_wsgi_application return import_string(app_path) File "/home/user/anaconda3/lib/python3.7/site-packages/django/utils/module_loading.py", line 17, in import_string module = import_module(module_path) File "/home/user/anaconda3/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 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/home/user/Dev/try_django_new/src/try_django/wsgi.py", line 16, in <module> application = get_wsgi_application() File "/home/user/anaconda3/lib/python3.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application return WSGIHandler() File "/home/user/anaconda3/lib/python3.7/site-packages/django/core/handlers/wsgi.py", … -
Add range and ><= operators to django form
I am building enterprise software which someone can use to input order data from a customer. Sometimes customers order something with length 1000+ or will order something within a range of 400-600 for example. How can I display these options in a dynamic form which inputs an integer into a model? Will my model have to have max_length min_length, max_width, min_width etc or is there a better way? I've considered creating non-required fields and dynamically displaying the form depending on a dropdown menu choice near every dimension with (greater than, equal to, less than). This will make me create around 6 new fields for a basic l/w/h input. For example: If someone wants a range they can click on the side dropdown near the dimension and select range, which will then show a new input box which submits data to max_DIMENSION. Or when a user chooses > then the database saves that field as greater than. I expect to be input a range with 2 values, or a >/=/< with a single value.