python 3.x – Deploy co django en heroku falla por que no se puede hacer collectstatic con whiteNoise

Hola gracias por su ayuda de antemano

trato de hace un deploy en heroku pero recibo el siguiete error y no tengo idea de que es lo que pasa les agradeceria mucho su ayuda:

remote:          webfonts/fa-brands-400.eot
remote:        Please check the URL references in this CSS file, particularly any
remote:        relative paths which might be pointing to the wrong location.
remote:  !     Error while running '$ python collectstatic --noinput'.
remote:        See traceback above for details.
remote:        You may need to update application code to resolve this error.
remote:        Or, you can disable collectstatic for this application:
remote:           $ heroku config:set DISABLE_COLLECTSTATIC=1
remote:  !     Push rejected, failed to compile Python app.

Primer deploy…disculpen mi ignorancia pero no tengo idea de que es ese archivo webfonts/fa-brands-400.eot,por lo que entiendo hace referencia a un archivo que no existe pero como rastreo ese webfonts/fa-brands-400.eot?

python – Display crypto price in a table using django and cryptocompare

I’m trying to make a simple webpage in django where I can display the price of some cryptocurrencies. The user stores in the database the name of the crypto and its initial price. Then I want to fill a table with the ticker and the initial price taken from the database and the current price of each crypto taken with cryptocompare.

This is where the problem begin: the value of ‘current price’ is taken using cryptocompare, but how can I dinamycally display the value of the current price of each crypto in the table? Maybe the problem is easy to solve but I’m really new and I’m stuck, thanks in advance!
If you need more information ask me!

This is how the table in the index look like. I need to fill the last column with the daily price of the crypto
enter image description here

from django.db import models

# Create your models here.
class crypto(models.Model):
    ticker = models.CharField(max_length=200)
    initial_price = models.FloatField()

    def __str__(self):
        return self.ticker

from .models import crypto

def index_view(request):
    chart = FuncAnimation(plt.gcf(), animate, interval=1000)
    ticker_list = crypto.objects.all()
    return render(request, 'cryptochart/index.html', {'chart': chart, 'ticker_list': ticker_list})

and last, in a file called I wrote the functions to get the price

import cryptocompare
#get price of cryptocurrency
def get_crypto_price(cryptocurrency,currency):
    return cryptocompare.get_price(cryptocurrency,currency=currency)(cryptocurrency)(currency)

#get fullname of the cryptocurrency
def get_crypto_name(cryptocurrency):
    return cryptocompare.get_coin_list()(cryptocurrency)('FullName') 


<table style="width: 100%;">
            <th>Prezzo Iniziale</th>
            <th>Prezzo Giornaliero</th>                
        {% if ticker_list %}
        {% for ticker in ticker_list%}
        {% endif %}

django – Best Practice: Should cascading updates be handled by the frontend or the REST API?

I am designing a timesheet app for logging user tasks using React for frontend and Django REST Framework for backend. The database is PostgreSQL and I have a table for recording the tasks with 4 columns: date, start_time, duration, description.

I need a way to support the updating of a task after the user had created several. The problem is that each task is dependent on all the previous tasks, since its start_time will change if the duration of a task before it changes. So for example, suppose that task 1 has a start_time of 13:00 and a duration of 1 hour, task 2 has a start_time of 14:00 and a duration of 1 hour, and so on. If the user decided to update the duration of task 1 from 1 hour to 2 hours, that means the start_time of task 2 and all subsequent tasks must be increased by 1 hour.

I’m wondering what is the best way to implement such cascading updates. First option is to make the API backend responsible for it, so whenever the React frontend sends out a PUT request for a task, the DRF backend will not only update that task but also all subsequent tasks as well. Second option is to offload everything to the React frontend, making it responsible for sending out multiple PUT requests, for the updated task as well as all subsequent tasks.

I would think the first option of letting the backend handles everything is a better design, since this problem is technically a form of database constraint. But not too sure if it is appropriate for a REST API to handle. What would be the best practice in this case?

python – TypeError: contact() got an unexpected keyword argument ‘name’ -why I get such error in django?

Hello I am learning django framework for web development. After makemigrations and migrate command I did runserver command hence I got the following error.

File “D:learn”, line 21, in
TypeError: contact() got an unexpected keyword argument ‘name’
(06/Jun/2021 15:08:25) “POST /contact HTTP/1.1” 500 64573

from django.shortcuts import render
from home.models import contact

