Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • May 16 2015 16:59
    olasitarska commented #362
  • May 16 2015 16:59

    olasitarska on master

    Making post_detail.html more co… Merge pull request #362 from ve… (compare)

  • May 16 2015 16:59
    olasitarska closed #362
  • May 16 2015 16:57
    kvbik commented #362
  • May 16 2015 16:51
    veuu opened #362
  • May 16 2015 15:20
    hjwp commented #361
  • May 16 2015 15:16
    hjwp synchronize #361
  • May 16 2015 15:15
    hjwp synchronize #361
  • May 16 2015 15:12
    bmispelon commented #361
  • May 16 2015 15:08
    hjwp opened #361
  • May 16 2015 14:58
    bmispelon opened #360
  • May 16 2015 13:15
    bmispelon commented #359
  • May 16 2015 13:15

    bmispelon on master

    Provide alternative runserver c… Merge pull request #359 from Al… (compare)

  • May 16 2015 13:15
    bmispelon closed #359
  • May 16 2015 13:14
    keimlink commented #359
  • May 16 2015 13:13
    olasitarska commented #359
  • May 16 2015 13:09
    bmispelon commented #359
  • May 16 2015 11:53
    Almad opened #359
  • May 15 2015 20:00
    bmispelon commented #358
  • May 15 2015 19:59

    bmispelon on master

    fixing broken github link Merge pull request #358 from gs… (compare)

Power Pfft!
@powerpfft98
Got it... import mymodule
Power Pfft!
@powerpfft98
Another question.
Where is builtin sum function defined?
If i'm making another sum function with the same name, then how do I get the builin sum function?
Raphael Das Gupta
@das-g
You can access it through the builtins module, I think. See https://docs.python.org/3/library/builtins.html
Raphael Das Gupta
@das-g
Yeah, I've just tried it. That works.
Aiaulym
@Aiaulym
Hi! I have some problems please help me! My problem is why my local website is different than my website in pythonanywhere?
Did I something wrong?
Raphael Das Gupta
@das-g
Different in what way? Different content is normal and expected, as they have separate databases. The functionality and the theme should be the same though, if the revision (source code version) is in sync.
Aiaulym
@Aiaulym
If different content was expected what about posts? I cannot publish my posts through admin in pythonanywhere website or can you tell me how to publish them
Eventually I do not know how to work with website in pythonanywhere
and again there's no way to host my local site?
Raphael Das Gupta
@das-g

The idea is that you enter posts locally for testing your blog software. (Its functionality, its look and feel, etc.) Locally entered posts are thus not meant for publication - they allow you to play around without defacing your public website with for-testing-gibberish.

The website on pythonanywhere is your public blog. Posts you enter there are visible to the general public once published. Just like locally, there's two ways to enter posts on pythonanywhere:

  • in the interactive Django Python console (but you have to start it in the bash shell on the PythonAnywhere account website instead of in your local terminal)
  • through the Django admin web backend interface (add /admin to the address of your PythonAnywhere blog address. So in your case https://aiaulymr.pythonanywhere.com/admin )
    • for being able to log in there, you'll need to have created a "superuser" in the database on PythonAnywhere, too. If you haven't yet, create one with python manage.py createsuperuser in the PythonAnywhere bash shell. See this section of the tutorial.)
Aiaulym
@Aiaulym
Thank you but I already wrote a post in admin but it wasn't published on the web-page sorry but do you know what exactly I am doing wrong?
Raphael Das Gupta
@das-g
I don't know, but I can try to guess:
  • Did you set the publication date? If not the post will be considered unpublished and not yet displayed on the blog.
  • Is that publication date in the past? If not the post will be considered not-yet-published and not yet displayed on the blog.
Aiaulym
@Aiaulym
Oh thanks I suppose i forgot about pub date
:)
Raphael Das Gupta
@das-g
:smile:
Power Pfft!
@powerpfft98

You can access it through the builtins module, I think. See https://docs.python.org/3/library/builtins.html

I want to access it with an override
e.g.

from builtins import sum as addition

print(addition([1, 2, 3]))

Something like this is what I want to do @das-g

Raphael Das Gupta
@das-g
I believe that should work. (Except that addition is a horribly misleading name for builtins.sum.)
And such an alternative name is AFAIK called an "alias", not an "override". ("override" has a different meaning in programming and is used e.g. in Java.)
Power Pfft!
@powerpfft98

Thanks @das-g
Will call it 'alias' ^^
This is just my beginning :blush:

from builtins doesn't work. It shows the following error

>>> from builtins import sum as add
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'builins'

Looks like builtins is not a module :smiley:
How else do I alias the built-in sum function?

