Thursday, April 28, 2022

Re: SMTP Authentification error

In my experience, Gmail does not allow (or does not support) using it as a smarthost if all you have is a free account, and even if you get it to work it will eventually cause you headaches. I don't know if this has changed the last few years, but I feel it hasn't. It's much better to use another service. I use runbox.com; mailbox.org is another solution. These are both paid email services. In a recent thread, someone also mentioned mailgun and sendgrid, which may be better suited for this purpose.

Other than that, you should enter a breakpoint or something in your code to verify that the values of EMAIL_HOST_USER and EMAIL_HOST_PASSWORD are what they should.

Regards,

Antonis


On 28/04/2022 07.58, 'Delvin Alexander' via Django users wrote:
okay i did both but now i am getting this error. Any clue on why?

SMTPSenderRefused at /password-reset/

(530, b'5.7.0 Authentication Required. Learn more at\n5.7.0 https://support.google.com/mail/?p=WantAuthError w137-20020a62828f000000b0050d2f9c3409sm14545822pfd.199 - gsmtp', 'webmaster@localhost')

On Wednesday, April 27, 2022 at 12:27:02 AM UTC-7 dashlaksh...@gmail.com wrote:
Check whether you have turned on less secure apps or not.

On Wed, Apr 27, 2022, 11:07 'Delvin Alexander' via Django users <django...@googlegroups.com> wrote:
Hello everyone, 

May you please assist in informing me on what i need to do to resolve this issue. 

