Create account that can either be a person or a group

2016-05-19 Thread Karl Arunachal
I want to create user accounts for my website. The account can be either a
person or a group. So for *person* account I want to get different
information from them (such as First name, Last Name, ...), and for *group*
account get different information (such as Group name, ...). Basically
different form for *person* account and *group* account. The account itself
will have a unique primary key ( such as username/account id).

How should I do it? Should I make one to one relationship with account and
person, and the same with account and group? Or create just on Account
model and place a choice field to choose between Person and Group? Or how
do you prefer I should do it?


Thank you

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPXAsR1nYd8-hF88HSRgS8Zm8iDktxxcZ84u8wXfyrw7mU3tQg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


django summernote not working properly

2013-10-13 Thread Karl Arunachal
I am using django-summernote  as
a wysiwyg editor. And till now, I can save the post from the summernote
editor and can display it too using the safe filter. But some of its
functionalities are not there in my template.

   1. There is no image upload button in the editor.
   2. The Code style is displaying fine, but the Quote style is displaying
   just a regular text.

And finally, is it safe to use safe filter in the templates?

Please help me how do I solve this problem. Or I can't use it in django?
Thank you.

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CAPXAsR2RMRG-_-zNPS3H0QzCODMDN2zxedhqJiQT-Gp71kz0mQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Deployment + Apache2] difference between development server & production server

2013-09-18 Thread Karl Arunachal
Its always a pleasure. Have fun coding!


On Mon, Sep 16, 2013 at 11:20 PM, hung david wrote:

>
>
> On Monday, September 16, 2013 2:05:56 AM UTC+7, Kakar wrote:
>>
>> I dont know what you actually mean, but I think just by passing the url
>> that you have created in the urls.py, which points to the function you have
>> defined in ur views.py should work.
>>
>>
>>
> Yes you are right Kakar. I've figured it out and here is the solution I
> got ( the same as you say, but more specific ) :
> https://groups.google.com/forum/#!topic/django-users/ourayJhe1oY
> Thank you for the confirmation. This community is beautiful :D
>
> --
> 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 django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Resize image size in the view

2013-09-11 Thread Karl Arunachal
Hello Carlos! I tried using sorl thumbnail, but whenever I uploads the
image, it does upload the image cause I can see it in the folder, but the
apache server does not load the uploaded image. But when I load it through
the django's inbuilt server it loads the image correctly.


On Wed, Sep 11, 2013 at 11:37 AM, carlos  wrote:

> Hi you try use http://sorl-thumbnail.readthedocs.org/en/latest/
> is good
>
> Cheers
>
>
> On Tue, Sep 10, 2013 at 10:53 PM, Robin Lery  wrote:
>
>> Hello,
>> I have been trying to achieve thumbnail for the uploaded images, but it
>> just don't seem to resize the image on the apache server when the page is
>> loaded. Only when I run through the django's inbuilt server, it loads the
>> uploaded image. So, is there any way, that I can specify the size of the
>> image in the views and then call it in the template? Please help me here.
>> Thank you.
>>
>> --
>> 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 django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>  --
> 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 django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: message_set filter

2013-08-18 Thread Karl Arunachal
Suppose, A is the request.user. And 'msg' has all the mesasges sent by the
user A and all the messages that A has received. Now how will I separate
the messages for each user from 'msg', to make it like an Inbox for A. I
think I have made it clear now. If not, please ask again.
Thank you.


On Sun, Aug 18, 2013 at 2:17 PM, Avraham Serour <tovm...@gmail.com> wrote:

> so what's the question?
>
>
> On Sat, Aug 17, 2013 at 7:52 AM, Karl Arunachal <
> kakararunachalserv...@gmail.com> wrote:
>
>> Hello,
>> I have a model for messaging between the users.
>>
>> models.py:
>>
>> class Message(models.Model):
>> description = models.TextField()
>> date_added = models.DateTimeField(default=datetime.now)
>> sender = models.ForeignKey(User, related_name='sent_set')
>> recipient = models.ForeignKey(User, related_name='recieved_set')
>>
>> def __unicode__(self):
>> return "%s sent message: %s to %s" % (self.sender, self.description, 
>> self.recipient)
>>
>> def save(self, **kwargs):
>> if self.sender == self.recipient:
>> raise ValueError("Cannot message yourself")
>> super(Message, self).save(**kwargs)
>>
>>
>>
>> Till now I get all the messages (sent/recieved) of a particular user,
>>
>> from django.db.models import Q
>>
>>
>>
>> A = request.usermsg = Message.objects.filter(Q(sender=A)|Q(recipient=A))
>>
>>
>>
>> Suppose, msg has all the messages sent and recieved for user 'A'. Now
>> how would i filter from this 'msg',  all the message sent to and recieved
>> from a particular user 'B'.
>>
>> --
>> 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 django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>  --
> 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 django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: As a New Bee