Raphael Das Gupta
@das-g
That's peculiar. Why does the error message say 'builins' (without t) when you typed "builtins" (with t)?
AnonZebra
@AnonZebra
It's generally better not to define functions with the same as builtin functions - find another name for the new function you want to create instead. Defining functions with the same name as builtin functions makes your code harder to use for others, and if you build on it there's a huge risk that you'll accidentally use the wrong function (e. g. if you forget that sum() now refers to your own custom function). So for the sake of your own learning, please don't do that m( )m But, for the sake of learning about modules - a better way to refer to a specific function from a package is by importing the package and then calling that package's function by using <package>.<function> - see this link for how that would work with sum: https://dpaste.de/Sg3j#L2
**"with the same name as...". Oh and Power Pfft!, make sure you're using python 3 (e. g. the latest version of Python, 3.7.4). Using the code snippet I linked doesn't work in python 2 (which is used by default in Mac OX's Terminal, if you're on a Mac - you have to start commands with "python3" to use python 3). And yes like Raphael wrote, make sure there's no typo, like in 'builins'.
AnonZebra
@AnonZebra
Using Python 3 is always a good idea anyhow, since that's what almost everyone uses now, and Python 2 won't be officially maintained for much longer from what I gather. Anyway good luck Pythoning :D
Raphael Das Gupta
@das-g
Looks like Gunicorn isn't available on Windows. According to https://stackoverflow.com/q/11087682/674064, waitress may be an alternative.
minasong621
@minasong621

Hi! I'm in trouble like the below. How can I fix this?
(myvenv) C:...>python manage.py migrate
System check identified some issues:

WARNINGS:
?: (2_0.W001) Your URL pattern '^admin/' has a route that contains '(?P<', begins with a '^', or ends with a '$'. This was likely an oversight when migrating to django.urls.path().
Operations to perform:
Apply all migrations: admin, auth, blog, contenttypes, sessions
Running migrations:
No migrations to apply.

Piotr Niełacny
@LTe
@minasong621 it looks your are using old version of django. Can you localize method in urls.py that contains this admin thingy
In order to use regular expression try to use re_path instead of path method
minasong621
@minasong621
@LTe Thanks a lot! I'll try what you said! :)
pooya
@pooya1919

Traceback (most recent call last):
File "C:\Users\Com21\PycharmProjects\untitled2\venv\lib\site-packages\django\db\backends\utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "C:\Users\Com21\PycharmProjects\untitled2\venv\lib\site-packages\django\db\backends\sqlite3\base.py", line 305, in execute
return Database.Cursor.execute(self, query, params)
sqlite3.IntegrityError: NOT NULL constraint failed: auth_user.last_login

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\Com21\PycharmProjects\untitled2\venv\lib\site-packages\django\core\management__init.py", line 371, in execute_from_command_line
utility.execute()
File "C:\Users\Com21\PycharmProjects\untitled2\venv\lib\site-packages\django\core\management\
init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Com21\PycharmProjects\untitled2\venv\lib\site-packages\django\core\management\base.py", line 288, in run_from_argv
self.execute(args, **cmd_options)
File "C:\Users\Com21\PycharmProjects\untitled2\venv\lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 59, in execute
return super().execute(
args, options)
File "C:\Users\Com21\PycharmProjects\untitled2\venv\lib\site-packages\django\core\management\base.py", line 335, in execute
output = self.handle(*args,
options)
File "C:\Users\Com21\PycharmProjects\untitled2\venv\lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 179, in handle
self.UserModel._default_manager.db_manager(database).create_superuser(user_data)
File "C:\Users\Com21\PycharmProjects\untitled2\venv\lib\site-packages\django\contrib\auth\models.py", line 161, in create_superuser
return self._create_user(username, email, password,
extra_fields)
File "C:\Users\Com21\PycharmProjects\untitled2\venv\lib\site-packages\django\contrib\auth\models.py", line 144, in _create_user
user.save(using=self._db)
File "C:\Users\Com21\PycharmProjects\untitled2\venv\lib\site-packages\django\contrib\auth\base_user.py", line 73, in save
super().save(args, **kwargs)
File "C:\Users\Com21\PycharmProjects\untitled2\venv\lib\site-packages\django\db\models\base.py", line 729, in save
force_update=force_update, update_fields=update_fields)
File "C:\Users\Com21\PycharmProjects\untitled2\venv\lib\site-packages\django\db\models\base.py", line 759, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "C:\Users\Com21\PycharmProjects\untitled2\venv\lib\site-packages\django\db\models\base.py", line 842, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "C:\Users\Com21\PycharmProjects\untitled2\venv\lib\site-packages\django\db\models\base.py", line 880, in _do_insert
using=using, raw=raw)
File "C:\Users\Com21\PycharmProjects\untitled2\venv\lib\site-packages\django\db\models\manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(
args, **kwargs)
File "C:\Users\Com21\PycharmProjects\untitled2\venv\lib\site-packages\django\db\models\query.py", line 1128, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "C:\Users\Com21\PycharmProjects\untitled2\venv\lib\site-packages\django\db\models\sql\compiler.py", line 1285, in execute_sql
cursor.execute(sql, params)
File "C:\Users\Com21\PycharmProjects\untitled2\venv\lib\site-packages\django\db\backends\utils.py", line 100, in execute
return super().execute(sql, params)
File "C:\Users\Com21\PycharmProjects\untitled2\venv\lib\site-packages\django\db\backends\utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "C:\Users\Com21\PycharmProjects\untitled2\venv\lib\site-packages\django\db\backends\utils.py", line 77, in _execute_wit

