Re: Credentials fail from custom Auth backend

2021-07-04 Thread David Crandell
There is no error. It just says invalid login. I get the login template and
it rejects my credentials.

David L. Crandell
469-585-5009
g uitard...@outlook.com
guitardave8...@gmail.com
da...@onholdwizard.com



On Sun, Jul 4, 2021 at 9:15 PM ANi  wrote:

> What does the error message say?
> guitard...@gmail.com 在 2021年7月4日 星期日下午1:48:58 [UTC+8] 的信中寫道:
>
>> Hello, I am using a custom auth backend and everything displays properly,
>> except I cannot login with the credentials in my model. I have spent 5
>> hours on this and cannot figure it out. Please help.
>>
>> views.py
>>
>> class MyLogin(LoginView):
>> template_name = 'employees/login.html'
>> form_class = LoginForm
>>
>>
>> def form_valid(self, form):
>> user = form.get_user()
>> employee = Emp.objects.get(email=user)
>> if employee.is_active:
>> EmpBackend.authenticate(self.request, username=user,
>> password=form.password)
>>
>> return HttpResponseRedirect(self.get_success_url())
>>
>> backends.py
>>
>> from django.contrib.auth.backends import ModelBackend
>> from .models import Emp
>>
>>
>> class EmpBackend(ModelBackend):
>> def authenticate(self, request, username=None, password=None, **kwargs):
>> try:
>> user = Emp.objects.get(email=username)
>> if user.check_password(password):
>> return user
>> except Emp.DoesNotExist:
>> return None
>>
>> return None
>>
>> def get_user(self, user_id):
>> try:
>> return Emp.objects.get(pk=user_id)
>> except Emp.DoesNotExist:
>> return None
>>
>> models.py
>>
>> class Emp(AbstractBaseUser):
>> first_name = models.CharField(max_length=100, default=None)
>> last_name = models.CharField(max_length=100, default=None)
>> email = models.EmailField(max_length=255, default=None, unique=True)
>> username = models.CharField(max_length=100, default=None, null=True)
>> phone = models.CharField(max_length=20, default=None, null=True,
>> blank=True)
>> password = models.CharField(max_length=100)
>> address1 = models.CharField(max_length=100, default=None, null=True,
>> blank=True)
>> address2 = models.CharField(max_length=100, default=None, null=True,
>> blank=True)
>> city = models.CharField(max_length=100, default=None, null=True,
>> blank=True)
>> state = models.CharField(max_length=100, default=None, null=True,
>> blank=True)
>> zip = models.CharField(max_length=10, default=None, null=True, blank=True)
>> position = models.CharField(max_length=50, default=None)
>> date_hired = models.DateTimeField(auto_now_add=True)
>> date_updated = models.DateTimeField(auto_now_add=True)
>> date_terminated = models.DateTimeField(default=None, null=True,
>> blank=True)
>> is_active = models.BooleanField(default=True)
>> status = models.SmallIntegerField(default=0)
>> emp_is_salary = models.BooleanField(default=False)
>> emp_pto_rate = models.DecimalField(max_digits=8, decimal_places=4,
>> default=0.0)
>> emp_user_level = models.SmallIntegerField(default=1)
>> emerg_contact1 = models.CharField(max_length=100, default=None,
>> null=True, blank=True)
>> emerg_contact1_phone = models.CharField(max_length=20, default=None,
>> null=True, blank=True)
>> emerg_contact1_address = models.CharField(max_length=200, default=None,
>> null=True, blank=True)
>> emerg_contact1_city_st = models.CharField(max_length=200, default=None,
>> null=True, blank=True)
>> emerg_contact2 = models.CharField(max_length=100, default=None,
>> null=True, blank=True)
>> emerg_contact2_phone = models.CharField(max_length=20, default=None,
>> null=True, blank=True)
>> emerg_contact2_address = models.CharField(max_length=200, default=None,
>> null=True, blank=True)
>> emerg_contact2_city_st = models.CharField(max_length=200, default=None,
>> null=True, blank=True)
>> emp_note = models.TextField(default=None, null=True, blank=True)
>> emp_hourly_rate = models.DecimalField(max_digits=8, decimal_places=4,
>> default=0.0)
>> emp_net_pto = models.DecimalField(max_digits=8, decimal_places=4,
>> default=0.0)
>> emp_pto_prev = models.DecimalField(max_digits=8, decimal_places=4,
>> default=0.0)
>> emp_image = models.ImageField(upload_to='profile-pics/',
>> default='profile-pics/default.png', null=True, blank=True)
>> last_login = models.DateTimeField(default=None, null=True)
>> is_staff = models.BooleanField(default=True, blank=True)
>> date_joined = models.DateTimeField(auto_now_add=True, blank=True)
>> is_superuser = models.BooleanField(default=False, blank=True)
>>
>> USERNAME_FIELD = 'email'
>> REQUIRED_FIELDS = []
>>
>> def get_full_name(self):
>> return f'{self.first_name} {self.last_name}'
>>
>> def get_email(self):
>> return self.email
>>
>> def __str__(self):
>> return self.email
>>
>> def has_perm(self, perm, obj=None):
>> return True
>>
>> def has_module_perms(self, app_label):
>> return True
>>
>> @property
>> def is_staff(self):
>> return self.staff
>>
>> @property
>> def is_admin(self):
>> return self.admin
>>
>> def save(self, *args, **kwargs):
>> super(Emp, self).save(*args, **kwargs)
>>
>> img = Image.open(self.emp_image.path)
>>
>> if img.height > 300 or img.width > 3

