Re: NGINX + GUNICORN

2020-09-11 Thread Julio Cojom
It depends, some people use virtualenvs, so you need to install gunicorn in
each project.

https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04

this might help, just change dependencies install to fit your os.

In my case, I deploy multiple projects with the same python and
dependencies install without virtualenv and made a little script, need
improvement but it's enough to pull some project from a repo and install
the app.

It take 3 params, repository, db name and domain name.
db name equals to project name in my case.







El vie., 11 sept. 2020 a las 4:44, Kasper Laudrup ()
escribió:

> Hi Giovanni,
>
> On 11/09/2020 12.24, Giovanni Silva wrote:
> > No...
> > I want to access www.aidacomunicacao.com.br
> >  and I hope see the django webpage
> >
>
> Then don't listen on port 81, but use the default port 80 for
> non-encrypted HTTP traffic.
>
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/9b32d1a8-b947-6b48-0e93-aab3dae8470a%40stacktrace.dk
> .
>

-- 
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/CAHRQUHni7xh79yr0k4TJRCxRmtkLMgf7Xv57ktKB%2BsFL0WOqxw%40mail.gmail.com.
#!/bin/bash

#1. clone repo and cd

cd /home/user/
git clone $1
REPO=$1
FOLDER=${REPO%.*}
FOLDER=${FOLDER##*/}

cd $FOLDER

# crea .env
#improve to make random str to secret key
cat > /home/user/$FOLDER/.env << EOL
SECRET_KEY=some_secreat_key
ALLOWED_HOSTS=localhost,$3, www.$3
DEBUG=True
DB_NAME=$2
DB_USER=$2
HOST=some_host
PORT=some port
DB_PASSWORD=some_password
PRODUCTION=True
EOL

#asigna permisos a la carpeta de la app
cd ..
chown -R user:user $FOLDER

#Creación de socket
cat > /etc/systemd/system/gunicorn_$2.socket << EOL
[Unit]
Description=$2 socket"

[Socket]
ListenStream=/run/gunicorn_$2.sock

[Install]
WantedBy=sockets.target
EOL

APP=${FOLDER//-/_}

#creación de servicio
cat > /etc/systemd/system/gunicorn_$2.service << EOL
[Unit]
Description=$2 daemon
Requires=gunicorn_$2.socket
After=network.target

[Service]
User=user
Group=www-data
WorkingDirectory=/home/user/$FOLDER
ExecStart=/usr/local/bin/gunicorn --access-logfile - --workers 3 --bind 
unix:/run/gunicorn_$2.sock $APP.wsgi:application
[Install]
WantedBy=multi-user.target
EOL

#inicia y habilita el servicio
systemctl daemon-reload
systemctl stop gunicorn_$2.socket
systemctl start gunicorn_$2.socket
systemctl daemon-reload
systemctl enable gunicorn_$2.socket

#habilita salida http
#bad practice, shoud ln to www/var/html and nginx go to www/var/html inestead 
of home/user/proyect
cat > /etc/nginx/sites-available/$3 << EOL
server {
server_name $3 www.$3;
location = /favicon.ico { access_log off; log_not_found off; }

location /staticfiles/ {
root /home/user/$FOLDER;
}
location /media/ {
root /home/user/$FOLDER;
}

location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn_$2.sock;
}
}
EOL


ln -s /etc/nginx/sites-available/$3 /etc/nginx/sites-enabled

nginx -t

systemctl restart nginx

certbot --nginx -d $3 -d www.$3



Re: Help me with the view please

2020-09-11 Thread coolguy
Technically your Fee model is designed incorrectly. You should have 
separate models for 'fees' and 'fees_paid' where fee would have been the 
foreign key in 'fees_paid. Fee should have a property like annual fee etc 
for each student as fee may be different based on student discounts etc. 
Then when student pays the fees, fees should go in a separate transactional 
table i.e. 'fees paid'. In your scenario, does each row in fee table 
carries the annual/school fee? if so then yes summing them up will 
definitely cause incorrect figure.

Here is what i would do if i don't change my models structure.

views.py
===
def student_detail(request, pk):
student = Student.objects.get(id=pk)

# in your case pick the first record from fee_set
first_record = student.fee_set.first()
school_fees = first_record.school_fees

paid_fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'))

balance_fees =  school_fees - paid_fees["total_paid_fees"] 

context = {"student": student,
   "paid_fees": paid_fees,
   "school_fees": school_fees,
   "balance_fees": balance_fees, }

return render(request, "student_details.html", context)

template
===

Student Detail
Student name: {{ student.name }}
School fees: {{ school_fees }}
Paid fees: {{ paid_fees.total_paid_fees }}
Remaining fees: {{ balance_fees }}


Output:


Student name: student1

School fees: 10.0

Paid fees: 35000.0

Remaining fees: 65000.0

On Friday, September 11, 2020 at 5:25:28 AM UTC-4 dex9...@gmail.com wrote:

> Sorry for bothering you @coolguy, you’re the only person who seems to be 
> nice to a Django beginner developer like me, and I would like to bother you 
> one more time
>
> Your solution for using methods in models is perfectly fine
>
> You see I want school_fees to be a fixed amount, example $300
>
> So when a student pays more than once(student.fee_set), lets say this 
> month student 1 pays $50 
>
> And another month pays $100 dollars, I want payments to added and 
> subtracted from fixed schools_fees($300)
>
> Remainingfees to be $300 – (($50)+($100))
>
>  
>
> BUT what “ 
> fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'), 
> total_school_fees=Sum('school_fees'))” 
> does is that it sums both paid fees school fees every time a student pays, 
> I want only paid fees to added every time a student pays but not school fees
>
>  
>
>  
>
>  
>
> Sent from Mail  for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Friday, September 11, 2020 4:27 AM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> If i choose to go with your way of calculation, i would do this...
>
>  
>
> def student_detail(request, pk):
>
> student = Student.objects.get(id=pk)
>
>
> fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'), 
> total_school_fees=Sum('school_fees'))
>
>  
>
> balance_fees = fees["total_school_fees"] - fees["total_paid_fees"]
>
>  
>
> context = {"student": student, 
> "fees": fees, "balance_fees": balance_fees, }
>
>  
>
> return render(request, "student_details.html", context)
>
>  
>
> Template e.g.
>
> 
>
> Student Detail
>
> Student name: {{ student.name }}
>
> School fees: {{ fees.total_school_fees }}
>
> Paid fees: {{ fees.total_paid_fees }}
>
> Remaining fees: {{ balance_fees }}
>
> 
>
>  
>
> Result:
>
> Student Detail
>
> Student name: student1
>
> School fees: 10.0
>
> Paid fees: 25000.0
>
> Remaining fees: 75000.0
>
> I hope this helps!
>
> On Thursday, September 10, 2020 at 2:16:27 PM UTC-4 dex9...@gmail.com 
> wrote:
>
> Thanks for helping me @coolguy,but it seems I ran into another problem, 
> the school fees and remaining fees somehow sums together, I want students 
> to pay school fees in phases, i.e, first quarter, second etc, and I want 
> remaining fee to be the difference between the initial school fees which is 
> 100 and total fee paid.
>
> Thanks in advance
>
>  
>
> My views.py for student
>
> Sent from Mail  for 
> Windows 10
>
>  
>
> *From: *coolguy
> *Sent: *Tuesday, September 8, 2020 11:58 PM
> *To: *Django users
> *Subject: *Re: Help me with the view please
>
>  
>
> I see now what you are asking...
>
>  
>
> I never do such calculations in views rather I create methods in models.py 
> to do so and call them in the template...
>
>  
>
> Like what you could do is..
>
>  
>
> class Student(models.Model):
>
> name = models.CharField(max_length=200, null=True, blank=True)
>
> classroom = models.ForeignKey(Classroom,
>
>
>   on_delete=models.DO_NOTHING, blank=True, 
> null=True)
>
>  
>
> def __str__(self):
>
> return *self*.name
>
>  
>
> def get_total_fee(self):
>
> return sum(student.school_fees for student in *self*
> .fee_set.all())
>
>  

