Django collectstatic error - python

Error:
This will overwrite existing files!
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: yes
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "D:\CODE\wamp\www\AMBIENTES\env\Lib\site-packages\django\core\management\__init__.py", line 459, in execute_manager
utility.execute()
File "D:\CODE\wamp\www\AMBIENTES\env\Lib\site-packages\django\core\management\__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\CODE\wamp\www\AMBIENTES\env\Lib\site-packages\django\core\management\base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "D:\CODE\wamp\www\AMBIENTES\env\Lib\site-packages\django\core\management\base.py", line 232, in execute
output = self.handle(*args, **options)
File "D:\CODE\wamp\www\AMBIENTES\env\Lib\site-packages\django\core\management\base.py", line 371, in handle
return self.handle_noargs(**options)
File "D:\CODE\wamp\www\AMBIENTES\env\Lib\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py", line 163, in handle_noargs
collected = self.collect()
File "D:\CODE\wamp\www\AMBIENTES\env\Lib\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py", line 113, in collect
handler(path, prefixed_path, storage)
File "D:\CODE\wamp\www\AMBIENTES\env\Lib\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py", line 287, in copy_file
if not self.delete_file(path, prefixed_path, source_storage):
File "D:\CODE\wamp\www\AMBIENTES\env\Lib\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py", line 219, in delete_file
self.storage.modified_time(prefixed_path)
File "D:\CODE\wamp\www\AMBIENTES\env\Lib\site-packages\django\core\files\storage.py", line 264, in modified_time
return datetime.fromtimestamp(os.path.getmtime(self.path(name)))
ValueError: timestamp out of range for platform localtime()/gmtime() function
(env) D:\CODE\wamp\www\lezcheung\lezcms>
Anyone know help me?

This looks like it's caused by files being collected by collectstatic having outrageously inaccurate last modified timestamps (like before 1970). Try searching google for tools that allow you to modify your files' last modified dates and change them to something reasonable.

I discoreved.
This is just cause I put some fonts in /static/fonts/ and the django don't accept fonts on Static Folder. So, i changed this files to /media/fonts/.
Worked! :D

Related

insufficient output in Traceback of python execution

How to further troubleshoot Django issue where only built-in package files are listed in traceback output, instead of those user-created files, which does not tell what is wrong in the *.py files I created.
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 393, in execute
self.check()
File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 423, in check
databases=databases,
File "/usr/local/lib/python3.7/site-packages/django/core/checks/registry.py", line 76, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "/usr/local/lib/python3.7/site-packages/wagtail/admin/checks.py", line 83, in inline_panel_model_panels_check
errors.extend(check_panels_in_model(cls))
File "/usr/local/lib/python3.7/site-packages/wagtail/admin/checks.py", line 110, in check_panels_in_model
context='InlinePanel model',
File "/usr/local/lib/python3.7/site-packages/wagtail/admin/checks.py", line 110, in check_panels_in_model
context='InlinePanel model',
File "/usr/local/lib/python3.7/site-packages/wagtail/admin/checks.py", line 110, in check_panels_in_model
context='InlinePanel model',
[Previous line repeated 984 more times]
File "/usr/local/lib/python3.7/site-packages/wagtail/admin/checks.py", line 100, in check_panels_in_model
if hasattr(cls, 'get_edit_handler'):
File "/usr/local/lib/python3.7/site-packages/wagtail/utils/decorators.py", line 29, in __get__
return self[owner]
RecursionError: maximum recursion depth exceeded while calling a Python object
Any thoughts on how to further troubleshoot?
You have not added the code.
Also the code already explained what's happening there. You are using wagtail decorator, you have to check how the decorator method works.
The error starts from last one
File "/usr/local/lib/python3.7/site-packages/wagtail/utils/decorators.py", line 29, in __get__
return self[owner]
I notice your issue is with threading and I guess you handling with large dataset or file.
Here you can increase the rate
import sys, threading
sys.setrecursionlimit(10**7) # max depth of recursion
threading.stack_size(2**27) # new thread will get stack of such size

Can't start test server with python django

I'm new to the Django framework and just trying to create a basic website, but when I try to open the server with the python manage.py runserver I get this error:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Users\siuba\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\siuba\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\siuba\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\siuba\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "C:\Users\siuba\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\base.py", line 369, in execute
output = self.handle(*args, **options)
File "C:\Users\siuba\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "C:\Users\siuba\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\Users\siuba\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 601, in run_with_reloader
exit_code = restart_with_reloader()
File "C:\Users\siuba\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 230, in restart_with_reloader
p = subprocess.run(args, env=new_environ, close_fds=False)
File "C:\Users\siuba\AppData\Local\Programs\Python\Python37\lib\site-packages\run\__init__.py", line 145, in __new__
process = cls.create_process(command, stdin, cwd=cwd, env=env, shell=shell)
File "C:\Users\siuba\AppData\Local\Programs\Python\Python37\lib\site-packages\run\__init__.py", line 121, in create_process
shlex.split(command),
File "C:\Users\siuba\AppData\Local\Programs\Python\Python37\lib\shlex.py", line 310, in split
return list(lex)
File "C:\Users\siuba\AppData\Local\Programs\Python\Python37\lib\shlex.py", line 299, in __next__
token = self.get_token()
File "C:\Users\siuba\AppData\Local\Programs\Python\Python37\lib\shlex.py", line 109, in get_token
raw = self.read_token()
File "C:\Users\siuba\AppData\Local\Programs\Python\Python37\lib\shlex.py", line 140, in read_token
nextchar = self.instream.read(1)
AttributeError: 'list' object has no attribute 'read'
Does anyone know the answer? If so please help!
Thanks
Are you following a tutorial? If so, please share it with us. There may be a problem with your python installation. Please delete all python installations on your computer and install the latest version. Then create django project again.

