Mirco
tanish
How to get the value of drop-down onchange
jr
Yuvi
Model class django.contrib.sessions.models.Session doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
Vishnu
hey guys can anyone help me how to upload csv files in django
OnlyGod
Vishnu
i'm able to upload bro but not able to validate it
Vishnu
like when given given a text file it gives an error message
Vishnu
MultiValueDictKeyError at /first_app/upload/8
'file'
Vishnu
Vishnu
IndexError at /first_app/upload/8
list index out of range
Vishnu
i'm able to upload and process the csv file but i'm not able to validate it
Vishnu
like when any other file or when there is no file i'm not able to validate it report back an error message
Vishnu
@login_required
def Upload(request,pk):
entitys = get_object_or_404(Entity, pk=pk)
template = "first_app/userupload.html"
prompt = {
'order': 'Order of the CSV should be Name, email and password'
}
if request.method == "GET":
return render(request,template,prompt)
csv_file = request.FILES['file']
if not csv_file.name.endswith('.csv'):
messages.error(request, 'Please upload a .csv file.')
data_set = csv_file.read().decode('UTF-8')
io_string = io.StringIO(data_set)
next(io_string)
for column in csv.reader(io_string,delimiter=',',quotechar="|"):
_, created = UserProfileInfo.objects.update_or_create(
entity = entitys,
name = column[0],
email = column[1]
)
context = {}
return redirect('users', pk=entitys.pk)
Vishnu
@login_required
def Upload(request,pk):
entitys = get_object_or_404(Entity, pk=pk)
template = "first_app/userupload.html"
prompt = {
'order': 'Order of the CSV should be Name, email and password'
}
if request.method == "GET":
return render(request,template,prompt)
csv_file = request.FILES['file']
if not csv_file.name.endswith('.csv'):
messages.error(request, 'Please upload a .csv file.')
data_set = csv_file.read().decode('UTF-8')
io_string = io.StringIO(data_set)
next(io_string)
for column in csv.reader(io_string,delimiter=',',quotechar="|"):
_, created = UserProfileInfo.objects.update_or_create(
entity = entitys,
name = column[0],
email = column[1]
)
context = {}
return redirect('users', pk=entitys.pk)
this is the views for upload
Vishnu
{% extends 'first_app/base.html' %}
{% block body_block %}
{% if user.is_authenticated %}
<div class="container"><br><br>
<div class="jumbotron">
<h1>Upload Users {{entity}} </h2>
{% if messages %}
{% for messages in messages %}
<div>
<strong>{{ message|safe }}</strong>
</div>
{% endfor %}
{% else %}
{{order}}
<form method="POST" enctype="multipart/form-data" >
{% csrf_token %}
<label>
Upload a file
</label>
<input type="file" name="file">
<p>Only accepts CSV files</p>
<button class="btn btn-success"> Upload</button>
</form>
{% endif %}
{% else %}
<h1>Please login</h1>
{% endif %}
{% endblock %}
Vishnu
this is the template for upload
Vishnu
can anyone help me out with this
Anonymous
Hi everyone
Anonymous
Can I paste here stack overflow link?
Anonymous
Can't find tab with rules here
Anonymous
Thanks)
Роман
Hello guys! I got "sorry, too many clients already" error in my django web-app. In google I read that the problem is related to the connection-records that are stored in database and the only solution is to increase the maximum number of those records (max_connection parameter). I increased it up to 300 but still getting the same error. If anyone faced the same problem can I ask for some advice?
Anonymous
I want make a field in database that can hold multiple values (etc. Days of week)
User can select days
How I can make it?
Abhishek
Can anyone help me, regarding context_processors use Django
Anonymous
Anonymous
Example : Saturday, Monday
Just in one field
Abhishek
Abhishek
Use input type checkbox, and get all data in your view function by getlist() function you get list , after this you can add in your table
usEr1024
Django Vue
Abhishek
Anyone here , who used custom context_processor in django ?
EscanOr
Abhishek
I want to make global function , for Access data in base.html template,.. because i have multiple user in db and i just want to give permission to few user to access menu on navbar
First name (optional)
Hi
can users see what website cache ?
I mean. with inspect, etc.
Khumoyun
Hello,
Question: How to implement DJango pagination load more button with Ajax? any ideas or examples
Hasan
Anonymous
hello, for clarity i posted this question on stack overflow about django-channels.
my socket disconnects before connection is established
https://stackoverflow.com/questions/64942970/django-channels-works-locally-but-fails-on-server
Anonymous
but it works fine locally
Loki
Anybody know android socket programming? Dm me.. I need some help in my college project
Украинский
Loki
I know but thought someone will help me out with this
Mirco
Doragonsureiyā
Mirco
Move to the @pythonofftopic
singam
Can we django programs in repl.it website
singam
Guys anyone you know answer it
singam
Did you done any program in repl.it website
singam
Ok
singam
Bro Tq for reply
Anonymous
Anonymous
Is there a default username and password for admin panel?
Mirco
Mirco
Otherwise it'd be the first vulnerability someone could try to find into your web app
Yuvraj
Yuvraj
and enter the username and password you want for admin panel
Anonymous
Anonymous
Mirco
Oh Yes
So Django is not fan of admin admin
Or admin root
Anonymous
Mirco
Anonymous
I've seen many videos where people just say admin admin and login
Mirco
Mirco
Anonymous
Mirco
🤞🏻
Another best practice is to move admin panel to another url instead of using admin/
Anonymous
but are there some tools which can help us get subdomains/urls of a website?
Anonymous
😬😬😬
Mirco
Doragonsureiyā
😬😬😬
Read the rules before any activity: @PythonRules
tanish
Guys I have a drop down list in html page how to fetch it's value every time on change of selected valu
D
How to configure media root in settings?
VY.sh
Ghorz
D
M
import os in settings.py