Re: Setting an existing field to use ForeignKey can't access the object

2020-09-11 Thread Patrick Carra
Okay I figured it out. First I was using the wrong table (an old table that 
I should have deleted out). Second I needed to set the db_column attribute 
in my ForeignKey options).  Works like a charm now.  Sorry but thanks for 
the help!

On Friday, September 11, 2020 at 11:59:56 AM UTC-5 Patrick Carra wrote:

> OGUNSANYA I'm trying to access the related objects in the budget table 
> from the Circuitinfotable.  From what I can tell once they are related 
> using the ForeignKey I should be able to do this with c.budget but it 
> doesn't work for me.
>
> On Friday, September 11, 2020 at 10:43:39 AM UTC-5 Ogunsanya Opeyemi wrote:
>
>> Your ciecuitinfotable model does not have budget and budget_set field
>>
>> On Friday, September 11, 2020, Patrick Carra  wrote:
>>
>>> hello I am attempting to relate two existing tables 
>>>
>>> class Circuitinfotable(models.Model):
>>> id1 = models.AutoField(primary_key=True, null=False, unique=True)
>>> pid = models.CharField(max_length=255, blank=True, null=True)
>>> circuitid = models.CharField(max_length=255, blank=True, null=True)
>>> bandwidth = models.CharField(max_length=255, blank=True, null=True, 
>>> choices=bandwidth_list)
>>> region = models.CharField(max_length=255, blank=True, null=True, 
>>> choices=region_list)
>>> bw = models.IntegerField(blank=True, null=True)
>>> pathname = models.CharField(max_length=255, blank=True, null=True)
>>> handoffalocaddress = models.CharField(max_length=255, blank=True, 
>>> null=True)
>>> handoffaloccity = models.CharField(max_length=255, blank=True, 
>>> null=True)
>>> handoffalocst = models.CharField(max_length=255, blank=True, 
>>> null=True)
>>> alocationaddress = models.CharField(max_length=255, blank=True, 
>>> null=True)
>>> alocationcity = models.CharField(max_length=255, blank=True, 
>>> null=True)
>>>
>>> class Budgettable(models.Model):
>>> id = models.CharField(primary_key=True, max_length=255)
>>> circuitid = models.CharField(max_length=255, blank=True, null=True)
>>> pid = models.CharField(max_length=255, blank=True, null=True)
>>> monthnum = models.IntegerField(blank=True, null=True)
>>> yearnum = models.IntegerField(blank=True, null=True)
>>> budgetmrc = models.TextField(blank=True, null=True)  # This field 
>>> type is a guess.
>>> actualmrc = models.TextField(blank=True, null=True)  # This field 
>>> type is a guess.
>>> region = models.CharField(max_length=255, blank=True, null=True)
>>> circuitref = models.ForeignKey(Circuitinfotable, 
>>> on_delete=models.CASCADE, to_field='id1')
>>>
>>> class Meta:
>>> managed = False
>>>
>>> If open a shell and import Circuitinfotable and Budget and run the 
>>> following code:
>>> from finance.models import Circuitinfotable, Budget
>>> c=Circuitinfotable.objects.get(id1=695)
>>> c.budget
>>> c.budget_set.all
>>>
>>> I get an error:
>>> Traceback (most recent call last):
>>>   File "", line 1, in 
>>> AttributeError: 'Circuitinfotable' object has no attribute 'budget'
>>>
>>> or 
>>>
>>> Traceback (most recent call last):
>>>   File "", line 1, in 
>>> AttributeError: 'Circuitinfotable' object has no attribute 'budget_set'
>>>
>>> I set up my budget file to have the circuitref populated with the id1 
>>> field of the Circuitinfotable.
>>>
>>> In my code I can query these two objects and manually relate them myself 
>>> in the view but I cannot get the django ORM to do this for me.  Any 
>>> suggestions?
>>>
>>> -- 
>>> 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/350ce6b2-d63b-45ae-bdc6-f9b123b3d04cn%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>>
>>
>> -- 
>> OGUNSANYA OPEYEMI
>>
>>