Re: Credentials fail from custom Auth backend

2021-07-04 Thread ANi
What does the error message say? 
guitard...@gmail.com 在 2021年7月4日 星期日下午1:48:58 [UTC+8] 的信中寫道:

> Hello, I am using a custom auth backend and everything displays properly, 
> except I cannot login with the credentials in my model. I have spent 5 
> hours on this and cannot figure it out. Please help.
>
> views.py
>
> class MyLogin(LoginView):
> template_name = 'employees/login.html'
> form_class = LoginForm
>
>
> def form_valid(self, form):
> user = form.get_user()
> employee = Emp.objects.get(email=user)
> if employee.is_active:
> EmpBackend.authenticate(self.request, username=user, 
> password=form.password)
>
> return HttpResponseRedirect(self.get_success_url())
>
> backends.py
>
> from django.contrib.auth.backends import ModelBackend
> from .models import Emp
>
>
> class EmpBackend(ModelBackend):
> def authenticate(self, request, username=None, password=None, **kwargs):
> try:
> user = Emp.objects.get(email=username)
> if user.check_password(password):
> return user
> except Emp.DoesNotExist:
> return None
>
> return None
>
> def get_user(self, user_id):
> try:
> return Emp.objects.get(pk=user_id)
> except Emp.DoesNotExist:
> return None
>
> models.py
>
> class Emp(AbstractBaseUser):
> first_name = models.CharField(max_length=100, default=None)
> last_name = models.CharField(max_length=100, default=None)
> email = models.EmailField(max_length=255, default=None, unique=True)
> username = models.CharField(max_length=100, default=None, null=True)
> phone = models.CharField(max_length=20, default=None, null=True, 
> blank=True)
> password = models.CharField(max_length=100)
> address1 = models.CharField(max_length=100, default=None, null=True, 
> blank=True)
> address2 = models.CharField(max_length=100, default=None, null=True, 
> blank=True)
> city = models.CharField(max_length=100, default=None, null=True, 
> blank=True)
> state = models.CharField(max_length=100, default=None, null=True, 
> blank=True)
> zip = models.CharField(max_length=10, default=None, null=True, blank=True)
> position = models.CharField(max_length=50, default=None)
> date_hired = models.DateTimeField(auto_now_add=True)
> date_updated = models.DateTimeField(auto_now_add=True)
> date_terminated = models.DateTimeField(default=None, null=True, blank=True)
> is_active = models.BooleanField(default=True)
> status = models.SmallIntegerField(default=0)
> emp_is_salary = models.BooleanField(default=False)
> emp_pto_rate = models.DecimalField(max_digits=8, decimal_places=4, 
> default=0.0)
> emp_user_level = models.SmallIntegerField(default=1)
> emerg_contact1 = models.CharField(max_length=100, default=None, null=True, 
> blank=True)
> emerg_contact1_phone = models.CharField(max_length=20, default=None, 
> null=True, blank=True)
> emerg_contact1_address = models.CharField(max_length=200, default=None, 
> null=True, blank=True)
> emerg_contact1_city_st = models.CharField(max_length=200, default=None, 
> null=True, blank=True)
> emerg_contact2 = models.CharField(max_length=100, default=None, null=True, 
> blank=True)
> emerg_contact2_phone = models.CharField(max_length=20, default=None, 
> null=True, blank=True)
> emerg_contact2_address = models.CharField(max_length=200, default=None, 
> null=True, blank=True)
> emerg_contact2_city_st = models.CharField(max_length=200, default=None, 
> null=True, blank=True)
> emp_note = models.TextField(default=None, null=True, blank=True)
> emp_hourly_rate = models.DecimalField(max_digits=8, decimal_places=4, 
> default=0.0)
> emp_net_pto = models.DecimalField(max_digits=8, decimal_places=4, 
> default=0.0)
> emp_pto_prev = models.DecimalField(max_digits=8, decimal_places=4, 
> default=0.0)
> emp_image = models.ImageField(upload_to='profile-pics/', 
> default='profile-pics/default.png', null=True, blank=True)
> last_login = models.DateTimeField(default=None, null=True)
> is_staff = models.BooleanField(default=True, blank=True)
> date_joined = models.DateTimeField(auto_now_add=True, blank=True)
> is_superuser = models.BooleanField(default=False, blank=True)
>
> USERNAME_FIELD = 'email'
> REQUIRED_FIELDS = []
>
> def get_full_name(self):
> return f'{self.first_name} {self.last_name}'
>
> def get_email(self):
> return self.email
>
> def __str__(self):
> return self.email
>
> def has_perm(self, perm, obj=None):
> return True
>
> def has_module_perms(self, app_label):
> return True
>
> @property
> def is_staff(self):
> return self.staff
>
> @property
> def is_admin(self):
> return self.admin
>
> def save(self, *args, **kwargs):
> super(Emp, self).save(*args, **kwargs)
>
> img = Image.open(self.emp_image.path)
>
> if img.height > 300 or img.width > 300:
> output_size = (300, 300)
> img.thumbnail(output_size)
> img.save(self.emp_image.image)
>
> self.last_login = timezone.utc
>
> def get_absolute_url(self):
> return reverse('employees:emp-detail', args=[self.id])
>
> objects = UserManager()
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this 

