Open steven-king opened 10 years ago
So we need to follow the instructions and do sections from "creating project" to "play with API". Is that correct?
Yeah - doing everything on that page to create a poll app.
So I just did Part 1 of the Tutorial and went to move on to Part 2 (I setup the settings.py file the way we went through in class instead of the defaults that appear), and when I went to log-in to the admin, I got an error saying that I was using the Sites Framework without having a SITE_ID set. I was able to get around that by commenting out django.contrib.sites in the installed apps, but the admin site isn't styled. Is there something else I need to change in the settings.py file to make sure the styling for that is getting called?
Here are screenshots of my settings.py file and what the admin site looks like.
FIX: In settings.py there needs to be a trailing comma after os.path.join(PROJECT_ROOT, 'static_media') in the STATICFILES_DIRS
I followed the class instructions and tried following the link's instructions and ended up having the directories in different places. Can someone help? I'm pretty confused right now...
Hi guys:
I am really stuck with the assignment. I look over the part 1 and understand pretty well what is going on. However, it seems that I have trouble implementing the steps on my computer.
I have created a new virtual environment called assignment-env Then I activate the assignment-env After that, I run the command pip install Django==1.6. (The tutorial is for 1.6) Next, I set up a project called mysite just as the part 1 instruction states Then, I try to run the command python manage.py syncdb.
However, I can't get this command to work. I refer back to the class slides for help and didn't see I did anything wrong. I also tried to install different version of Django and it still doesn't work.
Can anyone help me. I am running Ubuntu.
@duanyang Your file structure should look like this.
Yu can move them using the OS or you can and should do it by using the mv [what] [to]
@epait Thanks for helping and sharing!
@duanyang Make sure that you're in the mysite directory (while in your venv before trying to run the syncdb command.
(mysite-env)$ cd mysite (mysite-env) mysite $ python manage.py syncdb
@shawannewang Make sure that you're in the right directory when you're running commands.
$ cd DJANGO_PROJECTS DJANGO_PROJECTS $ virtualenv mysite-env DJANGO_PROJECTS $ . mysite-env/bin/activate (mysite-env) DJANGO_PROJECTS $ pip install django (mysite-env) DJANGO_PROJECTS $ django-admin.py startproject mysite (mysite-env) DJANGO_PROJECTS $ cd mysite (mysite-env) mysite $ …
Also, sometimes in Ubuntu you'll instead run:
(mysite-env) DJANGO_PROJECTS $ django-admin startproject mysite
@caseymm Thanks! It worked up until I tried django-admin startproject mysite. I tried it with and without .py but it keeps saying 'command not found' or this shows up:
'did you mean: Command 'django-admin' from package 'python-django' (main)'
@shawannewang Try this:
sudo ln -s /usr/lib/python2.7/dist-packages/django/bin/django-admin.py /usr/local/bin/django-admin.py
http://wecanrify.wordpress.com/2012/07/05/installing-the-django-framework-on-ubuntu-12-04-3/
@caseymm
It ran (I entered the code and then my password when prompted, so it should've worked), but when I tried django-admin again it still gave me command not found. I tried googling solutions, but most of them seemed to give similar answers which don't work either. Not sure what is up with that...thank you for the help, though! I appreciate it a lot.
Edit: Oh! I figured out why now. I tried django-admin.py --help and it worked totally fine afterwards. hm...
thanks @caseymm
Hi guys:
For part 2 of tutorial, I update admin.py with following codes:
from django.contrib import admin from polls.models import Poll
class PollAdmin(admin.ModelAdmin): fieldsets = [ (None, {'fields': ['question']}), ('Date information', {'fields': ['pub_date']}), ]
admin.site.register(Poll, PollAdmin)
However, when I refresh my webpage, I didn't get the same result as the tutorial states.
The screenshot below shows what I get. Somehow, the phrase "Date information" doesn't show up as it suppose to. Does anyone get similar problem?
The code you provided is displaying properly. I am not sure where you are in the tutorial but if you are trying to do this: https://docs.djangoproject.com/en/dev/_images/admin07.png Then then you should be viewing a different page. Look at the bread crumbs. pools->question. Let me know if I am misunderstanding or let me see better where you are in the tutorial.
Hi guys:
I am currently doing the section "Use generic views: Less code is better" on https://docs.djangoproject.com/en/1.6/intro/tutorial04/
I follow the instruction and make necessary change.
However, I get the following message when I try to run the poll (127.0.0.1:800/polls/1)
Does anyone know what is going on?
It would be a lot easier to help if you also posted your code, but since the error is saying DetailView must be called with a pk or slug, it looks like you might have skipped over changing 'poll_id' to 'pk' in your urls.py file for DetailView and ResultsView since "The DetailView generic view expects the primary key value captured from the URL to be called "pk", so we’ve changed poll_id to pk for the generic views.".
Do Part 1: https://docs.djangoproject.com/en/1.6/intro/tutorial01/