Re: Best digital ocean plan for a production server

2022-07-10 Thread Ryan Nowakowski
Ram,

It depends.  How many http transactions per second are you expecting?
What database are you using?   Based on your estimated http TPS, how
many database queries per second are you expecting?  What percentange of
those database queries are read vs write?

- Ryan N

On Sat, Jul 09, 2022 at 09:20:17PM -0600, Ram wrote:
> Hi,
> 
> We are planning to launch our application in production once all the
> testing is completed after deployment to our development server. We are
> using Jenkins CI automation to deploy the code to the development server
> and we will do the same in production server too, but we are currently
> doing a feasibility study to understand which options are good for Django
> web application for both Web and Mobile app.
> 
> If anyone in this Django users community is currently on any Digital
> Ocean's production server plan, could you share some details and
> suggestions.
> 
> Best regards,
> ~Ram

-- 
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/20220710192831.GF18918%40fattuba.com.


Re: INSTALACION PYTHON / DJANGO EN DEBIAN

2022-07-10 Thread Miguel Ángel Cumpa Ascuña
Hi
sudo apt install python3-pip
sudo pip3 install --upgrade pip
sudo pip install django

El sáb, 9 jul 2022 a las 12:44, GLIBERT CERTAD ()
escribió:

> Estimados, buenas tardes. Hasta ahora he trabajado con Python y Django en
> Sistema Operativo de Windows. Pero por razones labrales, he iniciado un
> proyecto y el servidor disponible posee Debian 9. Cuales son los comandos y
> los pasos para instalar tanto Python como Django en dicho servidor.
>
> Sin más y agradeciendo de antemano;
>
> Glibert Certad
>
> --
> 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/c7b05a27-1068-4197-9fc9-768060cee02cn%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/CAOZHYKNbaWqdxXT%2B7atp6nESd7k%3DDQaugRDUtbtHPD-N%2BqKgFA%40mail.gmail.com.


Re: Static Code analysis and Security Scanning tools for Django Web Applications

2022-07-10 Thread Ram
Hello Christian,

Thank you for your suggestion. I see Bandit in the supported tools in
Prospector:  https://prospector.landscape.io/en/master/supported_tools.html
, but not finding bugbear. We will try to add Bandit and see.

Best regards,
~Ram

On Fri, Jul 8, 2022 at 9:27 AM Christian Ledermann <
christian.lederm...@gmail.com> wrote:

