class AddCurrency(forms.Form):
def __init__(self, server, *args, **kwargs):
super(AddCurrency, self).__init__(*args, **kwargs)
self.fields['server'].queryset = server
self.fields['availability'].error_messages = {
'invalid': _('Неверное количество.'),
'min_value': _('Неверное количество.'),
'max_value': _('Неверное количество.'),
}
self.fields['price'].error_messages = {
'invalid': _('Неверная цена.'),
'min_value': _('Неверная цена.'),
'max_value': _('Неверная цена.'),
}
server = forms.ModelChoiceField(queryset=None, empty_label=None, required=False,
widget=forms.CheckboxInput(attrs={'type': 'checkbox'}))
price = forms.DecimalField(required=False, decimal_places=None, min_value=0, max_value=10000000.00,
widget=forms.TextInput(attrs={}))
availability = forms.IntegerField(required=False, min_value=0, max_value=10000000,
widget=forms.TextInput(attrs={}))
class Sell(models.Model):
class Meta:
abstract = True
owner = models.ForeignKey('Customer', default=1, blank=True, verbose_name='Продавец', on_delete=models.CASCADE)
games = models.ForeignKey(Games, blank=True, verbose_name='Игра', on_delete=models.CASCADE)
server = models.ForeignKey(Servers, blank=True, default=1, verbose_name='Сервер', on_delete=models.CASCADE)
price = models.DecimalField(verbose_name='Цена в $', null=True, decimal_places=2, max_digits=10, blank=True)
date = models.DateField("Дата создания", auto_now=False, blank=True, null=True)
availability = models.PositiveIntegerField(verbose_name='Наличие', null=True, blank=True)
price_eur = models.DecimalField(verbose_name='Цена в Евро', null=True, decimal_places=2, max_digits=10, blank=True)
price_rub = models.DecimalField(verbose_name='Цена в Рубли', null=True, decimal_places=2, max_digits=10, blank=True)
def __str__(self):
return f'{self.owner}'
def save(self, *args, **kwargs):
self.price_eur = Round(self.price * Decimal(currency_conversion_eur), 2)
self.price_rub = Round(self.price * Decimal(currency_conversion_rub), 2)
super().save(*args, **kwargs)
class Currency(Sell):
class Meta:
verbose_name = "Игровая валюта(Продажа)"
verbose_name_plural = "Игровая валюта(Продажа)"
ordering = ('-availability',)
class FilterServerForm(forms.ModelForm):
def __init__(self, servers_currency, *args, **kwargs):
super(FilterServerForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_class = 'form_server_currency'
self.helper.form_method = 'post'
self.helper.form_action = reverse('games_detail', kwargs={'sale_announcement': self.instance.pk})
self.helper.help_text_inline = True
self.helper.html5_required = True
self.fields['name'].queryset = servers_currency
self.fields['name'].empty_label = 'Сервер'
name = forms.ModelChoiceField(queryset=Servers.objects.all(), label=False, empty_label=None, required=False)
user_active = forms.BooleanField(label=False, required=False)
class Meta:
model = Games
fields = '__all__'
Traceback (most recent call last):
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\asgiref\sync.py", line 482, in thread_handler
raise exc_info[1]
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\django\core\handlers\exception.py", line 42, in inner
response = await get_response(request)
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\django\core\handlers\base.py", line 253, in _get_response_async
response = await wrapped_callback(
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\asgiref\sync.py", line 444, in __call__
ret = await asyncio.wait_for(future, timeout=None)
File "C:\Users\Vitaliy\AppData\Local\Programs\Python\Python39\lib\asyncio\tasks.py", line 440, in wait_for
File "C:\Users\Vitaliy\PycharmProjects\Funpay\funpay\Pay\forms.py", line 25, in __init__
self.helper.form_action = reverse('games_detail', kwargs={'sale_announcement': self.instance.pk})
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\django\urls\base.py", line 88, in reverse
return resolver._reverse_with_prefix(view, prefix, *args, **kwargs)
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\django\urls\resolvers.py", line 802, in _reverse_with_prefix
raise NoReverseMatch(msg)
django.urls.exceptions.NoReverseMatch: Reverse for 'games_detail' with keyword arguments '{'sale_announcement': None}' not found. 2 pattern(s) tried: ['ru/currency/(?P<sale_announcemen
t>[0-9]+)/\\Z', 'currency/(?P<sale_announcement>[0-9]+)/\\Z']
HTTP GET /ru/currency/1/ 500 [0.12, 127.0.0.1:50888]
class FilterServerForm(forms.ModelForm):
def __init__(self, servers_currency, *args, **kwargs):
super(FilterServerForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_class = 'form_server_currency'
self.helper.form_method = 'post'
self.helper.form_action = reverse('games_detail', kwargs={'sale_announcement': self.instance.pk})
self.helper.help_text_inline = True
self.helper.html5_required = True
self.fields['name'].queryset = servers_currency
self.fields['name'].empty_label = 'Сервер'
name = forms.ModelChoiceField(queryset=Servers.objects.all(), label=False, empty_label=None, required=False)
user_active = forms.BooleanField(label=False, required=False)
class Meta:
model = Games
fields = '__all__'
Traceback (most recent call last):
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\asgiref\sync.py", line 482, in thread_handler
raise exc_info[1]
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\django\core\handlers\exception.py", line 42, in inner
response = await get_response(request)
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\django\core\handlers\base.py", line 253, in _get_response_async
response = await wrapped_callback(
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\asgiref\sync.py", line 444, in __call__
ret = await asyncio.wait_for(future, timeout=None)
File "C:\Users\Vitaliy\AppData\Local\Programs\Python\Python39\lib\asyncio\tasks.py", line 440, in wait_for
File "C:\Users\Vitaliy\PycharmProjects\Funpay\funpay\Pay\forms.py", line 25, in __init__
self.helper.form_action = reverse('games_detail', kwargs={'sale_announcement': self.instance.pk})
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\django\urls\base.py", line 88, in reverse
return resolver._reverse_with_prefix(view, prefix, *args, **kwargs)
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\django\urls\resolvers.py", line 802, in _reverse_with_prefix
raise NoReverseMatch(msg)
django.urls.exceptions.NoReverseMatch: Reverse for 'games_detail' with keyword arguments '{'sale_announcement': None}' not found. 2 pattern(s) tried: ['ru/currency/(?P<sale_announcemen
t>[0-9]+)/\\Z', 'currency/(?P<sale_announcement>[0-9]+)/\\Z']
HTTP GET /ru/currency/1/ 500 [0.12, 127.0.0.1:50888]
Traceback (most recent call last):
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\django\db\backends\utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedTable: ОШИБКА: отношение "Pay_games" не существует
LINE 1: SELECT COUNT(*) AS "__count" FROM "Pay_games"
^
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Vitaliy\PycharmProjects\Funpay\Funpay\manage.py", line 22, in <module>
main()
File "C:\Users\Vitaliy\PycharmProjects\Funpay\Funpay\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line
utility.execute()
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\django\core\management\__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\django\core\management\base.py", line 414, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\django\core\management\base.py", line 455, in execute
self.check()
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\django\core\management\base.py", line 487, in check
all_issues = checks.run_checks(
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\django\core\checks\registry.py", line 88, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\django\core\checks\urls.py", line 14, in check_url_config
return check_resolver(resolver)
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\django\core\checks\urls.py", line 24, in check_resolver
return check_method()
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\django\urls\resolvers.py", line 480, in check
for pattern in self.url_patterns:
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\django\utils\functional.py", line 49, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\django\urls\resolvers.py", line 696, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\django\utils\functional.py", line 49, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\django\urls\resolvers.py", line 689, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\Vitaliy\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "C:\Users\Vitaliy\PycharmProjects\Funpay\Funpay\Funpay\urls.py", line 9, in <module>
path('', include('Pay.urls')),
File "C:\Users\Vitaliy\PycharmProjects\Funpay\venv\lib\site-packages\django\urls\conf.py", line 38, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\Vitaliy\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "C:\Users\Vitaliy\PycharmProjects\Funpay\Funpay\Pay\urls.py", line 3, in <module>
from .views import (
File "C:\Users\Vitaliy\PycharmProjects\Funpay\Funpay\Pay\views.py", line 15, in <module>
from .utils import (
File "C:\Users\Vitaliy\PycharmProjects\Funpay\Funpay\Pay\utils.py", line 1, in <module>
from .forms import FilterServerForm, ProfileForm, AddAll, SearchForm, LoginUserForm
File "C:\Users\Vitaliy\PycharmProjects\Funpay\Funpay\Pay\forms.py", line 221, in <module>
django.db.utils.ProgrammingError: ОШИБКА: отношение "Pay_games" не существует
LINE 1: SELECT COUNT(*) AS "__count" FROM "Pay_games"
^