Re: My Django powered website for web based learning

2009-09-28 Thread Parag Shah
Thanks Alex. I am glad you liked the course videos, I am also planning to
add more videos as I find them.

-- 
Thanks & Regards
Parag Shah
http://blog.adaptivesoftware.biz

On Mon, Sep 28, 2009 at 4:24 PM, Alex <alexanderschmi...@googlemail.com>wrote:

>
> Good job! Didn't have much time to check the content but the first 4
> or 5 videos seemed very interesting.
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: My Django powered website for web based learning

2009-09-27 Thread Parag Shah
Sorry about that. It should be accessible now:

http://www.adaptivelearningonline.net

-- 
Thanks & Regards
Parag Shah
http://blog.adaptivesoftware.biz


On Sun, Sep 27, 2009 at 9:55 PM, Grant Livingston <blindrabb...@gmail.com>wrote:

> Same here..
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



[ANN] My Django powered website for web based learning

2009-09-27 Thread Parag Shah
Hello,

I have created a Django powered website for open learning which organizes
various computer science related course videos in the form of structured
courses.

Many thanks to the excellent Django and Python community for helping me get
through the issues I faced.

The website is hosted at: http://www.adaptivelearningonline.net

I also plan to open source the code (as soon as I clean it up :-) )

-- 
Thanks & Regards
Parag Shah
http://blog.adaptivesoftware.biz

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Saving ModelForm with commit=False seems to be generating an INSERT in the database

2009-09-22 Thread Parag Shah

Thanks, you both are right.

user_form.save() is causing the INSERT of the related UserProfile
object. The User object in question here is django.contrib.auth's User
object.

It knows about the UserProfile model object from the following line in
settings.py
AUTH_PROFILE_MODULE = 'courses.userprofile'