Error while using inspectdb in Django

I already have an application using PostgreSQL as db. I want to build a service using Django. Tried "inspectdb"... but it is giving an expection:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 342, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.4/dist-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.4/dist-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.4/dist-packages/django/core/management/commands/inspectdb.py", line 25, in handle
for line in self.handle_inspection(options):
File "/usr/local/lib/python3.4/dist-packages/django/core/management/commands/inspectdb.py", line 70, in handle_inspection
constraints = connection.introspection.get_constraints(cursor, table_name)
File "/usr/local/lib/python3.4/dist-packages/django/db/backends/postgresql/introspection.py", line 172, in get_constraints
"foreign_key": tuple(used_cols[0].split(".", 1)) if kind.lower() == "foreign key" else None,
IndexError: list index out of range
Figured out the issue.
Apparently, the db user didn't have sufficient permissions.

Django can't find specific test, but runs it if module is defined

I have some tests in myproject/core/tests/test_views_front.py. When I try to run python manage.py test myproject.core.tests.test_views_front I get:
NOTE: Using test database settings!
NOTE: Logging is disabled!
Traceback (most recent call last):
File "manage.py", line 9, in <module>
execute_from_command_line(sys.argv)
File "/home/ben/.virtualenvs/myproject/local/lib/python2.7/site-packages/django/core/management/__in
it__.py", line 399, in execute_from_command_line
utility.execute()
File "/home/ben/.virtualenvs/myproject/local/lib/python2.7/site-packages/django/core/management/__in
it__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/ben/.virtualenvs/myproject/local/lib/python2.7/site-packages/django/core/management/comm
ands/test.py", line 50, in run_from_argv
super(Command, self).run_from_argv(argv)
File "/home/ben/.virtualenvs/myproject/local/lib/python2.7/site-packages/django/core/management/base
.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/ben/.virtualenvs/myproject/local/lib/python2.7/site-packages/django/core/management/comm
ands/test.py", line 71, in execute
super(Command, self).execute(*args, **options)
File "/home/ben/.virtualenvs/myproject/local/lib/python2.7/site-packages/django/core/management/base
.py", line 285, in execute
output = self.handle(*args, **options)
File "/home/ben/.virtualenvs/myproject/local/lib/python2.7/site-packages/south/management/commands/t
est.py", line 8, in handle
super(Command, self).handle(*args, **kwargs)
File "/home/ben/.virtualenvs/myproject/local/lib/python2.7/site-packages/django/core/management/comm
ands/test.py", line 88, in handle
failures = test_runner.run_tests(test_labels)
File "/home/ben/.virtualenvs/myproject/local/lib/python2.7/site-packages/django/test/runner.py", lin
e 144, in run_tests
suite = self.build_suite(test_labels, extra_tests)
File "/home/ben/.virtualenvs/myproject/local/lib/python2.7/site-packages/django/test/runner.py", lin
e 63, in build_suite
tests = self.test_loader.loadTestsFromName(label)
File "/usr/lib/python2.7/unittest/loader.py", line 100, in loadTestsFromName
parent, obj = obj, getattr(obj, part)
AttributeError: 'module' object has no attribute 'test_views_front'
This also happens if I run python manage.py test myproject.core.tests.test_views_front.FrontPageViewTests. However, if I simply run python manage.py test or python manage.py test myproject.core.tests then all the tests (including the ones in the aforementioned file) run fine. I found this solution but my test file seems to import fine, without any errors or warnings. Is there anything else I might be missing?
You can't run test from a specific file in Django. You can either run all the test from myproject.core.tests like you did or a specific TestCase:
myproject.core.tests.YourTestCase

Python, Django - loaddata issue "RemovedInDjango18Warning"

I have a local python environment working, but when I try and load in initial data.
python manage.py loaddata initial_data.json
I get an error about "RemovedInDjango18Warning"?
I am not a python dev to say - so this error is new to me.
C:\Python27\aasoo>python manage.py loaddata initial_data.json
C:\Python27\lib\site-packages\djorm_pgfulltext\models.py:323: RemovedInDjango18Warning: `SearchManagerMixIn.get_query_set` method should be renamed `get_queryset`.
class SearchManager(SearchManagerMixIn, models.Manager):
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 385, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 338, in execute
output = self.handle(*args, **options)
File "C:\Python27\lib\site-packages\modeltranslation\management\commands\loaddata.py", line 50, in handle
return super(Command, self).handle(*fixture_labels, **options)
File "C:\Python27\lib\site-packages\django\core\management\commands\loaddata.py", line 61, in handle
self.loaddata(fixture_labels)
File "C:\Python27\lib\site-packages\django\core\management\commands\loaddata.py", line 91, in loaddata
self.load_label(fixture_label)
File "C:\Python27\lib\site-packages\django\core\management\commands\loaddata.py", line 142, in load_label
for obj in objects:
File "C:\Python27\lib\site-packages\django\core\serializers\json.py", line 81, in Deserializer
six.reraise(DeserializationError, DeserializationError(e), sys.exc_info()[2])
File "C:\Python27\lib\site-packages\django\core\serializers\json.py", line 75, in Deserializer
for obj in PythonDeserializer(objects, **options):
File "C:\Python27\lib\site-packages\django\core\serializers\python.py", line 122, in Deserializer
m2m_data[field.name] = [m2m_convert(pk) for pk in field_value]
django.core.serializers.base.DeserializationError: Problem installing fixture 'C:\Python27\aasoo\content\fixtures\initial_data.json': 'int' object is not iterable
C:\Python27\aasoo>
You should rename get_query_set to get_queryset in SearchManagerMixIn. Can you paste the definition of the class if you need more help.

Categories