-- 
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/0c0d7b78-c04c-45b0-af41-a29b76715021n%40googlegroups.com.


Re: Setting an existing field to use ForeignKey can't access the object

2020-09-11 Thread Patrick Carra
OGUNSANYA I'm trying to access the related objects in the budget table from 
the Circuitinfotable.  From what I can tell once they are related using the 
ForeignKey I should be able to do this with c.budget but it doesn't work 
for me.

On Friday, September 11, 2020 at 10:43:39 AM UTC-5 Ogunsanya Opeyemi wrote:

> Your ciecuitinfotable model does not have budget and budget_set field
>
> On Friday, September 11, 2020, Patrick Carra  wrote:
>
>> hello I am attempting to relate two existing tables 
>>
>> class Circuitinfotable(models.Model):
>> id1 = models.AutoField(primary_key=True, null=False, unique=True)
>> pid = models.CharField(max_length=255, blank=True, null=True)
>> circuitid = models.CharField(max_length=255, blank=True, null=True)
>> bandwidth = models.CharField(max_length=255, blank=True, null=True, 
>> choices=bandwidth_list)
>> region = models.CharField(max_length=255, blank=True, null=True, 
>> choices=region_list)
>> bw = models.IntegerField(blank=True, null=True)
>> pathname = models.CharField(max_length=255, blank=True, null=True)
>> handoffalocaddress = models.CharField(max_length=255, blank=True, 
>> null=True)
>> handoffaloccity = models.CharField(max_length=255, blank=True, 
>> null=True)
>> handoffalocst = models.CharField(max_length=255, blank=True, 
>> null=True)
>> alocationaddress = models.CharField(max_length=255, blank=True, 
>> null=True)
>> alocationcity = models.CharField(max_length=255, blank=True, 
>> null=True)
>>
>> class Budgettable(models.Model):
>> id = models.CharField(primary_key=True, max_length=255)
>> circuitid = models.CharField(max_length=255, blank=True, null=True)
>> pid = models.CharField(max_length=255, blank=True, null=True)
>> monthnum = models.IntegerField(blank=True, null=True)
>> yearnum = models.IntegerField(blank=True, null=True)
>> budgetmrc = models.TextField(blank=True, null=True)  # This field 
>> type is a guess.
>> actualmrc = models.TextField(blank=True, null=True)  # This field 
>> type is a guess.
>> region = models.CharField(max_length=255, blank=True, null=True)
>> circuitref = models.ForeignKey(Circuitinfotable, 
>> on_delete=models.CASCADE, to_field='id1')
>>
>> class Meta:
>> managed = False
>>
>> If open a shell and import Circuitinfotable and Budget and run the 
>> following code:
>> from finance.models import Circuitinfotable, Budget
>> c=Circuitinfotable.objects.get(id1=695)
>> c.budget
>> c.budget_set.all
>>
>> I get an error:
>> Traceback (most recent call last):
>>   File "", line 1, in 
>> AttributeError: 'Circuitinfotable' object has no attribute 'budget'
>>
>> or 
>>
>> Traceback (most recent call last):
>>   File "", line 1, in 
>> AttributeError: 'Circuitinfotable' object has no attribute 'budget_set'
>>
>> I set up my budget file to have the circuitref populated with the id1 
>> field of the Circuitinfotable.
>>
>> In my code I can query these two objects and manually relate them myself 
>> in the view but I cannot get the django ORM to do this for me.  Any 
>> suggestions?
>>
>> -- 
>> 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/350ce6b2-d63b-45ae-bdc6-f9b123b3d04cn%40googlegroups.com
>>  
>> 
>> .
>>
>
>
> -- 
> OGUNSANYA OPEYEMI
>
>