Re: Email Form with attachments

2021-07-04 Thread David Crandell
Attachments need to be written to mail headers using MIME.

This article gives a good 
breakdown 
https://stackoverflow.com/questions/1633109/creating-a-mime-email-template-with-images-to-send-with-python-django

On Sunday, July 4, 2021 at 10:30:10 AM UTC-5 sebasti...@gmail.com wrote:

> Hello,
>
> i need a form where i have normal email fields like:
>
> to_address, from_address, subject, message and also i drag and drop zone 
> where i can drop attachments. I have allready implement a normal drag and 
> drop zone in another form where i can drag and drop files and it is upload 
> und stored.
>
> But when i create a new email email is not stored so i can't linked new 
> files with this new email. 
>
> How does it work? That i store attachments and when user then click submit 
> from email form then all attachments are linked with new email?
>
> Regards
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/463e828d-8642-485e-9583-a7c788feb072n%40googlegroups.com.


looking for mobile developers

2021-07-04 Thread Theresa Taye
Hello guys,

I need flutter users for a project urgently if you are interested, please
contact me.

Best regards

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAENBRfMdOTe4NTJNONwZaD-U78wsQ%2BG4wU9W_gKFwRab1PuPVw%40mail.gmail.com.


Re: Django beginner

2021-07-04 Thread Kuassi Israel
HELLO. I THINK THAT THE BEST WAY IT IS THE OFFICIAL DOCUMENTATION. YOU
HAVE ANYTHING YOU WANT INSIDE THE DOCUMENTATION.

On Sun, Jul 4, 2021 at 5:25 PM Samin Serge  wrote:

> Hello everyone,
>
> Please i'm a Django beginner and would to know the best way to commence
> and access quickly with Django.
>
> thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e7df62d9-ef45-40df-a065-32e5ac850980n%40googlegroups.com
> 
> .
>


-- 
Israël KUASSI

Web Software developer

Technique | PayDunya
+221338659045 | +221771022089
kuassi.isr...@paydunya.com
www.paydunya.com
Immeuble Forum Center-VDN, Ouest Foire en face CICES, DAKAR
[image: facebook] 
[image: twitter] 
[image: linkedin] 
Create Your Own Free Signature

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGMKQD6TS7uvLSZpgb5obSroHLsc7By7E1Qo-YaNGOnkM5O_Ag%40mail.gmail.com.


Need an Advice about large database I/O

2021-07-04 Thread Mottaz Hegaze
Hello Friends,

Hope all is well,

I have a project that involves reading large data files ( csv, excel sheets
) and writing them to a database.

I am thinking of using the django ORM to read / write from files from / to
the database ( maybe postgresql ) and to use Django templates to show
records from the database.

Is django the write solution for this? using ORM and templates ?

When writing thousands of records to the database , can I execute this in
another thread or asynchronously ?

When reading millions of records from a database , how to do it
without freezing the view until all records are loaded ?

Looking forward to all your thoughts.

Regards

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHV4E-ep4Ut%2BEzpc%2BDB5VmJ%2BQn_m90Cqh2wGj0DCC82d%2BQoyBg%40mail.gmail.com.