# Create your views here.
def home(request):
    return render(request, 'home.html')

def about(request):
    return render(request, 'about.html')

def projects(request):
    return render(request, 'projects.html')

def contact(request):
    if request.method=="POST":
        print('the deta has been written to the db')
    return render(request, 'contact.html')

”’ file”’

from django.db import models

# Create your models here.
class contact(models.Model):
    name = models.CharField(max_length=30)
    email = models.EmailField(max_length=50, null='True')
    phone = models.CharField(max_length=10)
    desc = models.TextField()

security – How can I stop the macOS firewall from blocking Django server (Python)?

For several years I have been regularly using Python’s Django framework and running its web server for development purposes on my local machine. I took a break over the past year and am now returning to Django after upgrading my Mac to Big Sur in the interim. However, the firewall is now blocking my Django server and I can’t figure out how to fix this.

I have verified that the firewall is indeed the issue. If I try to issue a request to the Django server from another computer on the network, the request will time out if the firewall is active. If I disable the firewall, the same request will succeed.

I have gone into System Preferences -> Firewall -> Firewall Options. The python binary from my project’s venv/bin directory was added to the list in Firewall Options and had Allow Incoming Connections enabled. I tried removing it from this list as well, in the hopes of forcing a new system prompt to allow incoming connections, but that has not worked and now python is not listed under the Firewall Options list of applications. I cannot add it back into the list either.

I’m at a bit of a loss for what to do here. It used to work fine, but since updating my macOS version, something has been changed that is causing the firewall to block incoming connections to the Django server.

django – why coverage report differs according to how I execute it

I am writing a django app. I am trying unittest and pytest with coverage. And depending on how I run tests, I get different coverage report.

Relevant Code

I have this in , a runner for pytest:

class PytestTestRunner(UnManagedModelTestRunner):
    def __init__(self, verbosity=1, failfast=False, keepdb=False, **kwargs):
        self.verbosity = verbosity
        self.failfast = failfast
        self.keepdb = keepdb
    def run_tests(self, test_labels):
        """Run pytest and return the exitcode.
        It translates some of Django's test command option to pytest's.
        import pytest
        argv = ()
        if self.verbosity == 0:
        if self.verbosity == 2:
        if self.verbosity == 3:
        if self.failfast:
        if self.keepdb:
        return pytest.main(argv)

TEST_RUNNER = "settings_test.UnManagedModelTestRunner"

And also this script to run tests:

USAGE = """
python         (will run unittest suite)
python unittest      (will run unittest suite)
python pytest      (will run pytest suite + coverage)

    'pytest': 'testapp.settings_test.PytestTestRunner',               # pytest
    'unittest': 'testapp.settings_test.UnManagedModelTestRunner',     # unittest

if __name__ == "__main__":
    os.environ('DJANGO_SETTINGS_MODULE') = 'testapp.settings_test'

    # Get argument to decide which test suite to run.
    arguments = sys.argv(1:)
    arg = arguments(0) if 0 < len(arguments) else "unittest"
    runner = TEST_RUNNERS_MAP(arg)

    TestRunner = get_runner(settings, test_runner_class=runner)
    test_runner = TestRunner()
    failures = test_runner.run_tests(("unit_tests"))

Test runs

$ pytest

Name                                                 Stmts   Miss Branch BrPart  Cover   Missing
api/                                   4      0      0      0   100%
api/models/                25     10      2      0    56%   14,28,31
api/models/                     11      0      0      0   100%
api/models/       6      0      0      0   100%
api/                                 5      0      0      0   100%
api/serializers/                6      6      0      0     0%   1-9
api/                                   5      5      0      0     0%   1-7
api/views/                   55     55     10      0     0%   1-123
api/views/                      6      6      0      0     0%   1-9
TOTAL                                                  123     82     12      0    30%

FAIL Required test coverage of 100.0% not reached. Total coverage: 30.37%

I think with the next one the only difference is urls file.

$ coverage run unittest
$ coverage report

Name                                                 Stmts   Miss Branch BrPart  Cover   Missing
api/                                   4      0      0      0   100%
api/models/                25     10      2      0    56%   14,28,31
api/models/                     11      0      0      0   100%
api/models/       6      0      0      0   100%
api/                                 5      0      0      0   100%
api/serializers/                6      6      0      0     0%   1-9
api/                                   5      0      0      0   100%
api/views/                   55     55     10      0     0%   1-123
api/views/                      6      6      0      0     0%   1-9