-- 
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/dcc6787c-48b8-4d11-894b-e9fb9d57542dn%40googlegroups.com.


Re: Setting an existing field to use ForeignKey can't access the object

2020-09-11 Thread Ogunsanya Opeyemi
Your ciecuitinfotable model does not have budget and budget_set field

On Friday, September 11, 2020, Patrick Carra  wrote:

> hello I am attempting to relate two existing tables
>
> class Circuitinfotable(models.Model):
> id1 = models.AutoField(primary_key=True, null=False, unique=True)
> pid = models.CharField(max_length=255, blank=True, null=True)
> circuitid = models.CharField(max_length=255, blank=True, null=True)
> bandwidth = models.CharField(max_length=255, blank=True, null=True,
> choices=bandwidth_list)
> region = models.CharField(max_length=255, blank=True, null=True,
> choices=region_list)
> bw = models.IntegerField(blank=True, null=True)
> pathname = models.CharField(max_length=255, blank=True, null=True)
> handoffalocaddress = models.CharField(max_length=255, blank=True,
> null=True)
> handoffaloccity = models.CharField(max_length=255, blank=True,
> null=True)
> handoffalocst = models.CharField(max_length=255, blank=True,
> null=True)
> alocationaddress = models.CharField(max_length=255, blank=True,
> null=True)
> alocationcity = models.CharField(max_length=255, blank=True,
> null=True)
>
> class Budgettable(models.Model):
> id = models.CharField(primary_key=True, max_length=255)
> circuitid = models.CharField(max_length=255, blank=True, null=True)
> pid = models.CharField(max_length=255, blank=True, null=True)
> monthnum = models.IntegerField(blank=True, null=True)
> yearnum = models.IntegerField(blank=True, null=True)
> budgetmrc = models.TextField(blank=True, null=True)  # This field type
> is a guess.
> actualmrc = models.TextField(blank=True, null=True)  # This field type
> is a guess.
> region = models.CharField(max_length=255, blank=True, null=True)
> circuitref = models.ForeignKey(Circuitinfotable,
> on_delete=models.CASCADE, to_field='id1')
>
> class Meta:
> managed = False
>
> If open a shell and import Circuitinfotable and Budget and run the
> following code:
> from finance.models import Circuitinfotable, Budget
> c=Circuitinfotable.objects.get(id1=695)
> c.budget
> c.budget_set.all
>
> I get an error:
> Traceback (most recent call last):
>   File "", line 1, in 
> AttributeError: 'Circuitinfotable' object has no attribute 'budget'
>
> or
>
> Traceback (most recent call last):
>   File "", line 1, in 
> AttributeError: 'Circuitinfotable' object has no attribute 'budget_set'
>
> I set up my budget file to have the circuitref populated with the id1
> field of the Circuitinfotable.
>
> In my code I can query these two objects and manually relate them myself
> in the view but I cannot get the django ORM to do this for me.  Any
> suggestions?
>
> --
> 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/350ce6b2-d63b-45ae-bdc6-f9b123b3d04cn%
> 40googlegroups.com
> 
> .
>


