Satyakam Goswami said:
Work on the beta site by chaning the branch
$git branch
*master
$git checkout course-beta
to list all the available branches
$git branch -a
This course will become read-only in the near future. Tell us at community.p2pu.org if that is a problem.
This task is optional but highly recommended to get comfortable with the development tools. The target dates are optional as well, but task 1 and 2 are required before this task.
Make a change and see what happens locally
Examples of changes to make to test/explore Lernanta and your local installation:
After your change, reload the site on your localhost to make sure tha the change happened. Also, experiment with git if you're not already familiar with it with things like commiting locally then reverting back out of the change. Various cheat sheets.
If you run into problems, check the wiki or ask us by posting a comment here.
Writing Task:
Then, tell your fellow participants how the experimentation went. Post as a comment below or post a comment with a link to your blog post.
Did you run into any problems? Discover anything interesting?
Work on the beta site by chaning the branch
$git branch
*master
$git checkout course-beta
to list all the available branches
$git branch -a
Ho do i add or remove the top level schools and also change the logo ?
Hi Satyakam
To add another top level school, you need to add the school using the admin interface (http://localhost:8000/en/admin).
After you've done that the school will show up on the learn page, but not in the footer. To show the school in the footer you need to update the code in https://github.com/p2pu/lernanta/blob/master/lernanta/apps/schools/templatetags/school_tags.py#L18
Hope that helps
Cheers
Dirk
ok i see the admin site , what is the default username , i do not see any admin user how do i login as admin ?
-Satya
There is no admin user create one by running the command
$./manage.py createsuperuser
-Satya
Hello,
I have a couple of questions on language settings in lernanta.
How does lernanta handle a URL such as "localhost:8000/en" or "localhost:8000/es"?
I noticed that I can change urls from "/en/" to "/es" by changing language preferences in my browser. I also know that Django will use the Accept-Language header to set the current localization. But I am not sure how the lernanta application itself uses this information.
As far as I can see the URL patterns only handle urls such as "localhost:8000/pagename" and not "localhost:8000/en/pagename" or "localhost:8000/en/pagename".
A second question is why translations are not showing up in my local setup even when I change the browser language preference, and/or the LANGUAGE_CODE value in the settings.py file.
According to Django documentation it will load translations from "locale" directory if it is present in the same directory as the "settings.py" file. I have this directory, and there are .mo and .po files in sub-directories of this directory.
Thanks,
Prasanth
Hi Prasanth
Lernanta uses middleware to rewrite the URL according to the HTTP headers
The applicable middleware is i10n.LocaleURLRewriter and is configure in setting.py. It also uses i10n.urlresolvers.Prefixer to determine the language.
As for the second question, I'm not exactly sure? It works on my local host when I manually change the URL.
You shouldn't need to change to LANGUAGE_CODE in setting.py, I think LANGUAGE_CODE just sets the initial value used for new users and new course forms. And probably when the HTTP headers doesn't contain any language info.
Hope that helps a bit.
On my localhost, static files are served properly for URLs starting with "/static" but not for URLs starting with "/en/static". And, it is taking longer to load front page from my local server, than to download the same from p2p2.org.
For example:
$ ./manage.py runserver
Validating models...
0 errors found
Django version 1.3.1, using settings 'lernanta.settings_local'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[04/Jun/2012 03:27:56] "GET /en/ HTTP/1.1" 200 161327
[04/Jun/2012 03:27:56] "GET /static/css/style.css?v=1 HTTP/1.1" 200 4760
[04/Jun/2012 03:27:56] "GET /static/css/batucada.css?v=1 HTTP/1.1" 200 144866
[04/Jun/2012 03:27:56] "GET /static/css/style-en.css?v=1 HTTP/1.1" 200 0
[04/Jun/2012 03:27:57] "GET /en/static/css/jcarousel/tango/skin.css HTTP/1.1" 404 17119
[04/Jun/2012 03:27:58] "GET /en/static/css/font-awesome.css HTTP/1.1" 404 17095
[04/Jun/2012 03:27:59] "GET /en/static/js/libs/prettify/prettify.css HTTP/1.1" 404 17122
"en" is the LANGUAGE_CODE, and I am running code from he current master on github.
I am still learning Django and can't tell how and where the "/en" URLs get generated. I experimented by commenting out 'l10n.middleware.LocaleURLRewriter' middleware in settings.py. But then I get redirected to "archive.p2pu.org". I confirmed that the middleware was disabled by using "./mange.py diffsettings" and by checking "django.conf.settings.MIDDLEWARE_CLASSES" in Django shell.
This raises another question: Does the develpment setting use settings.py or settings_local.py? In "manage.py" file only the latter is imported (if present). Using "./manage.py shell" I inspected os.environ['DJANGO_SETTINGS_MODULE'], and it is set to "lernanta.settings_local". But then how did changes in "settings.py" show up in Django? Is Django automatically reading "settings.py"?
Any help would be appreciated. I did read the Github wiki pages, but couldn't find this information: appologies if I missed something.
Hi Prasanth,
I've noticed the static issue too, it seems to be making a lot more calls since changes around this commit: https://github.com/p2pu/lernanta/commit/0f1706f8665329a1847a8ae56b9471825a94d2a5
Not sure that is intended, as I know little Django too; Dirk can probably clarify that.
The language redirect uses the variable SUPPORTED_NONLOCALES in the settings.py file. If you have a look at the file apps/l10n/urlresolvers.py you will see how it loops on that variable and redirects accordingly.
As far as I know, local settings can override some of the app settings in settings.py, so both files are actually used.
Hope that helps a little! :)
Hi Prasanth
Previously django stored all static files in a single location, normally /media. Recently they decided to split user uploaded files from static files like JavaScript and CSS. I updated Lernanta about two weeks ago and sorted out a bunch of problems, but clearly not everything.
I don't really know why you get accesses to /en/static? On my local host I'm only getting access to /static/ and one access to https://p2pu.org/en/static/member-missing.png. The member-missing.png access happens because profile pictures are loaded from gravatar if they don't have a profile picture specified.
I'll see if I can find anything strange going on, but if you find something in the meantime, please let us know.
Thanks for your input!
I think I figured out what the problem may be!
Is DEBUG set to False in you setting_local.py? When running your code with DEBUG=True runserver automatically sorts out your static files for you. This is just for convenience while developing. Once you set DEBUG=False, it doesn't do so anymore.
Currently there is a URL mapping for serving the media files when DEBUG=True, but there isn't one for the static files, see this.
You can add one for static files - use STATIC_URL and STATIC_ROOT and be sure to run 'manage.py collectstatic' to get all the static files at STATIC_ROOT
I added an issue on github about this.
Hello,
Setting DEBUG=True solves the problem. I had set DEBUG=False to see the 404 page. Thanks for the help.
I have opened a pull request (#134) on Github that fixes this issue in the manner you suggest.
Looking at urls.py, there doesn't seem to be code that checks the value of DEBUG. Is this specified somewhere else?
Running runserver gives following log messages:
$ ./manage.py runserverValidating models...0 errors foundDjango version 1.3.1, using settings 'lernanta.settings_local'Development server is running at http://127.0.0.1:8000/Quit the server with CONTROL-C.[05/Jun/2012 01:51:18] "GET /en/ HTTP/1.1" 200 12150[05/Jun/2012 01:51:18] "GET /static/css/style.css?v=1 HTTP/1.1" 301 0[05/Jun/2012 01:51:18] "GET /static/css/batucada.css?v=1 HTTP/1.1" 301 0[05/Jun/2012 01:51:18] "GET /static/css/style-en.css?v=1 HTTP/1.1" 301 0[05/Jun/2012 01:51:18] "GET /en/static/css/style.css?v=1 HTTP/1.1" 304 0[05/Jun/2012 01:51:18] "GET /en/static/css/batucada.css?v=1 HTTP/1.1" 304 0[05/Jun/2012 01:51:18] "GET /en/static/css/style-en.css?v=1 HTTP/1.1" 304 0
Hi Prasanth
Thank you very much for the pull request on github, I went ahead and merged it to master!
I assume that django.views.static_serve checks for the DEBUG flag. They mention that it only works for DEBUG=True in the documentation.
Hello,
Thanks for the pointers.
It seems that if the current code is directly pushed to production, then Django will end up serving both static files and media files. So, in production do we configure apache (or other servers) to serve both STATIC_URL and MEDIA_URL directly, without going to Django?
Prasanth
I'm trying to play around with my local dev environment and need to create some dummy content but when I try and create a study group(same error when I change it to a course or challenge) it gives me this error when I try and submit the form:
__init__() got an unexpected keyword argument 'parser'
Hey Corbin, seems like your DB is out of sync with your models. Have you run migrations as?
python manage.py migrate --all --delete-ghost-migrations
More info in the cheat sheet.
I had not tried that command yet, I ran it but am still getting the same error.
I also tried: python manage.py test
and it tells me: FAILED (errors=42)
it looks like a lot of the errors are: DatabaseError: no such table: users_userprofile
also, running: ./sh/schemamigration
goes through all the tables telling me "Nothing seems to have changed"
I asked this same question on the p2pu-dev mailing list and got a reponse telling me to try this out:
http://lists.p2pu.org/pipermail/p2pu-dev/2012-February/002446.html
which is a command to put some dummy challenges in the database:
python manage.py loaddata apps/badges/fixtures/test_challenges_with_bagdes.json
This works, but I am still unable to make any changes to those courses and still can't create any new ones or even add any comments. Does anyone else have any ideas?
Try running: FORCE_DB=True python manage.py test
I just replied at http://lists.p2pu.org/pipermail/p2pu-dev/2012-April/002566.html
try installing the latest version of bleach by running 'pip install -U bleach'
>>pip install -U bleach
Requirement already up-to-date: bleach
Hooray! Thank you!
FORCE_DB=True python manage.py test
fixed everything, I can create new groups and add comments without error now.
although, none of the courses are showing up in the Learn section. Even if I click "View All" it shows nothing. I can only find the courses through my user dashboard
Hey Corbin,
are the courses published or 'under development'? if it's the latter then they don't show on 'normal' searches.
cheers,
José
Zuzel helped me through the mailing list.
The test badge challenges and the study group I had created were all marked as "Under Development" so they weren't showing up.
I unchecked those and the badge challenges appeared under view all. I still couldn't see the test study group I created though. Although it did list the two tags (div, test) (and had previously as well, while it was "Under Development"). I changed it to a challenge and sure enough it showed up. So is this a bug or is "View All" not supposed to show study groups? Either way I don't think it should say under tags: div(1) test(1) and then give zero results when clicked.
I wonder, the coments thread looks strange on my brower...
The thread jumps to the left at the bottom - If I could have a confirmation that this indeed happens on other peoples browsers, I'll do a CSS tweak and float the comments to the right.
An experiment: https://lernanta.pasosdeJesus.org it is running the latest version.
I added instruction on how to run it with FastCGI and Apache on OpenBSD to: https://dhobsd.pasosdejesus.org/?id=Desarrollar+Lernanta+en+OpenBSD+adJ
Well, not everything is resolved, since it still can't send emails.
Love it! Maybe I should do something similar. I can't test activity feeds unless I open up my dev box. I didn't quite want to do that for obvious reasons but this would work well for that sort of testing.
And thank you for writing up how you did it :)
Problem found for the situation with log and template /.
See:
https://github.com/jbalogh/django-cache-machine/commit/416804a5052d101b0f4026b3a26aa94753086e63
that code was commited yesterday to django-cache-machine if today we did
pip install -r requirements/prod.txt
We have this new code that requires something that our django.utils doesn't have.
For the moment please edit sources installed of django-cache-machine to leave the previous version.
I found a temporal solution, please undo fixes to the sources, be sure to run current sources by running:
git fetch origin git fetch upstream git merge upstream/master git merge origin/masterand after that
git diffshoul be blank.
Then please apply the change at: https://github.com/vtamara/lernanta/commit/a68a6fbb5bd49947fd1cdd84689edc724fa25aaf
After that, please do:
pip install -r requirements/prod.txtThen
./manage.py runserverit should work (without report problems with module log), and when you see http://127.0.0.1:8000 you should not obtain any error.
Looks like zuzel has fixed too. I just updated and all seems to be well. Also she upgraded us to Django 1.3.
Here's how to get the newest changes after updating your local code from the P2PU github repository:
And this is the commit that did it: https://github.com/p2pu/lernanta/commit/142a4c3050cb5e7352f01bf1c71519013aee1990
I ran the commands you mention above but am still getting this error when I view the site home page:
TemplateSyntaxError at / Caught OperationalError while rendering: (1054, "Unknown column 'schools_school.image' in 'field list'")
Not sure what to do next.
First update sources, if you forked the repository it would be with:
git fetch origin git merge origin/master git fetch upstream git merge upstream/master
Thanks for your help Vladimir.
Got it working :-) Turns out it was a problem in my database. Here's what I did in case anyone else has the same problem. I ran the following commands:
git fetch origin
git merge origin/master
git fetch upstream
git merge upstream/master
mkvirtualenv --clear --no-site-packages lernanta
pip install -r requirements/compiled.txt
pip install -r requirements/prod.txt
pip install -r requirements/dev.txt
Then I ran the syncdb script
python manage.py syncdb --noinput --migrate
which brought up this error (I'm only pasting the beginning of the error output as it's pretty long):
Skipping creation of NoticeTypes as notification app not found Syncing... Creating tables ... Installing custom SQL ... Installing indexes ... No fixtures found. Migrating... Running migrations for users: - Migrating forwards to 0010_auto__add_field_userprofile_preflang. > users:0003_auto__add_userprofile ! Error found during real run of migration! Aborting. ! Since you have a database that does not support running ! schema-altering statements in transactions, we have had ! to leave it in an interim state between migrations. ! You *might* be able to recover with: = DROP TABLE `users_userprofile` CASCADE; []
I tried to run the "DROP TABLE" command but it didn't work for me so I dropped and recreated the database, after which the syncdb script worked with no errors, and I was able to access the site with no error :-)
As an aside I got this error warning when running one of the requirements scripts:
Downloading/unpacking MySQL-python==1.2.3c1 (from -r requirements/compiled.txt (line 1)) Downloading MySQL-python-1.2.3c1.tar.gz (89Kb): 89Kb downloaded Running setup.py egg_info for package MySQL-python Downloading/unpacking PIL==1.1.7 (from -r requirements/compiled.txt (line 2)) Downloading PIL-1.1.7.tar.gz (506Kb): 506Kb downloaded Running setup.py egg_info for package PIL WARNING: '' not a valid package name; please use only.-separated package names in setup.py
Doesn't seem to cause any problems though.
Now after starting the server this is all I get:
Django version 1.2.5, using settings 'lernanta.settings_local' Development server is running at http://127.0.0.1:8000/ Quit the server with CONTROL-C.
That looks right but I don't have it running right this second. It won't do much till you hit it with a browser or such.
If you go to a web browser and put in the address: http://localhost:8000/ or http://127.0.0.1:8000/
What happens? It should load up P2PU and the place where the server is running should now have a lot of text.
Ah ok. It's loaded up but it's a page with a "TemplateSyntaxError at /" heading
I also had that happen and filed a bug report so hopefully we get in a fix soon :)
I think this is why Julia commented out some of the Activity code: http://new.p2pu.org/en/groups/introduction-to-contributing-to-lernata/content/task-three-experiment/#916
The other pages should work so you should be able to create an account and log in:
http://localhost:8000/en/login/?next=/en/
Once you're logged in, you don't see the landing page that is causing the problems. I haven't tested this but that's my theory :)
Yup thanks for all the help Jessica, I can create accounts. Not sure if the confirmation email part is working though.
Hi Faheem,
I ran into the same problem with emails not arriving (I figured it was my local setup). You can get around it by going to the admin section and logging in with the username and password you used to create your account. The admin interface can be found at http://127.0.0.1:8000/en/admin/.
Julia
Thanks Julia it worked :D
The email to activate the account should be in the window where the server is running:
http://www.flickr.com/photos/digifoo/5593967846/
Just copy that url and paste it into the browser. Take out the "=" though cause that's formatting and not part of the real url.
You might have to scroll up a little to find it.
Or, do it via admin. :) I sometimes test a full registration with email to make sure localization, captcha and such was working.
Thank you, seems to be all working now, phew. Now onto the experiments :)
For one line instead of two, I was thinking of truncating the string's length of what is shown on the page. It looks like I didn't update for the new code. Oops. Sorry about that :) I first wrote this a while ago.
I made a comment on your post/patch on Lighthouse. For all sized fixes, we do pull requests. That might change in time, but for now it's working out well. Since it was confusing, I'll update the wiki more about how to submit changes.
And thank you again for working on a real bug :) When you put in the pull request, I'll test and merge.
django.core.exceptions.ImproperlyConfigured: ImportError activity: No module named log
python manage.py syncdb --noinput --migrate
Getting the same issue.
Me too. I just set up a new development environment on my laptop and run into the same thing. I tried deleting the environment by mkvirtualenv --clear lernanta and then reinstalling the requirements. Still got the missingmodule named log.
My old setup does this alright but I am missing a schools_school image.
Going to try grabbing some of the pull requests to see if it fixes it.
Merged and pushed pull requests but still getting the same problem. But if anyone was having a problem with migration, that should be fixed now thanks to Vladimir :)
I'm not able to reproduce it, what is the result of:
./manage.py migrate --list
?
Please try also this, in the seciont DATABASES of settings_locale.py rename 'default' for 'm' and add:
'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'lernanta.db', },
and save. With this you are configuring a sqlite database lernanta.db. After that run:
./manage.py syncdb --migrate --noinput
And if fails send me the whole log.
Thanks for the help!
(lernanta)Julia-Kulla-Maders-MacBook-Pro:lernanta JuliaKM$ ./manage.py migrate --list Traceback (most recent call last): File "./manage.py", line 26, in <module> execute_manager(settings) File "/Users/JuliaKM/Users/JuliaKM/Code/python/lernanta/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager utility.execute() File "/Users/JuliaKM/Users/JuliaKM/Code/python/lernanta/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/JuliaKM/Users/JuliaKM/Code/python/lernanta/lib/python2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command klass = load_command_class(app_name, subcommand) File "/Users/JuliaKM/Users/JuliaKM/Code/python/lernanta/lib/python2.7/site-packages/django/core/management/__init__.py", line 67, in load_command_class module = import_module('%s.management.commands.%s' % (app_name, name)) File "/Users/JuliaKM/Users/JuliaKM/Code/python/lernanta/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module __import__(name) File "/Users/JuliaKM/Users/JuliaKM/Code/python/lernanta/lib/python2.7/site-packages/south/management/commands/__init__.py", line 10, in <module> import django.template.loaders.app_directories File "/Users/JuliaKM/Users/JuliaKM/Code/python/lernanta/lib/python2.7/site-packages/django/template/loaders/app_directories.py", line 23, in <module> raise ImproperlyConfigured('ImportError %s: %s' % (app, e.args[0])) django.core.exceptions.ImproperlyConfigured: ImportError activity: No module named log
(lernanta)Julia-Kulla-Maders-MacBook-Pro:lernanta JuliaKM$ ./manage.py syncdb --migrate --noinput Traceback (most recent call last): File "./manage.py", line 26, in <module> execute_manager(settings) File "/Users/JuliaKM/Users/JuliaKM/Code/python/lernanta/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager utility.execute() File "/Users/JuliaKM/Users/JuliaKM/Code/python/lernanta/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/JuliaKM/Users/JuliaKM/Code/python/lernanta/lib/python2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command klass = load_command_class(app_name, subcommand) File "/Users/JuliaKM/Users/JuliaKM/Code/python/lernanta/lib/python2.7/site-packages/django/core/management/__init__.py", line 67, in load_command_class module = import_module('%s.management.commands.%s' % (app_name, name)) File "/Users/JuliaKM/Users/JuliaKM/Code/python/lernanta/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module __import__(name) File "/Users/JuliaKM/Users/JuliaKM/Code/python/lernanta/lib/python2.7/site-packages/south/management/commands/__init__.py", line 10, in <module> import django.template.loaders.app_directories File "/Users/JuliaKM/Users/JuliaKM/Code/python/lernanta/lib/python2.7/site-packages/django/template/loaders/app_directories.py", line 23, in <module> raise ImproperlyConfigured('ImportError %s: %s' % (app, e.args[0])) django.core.exceptions.ImproperlyConfigured: ImportError activity: No module named log
It is a problem with the python packages. I tried from a Linux after running pip install -r requirements/prod.txt and the problem occurred. After checking what it tries I did:
pip install --upgrade django-cache-machine
After that ./manage.py dbshell works as well as the rest.
Thanks Vladimir, I think that solved it.
When entering:
mysqladmin -u <user> -p create <database name>
Should I be typing? :
mysqladmin -u lernanta -p create lernanta
Thanks Vladimir! That fixed the problem!
I also ran into an error with the activity model that I got around by commenting out the code below
class ActivityManager(ManagerBase): def public(self): """Get list of activities to show on splash page."""
Hi Faheem,
You need to use the user that you have for mysql. I have to do that with root first then make a lernanta user. If you have already, then you're set.
To make a lernanta user and grant everything to it:
> mysql -u root -p (prompts for password … enter it)
now are in mysql monitor
> create user 'lernanta'@'localhost' identified by 'lernpassword';
> grant all privileges on *.* to 'lernanta'@'localhost';
If you don't have the database already, you can create it in the mysql monitor with:
> create database lernanta;
Also, make sure your settings_local.py mirror what you have set up. So whatever password you put in, put it there.
Hope that helps!
I should read the output when running those. Thank you again for your help, Vladimir! That fixed my issue as well :)
Me too. We didn't used to get that. I'm going to file a bug report since we shouldn't need to comment out code in order to develop.
Hi Jessica,
I keep getting 'Access Denied' after entering what I would think the root pw would be. Is there a specific mySQL root pw?
You may have set it and forgotten. Happens to me too :)
Here are a few ways to reset it:
http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html
Let me know if that didn't work for you.
I'm doing this on a clean install and it's the first time I'm doing anything mySQL related.
EDIT:
But now I get :
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
hmm.
Sorted! Had to flush priveleges.