Hi, On 08/11/2015 11:56 AM, [email protected] wrote: > I'm studying the Django Project tutorial > <https://docs.djangoproject.com/en/1.8/intro/tutorial01/> using Python > 2.7 (because that's my department's current standard) and Django 1.8.2 > (because that's the current stable version). > > The tutorial says, "If you are still using Python 2.7, you will need to > adjust the code samples slightly, as described in comments." What > comments does it mean?
Python code comments, in the code samples that need adjusting. The first example I see is in the `polls/models.py` code sample in this section: https://docs.djangoproject.com/en/1.8/intro/tutorial01/#playing-with-the-api See the "__unicode__ on Python 2" comments? > The section "Playing with the API" instructs me to run the command: > > $ python manage.py shell > or >>>> import django >>>> django.setup() > > Being a methodical sort, I tried both. The first works. The second gives > me a bunch of errors, beginning with: > > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File "c:\Python27\lib\site-packages\django\__init__.py", line 17, in setup > configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) > > I think it's complaining about an incompatibility between Python 2.7 and > Python 3.2. Can't say without seeing more of the traceback. I doubt it though, since this only executes code in Django itself, which is fully compatible with both Python 2 and 3. > I can evade the immediate problem by using "python manage.py shell" > instead, but I expect further problems in short order, and I need to > know how to fix them. > > So, where are these "comments" that tell me what to do? I don't see any > in that part of the tutorial. I opened __init__.py, and there are no > helpful comments there, either. You don't need to adjust anything at all in Django itself to adapt to Python 2; Django fully supports both 2 and 3. You just need to make sure that the code you write yourself is Python 2 compatible. Where the tutorial tells you to type some code in a file, it gives the Python 3 version, but has comments showing what needs to be adjusted for Python 2. There's nothing special you need to do until you get to those code samples. > I could figure this out myself, but I can't see debugging my way through > the entire Django codebase. I'm being paid to write an application, not > fix up Django. You don't need to fix up Django. > Either I'm missing the comments that the tutorial promised me, or it has > left me in the lurch. Can someone explain, please? Just continue with the tutorial, and read the code samples (including comments) carefully, when you reach them. Your issue when running `django.setup()` is probably entirely unrelated, but in order to debug it we'd need to see the full traceback. Carl -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/55CA31AA.4040707%40oddbird.net. For more options, visit https://groups.google.com/d/optout.
signature.asc
Description: OpenPGP digital signature