- SMTPAuthenticationError at /password-reset/
- (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials j64-20020a62c543000000b0050d260c0ea8sm13366402pfg.110 - gsmtp')


I included the 16 character code to my environment variable and called it in my settings.pymfile,  but still the error occurs. Also here is my settings.py file:

- EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = os.environ.get('DB_USER')
EMAIL_HOST_PASSWORD = os.environ.get('DB_PASSWORD')
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c18935a8-43bf-4a15-a5ba-95209009498dn%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a6f92133-32db-4f4a-ae46-bb1f7644b431n%40googlegroups.com.

Friday, April 15, 2022

Re: Using Multiple databases

On Wed, Apr 06, 2022 at 08:59:09AM -0700, Vasanth Mohan wrote:
> I'm building a PoC for a multi-tenant app where I'm trying to use the same
> schema across multiple databases with Django instance. I've got a couple of
> questions and I'd be happy to have some input
>
> 1. Is there a way to define the *using()* function to use with Models via a
> lib/middleware?
> 2. Is there a way to create admin users so that they have access to
> specific databases?

You probably want to create a custom database router[1].

[1] https://docs.djangoproject.com/en/4.0/topics/db/multi-db/#automatic-database-routing

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20220415180748.GC15520%40fattuba.com.

Re: Filtering User Data/Records

On Thu, Apr 07, 2022 at 01:08:19PM +0300, tech george wrote:
> I am trying to filter my medicine stock data so that Pharmacist 1 can only
> view their records but not Pharmacist 's 2 records.
>
> So far nothing is filtered and all the pharmacists can see all the
> available records, Please advise.

I'm assuming the view you're having problems with is manageStock3. You
probably want to filter stocks based on the pharmacist that is logged in. Try
something like:

stocks = Stock.objects.filter(pharmacist_id=request.user)

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20220415180258.GB15520%40fattuba.com.

Wednesday, April 13, 2022

Re: Calculated Fields

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsDNBGBJfrABDACxIFOMQIsP94wTkgf76JEHyTITmYnprsTeRmDet01G5etZ9ZHm
RmrqYVFzXu1aSBbaejm/ppbRrBB7YmFETbpnZepWJnuhridvjV37duRH3g/9ppiy
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+y0NDlxWCZOaGp
ucR+ueFKv1de3nVjdd6oN+MIO9gQ3NE53FrO46A3APy6Ex02Mxub8nNnQjXcStHZ
BHO6KilQ+QLzSektD8IpHM7tR6P+5PP6AQ==
=NePe
-----END PGP PUBLIC KEY BLOCK-----
On 13/04/2022 16.51, Ahmedrufai Otuoze wrote:
> This is not a spam. I just tok a course on that aspect and wanted to help.
> No strings attached.
>
> I may have gone against the policy and that's because I wasn't aware.
> My intentions were genuine...
>

You were not the one I was replying to so I don't understand why you are
replying like you were advertising this.

Harsh Jain has previously been spamming this mailing list and he's the
one I was replying to.

Kind regards,

Kasper Laudrup

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8f8efa76-713f-86c8-ed18-188482af2882%40stacktrace.dk.

Sunday, April 10, 2022

Re: Calculated Fields

As was found out with the conversation with Mike Dewhirst, the error appears to be because of wrong understanding of operator precedence. That's easy to correct with parentheses.

Except for that, I wouldn't do it that way; I wouldn't store the total price in the database, because it's likely to create problems. Models that have not (yet) been saved to the database will not have a total price. Models that have been loaded from the database, modified, but not (yet) updated in the database will have a wrong total price. Saving to the database with bulk operations or with plain SQL may result in no total price. These are all symptoms of storing redundant information in the database, which is something that should be avoided.

Instead, I would do this:

class Stock(models.Model):
    unit_price = models.DecimalField(max_digits=10, decimal_places=2, default='0', blank=True, null=True)
    quantity = models.IntegerField(default='0', blank=True, null=True)
    reorder_level = models.IntegerField(default='0', blank=True, null=True)

    @property
    def total_price(self):
        return (self.quantity + self.reorder_level) * self.unit_price



On 10/04/2022 20.49, tech george wrote:

Hello,

I am trying to calculate fields directly from a model but no luck. I want to get total_price from quantity, reoder_level and unit price. My code is abelow, Please advise.

class Stock(models.Model):
    unit_price = models.DecimalField(max_digits=10, decimal_places=2, default='0', blank=True, null=True)
    quantity = models.IntegerField(default='0', blank=True, null=True)
    total_price = models.DecimalField(max_digits=10, decimal_places=2,default=1)
    reorder_level = models.IntegerField(default='0', blank=True, null=True)


    def save(self, *args, **kwargs):
        self.total_price = self.quantity + self.reorder_level * self.unit_price
        super(Stock, self).save(*args, **kwargs)


What am i my doing wrong

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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CADYG20HBcMMGq6QodO0v%2BeZVmfS%2Bmr4aCSro5FZeeRLFdQztnQ%40mail.gmail.com.

Friday, April 8, 2022

Re: NameError:

Hi! In the line where the error occurs, Pharmacist has not been defined yet. Move your Pharmacist model before your Patients model.

Regards,

Antonis


On 08/04/2022 20.49, tech george wrote:

Hello,

I've been struggling with the below error, what might be the problem?

I have used the same ForeignKey in other models.. all works ok, except this.

Please advise.

Models:

class CustomUser(AbstractUser):
    user_type_data = ((1, "AdminHOD"), (2, "Pharmacist"), (3, "Doctor"), (4, "PharmacyClerk"),(5, "Patients"))
    user_type = models.CharField(default=1, choices=user_type_data, max_length=10)



class Patients(models.Model):
    gender_category=(
        ('Male','Male'),
        ('Female','Female'),
    )

    nurse = models.ForeignKey(Pharmacist, related_name='Pharmacist', on_delete=models.CASCADE, null=True)
    admin = models.OneToOneField(CustomUser,null=True, on_delete = models.CASCADE)
    reg_no=models.CharField(max_length=30,null=True,blank=True,unique=True)
    gender=models.CharField(max_length=7,null=True,blank=True,choices=gender_category)
    first_name=models.CharField(max_length=20,null=True,blank=True)
    last_name=models.CharField(max_length=20,null=True,blank=True)
    date_admitted=models.DateTimeField(auto_now_add=True, auto_now=False)
    last_updated = models.DateTimeField(auto_now_add=False, auto_now=True)

    def __str__(self):
        return str(self.admin)


Error:

nurse = models.ForeignKey(Pharmacist, related_name='Pharmacist', on_delete=models.CASCADE, null=True)
NameError: name 'Pharmacist' is not defined


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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CADYG20GbMnoGjkT7VtD1FFMw3Tr8Axaepnf27vDyvqYvMb%2BUiQ%40mail.gmail.com.