I can unserstand the need to create a blank UserProfile object when a
User object is created (perhaps to ensure that a User always has a
UserProfile... even if it's an empty one)

I tried to changing my code, so I update the user_profile_form after
saving the user_form. But that gives me an error because it cannot
find the related object.

Now I am in a situation where if I try to save both the forms, I get a
duplicate key error, and if I try to update the user_profile_form, the
primary key of the related User is not found. I think this may be
because the save and update are happening on the same transaction
because of the transaction middleware I am using.

Is there a good solution to this problem?

-- 
Thanks & Regards
Parag Shah
http://blog.adaptivesoftware.biz



<a...@clearwind.ca> wrote:
>
>> Why is an INSERT statement being generated even though I have
>> commit=False? The two inserts are causing an Exception which prevent
>> the actual user data from being saved (a row in the
>> courses_userprofile table does get created, but with all columns
>> except the id being blank)
>
> Its odd that the two insert statements have different values for email,
> since between the user_profile_form.save and user_profile.save, you
> arent adding the email in. As Daniel suggested, its more likely the save
> is coming from elsewhere.
>
> Install django-debug-toolbar, then click on the "explain" link on the
> SQL statement, this will tell you exactly where the statement is coming
> from.
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Saving ModelForm with commit=False seems to be generating an INSERT in the database

2009-09-20 Thread Parag Shah

Hello,

I have a UserProfile Model object which has the
django.contrib.auth.models.User as it's ForeignKey.

There is a register function in the view module, which goes like this:

def register(request):
  if request.method == 'POST':
  user_form = UserCreationForm(request.POST)
  user_profile_form = UserProfileForm(request.POST)
  if user_form.is_valid() and user_profile_form.is_valid():
user = user_form.save()
user_profile = user_profile_form.save(commit=False)
user_profile.user = user
user_profile.save()
return HttpResponseRedirect("/")


The statement
user_profile = user_profile_form.save(commit=False)
is causing the following statement to appear in the MySql log
INSERT INTO `courses_userprofile` (`user_id`, `full_name`, `email`,
`website`, `timezone`, `bio`) VALUES (39, '', '', '', '', '')

And then the statement
user_profile.save()
is causing another INSERT statement
 INSERT INTO `courses_userprofile` (`user_id`, `full_name`, `email`,
`website`, `timezone`, `bio`) VALUES (39, 'Test User10',
'testus...@ten.com', '', '', '')

Why is an INSERT statement being generated even though I have
commit=False? The two inserts are causing an Exception which prevent
the actual user data from being saved (a row in the
courses_userprofile table does get created, but with all columns
except the id being blank)

Am I doing something incorrect?

-- 
Thanks & Regards
Parag Shah

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: html Escape

2009-08-24 Thread Parag Shah
Hi,

You can use the strip_tags function to strip all html from text.

from django.utils.html import strip_tags

In your view
comment = strip_tags(request.POST["comment"])

--
Regards
Parag

On Tue, Aug 25, 2009 at 4:25 AM, When ideas fail
<andrewkenyon...@gmail.com>wrote:

>
> Hello, i want to allow users to post comments and I don't want them to
> be allowed to put html in comments.
>
> However I would like the to be able to use paragraph p tags and 
> tags but not anything other. Could someone tell me how to do this?
>
> Thanks
>
> Andrew
> >
>


-- 
Thanks & Regards
Parag Shah
http://blog.adaptivesoftware.biz

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Converting some objects during serialization

2009-08-05 Thread Parag Shah
Hello,

I am serializing an QuerySet into json for being used by Javascript in the
browser. One of the fields which is serialized is a Django DateTime field.
When it is serialized, it gets represented as -mm-dd hh:mm:ss

However in the browser I would like to display the date as 'August 5, 2009
4:12'

One way to do this is to accept whatever String Django generates and then
parse it in Javascript to display what I want to display. Another way is to
get the desired format in the serialized JSON String.

Is it possible to control the serialization process to change some data as
it is being serialized, or alternately associate some format with the
QuerySet so that it returns the date in a certain format?

-- 
Thanks & Regards
Parag Shah

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Finding a Django expert to review my code

2009-07-31 Thread Parag Shah
Hi Rex,

I am not a django expert (in fact I have just started working with Django
about a month back), but I have been in software development for a while.

Remote code review sounds like an interesting exercise. I will be glad to
help you with the review, but with no prior promises on the outcome :-) I am
hoping to share what I know and also learn some new things myself.

-- 
Thanks & Regards
Parag Shah
http://blog.adaptivesoftware.biz

On Fri, Jul 31, 2009 at 11:51 AM, Rex <rex.eastbou...@gmail.com> wrote:

>
> I just created my first Django site (as an academic research project).
> Now that it is done, I would like to get feedback on my code from a
> Django expert so that I can learn where I can improve as a Django dev.
> How can I find someone to spend 1 or 2 hours reviewing my code with
> me? I found a few employment posting websites, but they seemed more
> geared toward posting jobs or large freelance projects, not something
> small like this.
>
> Thanks,
>
> Rex
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problems with mod_wsgi and django

2009-07-27 Thread Parag Shah
Thanks to everyone for your help. The problem was with permissions. Once I
gave o+rx to www-data, it started working.

-- 
Thanks & Regards
Parag Shah
http://blog.adaptivesoftware.biz


On Mon, Jul 27, 2009 at 12:40 PM, Graham Dumpleton <
graham.dumple...@gmail.com> wrote:

>
>
>
> On Jul 27, 5:02 pm, Parag Shah <adapti...@gmail.com> wrote:
> > Hello,
> >
> > I am trying to configure Apache2 server with mod_wsgi for my Django
> > application. However when I try to access the website I get the following
> > msg on the browser:
> >
> > Forbidden
> >
> > You don't have permission to access / on this server.
> >
> > Here are the contents of my httpd.conf which has been setup to access
> > mod_wsgi
> >
> >
> ---
> -
> >
> > 
> > Order allow,deny
> > Allow from all
> > 
> >
> > WSGIScriptAlias /
> > /root/public_html/projects/adaptivelearning/apache/django.wsgi
> >
> ---
> -
> > Apache is running as www-data user.
> > When I look into my Apache error.log file I see the following line:
> >
> >  (13)Permission denied: /root/.htaccess pcfg_openfile: unable to check
> > htaccess file, ensure it is readable
> >
> > I do not have a .htaccess file in /root, but I do not understand why
> Apache
> > is looking for /root/.htaccess
> >
> > Am I missing something in the configuration? Thanks in advance for the
> help.
>
> Apache runs as www-data user. That user must have read access to
> directories from / down to directory where your WSGI application
> script file is. The error above suggests that directory '/root' is not
> readable to the www-data user. In other words, permissions of the
> directory are likely something like 'rwxr-x---'. So, no o+rx.
>
> Technically you can get away with o+x in circumstances where Apache
> doesn't need a directory browsing ability.
>
> Graham
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Problems with mod_wsgi and django

2009-07-27 Thread Parag Shah
Hello,

I am trying to configure Apache2 server with mod_wsgi for my Django
application. However when I try to access the website I get the following
msg on the browser:


Forbidden

You don't have permission to access / on this server.


Here are the contents of my httpd.conf which has been setup to access
mod_wsgi




Order allow,deny
Allow from all


WSGIScriptAlias /
/root/public_html/projects/adaptivelearning/apache/django.wsgi

Apache is running as www-data user.
When I look into my Apache error.log file I see the following line:

 (13)Permission denied: /root/.htaccess pcfg_openfile: unable to check
htaccess file, ensure it is readable

I do not have a .htaccess file in /root, but I do not understand why Apache
is looking for /root/.htaccess

Am I missing something in the configuration? Thanks in advance for the help.

-- 
Thanks & Regards
Parag Shah
http://blog.adaptivesoftware.biz

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to make email field unique in model User from contrib.auth in Django

2009-07-21 Thread Parag Shah
Yes that is also a good idea. Validate the form with an AJAX call when the
user enters the email addr (or clicks on Submit)

--
Thanks & Regards
Parag Shah
http://blog.adaptivesoftware.biz

On Wed, Jul 22, 2009 at 11:21 AM, Andy McKay <a...@clearwind.ca> wrote:

>
> Use a pre-save signal, but also validate your forms correctly.
>
> On 21-Jul-09, at 12:33 PM, ramu...@gmail.com wrote:
> > Another idea may be to open a new ticket and upload a patch with new
> > parameter inside settings.py:
> >
> > AUTH_USER_EMAIL_UNIQUE = True
>
> You could do that, but if I had anything to do with it, it would be
> rejected, so don't bother :)
> --
>   Andy McKay
>   Clearwind Consulting: www.clearwind.ca
>   Blog: www.agmweb.ca/blog/andy
>   Twitter: twitter.com/clearwind
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to design a new website? (about apps)

2009-07-21 Thread Parag Shah
If the extra user information will be needed by other apps (forum and poll,
etc) then it should be a separate app such that other apps can depend on it
(I do not know if there is a formal way in Django to specify such a
dependency) The image upload form and browser can be one app, and the forum
can (as you mentioned) be a separate app as well.

I am somewhat new to Django as well, so these suggestions are from my
limited knowledge of Django design.

--
Thanks & Regards
Parag Shah
http://blog.adaptivesoftware.biz

On Wed, Jul 22, 2009 at 3:49 AM, Léon Dignòn <leon.dig...@gmail.com> wrote:

>
> Ok, I have finished the tutorials and learned a lot about Django. I
> created a polls application and tuned the admin site, etc.
>
> Now I want to continue in a bigger application. After some successful
> coding I ran into a big problem not covered by any piece of
> documentation out there:
>
> 1. Do I need apps and
> 2. when to create them?
>
>
> I plan to create a site where users can basically upload specific
> images, rate images of other users and -if they like - to download
> them. Any user should have a profile with additional information.
> Images are categorized and users can browse them and filter them.
> Maybe in future other functions like a forum or stuff will follow.
>
> Well, the forum is, just like the poll, an application, because it is
> not a basic function but a separate and autonomous function. But the
> additional user information and the upload form and the image browser
> are basic functions which interact with each other little more than
> poll and forum.
>
> I am highly confused …
>
> These questions I would love to see answered:
> - Do I create an app for the additional user information, or do I
> create a model.py in the site root because it's a main functionality?
> - Do I create an app for the image upload and browser, or do I create
> a model.py in the site root because it's a main functionality?
> --~--~-~--~~~---~--~~
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to make email field unique in model User from contrib.auth in Django

2009-07-21 Thread Parag Shah
One thought which comes to my mind is to have a pre-save signal when a User
object is saved. Though I am not sure of this is the best way.

--
Thanks & Regards
Parag Shah

On Wed, Jul 22, 2009 at 1:03 AM, ramu...@gmail.com <ramu...@gmail.com>wrote:

>
> I need to patch the standard User model of contrib.auth by ensuring
> the email field entry is unique:
>
> User._meta.fields[4].unique = True
>
> Where is best place in code to do that?
>
> I want to avoid using the number fields[4]. It's better to user fields
> ['email'], but fields is not dictionary, only list.
>
> Another idea may be to open a new ticket and upload a patch with new
> parameter inside settings.py:
>
> AUTH_USER_EMAIL_UNIQUE = True
>
> Any suggestions on the most correct way to achieve email address
> uniqueness in the Django User model?
>
> Copy from here:
>
> http://stackoverflow.com/questions/1160030/how-to-make-email-field-unique-in-model-user-from-contrib-auth-in-django
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: TransactionMiddleware not working

2009-07-21 Thread Parag Shah
Thanks for the help.

Transactions work just fine after changing MyISam to InnoDB.

--
Thanks & Regards
Parag Shah

On Tue, Jul 21, 2009 at 7:42 PM, Randy Barlow <rbar...@americanri.com>wrote:

>
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Parag Shah declared:
> > I am using MySql. I believe it does support transactions.
>
> MySQL only supports transactions if you are using INNODB tables.  This
> is not the default.
>
> - --
> Randy Barlow
> Software Developer
> The American Research Institute
> http://americanri.com
> 919.228.4971
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v2.0.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkplzMAACgkQw3vjPfF7QfWmzwCfY/kP3fEltHzOEfBQc/BZ+HrN
> ufAAnjgRqhFwDbPym+4fo1NxiR1mrBgu
> =mSLk
> -END PGP SIGNATURE-
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: TransactionMiddleware not working

2009-07-21 Thread Parag Shah
Hi Andrew,

I am using MySql. I believe it does support transactions. Here is the
version line of my instance of MySql

$mysql -V
mysql  Ver 14.12 Distrib 5.0.67, for debian-linux-gnu (x86_64) using
readline 5.2

--
Thanks & Regards
Parag Shah

On Tue, Jul 21, 2009 at 7:16 PM, Andrew Fong <fongand...@gmail.com> wrote:

>
> Just double checking, but are you using a DB that supports
> transactions?
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



TransactionMiddleware not working

2009-07-21 Thread Parag Shah
Hello,

Hello,

I am using TransactionMiddleware to get per request transactions working in
my Django project. However, it does not seem to be working.

I have a view in which I save an object and when I try to save a related
object there is an Exception. However, the first object is still saved.
Please find my code at: http://pastebin.com/f5b498b16

The topic_add(...) method is a view method which results in adding 3 rows
when a topic is added to a course:
1. Add the topic to the courses_topic table
2. Add a row to the courses_topic_courses table (because there is a
many-to-many relationship between Topic and Course)
3. Add a row to the courses_topicorder table

I deliberately introduced an error before step 3, yet step 1 and 2 were
carried out successfully.

Any help is appreciated.

--
Thanks & Regards
Parag Shah

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---