-- 
OGUNSANYA OPEYEMI

-- 
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/CABJxPrFezxpvq%3D4JO_MsSFJuTsx83E_jsDWybJv_%3Dhy5f5QGtw%40mail.gmail.com.


Setting an existing field to use ForeignKey can't access the object

2020-09-11 Thread Patrick Carra
hello I am attempting to relate two existing tables 

class Circuitinfotable(models.Model):
id1 = models.AutoField(primary_key=True, null=False, unique=True)
pid = models.CharField(max_length=255, blank=True, null=True)
circuitid = models.CharField(max_length=255, blank=True, null=True)
bandwidth = models.CharField(max_length=255, blank=True, null=True, 
choices=bandwidth_list)
region = models.CharField(max_length=255, blank=True, null=True, 
choices=region_list)
bw = models.IntegerField(blank=True, null=True)
pathname = models.CharField(max_length=255, blank=True, null=True)
handoffalocaddress = models.CharField(max_length=255, blank=True, 
null=True)
handoffaloccity = models.CharField(max_length=255, blank=True, 
null=True)
handoffalocst = models.CharField(max_length=255, blank=True, null=True)
alocationaddress = models.CharField(max_length=255, blank=True, 
null=True)
alocationcity = models.CharField(max_length=255, blank=True, null=True)

class Budgettable(models.Model):
id = models.CharField(primary_key=True, max_length=255)
circuitid = models.CharField(max_length=255, blank=True, null=True)
pid = models.CharField(max_length=255, blank=True, null=True)
monthnum = models.IntegerField(blank=True, null=True)
yearnum = models.IntegerField(blank=True, null=True)
budgetmrc = models.TextField(blank=True, null=True)  # This field type 
is a guess.
actualmrc = models.TextField(blank=True, null=True)  # This field type 
is a guess.
region = models.CharField(max_length=255, blank=True, null=True)
circuitref = models.ForeignKey(Circuitinfotable, 
on_delete=models.CASCADE, to_field='id1')

class Meta:
managed = False

If open a shell and import Circuitinfotable and Budget and run the 
following code:
from finance.models import Circuitinfotable, Budget
c=Circuitinfotable.objects.get(id1=695)
c.budget
c.budget_set.all

I get an error:
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'Circuitinfotable' object has no attribute 'budget'

or 

Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'Circuitinfotable' object has no attribute 'budget_set'

I set up my budget file to have the circuitref populated with the id1 field 
of the Circuitinfotable.

In my code I can query these two objects and manually relate them myself in 
the view but I cannot get the django ORM to do this for me.  Any 
suggestions?

-- 
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/350ce6b2-d63b-45ae-bdc6-f9b123b3d04cn%40googlegroups.com.


Re: Help with payment processing in django

2020-09-11 Thread Omkar Parab
Check-out last few videos of this  series.

https://www.youtube.com/playlist?list=PLpyspNLjzwBnGesxJOt_0r4xTWR80j7Y3

On Fri, Sep 11, 2020, 4:22 PM shyam.ac...@gmail.com <
shyam.acharjy...@gmail.com> wrote:

>
> Hi guys, I am working on a project which offers contents  and every
> content has a different price. i want the users to see only the overview of
> the content, and if they want full access to the content they have to buy
> it. If anyone here has done something like this before please let me know.
>
> --
> 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/688d1a79-c94c-406b-9305-67927a9346f0n%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/CAJY8mfxJMOLH4r8NOdtZfZOyvW2vYgeCRM93VxW15u3U1WCvug%40mail.gmail.com.


Re: Help with payment processing in django

2020-09-11 Thread Ogunsanya Opeyemi
Hi i have message me on whatsapp lets talk 09062351846