Re: Django beginner

2021-07-04 Thread CHRISTO KRIEGLER
Here is someone teaching
Symaxx 
Fri, Jul 2, 10:16 PM (2 days ago)
to Django Unsubscribe
I teach Django the Python framework for free. Those interested join my
Whatsapp group for free live sessions
https://chat.whatsapp.com/DpOEaJTyhcXGF4YnFe3XLm

#pythonprogramming

 #python

 #django

Christo Kriegler

Founder / President

Management | Advertron
+2787 073 5706 <+2787+073+5706> | +2782 440 7831 <+2782+440+7831>
chri...@advertron.co.za
www.advertron.co.za


On Sun, Jul 4, 2021 at 7:25 PM Samin Serge  wrote:

> Hello everyone,
>
> Please i'm a Django beginner and would to know the best way to commence
> and access quickly with Django.
>
> thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e7df62d9-ef45-40df-a065-32e5ac850980n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA4mTE%3DT0uYKzR78Qg80YLHMms0L8pnPchG6UpPDQkB%3DJpJ9xA%40mail.gmail.com.


Re: Django beginner

2021-07-04 Thread Lalit Suthar
I followed these 2

https://www.youtube.com/playlist?list=PLEsfXFp6DpzTD1BD1aWNxS2Ep06vIkaeW
https://docs.djangoproject.com/en/2.2/intro/tutorial01/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGp2JVGPg%3D4a3JWbRY6sbz5EjLyEmYTKv620xRxBWvpSHc9G%3DQ%40mail.gmail.com.


Re: i am trying to learn django from django documentation but i am getting an error message in the first part of the documentation

2021-07-04 Thread Lalit Suthar
rewrite polls/urls.py like below
path(''", views.index, name='index'),

On Fri, 25 Jun 2021 at 18:59, Symaxx  wrote:

> I started learning Django from the documentation but it was very hard for
> me and it took me a very long time to grasp the concept
>
> I suggest you try using books by w.s vincent http://wsvincent.com/books/ these
> are the best for me and them help you stay engaged
>
> On Wed, Jun 23, 2021 at 5:19 PM vatsal narula 
> wrote:
>
>> Using the URLconf defined in blogs.urls, Django tried these URL patterns,
>> in this order:
>>
>> admin/ The current path, polls/, didn’t match any of these. this is the
>> error i am getting after i wrote the following code:
>>
>>1.
>>
>>for urls.py
>>from django.contrib import admin from django.urls import include,
>>path urlpatterns = [ path('polls/', include('polls.urls')), path('admin/',
>>admin.site.urls), ]
>>2.
>>
>>for polls/urls.py
>>from django.urls import path from . import views urlpatterns = [
>>path('', views.index, name='index'), ]
>>
>> 3.for polls/views.py
>>
>>  """ from django.http import HttpResponse
>> def index(request): return HttpResponse("Hello, world. You're at the
>> polls index.") """
>>
>> *how i can i remove this error in vs code*
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/5750b076-eddf-400d-b180-4ec7d46aa0e3n%40googlegroups.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CANPYDAttdvo3pLcQQ_j5uS3T0%2BNvYB_eSXn%2BMmS%2BO9s9n0i4OQ%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGp2JVEmazmCMq-01YuibMWmT7ecR2kYY%2BhezB2em%3DGcbst88Q%40mail.gmail.com.


Django beginner

2021-07-04 Thread Samin Serge
Hello everyone,

Please i'm a Django beginner and would to know the best way to commence and 
access quickly with Django.

thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e7df62d9-ef45-40df-a065-32e5ac850980n%40googlegroups.com.


503 for https://docs.djangoproject.com/

2021-07-04 Thread xiao A Zhuang
Error 503 certificate has expired

certificate has expired
Guru Mediation:

Details: cache-hkg17930-HKG 1625381791 3724040438

Varnish cache server

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4810de6e-a814-4bda-b981-7dbc85c99aadn%40googlegroups.com.


Email Form with attachments

2021-07-04 Thread sebasti...@gmail.com
Hello,

i need a form where i have normal email fields like:

to_address, from_address, subject, message and also i drag and drop zone 
where i can drop attachments. I have allready implement a normal drag and 
drop zone in another form where i can drag and drop files and it is upload 
und stored.

But when i create a new email email is not stored so i can't linked new 
files with this new email. 

How does it work? That i store attachments and when user then click submit 
from email form then all attachments are linked with new email?

Regards

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d3d67ab1-b7a5-46e5-8f05-af331ca08fben%40googlegroups.com.