@pooya1919 how i solve this problem?
Voodlaz
@Voodlaz
can send me the open source of the website?
pls
Piotr Niełacny
@LTe
@pooya1919 your database is inconsistent, try to recreate database from scratch if you can
pooya
@pooya1919
@LTe thanks a lot
rohitam
@rohitam
Hi
Piotr Niełacny
@LTe
Hi
mmichaud3
@mmichaud3
The people there say “Looks like your wsgi file is not pointing to your django settings file”
Any Advice on how to fix?
Piotr Niełacny
@LTe
@mmichaud3 what is the problem? Can you show error message or what is going on?

In wsgi.py there is os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')

It will take env variable from your system but if there is none it will set mysite.settings in my case. This is mysite directory and settings file in your project directory. Name of your module is probably wrong (?)

mmichaud3
@mmichaud3
2019-09-12 02:22:42,843: Error running WSGI application
2019-09-12 02:22:42,857: NameError: name 'BASE_DIR' is not defined
2019-09-12 02:22:42,857: File "/var/www/mmichaud3_pythonanywhere_com_wsgi.py", line 15, in <module>
2019-09-12 02:22:42,858: application = get_wsgi_application()
2019-09-12 02:22:42,858:
2019-09-12 02:22:42,858: File "/home/mmichaud3/mmichaud3.pythonanywhere.com/myenv/Lib/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2019-09-12 02:22:42,858: django.setup(set_prefix=False)
2019-09-12 02:22:42,858:
2019-09-12 02:22:42,859: File "/home/mmichaud3/mmichaud3.pythonanywhere.com/myenv/Lib/site-packages/django/init.py", line 19, in setup
2019-09-12 02:22:42,859: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2019-09-12 02:22:42,859:
2019-09-12 02:22:42,859: File "/home/mmichaud3/mmichaud3.pythonanywhere.com/myenv/Lib/site-packages/django/conf/init.py", line 79, in getattr
2019-09-12 02:22:42,861: self._setup(name)
2019-09-12 02:22:42,861:
2019-09-12 02:22:42,861: File "/home/mmichaud3/mmichaud3.pythonanywhere.com/myenv/Lib/site-packages/django/conf/init.py", line 66, in _setup
2019-09-12 02:22:42,862: self._wrapped = Settings(settings_module)
2019-09-12 02:22:42,862:
2019-09-12 02:22:42,862: File "/home/mmichaud3/mmichaud3.pythonanywhere.com/myenv/Lib/site-packages/django/conf/init.py", line 157, in init
2019-09-12 02:22:42,862: mod = importlib.import_module(self.SETTINGS_MODULE)
2019-09-12 02:22:42,863:
2019-09-12 02:22:42,863: File "/home/mmichaud3/mmichaud3.pythonanywhere.com/myenv/Lib/site-packages/isort/init.py", line 25, in <module>
2019-09-12 02:22:42,863: from . import settings # noqa: F401
2019-09-12 02:22:42,863:
2019-09-12 02:22:42,864: File "/home/mmichaud3/mmichaud3.pythonanywhere.com/myenv/Lib/site-packages/isort/settings.py", line 359, in <module>
2019-09-12 02:22:42,864: STATIC_ROOT = os.path.join(BASE_DIR, 'static')
2019-09-12 02:22:42,865: *
2019-09-12 02:22:42,865: If you're seeing an import error and don't know why,
2019-09-12 02:22:42,865: we have a dedicated help page to help you debug:
2019-09-12 02:22:42,865: https://help.pythonanywhere.com/pages/DebuggingImportError/
panther101
@panther101
Hi
I am a bit new to Django and am struggling with settings.py to allow other hosts to access my development server running on Windows 10.
I have tried ALLOWED_HOSTS=['*'] to allow all hosts to access the Django. It didn't work.
I have no problem running and accessing on the same server, though.
Any help would be much appreciated. Thank you.
Piotr Niełacny
@LTe
@mmichaud3 you can show your setting.py?
@panther101 it depends also on your DEBUG flag. Based on documentation ALLOWED_HOSTS = ['*'] should be fine but only in case of DEBUG = False. But you can try also add 0.0.0.0. This address means that you will allow to connect from any address IP.