On Friday, September 11, 2020, shyam.ac...@gmail.com <
shyam.acharjy...@gmail.com> wrote:

>
> Hi guys, I am working on a project which offers contents  and every
> content has a different price. i want the users to see only the overview of
> the content, and if they want full access to the content they have to buy
> it. If anyone here has done something like this before please let me know.
>
> --
> 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/688d1a79-c94c-406b-9305-67927a9346f0n%
> 40googlegroups.com
> 
> .
>


-- 
OGUNSANYA OPEYEMI

-- 
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/CABJxPrFxx4OVQgwMwEzHzorr1BPmOaaLW%3DJqpo1WYdT5Dqu2jQ%40mail.gmail.com.


Help with payment processing in django

2020-09-11 Thread shyam.ac...@gmail.com

Hi guys, I am working on a project which offers contents  and every  
content has a different price. i want the users to see only the overview of 
the content, and if they want full access to the content they have to buy 
it. If anyone here has done something like this before please let me know.

-- 
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/688d1a79-c94c-406b-9305-67927a9346f0n%40googlegroups.com.


Re: NGINX + GUNICORN

2020-09-11 Thread Kasper Laudrup

Hi Giovanni,

On 11/09/2020 12.24, Giovanni Silva wrote:

No...
I want to access www.aidacomunicacao.com.br 
 and I hope see the django webpage




Then don't listen on port 81, but use the default port 80 for 
non-encrypted HTTP traffic.


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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9b32d1a8-b947-6b48-0e93-aab3dae8470a%40stacktrace.dk.


Re: NGINX + GUNICORN

2020-09-11 Thread Giovanni Silva
No...
I want to access www.aidacomunicacao.com.br and I hope see the django
webpage

Em sex, 11 de set de 2020 04:39, Kasper Laudrup 
escreveu:

> Hi Giovanni,
>
> On 10/09/2020 23.58, Giovanni Silva wrote:
> > */This doesn't work. /*
> >
> > NGINX - FILE
> > server {
> >  listen 81;
> >  server_name www.aidacomunicacao.com.br
>
> If I go to http://www.aidacomunicacao.com.br:81/ as you have configured
> here, I see the default Django welcome page.
>
> Is this not what you expected?
>
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b82a98c4-0bb1-858f-fa4d-8779525f3cad%40stacktrace.dk
> .
>

-- 
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/CABO2r9dM-TaTQ4Jt6VU545SjZm4B3SSNa11pwk5SJFCFWBOJCA%40mail.gmail.com.


Re: I am getting this error plz help me out of this.

2020-09-11 Thread Hedrick Godson's
In ur anchor tag in template {% url "xyz:rst" post.pk %}

On Thu, 10 Sep 2020, 20:15 amr  wrote:

> In your views function you passed a (pk) so you must pass it in your path
> in (urls.py) as
> path('postdetail//', views.post_detail, name='post_detail')
> Then in your template in(href="{% url 'appname:post_detail' post.id %}")
> and you will redirect to your  url as (localhost:port/postdetail/1) or 2
> or 3 or 4 . or whatever
> hope this helps
>
> On Thursday, September 10, 2020 at 4:08:18 PM UTC+2 mailto...@gmail.com
> wrote:
>
>> url for post_detail should have 
>>
>> On Thu, Sep 10, 2020 at 7:30 PM Yash Lanjewar 
>> wrote:
>>
>>> [image: 1.png]
>>> [image: 2.png]
>>> [image: 3.png]
>>> [image: 4.png]
>>>
>>> --
>>> 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/CAM%3DybSOsbGWm-9LvGYgu5QpNQZA%3DZvGY00C%2Bj5CHuoiG8nmFxQ%40mail.gmail.com
>>> 
>>> .
>>>
>>
>>
>> --
>> Thanks & Regards
>>
>> Regards,
>> Danish
>>
> --
> 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/d25aa9e1-d753-4c6e-83a7-fcda03731514n%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/CAJAxQD%3DvjnGNPsPbOsZBLSP0UDGRunX82c7QQ7PJJ%3Dy1mjGjWw%40mail.gmail.com.


RE: Help me with the view please

2020-09-11 Thread fadhil alex
Sorry for bothering you @coolguy, you’re the only person who seems to be nice to a Django beginner developer like me, and I would like to bother you one more timeYour solution for using methods in models is perfectly fineYou see I want school_fees to be a fixed amount, example $300So when a student pays more than once(student.fee_set), lets say this month student 1 pays $50 And another month pays $100 dollars, I want payments to added and subtracted from fixed schools_fees($300)Remainingfees to be $300 – (($50)+($100)) BUT what “ fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'), total_school_fees=Sum('school_fees'))” does is that it sums both paid fees school fees every time a student pays, I want only paid fees to added every time a student pays but not school fees   Sent from Mail for Windows 10 From: coolguySent: Friday, September 11, 2020 4:27 AMTo: Django usersSubject: Re: Help me with the view please If i choose to go with your way of calculation, i would do this... def student_detail(request, pk):student = Student.objects.get(id=pk)fees = student.fee_set.aggregate(total_paid_fees=Sum('paid_fees'), total_school_fees=Sum('school_fees')) balance_fees = fees["total_school_fees"] - fees["total_paid_fees"] context = {"student": student, "fees": fees, "balance_fees": balance_fees, } return render(request, "student_details.html", context) Template e.g.Student DetailStudent name: {{ student.name }}School fees: {{ fees.total_school_fees }}Paid fees: {{ fees.total_paid_fees }}Remaining fees: {{ balance_fees }} Result:Student DetailStudent name: student1School fees: 10.0Paid fees: 25000.0Remaining fees: 75000.0I hope this helps!On Thursday, September 10, 2020 at 2:16:27 PM UTC-4 dex9...@gmail.com wrote:Thanks for helping me @coolguy,but it seems I ran into another problem, the school fees and remaining fees somehow sums together, I want students to pay school fees in phases, i.e, first quarter, second etc, and I want remaining fee to be the difference between the initial school fees which is 100 and total fee paid.Thanks in advance My views.py for studentSent from Mail for Windows 10 From: coolguySent: Tuesday, September 8, 2020 11:58 PMTo: Django usersSubject: Re: Help me with the view please I see now what you are asking... I never do such calculations in views rather I create methods in models.py to do so and call them in the template... Like what you could do is.. class Student(models.Model):name = models.CharField(max_length=200, null=True, blank=True)classroom = models.ForeignKey(Classroom,  _on_delete_=models.DO_NOTHING, blank=True, null=True) def __str__(self):return self.name     def get_total_fee(self):return sum(student.school_fees for student in self.fee_set.all()) def get_total_paid_fee(self):return sum(student.paid_fees for student in self.fee_set.all()) def get_remaining_fee(self):total_fee = self.get_total_fee()total_paid = self.get_total_paid_fee()return float(total_fee - total_paid) and in template you can call...{{ student.get_remaining_fee }}On Tuesday, September 8, 2020 at 1:35:56 PM UTC-4 dex9...@gmail.com wrote:Thank you for your help @coolguy..but my real problem lies in writing the code for “fee_remaining”, can you help me with that also..thanks Sent from Mail for Windows 10 From: coolguySent: Tuesday, September 8, 2020 7:45 PMTo: Django usersSubject: Re: Help me with the view please In your return line of code, you are referring to context variable but I don't see you assigned any value to this context variable in your code.Or if you want to send three variables i.e. "fees", "total_fees" and "fee_remaining"... you need to send them separately like return render(request, 'website/students.html', {"fees": fees, "total_fees": total_fees, "fee_remaining": fee_remaining }) then use these variables on your students.html template.   On Tuesday, September 8, 2020 at 12:21:21 PM UTC-4 dex9...@gmail.com wrote:My Modelsclass Student(models.Model):name = models.CharField(max_length=200, null=True, blank=True)classroom = models.ForeignKey(‘Classroom’,_on_delete_=models.DO_NOTHING,blank=True, null=True)class Classroom(models.Model):name = models.CharField(max_length=40,blank=True, null=True)class Fee(models.Model):student = models.ForeignKey(Student, _on_delete_=models.CASCADE, null=True,)classroom = models.ForeignKey(Classroom, _on_delete_=models.CASCADE, null=True)school_fees = models.FloatField(default=100)paid_fees = models.FloatField(null=False)remaining_fees = models.FloatField(blank=True)completed = models.BooleanField(null=False, default=False)views.pydef student(request, pk):student = Student.objects.get(id=pk)fees = student.fee_set.all().order_by('-publish_date') total_fees = student.fee_set.all().filter(student__id=pk) .aggregate(sum=Sum('paid_fees', flat=True)['sum'] fees_remaining = () return render(request, 

Re: NGINX + GUNICORN

2020-09-11 Thread Kasper Laudrup

Hi Giovanni,

On 10/09/2020 23.58, Giovanni Silva wrote:

*/This doesn't work. /*

NGINX - FILE
server {
     listen 81;
     server_name www.aidacomunicacao.com.br 


If I go to http://www.aidacomunicacao.com.br:81/ as you have configured 
here, I see the default Django welcome page.


Is this not what you expected?

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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b82a98c4-0bb1-858f-fa4d-8779525f3cad%40stacktrace.dk.


Re: NGINX + GUNICORN

2020-09-11 Thread Sunday Iyanu Ajayi
>From what I see, you what to host your webapp on two domain name (addresses)

1. www.ascende.com.br; :80
2.  www.aidacomunicacao.com.br :80

Right???
*AJAYI Sunday *
(+234) 806 771 5394
*sunnexaj...@gmail.com *



On Thu, Sep 10, 2020 at 10:59 PM Giovanni Silva  wrote:

> Hello..
>
> *This webpage works fine:*
>
> NGINX - FILE
> server {
> listen 80;
> server_name www.ascende.com.br;
>
> location = /favicon.ico { access_log off; log_not_found off; }
> location /static/ {
> root /home/ascende/Site;
> }
>
> location / {
> include proxy_params;
> proxy_pass http://unix:/run/gunicorn.sock;
> }
> }
>
> GUNICORN SOCKET
> [Unit]
> Description=gunicorn socket
>
> [Socket]
> ListenStream=/run/gunicorn.sock
>
> [Install]
> WantedBy=sockets.target
>
> GUNICORN SERVICE
> [Unit]
> Description=gunicorn daemon
> Requires=gunicorn.socket
> After=network.target
>
> [Service]
> User=ascende
> Group=www-data
> WorkingDirectory=/home/ascende/Site
> ExecStart=/home/ascende/Site/venv/bin/gunicorn \
>   --access-logfile - \
>   --workers 3 \
>   --bind unix:/run/gunicorn.sock \
>   SiteAscende.wsgi:application
>
> [Install]
> WantedBy=multi-user.target
>
> *This doesn't work. *
>
> NGINX - FILE
> server {
> listen 81;
> server_name www.aidacomunicacao.com.br;
>
> location = /favicon.ico { access_log off; log_not_found off; }
> location /static/ {
> root /home/aida/Site;
> }
>
> location / {
> include proxy_params;
> proxy_pass http://unix:/run/siteaida.sock;
> }
> }
>
> GUNICORN SOCKET2
> [Unit]
> Description=siteaida socket
>
> [Socket]
> ListenStream=/run/siteaida.sock
>
> [Install]
> WantedBy=sockets.target
>
> GUNICORN SERVICE2
> [Unit]
> Description=siteaida daemon
> Requires=siteaida.socket
> After=network.target
>
> [Service]
> User=aida
> Group=www-data
> WorkingDirectory=/home/aida/Site
> ExecStart=/home/aida/Site/venv/bin/gunicorn \
>   --access-logfile - \
>   --workers 3 \
>   --bind unix:/run/siteaida.sock \
>   SitaAIDA.wsgi:application
>
> [Install]
> WantedBy=multi-user.target
>
>
> Em qui., 10 de set. de 2020 às 04:52, Kasper Laudrup <
> laud...@stacktrace.dk> escreveu:
>
>> Hi Giovanni,
>>
>> On 10/09/2020 07.59, Giovanni Silva wrote:
>> > Dears,
>> >
>> > can anyone help-me to configure a NGINX + GUNICORN to multiple projects?
>> >
>> > for the first project everything is work fine, for the second project,
>> I
>> > create a new .socket file and new service file..
>> >
>> > The nginx and gunicorn is running, but when I try to access my site,
>> > appears the default page of nginx..
>> >
>> > Any suggestions??
>> >
>>
>> You would probably have a better chance of getting some help if you
>> provide us with the relevant parts of your nginx configuration and a bit
>> more information about your setup (OS etc.).
>>
>> Anyway, have you tried following this guide:
>>
>>
>> http://michal.karzynski.pl/blog/2013/10/29/serving-multiple-django-applications-with-nginx-gunicorn-supervisor/
>>
>> 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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/dd25b9fd-60c3-8f2f-5f76-886ec8d2e649%40stacktrace.dk
>> .
>>
>
>
> --
> *Giovanni Silva*
> (31) 9 9532-1877
>
> --
> 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/CABO2r9dM82yukSLGPtJ7okynr-cTXF5%3DP8G85wqjxT8rDLeV_w%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/CAKYSAw3H%3DZ8K8zqqT%3DdjFAD9cqiY40gNQu7u09vYFTyqZ7W0Lw%40mail.gmail.com.