But if I run pytest from the script. Most of them are at 0%

$ python pytest

Name                                                 Stmts   Miss Branch BrPart  Cover   Missing
api/                                   4      4      0      0     0%   1-6
api/models/                25     25      2      0     0%   1-57
api/models/                     11     11      0      0     0%   1-14
api/models/       6      6      0      0     0%   1-13
api/                                 5      0      0      0   100%
api/serializers/                6      6      0      0     0%   1-9
api/                                   5      5      0      0     0%   1-7
api/views/             55     55     10      0     0%   1-123
api/views/                      6      6      0      0     0%   1-9
TOTAL                                                  123    118     12      0     4%

FAIL Required test coverage of 100.0% not reached. Total coverage: 3.70%

django – TemplateView looks for the template in a different place than ListView / DetailView / CreateView?

So I’m trying to show the homepage template with templateView but it confused me a lot. Right now I have 3 apps (main, users, polls). With the following structure:

├── main
│   └── ...
├── (Project Folder)
│   └── ...
├── polls
│   └── ...
├── users
│   └── ...
└── templates
    ├── main
    │     └── ...
    ├── polls
    │     └── ...
    └── base.html (for extends)

I already have some views from polls working (CreateView, ListView, DetailView). I know that the templates for default are searched inside the app folder but I changed it to have it at the level of the apps as you can see above.

But with this new app (main) where I have the index view, it doesn’t work the same. The index.html is searched in templates/index.html and not in templates/main/index.html. Why with the polls app works by having a folder with the app name inside templates but with main don’t work like that?

        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': (os.path.join(BASE_DIR, 'templates')),
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': (


# Django imports
from django.views.generic import TemplateView

class Index(TemplateView):
    template_name = 'index.html'


from django.contrib import admin
from django.urls import path, include

urlpatterns = (
    path('', include('main.urls')),
    path('', include('users.urls')),
    path('', include('polls.urls')),

django – Cadastrando um produto e tentando gravar o preço médio

Fico grato pela ajuda, estou querendo cadastrar uma compra de um produto e logo calcular o preço médio.


def compras_produtos(request):
    form = ComprasForm(request.POST or None)
    if form.is_valid():
        return redirect('compras_produtos')
    return render(request, 'cadastra_compras.html', {'form': form})


class Produto(models.Model):
    nome_produto = models.CharField(max_length=100, unique=True, verbose_name='nome')

    class Meta:
        db_table = 'produto'

    def __str__(self):
        return self.nome_produto

class Compra_Produto(models.Model):
    produto = models.ForeignKey(Produto, on_delete=models.CASCADE, verbose_name='Produto')
    quantidade = models.IntegerField(blank=False, null=True, verbose_name='Quantidade')
    valor_produto = models.DecimalField(max_digits=10, decimal_places=2, blank=False, null=True, verbose_name='Preço')
    valor_medio = models.DecimalField(max_digits=10, decimal_places=2, verbose_name='Preço Médio')

    class Meta:
        db_table = 'compra'

    def __str__(self):
        return self.produto

python – Mostrar imagen y texto en django

tengo el siguiente codigo, en una funcion en el archivo que me envia una imagen y una cadena de texto a un html para mostrarlos a ambos:

img = None
    with open(camino, "rb") as archivo_imagen:
        img = base64.b64encode('utf-8')
    context = {'imagen': img, 'texto': resultado}
    return render(request, 'plantillas/barra.html', context)

este es el codigo donde debe mostrarme la imagen y la cadena de texto:

    {% if imagen %}
        <img src="data:image/png,base64, {{ imagen }}">
    {% endif %}

mi problema es que al devolver el html este no me aparece la imagen, solo me aparece un icono indicando que hay una imagen, ademas el texto me aparece todo junto y pegado ademas de visualizar la etiquetas html como el “br”, como puedo corregir este error?

este es un ejemplo de como se ve la vista del html:

introducir la descripción de la imagen aquí

django – error code=H10 desc=”App crashed” method=GET I Have Installed Gunicorn But Its Showing Error

django – error code=H10 desc=”App crashed” method=GET I Have Installed Gunicorn But Its Showing Error – Stack Overflow

DreamProxies - Cheapest USA Elite Private Proxies 100 Private Proxies 200 Private Proxies 400 Private Proxies 1000 Private Proxies 2000 Private Proxies - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive New Proxy Lists Every Day Proxies123