2013-08-17 Thread Karl Arunachal
Pycharm!


On Fri, Aug 16, 2013 at 7:58 PM, Apokalyptica Painkiller <
apokalyptic...@gmail.com> wrote:

> Hello Sujeet try this IDE: http://ninja-ide.org/
>
> I hope you like it!
>
>
> 2013/8/16 Sujeet Buddiga 
>
>> Hi Djano'ans,
>>Im a new bee to Django and would like to work with an
>> IDE. Please suggest proper tutorials with IDE that can make my learning
>> process simpler,easire and faster.
>>
>> *Please Dont mind if my English is not good.
>>
>>
>>
>> Thanks in Advance,
>> Sujeet
>>
>> --
>> 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 django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> --
> I live each day
> Like it's my last
> I live for rock and roll
> I never look back
>
> I'm a rocker
> Do as I feel as I say
> I'm a rocker
> And no one can take that away
>
>  --
> 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 django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


message_set filter

2013-08-16 Thread Karl Arunachal
Hello,
I have a model for messaging between the users.

models.py:

class Message(models.Model):
description = models.TextField()
date_added = models.DateTimeField(default=datetime.now)
sender = models.ForeignKey(User, related_name='sent_set')
recipient = models.ForeignKey(User, related_name='recieved_set')

def __unicode__(self):
return "%s sent message: %s to %s" % (self.sender,
self.description, self.recipient)

def save(self, **kwargs):
if self.sender == self.recipient:
raise ValueError("Cannot message yourself")
super(Message, self).save(**kwargs)



Till now I get all the messages (sent/recieved) of a particular user,

from django.db.models import Q

A = request.usermsg = Message.objects.filter(Q(sender=A)|Q(recipient=A))



Suppose, msg has all the messages sent and recieved for user 'A'. Now how
would i filter from this 'msg',  all the message sent to and recieved from
a particular user 'B'.

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: south in windows

2013-08-12 Thread Karl Arunachal
Thank you! That solved my problem.


On Mon, Aug 12, 2013 at 5:05 AM, Mike Dewhirst <mi...@dewhirst.com.au>wrote:

> On 12/08/2013 5:36am, Karl Arunachal wrote:
>
>> Hi,
>> I am trying to sync south in my db, but i can't sync it. Its giving me
>> an error:
>> (use ./manage.py migrate to migrate these)
>> Is there anyway to do this command, "./manage.py", in windows. I could
>> have done it by chmod + x manage.py in other os. But how do i do it in
>> windows? Is there any other way around to sync south in windows?
>> Thank you.
>>
>
> In Windows, the ./ is unnecessary. The command you want is ...
>
>  C:\path\to\managepy\python manage.py migrate
>
> ... where Windows knows how to launch Python and Python knows that
> manage.py is in the current working directory.
>
> hth
>
>
>> --
>> 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 
>> django-users+unsubscribe@**googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
>> .
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at 
>> http://groups.google.com/**group/django-users<http://groups.google.com/group/django-users>
>> .
>> For more options, visit 
>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>> .
>>
>>
>>
> --
> 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 
> django-users+unsubscribe@**googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at 
> http://groups.google.com/**group/django-users<http://groups.google.com/group/django-users>
> .
> For more options, visit 
> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
> .
>
>
>

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




south in windows

2013-08-11 Thread Karl Arunachal
Hi,
I am trying to sync south in my db, but i can't sync it. Its giving me an
error:
(use ./manage.py migrate to migrate these)
Is there anyway to do this command, "./manage.py", in windows. I could have
done it by chmod + x manage.py in other os. But how do i do it in windows?
Is there any other way around to sync south in windows?
Thank you.

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Help getting started: Which server setup for a beginner? Apache? lighttpd? To use or not virtualenv?

2013-07-30 Thread Karl Arunachal
If you are in windows, I guess i can help you.


On Tue, Jul 30, 2013 at 9:18 PM, Jared Nielsen wrote:

> I'm trying to learn Django but finding myself lost in troubleshooting
> hell. I can't find consistent information on the best approach for a
> beginner to get set up.
>
> I started setting up Apache with mod_wsgi, but ran into innumerable config
> errors. After some Googling about, I found a number of suggestions to use
> lighttpd instead. Installed that and more troubleshooting. And what's this
> about gunicorn?
>
> What's the best approach for a beginner? Where is my time best spent
> troubleshooting?
>
> Also, should I be using virtualenv? Inconsistent use across the various
> tutorials I'm reading.
>
> Many thanks in advance!
>
>
>  --
> 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 django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: background image

2013-07-30 Thread Karl Arunachal
Thank you. I will try as you told me. Just one more question, how do i
create different static directory for each user?


On Tue, Jul 30, 2013 at 5:37 PM, Christian Erhardt <
christian.erha...@mojo2k.de> wrote:

> Generally speaking you could extend the users profile and add a field to
> it. Then you could store the image during registration or when a user
> updates his settings. On the page where you want to show the image you
> could check for a image in the profile and show it.
>
> I started my project with pinax, which already hat the
> app django-user-accounts included, i then created a custom profile for my
> users (something like here:
> http://blog.tivix.com/2012/01/06/extending-user-model-in-django/). Now
> you have to adjust the forms for registering and modifying the user
> settings, so the user can set the fields you added to the profile (somewhat
> like this: http://dewful.com/?p=70). The form must contain a file upload
> field where the user can upload the image. Then i would save the image
> somewhere on the server, where you can access it from an template.
>
> Sorry, that i can not provide a step by step solution, but i hope i could
> push you in the right direction.
>
> regards Christian
>
> Am Dienstag, 30. Juli 2013 08:07:43 UTC+2 schrieb Kakar:
>
>> Hello,
>> What do I do to let user upload their own images, and as use it as their
>> profile's background.
>> I am out of clue. Please advice me.
>>
>> Thank you.
>>
>  --
> 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 django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: flatpages-tinymce

2013-07-30 Thread Karl Arunachal
Thank you.


On Sun, Jul 28, 2013 at 7:03 PM, Roberto López López
<roberto.lo...@uni.no>wrote:

>
> Your message is quite confusing and difficult to understand, I have to
> say. What are you asking for? To show tinymce within your change_form or
> within the admin app? What do you mean by "flat pages"? Which error are you
> getting?
>
>
>
>
> On 07/28/2013 08:35 AM, Karl Arunachal wrote:
>
>  Hello,
>  I am trying to use tinymce in the flat pages. But i just can't show it up
> in my admin. Please help me out where am going wrong.
>
> The javascript file is in:
>
> C:\Users\Kakar\web\cms\static\js\tinymce\tinymce.min.js
>
> urls.py:
>
> (r'^tiny_mce/(?P.*)$', 'django.views.static.serve', {
> 'document_root': 'C:/Users/Kakar/web/cms/static/js/tinymce' }),
>
> In my templates dir i have another admin folder, which have the
> change_form.html, and right after {{ media }}:
>
> 
> 
> tinyMCE.init({
> mode: "textareas",
> theme: "simple"
> });
> 
>
>  Please help me out. Thank you.
>  --
> 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 django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
>
> --
>
> Roberto López López
> System Developer
> Parallab, Uni Computing
> +47 55584091
>
>  --
> 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 django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




background image

2013-07-30 Thread Karl Arunachal
Hello,
What do I do to let user upload their own images, and as use it as their
profile's background.
I am out of clue. Please advice me.

Thank you.

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




flatpages-tinymce

2013-07-28 Thread Karl Arunachal
Hello,
I am trying to use tinymce in the flat pages. But i just can't show it up
in my admin. Please help me out where am going wrong.

The javascript file is in:

C:\Users\Kakar\web\cms\static\js\tinymce\tinymce.min.js

urls.py:

(r'^tiny_mce/(?P.*)$', 'django.views.static.serve', { 'document_root':
'C:/Users/Kakar/web/cms/static/js/tinymce' }),

In my templates dir i have another admin folder, which have the
change_form.html, and right after {{ media }}:



tinyMCE.init({
mode: "textareas",
theme: "simple"
});


Please help me out. Thank you.

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




tinymce

2013-07-27 Thread Karl Arunachal
Hello,
I am not able to use the tinymce editor in my flat pages.
My tinymce is in this dir:
C:\Users\Kakar\Downloads\Compressed\tinymce\js\tinymce\tinymce.min.js

And in my template dir i have another admin folder for 'change_form.html',
just below this line:



i have added this line for tiymce:



tinyMCE.init({
mode: "textareas",
theme: "simple"
});


In my urls.py, i have added:

(r'^tiny_mce/(?P.*)$', 'django.views.static.serve',
{'document_root':'C:/Users/Kakar/Downloads/Compressed/tinymce/js/tinymce'}),

Please, point me out, where am doing wrong. I am learning from a book
'Practical Django Projects'.

Thank you.

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




tinymce

2013-07-26 Thread Karl Arunachal
Hi,
I want to integrate tinymce in my text area. But i can't find any good
tutorials for it. Can some someone please advice me how to do this.
Thank you.

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: CSRF in javascript

2013-07-21 Thread Karl Arunachal
Ok! I will check. Thank you!


On Sun, Jul 21, 2013 at 4:27 AM, Fred Stluka <f...@bristle.com> wrote:

>  Karl,
>
> You are calling render_to_response() wrong.  See the docs at:
>
> https://docs.djangoproject.com/en/dev/topics/http/shortcuts/#render-to-response
>
> Instead of:
>
>
> variables = RequestContext(request, {
> 'bookmarks':[bookmark],
> 'show_edit':True,
> 'show_tags':True
> })
> return render_to_response('bookmark_list.html', variables)
>
> try:
>
> variables = {
>
> 'bookmarks':[bookmark],
> 'show_edit':True,
> 'show_tags':True
> }
> return render_to_response('bookmark_list.html', variables,
> RequestContext(request))
>
>
> --Fred
> --
> Fred Stluka -- mailto:f...@bristle.com <f...@bristle.com> --
> http://bristle.com/~fred/
> Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
> Open Source: Without walls and fences, we need no Windows or Gates.
> --
>
> On 7/20/13 3:39 PM, Karl Arunachal wrote:
>
>   I am sorry, i am really new to this things. Could you please point me
> out as to where I should add it.
>
> *js file:
>
> *function bookmark_edit() {
> var item = $(this).parent();
> var url = item.find(".title").attr("href");
> item.load("/save/?ajax=" + escape(url), null, function () {
> $("#save-form").submit(bookmark_save);
> });
> return false;
> }
>
> $(document).ready(function () {
> $("ul.bookmarks .edit").click(bookmark_edit);
> });
>
> function bookmark_save() {
> var item = $(this).parent();
> var data = {
> url: item.find("#id_url").val(),
> title: item.find("#id_title").val(),
> tags: item.find("#id_tags").val()
> };
> $.post("/save/?ajax", data, function (result) {
> if (result != "failure") {
> item.before($("li", result).get(0));
> item.remove();
> $("ul.bookmarks .edit").click(bookmark_edit);
> }
> else {
> alert("Failed to validate bookmark before saving.");
> }
> })
> return false;
> }
>
>  *save_form.html:
>
> *
> {% csrf_token %}
> {{form.as_p}}
> 
> 
>
>
>
>  *user_page.html:*
>
> {% extends "base.html" %}
> {% block external %}
> 
> {% endblock %}
> {% block title %} {{username}} {% endblock %}
> {% block head %} Bookmarks for {{username}} {% endblock %}
> {% block content %}
> {% include "bookmark_list.html" %}
> {% endblock %}
>
>
>  *views.py:*
>
> @login_required(login_url='/login/')
> def bookmark_save_page(request):
> ajax = request.GET.has_key('ajax')
> if request.method == 'POST':
> form = BookmarkSaveForm(request.POST)
> if form.is_valid():
> bookmark = _bookmark_save(request, form)
> if ajax:
> variables = RequestContext(request, {
> 'bookmarks':[bookmark],
> 'show_edit':True,
> 'show_tags':True
> })
> return render_to_response('bookmark_list.html', variables)
> else:
> return HttpResponseRedirect('/user/%s/' %
> request.user.username
> )
> else:
> if ajax:
> return HttpResponseRedirect('failure')
> elif request.GET.has_key('url'):
> url = request.GET['url']
> title = ''
> tags = ''
>
> try:
> link = Link.objects.get(url=url)
> bookmark = Bookmark.objects.get(
> link=link,
> user = request.user
> )
> title = bookmark.title
> tags = ' '.join(
> tag.name for tag in bookmark.tag_set.all()
> )
> except ObjectDoesNotExist:
> pass
> form = BookmarkSaveForm({
> 'url':url,
> 'title':title,
> 'tags':tags
> })
> else:
> form = BookmarkSaveForm()
>
> variables = RequestContext(request, {
> 'form': form
> })
> if ajax:
> return render_to_response(
> 

Re: CSRF in javascript

2013-07-20 Thread Karl Arunachal
I am sorry, i am really new to this things. Could you please point me out
as to where I should add it.

*js file:

*function bookmark_edit() {
var item = $(this).parent();
var url = item.find(".title").attr("href");
item.load("/save/?ajax=" + escape(url), null, function () {
$("#save-form").submit(bookmark_save);
});
return false;
}

$(document).ready(function () {
$("ul.bookmarks .edit").click(bookmark_edit);
});

function bookmark_save() {
var item = $(this).parent();
var data = {
url: item.find("#id_url").val(),
title: item.find("#id_title").val(),
tags: item.find("#id_tags").val()
};
$.post("/save/?ajax", data, function (result) {
if (result != "failure") {
item.before($("li", result).get(0));
item.remove();
$("ul.bookmarks .edit").click(bookmark_edit);
}
else {
alert("Failed to validate bookmark before saving.");
}
})
return false;
}

*save_form.html:

*
{% csrf_token %}
{{form.as_p}}





*user_page.html:*

{% extends "base.html" %}
{% block external %}

{% endblock %}
{% block title %} {{username}} {% endblock %}
{% block head %} Bookmarks for {{username}} {% endblock %}
{% block content %}
{% include "bookmark_list.html" %}
{% endblock %}


*views.py:*

@login_required(login_url='/login/')
def bookmark_save_page(request):
ajax = request.GET.has_key('ajax')
if request.method == 'POST':
form = BookmarkSaveForm(request.POST)
if form.is_valid():
bookmark = _bookmark_save(request, form)
if ajax:
variables = RequestContext(request, {
'bookmarks':[bookmark],
'show_edit':True,
'show_tags':True
})
return render_to_response('bookmark_list.html', variables)
else:
return HttpResponseRedirect('/user/%s/' %
request.user.username
)
else:
if ajax:
return HttpResponseRedirect('failure')
elif request.GET.has_key('url'):
url = request.GET['url']
title = ''
tags = ''

try:
link = Link.objects.get(url=url)
bookmark = Bookmark.objects.get(
link=link,
user = request.user
)
title = bookmark.title
tags = ' '.join(
tag.name for tag in bookmark.tag_set.all()
)
except ObjectDoesNotExist:
pass
form = BookmarkSaveForm({
'url':url,
'title':title,
'tags':tags
})
else:
form = BookmarkSaveForm()

variables = RequestContext(request, {
'form': form
})
if ajax:
return render_to_response(
'bookmark_save_form.html',
variables
)
else:
return render_to_response('bookmark_save.html',variables)

Please help me out. Thank you.


On Sun, Jul 21, 2013 at 12:53 AM, Fred Stluka <f...@bristle.com> wrote:

>  Karl,
>
> Since you already have a form, and are already submitting it
> as an Ajax request via JavaScript, the easiest way is to just
> put the {% csrf_token %} in the Django template for the page.
> We do that for our Ajax forms.
>
> If you are not using a Django template to generate the form,
> there are lots of other convenient options.  See:
> - https://docs.djangoproject.com/en/dev/ref/contrib/csrf/
> and especially:
> - https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax
>
> Also, you can find tons of working examples by Googling:
> django csrf ajax
>
> --Fred
> --
> Fred Stluka -- mailto:f...@bristle.com <f...@bristle.com> --
> http://bristle.com/~fred/
> Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
> Open Source: Without walls and fences, we need no Windows or Gates.
> --
>
> On 7/20/13 3:05 PM, Karl Arunachal wrote:
>
>   Hi,
>  In my users page, i have in place editing with ajax. And when i click
> edit, it works fine. But when i submit the form, it don't do anything. When
> i checked, this is the error:
>
> CSRF verification failed. Request aborted.
>
>  So, how do I place {% csrf_token %} in my javascript? Please advice.
>
>  Thank you.
>  --
> 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 django-users+unsubscr...@googlegroups.com.
> To post 

CSRF in javascript

2013-07-20 Thread Karl Arunachal
Hi,
In my users page, i have in place editing with ajax. And when i click edit,
it works fine. But when i submit the form, it don't do anything. When i
checked, this is the error:

CSRF verification failed. Request aborted.

So, how do I place {% csrf_token %} in my javascript? Please advice.

Thank you.

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Allow users to have a online store on the site

2013-07-19 Thread Karl Arunachal
Hello,
There's one plugin for wordpress called Marketpress E commerce, it has many
features, but what i am interested is that, with that plugin users can
create online store in your site and sell their products. So, is there any
plugin or package like Marketpress for django, which have this features?
I googled in this mater for hours, but didn't got any helpful answers.
Please advice if anybody knows about this stuff.
Thank you.

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.