> i'd recommend bugbear and bandit, but afaik they are already in prospector
>
> On Wed, 6 Jul 2022 at 06:16, Ram  wrote:
>
>> Hi,
>>
>> We have tried Prospector tool: https://prospector.landscape.io/en/master/
>>
>> and got the following result
>>
>>
>> Check Information
>>> =
>>>  Started: 2022-07-05 20:29:59.548372
>>> Finished: 2022-07-05 20:38:58.411776
>>>   Time Taken: 538.86 seconds
>>>Formatter: grouped
>>> Profiles: default, no_doc_warnings, no_test_warnings,
>>> strictness_medium, strictness_high, strictness_veryhigh, no_member_warnings
>>>   Strictness: None
>>>   Libraries Used: django, celery
>>>Tools Run: dodgy, mccabe, profile-validator, pycodestyle,
>>> pyflakes, pylint
>>>   Messages Found: 17186
>>
>>
>> but wondering if you guys use any other better tools than this. Our goal
>> is find out gaps and error from the following items:
>>
>> 1. Security scanning
>> 2. Static code analysis
>> 3. Vulnerabilities scanning
>>
>> Best regards,
>> ~Ram
>>
>>
>>
>>
>> --
>> 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/CA%2BOi5F17JJhVcAa5WY3gGSLX%3Db5qOhbK%3D2LeRBngtKsxvKiogw%40mail.gmail.com
>> 
>> .
>>
>
>
> --
> Best Regards,
>
> Christian Ledermann
>
> Galway, IE
> Mobile : +353 (0) 899748838
>
> https://www.linkedin.com/in/christianledermann
> https://github.com/cleder/
>
>
> <*)))>{
>
> If you save the living environment, the biodiversity that we have left,
> you will also automatically save the physical environment, too. But If
> you only save the physical environment, you will ultimately lose both.
>
> 1) Don’t drive species to extinction
>
> 2) Don’t destroy a habitat that species rely on.
>
> 3) Don’t change the climate in ways that will result in the above.
>
> }<(((*>
>
> --
> 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/CABCjzWqy%2Brx1mzEtJeNgM80%2Bf_uaFs-GrV-n_pz1%3D4hZeXDO6A%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/CA%2BOi5F1VCPL6GYk3JTA9nApuFFdcNeFKwKFSPdEQUW-%2BZ7ap3g%40mail.gmail.com.


AttributeError at /invoice/add_invoice/ 'int' object has no attribute '_meta' while using in_bulk

2022-07-10 Thread Kiran Chavan
I want to convert the model instances into a JSON object and then pass it 
to the HTML file. However, I get an AttributeError at this line:
`data = serializers.serialize("json", Inventory.objects.in_bulk())`

The full `views.py`:

def add_invoice(request):
  form = InvoiceForm(request.POST or None)
  data = serializers.serialize("json", Inventory.objects.in_bulk())
  total_invoices = Invoice.objects.count()
  queryset = Invoice.objects.order_by('-invoice_date')[:6]

  if form.is_valid():
form.save()
messages.success(request, 'Successfully Saved')
return redirect('/invoice/list_invoice')
  context = {
"form": form,
"title": "New Invoice",
"total_invoices": total_invoices,
"queryset": queryset,
"data": data,
  }
return render(request, "entry.html", context)

The Javascript code:

{{ data|json_script:"hello-data" }}

const data = 
JSON.parse(document.getElementById('hello-data').textContent);

document.getElementById('id_line_one').onchange = function(event){
document.getElementById('id_line_one_unit_price').value = 
data[event.target.value].fields.amount;
};



`models.py`:



class Inventory(models.Model):
  product_number = models.IntegerField(primary_key=True)
  product = models.TextField(max_length=3000, default='', blank=True, 
null=True)
  title = models.CharField('Title', max_length=120, default='', 
blank=True, unique=True)
  amount = models.IntegerField('Unit Price', default=0, blank=True, 
null=True)
  
  def __str__(self):
return self.title

How can I pass that JSON object and assign the amount value to the text 
field according to the object selected in the dropdown? Thanks
[image: Screenshot 2022-07-09 232808.jpg]

-- 
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/6176f7fe-9f50-4380-b044-3e46f2219c8fn%40googlegroups.com.


Uncaught TypeError: data.find is not a function

2022-07-10 Thread Kiran Chavan
I am trying to convert the model instances into a JSON object and then 
according to the value selected in the dropdown menu, I want to assign its 
amount to the `line_one_unit_price` text field in the form.

Javascript code:

{{ data|json_script:"hello-data" }}

const data = 
JSON.parse(document.getElementById('hello-data').textContent);

document.getElementById('id_line_one').onchange = function(event){
let elementInData = data.find(() => item.pk == event.target.value);
document.getElementById('id_line_one_unit_price').value = 
elementInData && elementInData.amount ? elementInData.amount : 0;
};



I guess, I am getting the error at `data.find` because `.find` is used on 
an array whereas the constant `data` is not an array? How do I convert that 
JSON object into an array? how do I assign the amount of the `title` 
selected in the forms to the `line_one_unit_price`?

[image: Screenshot 2022-07-09 232808.jpg]

When I click some title from the dropdown, I want the amount to be 
displayed in the `Unit Price`.

`views.py`:

def add_invoice(request):
  form = InvoiceForm(request.POST or None)
  data = serializers.serialize("json", Inventory.objects.all())
  total_invoices = Invoice.objects.count()
  queryset = Invoice.objects.order_by('-invoice_date')[:6]

  if form.is_valid():
form.save()
messages.success(request, 'Successfully Saved')
return redirect('/invoice/list_invoice')
  context = {
"form": form,
"title": "New Invoice",
"total_invoices": total_invoices,
"queryset": queryset,
"data": data,
  }
  return render(request, "entry.html", context)

`models.py`:

class Inventory(models.Model):
  product_number = models.IntegerField(primary_key=True)
  product = models.TextField(max_length=3000, default='', blank=True, 
null=True)
  title = models.CharField('Title', max_length=120, default='', 
blank=True, unique=True)
  amount = models.IntegerField('Unit Price', default=0, blank=True, 
null=True)

  def __str__(self):
return self.title

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/5edb2e69-fec9-4140-8658-3f409f795434n%40googlegroups.com.