Sumit
This is what i want
Learn django first
Sumit
newuser.name = yourname remove this
Sumit
default user model doesn''t have anyy field like name
Sumit
there is first_name and last_name
Sumit
use that
B120034_Mohammad Asim Khan
Ohhh
B120034_Mohammad Asim Khan
Learn django first
I am learning Django through codewithharry and got this through his video only
B120034_Mohammad Asim Khan
Okay let's not be unprofessional here
John
Heyy guys can anyone help me how to do a dependent drop down in admin panel
𝕯aniel
Category > sub category > sub category
John
Yaaa in my case just category and sub category
John
But I need it in the admin panel
𝕯aniel
Heyy guys can anyone help me how to do a dependent drop down in admin panel
Oh sorry in admin panel. Open the venv lib site package django search the admin app and copy from template admin folder in ur templates folder
𝕯aniel
After in this folder u can see base index and so on html files
Pandit
https://dpaste.org/q9UD in the last section there is all the module for loader
𝕯aniel
https://dpaste.org/q9UD in the last section there is all the module for loader
def index(request): context = { ​ 'item_list': Item.objects.all() } return render(request, 'food/index.html', context) ​
𝕯aniel
Why u use loader? You can render ur html page
𝕯aniel
And via context send data to page
Pandit
Why u use loader? You can render ur html page
im a noob im flwing a tutorial !!
𝕯aniel
urls path('', views.index, name='index')
Pandit
𝕯aniel
𝕯aniel
When you join to 127.0.0.1:8000
Pandit
No this ur routing
any video where it is explained!! i get confused when i see errors
𝕯aniel
And show me ur urls.py
𝕯aniel
Dont forget import a views
𝕯aniel
from . import views
Pandit
Dont forget import a views
from django.urls.conf import path from . import views urlpatterns = [ path('',views.index, name='index' ), path('item/',views.item ,name='item'), path('', views.index, name='index') ]
𝕯aniel
Yes if files in same folder
𝕯aniel
Now check
Pandit
okey
Pandit
Now check
https://dpaste.org/N8Kx
Pandit
Now check
worked sir
Pandit
Change ur views.py to it
thankyou ill search routing on youtube for explanation
Muhammadamin
hello guys i have some problem, can you help me???
Muhammadamin
SMTPServerDisconnected at /contact/ Connection unexpectedly closed: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Muhammadamin
class ContactView(generic.FormView): template_name = 'pages/contact.html' form_class = ContactForm def post(self, request, *args, **kwargs): first_name = request.POST.get('first_name') last_name = request.POST.get('last_name') email = request.POST.get('email') phone = request.POST.get('phone') subject = request.POST.get('subject') message = request.POST.get('message') message = f"From: {first_name} {last_name} email: {email} phone: {phone} \n theme: {subject} message: {message}" email_sent = send_mail('Sarlavha', message, settings.EMAIL_HOST_USER, [settings.DEFAULT_TO_EMAIL], fail_silently=False) if email_sent: messages.success(self.request, "Your feedback is accepted!") else: messages.error(self.request, "At this time we cannot receive your request") return redirect(request.path) this my views
Muhammadamin
settings.py goster
# Django Mptt EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = 587 EMAIL_HOST_USER = 'mirmux5@gmail.com' EMAIL_HOST_PASSWORD = '*******' # DEFAULT_FROM_EMAIL = 'abduraximdeveloper@gmail.com' DEFAULT_TO_EMAIL = 'mirmux5@gmail.com'
Muhammadamin
# del
thank you bro worked
𝕯aniel
thank you bro worked
have a good day
Muhammadamin
have a good day
same to you
Anand
I tried by creating a app password in my google account and it also worked
mukul
https://dpaste.org/qp9b/slim is this is way of doing ??? or their are other ways for this
Muhammadamin
# del
bro again it doesn`t work, why... I don`t know
Tridip
Is it possible to upload a 10GB file using Django??? If not, what should be the approach??
John
How do we store the console values and store them in db
John
I'm using Ajax
John
In Django and I'm confused
Deleted
Hey guys, how could I get CONCAT data of the table in Django? Say I have col A and B in the model, I want to get all the AB value in this table
venkatesh
Can anyone help to CSV data to json with multilevel format
Rudra
Which is best django or flask
Axror
hi guys. Pls explain me django-dajax. And may give me example about it pls
Mirco
Which is best django or flask
the comparison has no sense.
John
Is it possible to override the django default authentication with firebase authentication so it's never give any type of problem in future. Firebase authentication means i planning to build a mobile application so for authentication part I user firebase because It's super easy or free and there give some extra features but the rest of the database I planned for postgres and the backend for django So it's ok if I directly use django and store user information in seperate model ( not in django user model ) or I perform some overriding operation on default django user model and use that.
Shreehari
Hi How can i conditionally use {% include %} in a django html file? {% include "base/notification.html" %} I want to use this tag inside everywhere in my website except on the homepage. Can someone please share the proper tag to use? i tried something like this below, but it did not work {%ifnotequal request.resolver_match.url_name '' %} {% include "base/notification.html" %} {%endifnotequal%} UPDATE: Fixed it
McLean
help , im creating something like a video conferencing site for students so im not able to have a join function
Bhashkar
Hi Guys, Could you please tell me why the bellow code not working properly For mobile when the user submit empty then it save Null on database. mobile = models.CharField(max_length=20, unique=True, null=True, default=None, blank=True) But for email same thing not working, it save empty string in data base but i want to save Null email = models.EmailField(unique=True, null=True, default=None, blank=True)
Bhashkar
Can any one help ?
𝐄𝐫𝐟𝐚𝐧
Which is best django or flask
Each has its own use. I use Flask for smaller projects because it's very simple and I use Django for bigger projects because it's very powerful and clean.
Bhashkar
Hey the EmailField is basically a Charfield that checks for a valid email format. The problem might actually be with another part of your code. Can you share the views or something
View form = UserForm(data=request.POST, instance=user) if form.is_valid(): user = form.save() form class UserForm(forms.ModelForm): class Meta: model = User fields = ('first_name','last_name','username','email','mobile')
Bhashkar
Might also be because of setting unique as true then allowing null values
if not user.email: user.email = None user.save() Currently i am doing this,
Morteza
if not user.email: user.email = None user.save() Currently i am doing this,
you can use clean_email method and check if the email is empty string then return the email as null
Bhashkar
you can use clean_email method and check if the email is empty string then return the email as null
Yes but for mobile CharFiled it save Null if we pass empty string without any using checks. used null=True, default=None, blank=True
Bhashkar
But for email storing empty string rather then Null.
Morteza
But for email storing empty string rather then Null.
so you have to make it as null manually