Fwd:

2013-07-30 Thread Robin Lery
-- Forwarded message --
From: Robin Lery 
Date: Tue, Jul 30, 2013 at 9:22 PM
Subject:
To: django-users@googlegroups.com


Hello,
I am stuck at a point where i should be able to type in a search query on
the page and it django should get back a list of matching pages if any. But
it doesnt show me any pages, even though its there, and gives me an erros:

Page not found (404)
Request Method: GET  Request URL:
http://127.0.0.1:8000/search/?csrfmiddlewaretoken=W6n1O1vQCMyDojxEkR4mPnRrVz9lYVt1&q=one

No FlatPage matches the given query.

Please point me as to where am doing wrong. Thank you.

*my views.py:*

from django.http import HttpResponse
from django.template import loader, Context
from django.contrib.flatpages.models import FlatPage

def search(request):
query = request.GET['q']
 resuts = FlatPage.objects.filter(content__icontains=query)
template = loader.get_template('search/search.html')
 context = Context({
'query':query,
'resuts':resuts
 })
response = template.render(context)
return HttpResponse(response)

*urls.py:*

from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
(r'^tinymce/(?P.*)$', 'django.views.static.serve', {
'document_root': 'C:/Users/Kakar/web/cms/static/js/tinymce/' }),
(r'', include('django.contrib.flatpages.urls')),
(r'^search/$', 'search.views.search'),
)

*settings.py:*
In the installed-apps, I have installed 'search'.

*default.html:*



 {{ flatpage.title }}


 
{% csrf_token %}
Search:
 

 
{{ flatpage.title }}
{{ flatpage.content }}
 


*search.html:*



 Search


 You searched for "{{query}}"; the results are listed below.
{% if results %}
 
{% for page in results %}

 {{page.title}}

{% endfor %}
 
{% else %}
No results.
 {% endif %}


*
*

-- 
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.




django jquery

2013-07-31 Thread Robin Lery
Hi,
Can any one please suggest good book or tutorials if possible regarding
django and ajax (jquiry). I looked at one book "Django JavaScript
Integration AJAX and jQuery", but it was very confusing and outdated as
well,  didn't help much.Please suggest tutorials or books with latest
version. Would be very thankful.

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: django jquery

2013-07-31 Thread Robin Lery
I was thinking about client communication via ajax and jquery, but also
interested in jquery ui. I am a django noob and also with ajax. So its very
confusing for me how to integrate these two. Can you please advice where to
start?
Thank you.


On Wed, Jul 31, 2013 at 9:54 PM, Jonathan Baker <
jonathandavidba...@gmail.com> wrote:

> You've posed a pretty open-ended question. Are you looking to provide an
> API using Django that then a client communicates with via Ajax using
> jQuery? Or are you interested in, say, using jQuery to manipulate the UI
> generated by Django templates? If you can be more specific in your goals,
> more direction can provided.
>
> Jonathan
>
>
> On Wed, Jul 31, 2013 at 10:14 AM, Robin Lery  wrote:
>
>> Hi,
>> Can any one please suggest good book or tutorials if possible regarding
>> django and ajax (jquiry). I looked at one book "Django JavaScript
>> Integration AJAX and jQuery", but it was very confusing and outdated as
>> well,  didn't help much.Please suggest tutorials or books with latest
>> version. Would be very thankful.
>>
>> 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.
>>
>>
>>
>
>
>
> --
> Jonathan D. Baker
> Developer
> http://jonathandbaker.com
>
> --
> 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.




Friendship model

2013-08-08 Thread Robin Lery
Hi,
How do i create a Friendship model? Please guide 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.


Re: Friendship model

2013-08-09 Thread Robin Lery
Thank you! I'll check on it.


On Fri, Aug 9, 2013 at 12:36 PM, Rahul Gaur  wrote:

>
>
> On Fri, Aug 9, 2013 at 9:38 AM, Andy McKay  wrote:
>
>> On Thu, Aug 8, 2013 at 12:41 PM, Robin Lery  wrote:
>>
>>> How do i create a Friendship model? Please guide me.
>>>
>>
>> You would need to provide more detail to get much help. The tutorial
>> covers how to make models:
>>
>> https://docs.djangoproject.com/en/dev/intro/tutorial01/
>>
>>
>>
>
>
>
>
> I have implemented Follower and Following model for my project.
> Take a look a the this follower/followee relationship :
>
> class Follow(models.Model):
>>
>> """ Model to represent Following relationships """
>> follower = models.ForeignKey(User, related_name='following')
>>
>> followee = models.ForeignKey(User, related_name='followers')
>>
>> created = models.DateTimeField(default=timezone.now)
>>
>>
>> class Meta:
>> verbose_name = _('Following Relationship')
>>
>> verbose_name_plural = _('Following Relationships')
>>
>> unique_together = ('follower', 'followee')
>>
>>
>> def __unicode__(self):
>>
>> return "User %s follows %s" % (self.follower, self.followee)
>>
>>
>> def save(self, *args, **kwargs):
>>
>> # Ensure users can't be friends with themselves
>> if self.follower == self.followee:
>>
>> raise ValidationError("Users cannot follow themselves.")
>>
>> super(Follow, self).save(*args, **kwargs)
>>
>>
>
> If you hook this model to admin.py , you can add or remove followers to
> particular user.
> I use Tastypie to do these Operations [1].
> Friendship would be represented with a similar model , but since
> Friendship is bilateral (ie: you would need a way to add a model manager).
> What I mean to say , the Social Relation Model like above will hold your
> relations.
> Apart from this you would need a way to send friend request , and when
> user approves to request then only this model will be saved.
> I think following code will be helpful for you [2] .
>
>
>
> [1] -
> https://github.com/aregee/moksaya/blob/master/profiles/api.py#L177-L197
>
> [2] -
> https://github.com/revsys/django-friendship/blob/master/friendship/models.py#L125-L296
>
>
>
>
>
> --
>
> ---
> Rahul Gaur
> irc : iamaregee2
> Web: http://www.rahulgaur.info
> Github: https://github.com/aregee
>
> --
> 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.




django ajax runtime error - URL doesn't end in slash

2013-08-10 Thread Robin Lery
I am practicing from a tutorial where I have reached to create a search box
with jquery and ajax. Every thing is going good, except, when i press any
key in the search, I get an error,

RuntimeError at /articles/search You called this URL via POST, but the URL
doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect
to the slash URL while maintaining POST data. Change your form to point to
localhost:8000/articles/search/ (note the trailing slash), or set
APPEND_SLASH=False in your Django settings.

I checked for "/" in my code, but its there. Don't know what's going on.
Please help.

application's urls.py:

url(r'^search/$', 'article.views.search_title'),)

views.py:

def search_title(request):
if request.method == "POST":
search_text = request.POST['search_text']
else:
search_text = ''

articles = Article.objects.filter(title__contains=search_text)

return render_to_response('ajax_search.html', {'article': article})

I'm using jquery version: jquery-2.0.0.min.js

ajax.js:

$(function(){

$('#search').keyup(function() {

$.ajax({
type: "POST",
url: '/articles/search/',
data: {
'search_text' : $('#search').val(),
'csrfmiddlewaretoken' :
$("input[name=csrfmiddlewaretoken]").val()
},
success: searchSuccess,
dataType: 'html'
});

});
});
function searchSuccess(data, textStatus, jqXHR){
$('#search-results').html(data);}

And even when I inspect the ajax.js, in the last line

$('#search-results').html(data);

It reads it as:

$('#search-results').html(date);

Please help me somebody. Thank you.

My main url:

(r'^articles/', include('article.urls')),

-- 
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: django ajax runtime error - URL doesn't end in slash

2013-08-10 Thread Robin Lery
Ok! Here it is:

{% extends "base.html" %}

{% block sidebar %}

Articles
Create Article


Search
{% csrf_token %}





{% endblock %}

{% block content %}

Language is: {{language}}
Session Language is: {{session_language}}

{% if articles.count > 0 %}
{% for article in articles %}

{{article.title}}
{{article.body | lower | truncatewords:"10"}}
{{ article.likes }} people liked this article.


{% endfor %}
{% else %}
None to show.
{% endif %}

{% endblock %}


On Sat, Aug 10, 2013 at 11:22 PM, Jonathan D. Baker <
jonathandavidba...@gmail.com> wrote:

> Can you paste the markup for your search form?
>
> Sent from my iPhone
>
> On Aug 10, 2013, at 11:46 AM, Robin Lery  wrote:
>
> I am practicing from a tutorial where I have reached to create a search
> box with jquery and ajax. Every thing is going good, except, when i press
> any key in the search, I get an error,
>
> RuntimeError at /articles/search You called this URL via POST, but the URL
> doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect
> to the slash URL while maintaining POST data. Change your form to point to
> localhost:8000/articles/search/ (note the trailing slash), or set
> APPEND_SLASH=False in your Django settings.
>
> I checked for "/" in my code, but its there. Don't know what's going on.
> Please help.
>
> application's urls.py:
>
> url(r'^search/$', 'article.views.search_title'),)
>
> views.py:
>
> def search_title(request):
> if request.method == "POST":
> search_text = request.POST['search_text']
> else:
> search_text = ''
>
> articles = Article.objects.filter(title__contains=search_text)
>
> return render_to_response('ajax_search.html', {'article': article})
>
>  I'm using jquery version: jquery-2.0.0.min.js
>
> ajax.js:
>
> $(function(){
>
> $('#search').keyup(function() {
>
> $.ajax({
> type: "POST",
> url: '/articles/search/',
> data: {
> 'search_text' : $('#search').val(),
> 'csrfmiddlewaretoken' : 
> $("input[name=csrfmiddlewaretoken]").val()
> },
> success: searchSuccess,
> dataType: 'html'
> });
>
> });
> });
> function searchSuccess(data, textStatus, jqXHR){
> $('#search-results').html(data);}
>
> And even when I inspect the ajax.js, in the last line
>
> $('#search-results').html(data);
>
> It reads it as:
>
> $('#search-results').html(date);
>
> Please help me somebody. Thank you.
>
> My main url:
>
> (r'^articles/', include('article.urls')),
>
>  --
> 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.




django windows user

2013-08-10 Thread Robin Lery
Hello,
I am a windows user, and its great learning django and python as well. I am
just curious that, when I happen to deploy my site for production, is it
helpful to deploy in unix system. And if there is, please guide me to use
ssh and other stuff that is required to deploy so. Any help will be highly
appreciated.
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: django windows user

2013-08-11 Thread Robin Lery
No, i don't have a linux server or hosting provider yet. I was just
curious, as when the time will come to deploy in production level, what
other basic things should I know. I will try the tutorials on ssh that you
gave me. And thank you for your guidance!


On Sun, Aug 11, 2013 at 4:51 AM, Aaron C. de Bruyn wrote:

> Google is your friend.
>
> The first tutorial that came up when I searched for 'ssh for windows
> users' was this site:
> http://support.suso.com/supki/SSH_Tutorial_for_Windows
>
> Do you have an existing Linux server at your house or with a hosting
> provider?
>
> If managing a Linux server is too steep of a learning curve, there are
> several providers out there that will do that for you and provide you a
> simple way to deploy your application.
>
> A good resource is Django Hosting: http://djangohosting.com/
>
> Each provider has different requirements for 'automagically' deploying
> your site.  Some use 'requirements.txt' file or a 'Procfile'.
>
> Some people find Heroku easy and cheap for deploying small test
> applications: https://www.heroku.com/
>
> If you have specific questions, please ask them and the community would be
> glad to assist.
>
> -A
>
>
>
> On Sat, Aug 10, 2013 at 3:27 PM, Robin Lery  wrote:
>
>> Hello,
>> I am a windows user, and its great learning django and python as well. I
>> am just curious that, when I happen to deploy my site for production, is it
>> helpful to deploy in unix system. And if there is, please guide me to use
>> ssh and other stuff that is required to deploy so. Any help will be highly
>> appreciated.
>> 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: django windows user

2013-08-12 Thread Robin Lery
Thank you all! Just one more question though, does hosting provider
provides any interface like virtual machine or so? It would have been great
if they were.


On Mon, Aug 12, 2013 at 5:09 AM, Mike Dewhirst wrote:

> On 12/08/2013 8:47am, Aaron C. de Bruyn wrote:
>
>> MySQL or Postgresql for your database,  followed by some basic SSH/SCP
>> knowledge.  For Windows users I recommend two tools:  PuTTY and WinSCP.
>>
>
> If you have a choice go with PostgreSQL and Filezilla is a useful tool
> which knows the SSL/TLS protocols.
>
>
> --
> 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
> .
> 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.




RequestContext and request.user

2013-08-16 Thread Robin Lery
Hello,
I am all confused about these two things:
context_instance = RequestContext and request.user

Are they both equal? I suppose RequestContext includes a user varialble
from the given template. And request.user would also give the current
user's info, i guess. Can someone please give me insight about these two.
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: RequestContext and request.user

2013-08-17 Thread Robin Lery
Thank you Lucas!


On Fri, Aug 16, 2013 at 10:55 PM, Lucas Magnum wrote:

> Robin,
> RequestContext, includes TEMPLATE_CONTEXT_PROCESSORS results.
> request is a result of "django.core.context_processors.request".
>
>
> https://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-context-requestcontext
>
> []'s
>
> Lucas Magnum.
>
>
> 2013/8/16 Robin Lery 
>
>> Hello,
>> I am all confused about these two things:
>> context_instance = RequestContext and request.user
>>
>> Are they both equal? I suppose RequestContext includes a user varialble
>> from the given template. And request.user would also give the current
>> user's info, i guess. Can someone please give me insight about these two.
>> 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.


django query

2013-08-17 Thread Robin Lery
Hello,
I have a model like this:

class Forum(models.Model):
question = models.CharField(max_length=150)
body = models.TextField()
pub_date = models.DateTimeField(default=datetime.now)
image = models.ImageField(upload_to=get_upload_file_name)
creator = models.ForeignKey(User, related_name="creator_set")
likes = models.ManyToManyField(User, through="Like")

def __unicode__(self):
return self.question

class Like(models.Model):
forum = models.ForeignKey(Forum)
liked = models.ForeignKey(User)
liked_date = models.DateTimeField(default=datetime.now)

def __unicode__(self):
return "%s likes %s" % (self.liked, self.forum)

Now doing this gets me the list of users liked the forum:

>>>forums = Forum.objects.all()
>>>forums
>>>[, ]

But how do i get the username, or the users to use in the template. I get
all the list, like:

[, ]
[, ]

Please help.

-- 
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.


django static files through apache in windows

2013-08-22 Thread Robin Lery
I have configured apache to serve my project. But I can't yet configure it
to serve static files. Till now in my httpd.conf I have appended the code
that django documentation provides and its like this:

WSGIScriptAlias / C:/Users/robin/web/facebook/facebook/wsgi.py
WSGIPythonPath C:/Users/robin/web/facebook/



Order deny,allow
Allow from all



Now, what next do I do to serve static files through apache server. I know
its best to serve static files through nginx or other server, but it was to
hard to find tutorial for windows. So I would highly appreciate if someone
would guide me to serve static files throught apache as I am half way down
there, in windows. Or if some tutorials for other server for windows will
also be appreciated. 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: django static files through apache in windows

2013-08-22 Thread Robin Lery
my

STATIC_ROOT = 'C:/Users/robin/web/static_files_for_facebook/'

STATIC_URL = '/static/'

In httpd.conf I have added:

#Serve static files
AliasMatch /static/ C:/Users/robin/web/static_files_for_facebook/

   Order deny,allow
   Allow from all



After collectstatic command it has collected the static files, but its
still now showing up.




On Thu, Aug 22, 2013 at 10:15 PM, Tom Evans wrote:

> On Thu, Aug 22, 2013 at 5:14 PM, Robin Lery  wrote:
> > I have configured apache to serve my project. But I can't yet configure
> it
> > to serve static files. Till now in my httpd.conf I have appended the code
> > that django documentation provides and its like this:
> >
> > WSGIScriptAlias / C:/Users/robin/web/facebook/facebook/wsgi.py
> > WSGIPythonPath C:/Users/robin/web/facebook/
> >
> > 
> > 
> > Order deny,allow
> > Allow from all
> > 
> > 
> >
> > Now, what next do I do to serve static files through apache server. I
> know
> > its best to serve static files through nginx or other server, but it was
> to
> > hard to find tutorial for windows. So I would highly appreciate if
> someone
> > would guide me to serve static files throught apache as I am half way
> down
> > there, in windows. Or if some tutorials for other server for windows will
> > also be appreciated. Thank you!
>
> This is documented in django's documentation:
>
>
> https://docs.djangoproject.com/en/1.5/howto/deployment/wsgi/modwsgi/#serving-files
>
> Create a directory somewhere on disk, and add it as a location alias
> to your apache config, like so
>
> Alias /static/ C:/path/to/dir/you/made/
> 
>Order deny,allow
>Allow from all
> 
>
> Set the following settings:
>
> STATIC_ROOT = "C:/path/to/dir/you/made"
> STATIC_URL = "/static/"
>
> Run "python manage.py collectstatic".
>
> Cheers
>
> Tom
>
> --
> 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: django static files through apache in windows

2013-08-22 Thread Robin Lery
STATICFILES_DIRS = (
('assets','C:/Users/robin/web/facebook/static'),
)


On Thu, Aug 22, 2013 at 11:36 PM, Robin Lery  wrote:

> my
>
> STATIC_ROOT = 'C:/Users/robin/web/static_files_for_facebook/'
>
> STATIC_URL = '/static/'
>
> In httpd.conf I have added:
>
> #Serve static files
> AliasMatch /static/ C:/Users/robin/web/static_files_for_facebook/
> 
>Order deny,allow
>Allow from all
> 
>
>
> After collectstatic command it has collected the static files, but its
> still now showing up.
>
>
>
>
> On Thu, Aug 22, 2013 at 10:15 PM, Tom Evans wrote:
>
>> On Thu, Aug 22, 2013 at 5:14 PM, Robin Lery  wrote:
>> > I have configured apache to serve my project. But I can't yet configure
>> it
>> > to serve static files. Till now in my httpd.conf I have appended the
>> code
>> > that django documentation provides and its like this:
>> >
>> > WSGIScriptAlias / C:/Users/robin/web/facebook/facebook/wsgi.py
>> > WSGIPythonPath C:/Users/robin/web/facebook/
>> >
>> > 
>> > 
>> > Order deny,allow
>> > Allow from all
>> > 
>> > 
>> >
>> > Now, what next do I do to serve static files through apache server. I
>> know
>> > its best to serve static files through nginx or other server, but it
>> was to
>> > hard to find tutorial for windows. So I would highly appreciate if
>> someone
>> > would guide me to serve static files throught apache as I am half way
>> down
>> > there, in windows. Or if some tutorials for other server for windows
>> will
>> > also be appreciated. Thank you!
>>
>> This is documented in django's documentation:
>>
>>
>> https://docs.djangoproject.com/en/1.5/howto/deployment/wsgi/modwsgi/#serving-files
>>
>> Create a directory somewhere on disk, and add it as a location alias
>> to your apache config, like so
>>
>> Alias /static/ C:/path/to/dir/you/made/
>> 
>>Order deny,allow
>>Allow from all
>> 
>>
>> Set the following settings:
>>
>> STATIC_ROOT = "C:/path/to/dir/you/made"
>> STATIC_URL = "/static/"
>>
>> Run "python manage.py collectstatic".
>>
>> Cheers
>>
>> Tom
>>
>> --
>> 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: django static files through apache in windows

2013-08-22 Thread Robin Lery
In my html file I have link the css with 'assets', `href="{% static
"assets/css/face.css" %}">`. But there are two folders `assets` and
`admin`, after I made the command collectstatic. Is it the problem? Should
I direct css to `admin`?


On Thu, Aug 22, 2013 at 11:37 PM, Robin Lery  wrote:

> STATICFILES_DIRS = (
> ('assets','C:/Users/robin/web/facebook/static'),
> )
>
>
> On Thu, Aug 22, 2013 at 11:36 PM, Robin Lery  wrote:
>
>> my
>>
>> STATIC_ROOT = 'C:/Users/robin/web/static_files_for_facebook/'
>>
>> STATIC_URL = '/static/'
>>
>> In httpd.conf I have added:
>>
>> #Serve static files
>> AliasMatch /static/ C:/Users/robin/web/static_files_for_facebook/
>> 
>>Order deny,allow
>>Allow from all
>> 
>>
>>
>> After collectstatic command it has collected the static files, but its
>> still now showing up.
>>
>>
>>
>>
>> On Thu, Aug 22, 2013 at 10:15 PM, Tom Evans wrote:
>>
>>> On Thu, Aug 22, 2013 at 5:14 PM, Robin Lery  wrote:
>>> > I have configured apache to serve my project. But I can't yet
>>> configure it
>>> > to serve static files. Till now in my httpd.conf I have appended the
>>> code
>>> > that django documentation provides and its like this:
>>> >
>>> > WSGIScriptAlias / C:/Users/robin/web/facebook/facebook/wsgi.py
>>> > WSGIPythonPath C:/Users/robin/web/facebook/
>>> >
>>> > 
>>> > 
>>> > Order deny,allow
>>> > Allow from all
>>> > 
>>> > 
>>> >
>>> > Now, what next do I do to serve static files through apache server. I
>>> know
>>> > its best to serve static files through nginx or other server, but it
>>> was to
>>> > hard to find tutorial for windows. So I would highly appreciate if
>>> someone
>>> > would guide me to serve static files throught apache as I am half way
>>> down
>>> > there, in windows. Or if some tutorials for other server for windows
>>> will
>>> > also be appreciated. Thank you!
>>>
>>> This is documented in django's documentation:
>>>
>>>
>>> https://docs.djangoproject.com/en/1.5/howto/deployment/wsgi/modwsgi/#serving-files
>>>
>>> Create a directory somewhere on disk, and add it as a location alias
>>> to your apache config, like so
>>>
>>> Alias /static/ C:/path/to/dir/you/made/
>>> 
>>>Order deny,allow
>>>Allow from all
>>> 
>>>
>>> Set the following settings:
>>>
>>> STATIC_ROOT = "C:/path/to/dir/you/made"
>>> STATIC_URL = "/static/"
>>>
>>> Run "python manage.py collectstatic".
>>>
>>> Cheers
>>>
>>> Tom
>>>
>>> --
>>> 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.


my django admin page don't have the css when viewed over the apache server

2013-08-24 Thread Robin Lery
I just finished to serve my pages on the internet through apache. I can see
my webpage nicely, but when I try the admin, the django admin page don't
have the css with it, just the html page. But my webpage's css are
displaying nicely. What am I missing? Please guide me. Thank you!

my http.conf snippet:


WSGIPythonPath C:/Users/robin/web/etc/etc






Order deny,allow

Allow from all






#Alias /robots.txt /path/to/mysite.com/static/robots.txt

#Alias /favicon.ico /path/to/mysite.com/static/favicon.ico


AliasMatch ^/([^/]*\.css) C:/Users/robin/web/etc/etc/static/styles/$1


#Alias /media/ /path/to/mysite.com/media/

Alias /static/ C:/Users/robin/web/etc/etc/static/




Order deny,allow

Allow from all




#

#Order deny,allow

#Allow from all

#


WSGIScriptAlias / C:/Users/robin/web/etc/etc/etc/wsgi.py






Order allow,deny

Allow from all





-- 
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: Import Error: cannot import name timezone

2013-08-24 Thread Robin Lery
It should be
'from django.utils import timezone'
and not
'from django.db.utils import timezone'


On Sun, Aug 25, 2013 at 2:58 AM, Patrick Larmann  wrote:

> He Guys,
> I am currently completing part 1 of the django tutorial and having trouble
> with getting on of the modules correctly set up.
> I attached my output and my moduls.py file.
>
> --
> 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: Import Error: cannot import name timezone

2013-08-25 Thread Robin Lery
Good to hear that!


On Sun, Aug 25, 2013 at 7:19 AM, Patrick Larmann  wrote:

> Thanks fixed it?
>
>
> On Saturday, August 24, 2013 5:45:47 PM UTC-4, Robin Lery wrote:
>
>> It should be
>> 'from django.utils import timezone'
>> and not
>> 'from django.db.utils import timezone'
>>
>>
>> On Sun, Aug 25, 2013 at 2:58 AM, Patrick Larmann 
>> wrote:
>>
>>> He Guys,
>>> I am currently completing part 1 of the django tutorial and having
>>> trouble with getting on of the modules correctly set up.
>>> I attached my output and my moduls.py file.
>>>
>>> --
>>> 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...@**googlegroups.com.
>>> To post to this group, send email to django...@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.
>

-- 
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.


Passing variables to css file in django

2013-08-25 Thread Robin Lery
Is it possible to pass variables in css files, like in html file. Example:


In views.py:

def home(request):
bgcolor = "#999"
...
...

In the css file:

body {
background-color : {{bgcolor}};
}


If yes, can you please guide me how to achieve this? I would really
appreciate. 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: Passing variables to css file in django

2013-08-25 Thread Robin Lery
Oh! I am sorry. What I meant was, how do I let users customize their page
if they wanted to? I suppose I could have done this without using external
stylesheet, but yes, CSS is served fastest if it's static. I hope, I made
myself clear. Please guide me if there's a way to achive this


On Mon, Aug 26, 2013 at 5:39 AM, Andy McKay  wrote:

> Any string can be rendered as a template. This is covered pretty well in
> the docs:
>
> https://docs.djangoproject.com/en/dev/ref/templates/api/
>
> For example:
>
> >>> from django.template import Context, Template
> >>> t = Template("body { background-color: {{ bgcolor }} }")
> >>> c = Context({'bgcolor': '#999'})
> >>> t.render(context=c)
> u'body { background-color: #999 }'
>
> However, CSS is served fastest if it's static and on a CDN and not using a
> template and CPU resources to render.
>
> --
> 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: [] error

2013-08-26 Thread Robin Lery
You gave the .pyc file.


On Mon, Aug 26, 2013 at 7:47 PM, Patrick Larmann  wrote:

> Hello guys I am following the django docs tutorial part 1 and am having
> trouble moving on. Instead of receiving [] i get   [ Poll object>]. I have tried converting the unicode to str but to no avail.
> I am just trying to move on. THx guys.
>
> --
> 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: Removing the logged in user's name from the list of users in django

2013-08-30 Thread Robin Lery
I can still see my name (the logged in user's name) on the list..


On Fri, Aug 30, 2013 at 10:05 PM, C. Kirby  wrote:

> To remove the current user from your list just use an if statement in your
> template that tests the user instance you are iterating over against
> request.user
> i.e.
>
> {% for likes in forum.likes.all %}
>  {% if not likes.user is request.user %} href="/get/{{likes.user}}">{{l**ikes.get_full_name}}{% endif %}
> {% endfor %}
>
> To reverse the list I think you can do:
>
> {% for likes in forum.likes.all.reverse %}
>
>
> On Friday, August 30, 2013 10:35:46 AM UTC-5, Robin Lery wrote:
>>
>> I have a template that displays the numbers of likes and name of the
>> users liked the forum. But I don't want the request.user's (logged in
>> user's) name in the list, I just want the other user's name and not the
>> user itself. How do I achieve this? And also I want the list of the names
>> in the reverse order in the template (now its showing the latest liked user
>> in the last of the list.). Please guide me. Thank you.[image: Inline
>> image 1]
>>
>> forums.html:
>>
>> {% extends "base.html" %}{% load forum_tags %}
>> {% block content %}Logged in as -- {{request.user}}Forums:
>> {% if forums.count > 0 %}
>> {% for forum in forums %}
>> > href="/forum/get/{{forum.id}}/**">{{forum.question}}
>> {{forum.body | truncatewords:"30"}}
>> {% if user in forum.likes.all and forum.likes.count > 1 %}
>> http://forum.id>}}/">Unlike You and {{forum.likes.count | substract:1}} 
>> others liked
>> {% elif user in forum.likes.all %}
>> You liked it
>> {% else %}
>> http://forum.id>}}/">Like
>> {% endif %}
>> {% for likes in forum.likes.all %}
>> > href="/get/{{likes.user}}">{{l**ikes.get_full_name}}
>> {% endfor %}
>> {% endfor %}
>> {% else %}
>> Sorry! No forum to display.
>> {% endif %}
>> {% endblock %}
>>
>>
>> snippet of views.py:
>>
>> def forums(request):
>> forums = Forum.objects.all()
>> c = {'forums': forums}
>> return render(request, 'forums.html', c)
>>
>>   --
> 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.


Do I always have to run collectstatic to serve uploaded images by apache?

2013-09-04 Thread Robin Lery
I have a site, where users can upload images. And it works fine in django's
own server. But I am using apache to serve both my app and statics. And
when I upload any image, I can't see the pics. Only when I runcollectstatic I
can see them. Do I always have to run collectstatic? Is there any better
way to do this?

my settings.py snippet:

MEDIA_ROOT = 'C:/Users/Robin/web/leo/static'

STATIC_ROOT = 'C:/Users/Robin/static/'

STATICFILES_DIRS = (
"C:/Users/Robin/web/leo/static",

apache http.cont snippet:

AliasMatch ^/([^/]*\.css) C:/Users/Robin/static/styles/$1
Alias /static/ C:/Users/Robin/static/
Order deny,allowAllow from all
WSGIScriptAlias / C:/Users/Robin/web/leo/leo/wsgi.py
Order
allow,denyAllow from all

Please guide me. Any help will be appreciated greatly. 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: Do I always have to run collectstatic to serve uploaded images by apache?

2013-09-05 Thread Robin Lery
This is my template. Can you please check where I am wrong... Thank you
though!

{% block content %}


{% for Status in status %}
{{
Status.creator.get_full_name }}
{% if Status.image %}





{{Status}}


{% else %}
{{Status}}


{% endif %}
{% endfor %}


{% endblock %}



On Thu, Sep 5, 2013 at 9:51 PM, Kelvin Wong  wrote:

> Check your templates. I bet your tag there is giving the wrong root
> relative path to the user uploads.
>
>
> https://docs.djangoproject.com/en/dev/ref/templates/builtins/#get-media-prefix
>
> If Apache is giving you problems, what does it say in your Apache logs?
> Try debugging this like you would an Apache configuration error.
>
> K
>
>
> On Thursday, September 5, 2013 8:35:49 AM UTC-7, Robin Lery wrote:
>
>> I did as you told, but I can only see it, when I reload the page served
>> by the django's inbuilt server. Kindly check this -
>> https://mail.google.com/**mail/u/0/#sent/**140ee7fdc09d4f22<https://mail.google.com/mail/u/0/#sent/140ee7fdc09d4f22>
>>
>>
>> On Thu, Sep 5, 2013 at 2:29 AM, Kelvin Wong  wrote:
>>
>>> The MEDIA_ROOT is the local system location where the FileField in your
>>> models is going to store incoming files. Users submit files and they are
>>> placed in the location specified by the 'upload_to' setting of the field
>>> (usually a directory within MEDIA_ROOT).
>>>
>>> https://docs.djangoproject.**com/en/dev/ref/models/fields/#**
>>> django.db.models.FileField.**upload_to<https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField.upload_to>
>>>
>>> You should remove your MEDIA_ROOT from STATICFILES_DIRS.
>>>
>>> Then you should review this documentation.
>>>
>>> https://docs.djangoproject.**com/en/dev/topics/http/file-**uploads/<https://docs.djangoproject.com/en/dev/topics/http/file-uploads/>
>>>
>>> The 'collectstatic' command collects your static assets, not user
>>> submitted content. Your system is misconfigured and that is why it is
>>> collecting user submitted files.
>>>
>>> K
>>>
>>
>>  --
> 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.


Does easy thumbnails for django work for apache server?

2013-09-05 Thread Robin Lery
I have a page, which is served by apache. When I upload images by the
django's server (on localhost:8000) page, it does show me the uploaded
image properly. However when I upload images by the apache server (on
localhost) page, it does not show the uploaded image. Only when I reload
the page on the django's inbuilt server (localhost:8000) i can see it on
both the page served by the apache and django's server.

This was the index.html:

{% load static from staticfiles %}{% load thumbnail %}



leo



And here's the other part of it for image:

{% for Status in status %}
{{
Status.creator.get_full_name }}
{% if Status.image %}





{{Status}}


{% else %}
{{Status}}


{% endif %}
{% endfor %}

After I removed the EASY THUMBNAILS tag from the html file and made these
changes on the html file, I was ok.

{% load static from staticfiles %}



And this:







Why is apache behaving so? Or am I making some mistake here? Is it the
problem of easy_thumbnails tag??? Please guide 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.


Re: Do I always have to run collectstatic to serve uploaded images by apache?

2013-09-05 Thread Robin Lery
The problem was the easy-thumbnails tag! After I removed it, I was good to
go. Thanks though!


On Thu, Sep 5, 2013 at 10:41 PM, Robin Lery  wrote:

> my models.py :
>
> def get_upload_file_name(instance, filename):
> return "uploaded_files/%s_%s" %(str(time()).replace('.','_'), filename)
>
> class Status(models.Model):
> status = models.TextField()
> image = models.ImageField(upload_to=get_upload_file_name, blank=True)
>  pub_date = models.DateTimeField(default=datetime.now)
> creator = models.ForeignKey(User, related_name="creator_set")
>  likes = models.ManyToManyField(User, through="Like")
>
> class Meta:
> ordering = ['-pub_date']
>  verbose_name_plural = ('Status')
>
> def __unicode__(self):
> return self.status
>
>
> On Thu, Sep 5, 2013 at 10:39 PM, Robin Lery  wrote:
>
>> This is my template. Can you please check where I am wrong... Thank you
>> though!
>>
>> {% block content %}
>> 
>> 
>> {% for Status in status %}
>> {{ Status.creator.get_full_name 
>> }}
>> {% if Status.image %}
>> 
>> 
>> 
>> 
>> 
>> {{Status}}
>> 
>> 
>> {% else %}
>> {{Status}}
>> 
>> 
>> {% endif %}
>> {% endfor %}
>> 
>> 
>> {% endblock %}
>>
>>
>>
>> On Thu, Sep 5, 2013 at 9:51 PM, Kelvin Wong  wrote:
>>
>>> Check your templates. I bet your tag there is giving the wrong root
>>> relative path to the user uploads.
>>>
>>>
>>> https://docs.djangoproject.com/en/dev/ref/templates/builtins/#get-media-prefix
>>>
>>> If Apache is giving you problems, what does it say in your Apache logs?
>>> Try debugging this like you would an Apache configuration error.
>>>
>>> K
>>>
>>>
>>> On Thursday, September 5, 2013 8:35:49 AM UTC-7, Robin Lery wrote:
>>>
>>>> I did as you told, but I can only see it, when I reload the page served
>>>> by the django's inbuilt server. Kindly check this -
>>>> https://mail.google.com/**mail/u/0/#sent/**140ee7fdc09d4f22<https://mail.google.com/mail/u/0/#sent/140ee7fdc09d4f22>
>>>>
>>>>
>>>> On Thu, Sep 5, 2013 at 2:29 AM, Kelvin Wong  wrote:
>>>>
>>>>> The MEDIA_ROOT is the local system location where the FileField in
>>>>> your models is going to store incoming files. Users submit files and they
>>>>> are placed in the location specified by the 'upload_to' setting of the
>>>>> field (usually a directory within MEDIA_ROOT).
>>>>>
>>>>> https://docs.djangoproject.**com/en/dev/ref/models/fields/#**
>>>>> django.db.models.FileField.**upload_to<https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField.upload_to>
>>>>>
>>>>> You should remove your MEDIA_ROOT from STATICFILES_DIRS.
>>>>>
>>>>> Then you should review this documentation.
>>>>>
>>>>> https://docs.djangoproject.**com/en/dev/topics/http/file-**uploads/<https://docs.djangoproject.com/en/dev/topics/http/file-uploads/>
>>>>>
>>>>> The 'collectstatic' command collects your static assets, not user
>>>>> submitted content. Your system is misconfigured and that is why it is
>>>>> collecting user submitted files.
>>>>>
>>>>> K
>>>>>
>>>>
>>>>  --
>>> 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: Does easy thumbnails for django work for apache server?

2013-09-05 Thread Robin Lery
And also in the uploaded directory it was creating an extra image for the
same image.


On Thu, Sep 5, 2013 at 11:42 PM, Robin Lery  wrote:

> I have a page, which is served by apache. When I upload images by the
> django's server (on localhost:8000) page, it does show me the uploaded
> image properly. However when I upload images by the apache server (on
> localhost) page, it does not show the uploaded image. Only when I reload
> the page on the django's inbuilt server (localhost:8000) i can see it on
> both the page served by the apache and django's server.
>
> This was the index.html:
>
> {% load static from staticfiles %}{% load thumbnail %}
> 
> 
> 
> leo
> 
> 
>
> And here's the other part of it for image:
>
> {% for Status in status %}
> {{ Status.creator.get_full_name 
> }}
> {% if Status.image %}
> 
> 
> 
> 
> 
> {{Status}}
> 
> 
> {% else %}
> {{Status}}
> 
> 
> {% endif %}
> {% endfor %}
>
>  After I removed the EASY THUMBNAILS tag from the html file and made these
> changes on the html file, I was ok.
>
> {% load static from staticfiles %}
> 
> 
>
> And this:
>
> 
> 
>  width=300px />
> 
> 
>
>  Why is apache behaving so? Or am I making some mistake here? Is it the
> problem of easy_thumbnails tag??? Please guide 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.


Re: Do I always have to run collectstatic to serve uploaded images by apache?

2013-09-05 Thread Robin Lery
I did as you told, but I can only see it, when I reload the page served by
the django's inbuilt server. Kindly check this -
https://mail.google.com/mail/u/0/#sent/140ee7fdc09d4f22


On Thu, Sep 5, 2013 at 2:29 AM, Kelvin Wong  wrote:

> The MEDIA_ROOT is the local system location where the FileField in your
> models is going to store incoming files. Users submit files and they are
> placed in the location specified by the 'upload_to' setting of the field
> (usually a directory within MEDIA_ROOT).
>
>
> https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField.upload_to
>
> You should remove your MEDIA_ROOT from STATICFILES_DIRS.
>
> Then you should review this documentation.
>
> https://docs.djangoproject.com/en/dev/topics/http/file-uploads/
>
> The 'collectstatic' command collects your static assets, not user
> submitted content. Your system is misconfigured and that is why it is
> collecting user submitted files.
>
> K
>
>
> On Wednesday, September 4, 2013 12:41:03 PM UTC-7, Robin Lery wrote:
>>
>> I have a site, where users can upload images. And it works fine in
>> django's own server. But I am using apache to serve both my app and
>> statics. And when I upload any image, I can't see the pics. Only when I run
>> collectstatic I can see them. Do I always have to run collectstatic? Is
>> there any better way to do this?
>>
>> my settings.py snippet:
>>
>> MEDIA_ROOT = 'C:/Users/Robin/web/leo/**static'
>>
>> STATIC_ROOT = 'C:/Users/Robin/static/'
>>
>> STATICFILES_DIRS = (
>> "C:/Users/Robin/web/leo/**static",
>>
>>  apache http.cont snippet:
>>
>> AliasMatch ^/([^/]*\.css) C:/Users/Robin/static/styles/$**1
>> Alias /static/ C:/Users/Robin/static/
>> Order deny,allowAllow from all
>> WSGIScriptAlias / C:/Users/Robin/web/leo/leo/wsg**i.py
>> Order allow,denyAllow 
>> from all
>>
>>  Please guide me. Any help will be appreciated greatly. 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: Do I always have to run collectstatic to serve uploaded images by apache?

2013-09-05 Thread Robin Lery
my models.py :

def get_upload_file_name(instance, filename):
return "uploaded_files/%s_%s" %(str(time()).replace('.','_'), filename)

class Status(models.Model):
status = models.TextField()
image = models.ImageField(upload_to=get_upload_file_name, blank=True)
pub_date = models.DateTimeField(default=datetime.now)
creator = models.ForeignKey(User, related_name="creator_set")
likes = models.ManyToManyField(User, through="Like")

class Meta:
ordering = ['-pub_date']
verbose_name_plural = ('Status')

def __unicode__(self):
return self.status


On Thu, Sep 5, 2013 at 10:39 PM, Robin Lery  wrote:

> This is my template. Can you please check where I am wrong... Thank you
> though!
>
> {% block content %}
> 
> 
> {% for Status in status %}
> {{ Status.creator.get_full_name 
> }}
> {% if Status.image %}
> 
> 
> 
> 
> 
> {{Status}}
> 
> 
> {% else %}
> {{Status}}
> 
> 
> {% endif %}
> {% endfor %}
> 
> 
> {% endblock %}
>
>
>
> On Thu, Sep 5, 2013 at 9:51 PM, Kelvin Wong  wrote:
>
>> Check your templates. I bet your tag there is giving the wrong root
>> relative path to the user uploads.
>>
>>
>> https://docs.djangoproject.com/en/dev/ref/templates/builtins/#get-media-prefix
>>
>> If Apache is giving you problems, what does it say in your Apache logs?
>> Try debugging this like you would an Apache configuration error.
>>
>> K
>>
>>
>> On Thursday, September 5, 2013 8:35:49 AM UTC-7, Robin Lery wrote:
>>
>>> I did as you told, but I can only see it, when I reload the page served
>>> by the django's inbuilt server. Kindly check this -
>>> https://mail.google.com/**mail/u/0/#sent/**140ee7fdc09d4f22<https://mail.google.com/mail/u/0/#sent/140ee7fdc09d4f22>
>>>
>>>
>>> On Thu, Sep 5, 2013 at 2:29 AM, Kelvin Wong  wrote:
>>>
>>>> The MEDIA_ROOT is the local system location where the FileField in your
>>>> models is going to store incoming files. Users submit files and they are
>>>> placed in the location specified by the 'upload_to' setting of the field
>>>> (usually a directory within MEDIA_ROOT).
>>>>
>>>> https://docs.djangoproject.**com/en/dev/ref/models/fields/#**
>>>> django.db.models.FileField.**upload_to<https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField.upload_to>
>>>>
>>>> You should remove your MEDIA_ROOT from STATICFILES_DIRS.
>>>>
>>>> Then you should review this documentation.
>>>>
>>>> https://docs.djangoproject.**com/en/dev/topics/http/file-**uploads/<https://docs.djangoproject.com/en/dev/topics/http/file-uploads/>
>>>>
>>>> The 'collectstatic' command collects your static assets, not user
>>>> submitted content. Your system is misconfigured and that is why it is
>>>> collecting user submitted files.
>>>>
>>>> K
>>>>
>>>
>>>  --
>> 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.


sorl-thumbnail or easy thumbnail with apache

2013-09-09 Thread Robin Lery
Hello,
Has anyone tried sorl-thumbnail or easy_thumbnail with apache for users
uploaded media images??? I am really stuck with these. When I upload it
using the apache server, it does not load the uploaded image, it only loads
the ones that have been run through the django's inbuilt server. And only
when I run the django's inbuilt server it loads the uploaded image. I think
it does not process the application (sorl-thumbnail or easy_thumbnail) via
apache... Any help will be greatly appreciated. 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: sorl-thumbnail or easy thumbnail with apache

2013-09-09 Thread Robin Lery
I have used it in the templates. Do i use it in the models for uploaded
images???


On Tue, Sep 10, 2013 at 1:31 AM, Robin Lery  wrote:

> Hello,
> Has anyone tried sorl-thumbnail or easy_thumbnail with apache for users
> uploaded media images??? I am really stuck with these. When I upload it
> using the apache server, it does not load the uploaded image, it only loads
> the ones that have been run through the django's inbuilt server. And only
> when I run the django's inbuilt server it loads the uploaded image. I think
> it does not process the application (sorl-thumbnail or easy_thumbnail) via
> apache... Any help will be greatly appreciated. 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: Advanced Tutorial (how to write reusable app), last step does not work

2013-09-09 Thread Robin Lery
In order to create a reusable app, you have to create a new 'templates'
folder in your app and place the the absolute path in the templates
directory in your settings.py. And then create the html files as concerned
with your app in the templates directory you created within the app.

Robin


On Tue, Sep 10, 2013 at 1:40 AM, asherakhet06  wrote:

> Hello.  I'm a rookie as well and I'm having exactly this same issue.
>  Trying to figure out what to do, but haven't been successful
> unfortunately.  Based on what I read (convention over configuration),  I
> understand that I should to make a poll_list.html file and store this in
> templates, to get my site to work.  Or should I just change the name of my
> index.html file in templates?  Am I missing something here? Thanks a lot
> guys.
>
> On Friday, July 26, 2013 8:20:26 PM UTC-4, Cate Liu wrote:
>>
>>
>> I am a new newbie to Django.  Great tutorial BTW.  I followed it to the T
>> and 99.9% worked.
>> Except the last step in the Advanced tutorial, the step 3 in 'Using your
>> own package'.
>> I could see http://127.0.0.1:8000/admin/ and create polls without any
>> problem.
>> But http://127.0.0.1:8000/polls/ would give me the following error.
>>
>> I see there are two problems.
>> 1. /Users/nnn/django_exercises/**mysite/templates/polls/index.**html is
>> the wrong location, it should be $$/django_polls/polls/**
>> templates/polls/index.html.
>> 2. What is polls/poll_list.html?  Nowhere in the tutorial ever created
>> this file, no?
>>
>> Thanks for any advice.
>>
>>
>> --**--**
>> --**
>> TemplateDoesNotExist at /polls/
>>
>> polls/index.html, polls/poll_list.html
>>
>>  Request Method: GET  Request URL: http://127.0.0.1:8000/polls/  Django
>> Version: 1.5.1  Exception Type: TemplateDoesNotExist  Exception Value:
>>
>> polls/index.html, polls/poll_list.html
>>
>>  Exception Location: /Library/Python/2.7/site-**packages/django/template/
>> **loader.py in select_template, line 194  Python Executable:
>> /usr/bin/python  Python Version: 2.7.2  Python Path:
>>
>> ['/Users/nnn/django_exercises/**mysite',
>>  '/Users/nnn/py_pkg/lib/python/**django_polls-0.1-py2.7.egg',
>>  '/Users/nnn/py_pkg/lib/python'**,
>>  
>> '/System/Library/Frameworks/**Python.framework/Versions/2.7/**lib/python27.zip',
>>  
>> '/System/Library/Frameworks/**Python.framework/Versions/2.7/**lib/python2.7',
>>  
>> '/System/Library/Frameworks/**Python.framework/Versions/2.7/**lib/python2.7/plat-darwin',
>>  
>> '/System/Library/Frameworks/**Python.framework/Versions/2.7/**lib/python2.7/plat-mac',
>>  
>> '/System/Library/Frameworks/**Python.framework/Versions/2.7/**lib/python2.7/plat-mac/lib-**scriptpackages',
>>  
>> '/System/Library/Frameworks/**Python.framework/Versions/2.7/**Extras/lib/python',
>>  
>> '/System/Library/Frameworks/**Python.framework/Versions/2.7/**lib/python2.7/lib-tk',
>>  
>> '/System/Library/Frameworks/**Python.framework/Versions/2.7/**lib/python2.7/lib-old',
>>  
>> '/System/Library/Frameworks/**Python.framework/Versions/2.7/**lib/python2.7/lib-dynload',
>>  
>> '/System/Library/Frameworks/**Python.framework/Versions/2.7/**Extras/lib/python/PyObjC',
>>  '/Library/Python/2.7/site-**packages']
>>
>>  Server time: Fri, 26 Jul 2013 16:59:14 -0700
>>
>> Template-loader postmortem
>>
>> Django tried loading these templates, in this order:
>>
>>- Using loader django.template.loaders.**filesystem.Loader:
>>   - /Users/nnn/django_exercises/**mysite/templates/polls/index.**html,
>>   polls/poll_list.html (File does not exist)
>>- Using loader django.template.loaders.app_**directories.Loader:
>>   - 
>> /Library/Python/2.7/site-**packages/django/contrib/auth/**templates/polls/index.html,
>>   polls/poll_list.html (File does not exist)
>>   - 
>> /Library/Python/2.7/site-**packages/django/contrib/admin/**templates/polls/index.html,
>>   polls/poll_list.html (File does not exist)
>>
>>
>>  --
> 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.


Resize image size in the view

2013-09-10 Thread Robin Lery
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.


Resize image in the view

2013-09-10 Thread Robin Lery
Hello,
I have been trying to achieve thumbnail for the uploaded images using
sorl-thumbnail and easy_thumbnail, 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.


Re: Resize image size in the view

2013-09-10 Thread Robin Lery
Yes, same here. That's why I was asking, whether there's a way to call the
resize image in the view.


On Wed, Sep 11, 2013 at 11:55 AM, Karl Arunachal <
kakararunachalserv...@gmail.com> wrote:

> 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.
>

-- 
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 Robin Lery
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'leo.urls'

# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'leo.wsgi.application'

TEMPLATE_DIRS = (
"C:/Users/Robin/web/leo/templates",
"C:/Users/Robin/web/leo/status/templates",
# Put strings here, like "/home/html/django_templates" or
"C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'status',
'sorl.thumbnail',
)

# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
    'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}


On Wed, Sep 11, 2013 at 9:42 PM, carlos  wrote:

> Hi maybe you need check your configuration in your setting.py the
> media_root for example my config is
> https://github.com/CARocha/cesesma/blob/master/cesesma/settings.py
> and other problem maybe the alias media en your apache config. maybe paste
> your virtualhost config
>
> Cheers
>
>
> On Wed, Sep 11, 2013 at 12:26 AM, Robin Lery  wrote:
>
>> Yes, same here. That's why I was asking, whether there's a way to call
>> the resize image in the view.
>>
>>
>> On Wed, Sep 11, 2013 at 11:55 AM, Karl Arunachal <
>> kakararunachalserv...@gmail.com> wrote:
>>
>>> 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 recei

Iframe sandbox security

2013-10-16 Thread Robin Lery
I was planning to create an app where the users can create their own blog
page and others can link it in my web, like facebook. And then, I thought
about using iframe with the sandbox attribute to view the page with
the safe filter
in the template. So, is it safe to implement it in this way??? Or is there
any other way around? Please, any help will be much appreciated!

Thanks.

-- 
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/CA%2B4-nGrGVq2u4Nb0ZROooMM6r3NPvOyX68sBXaR0VF_uFgNAAQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


django-ckeditor image upload giving wrong url of the image

2013-10-17 Thread Robin Lery
When I try text editing and other text related stuffs and save it, the
editor does its job nicely. But when I try to upload an image it just take
a different url. I am on windows. Is it because of this, cause I saw a post
on this 
post,
but it didn't helped me either. It does get saved and they each have their
own thumbnails too. But its just that the wrong urls. I checked the src of
the image, and it was like this,



But it should have been like this,



And sometimes the src of the image is just like this,



This is the snippet of my settings.py:

CKEDITOR_UPLOAD_PATH = 'C:/Users/Nanyoo/web/demo/media'
MEDIA_ROOT = 'C:/Users/Nanyoo/web/demo/media'

I've included its url in my urls.py:

(r'^ckeditor/', include('ckeditor.urls')),

models.py:

from django.db import modelsfrom datetime import datetimefrom
django.contrib.auth.models import Userfrom time import time

def get_upload_file_name(instance, filename):
return "uploaded_files/%s_%s" %(str(time()).replace('.','_'), filename)
class Blog(models.Model):
title = models.CharField(max_length=200)
image = models.ImageField(upload_to=get_upload_file_name, blank=True)
pub_date = models.DateTimeField(default=datetime.now)
creator = models.ForeignKey(User, related_name="creator_set")
body = models.TextField()

In the forms.py:

from django import formsfrom django_summernote.widgets import
SummernoteWidgetfrom ckeditor.widgets import CKEditorWidget
class BlogForm(forms.Form):
title = forms.CharField(max_length=200,widget=SummernoteWidget())
body = forms.CharField(widget=CKEditorWidget())

In the index.html:

{% for blog in blogs %}

{{ blog.title | safe}}
{{ blog.body | safe}}

{% endfor %}

Please help me figure it out. Any help will be greatly appreciated!

Thanks!

-- 
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/CA%2B4-nGomdQf3%3DDbzArYUYeBdyjEhnVbDuc8KLmi%3DdwPsgBsROA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


django - differentiate users in the template

2013-10-30 Thread Robin Lery
So, I am trying to create a user page, and its url will be associated with
its username, something like this

http://domain.com/accounts/profile/robin/

And in that page, I want all the photo's uploaded by that user (here
'robin') to be displayed in the template. And another thing is, in the menu
bar, there's an link for the the profile page for the request.user, i.e.
the logged in user, suppose the user is 'kevin', and it will also direct it
to the request.user's url like:

http://domain.com/accounts/profile/kevin/

Somehow I managed to get the desired output. But what I also wanted was
that, even if I change the url to something different other than the
request.user's name, I wanted the request.user and the other username to be
differentiated easily, so that I can manipulate them in the templates. And
so I hopefully came with this solution. But I really don't know that this
is an appropriate solution. Because what if I change the username to
something other than the request.user and come up with all its information.
Please help me if there's any better way to do it. And feel free to ask me
if you didn't understand the question. Any suggestion will be much
appreciated! Thank you.

test.html:





Photos
{{user_1.username}}




{% block content %}
{% endblock %}



profile_page.html:

{% extends 'test.html' %}
{% block content %}{{user.username}}
{% for photo in photos %}{% endfor %}
{% endblock %}

models.py:

 class Photo(models.Model):
title = models.CharField(max_length=200)
image = models.ImageField(upload_to=get_upload_file_name, blank=True)
pub_date = models.DateTimeField(default=datetime.now)
creator = models.ForeignKey(User, related_name="creator_set")
likes = models.ManyToManyField(User, through="Like")

class Meta:
ordering = ['-pub_date']
verbose_name_plural = ('Photos')

 def __unicode__(self):
return self.title

app's urls.py:

url(r'^profile/(?P\w+)/$', 'userprofile.views.profile_page'),

views.py:

@login_requireddef profile_page(request, username):
if request.user.is_authenticated:
user_1 = request.user
user = User.objects.get(username=username)
user_photos = user.creator_set.all()
return render(request, 'profile_page.html',
{'user':user,'photos':user_photos, 'user_1':user_1})

-- 
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/CA%2B4-nGownkbHyhDVrmq6iZ2fDxmc-jY-5uGCQR74%3D7MdcXak6A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Django - How to combine queries in to one and display it in the template?

2013-11-03 Thread Robin Lery
Suppose this is a model for an app Blog:

class Blog(models.Model):
title = models.CharField(max_length=200)
pub_date = models.DateTimeField(default=datetime.now)
creator = models.ForeignKey(User)
content = BleachField()

And this is another model for an app Status:

class Status(models.Model):
content = BleachField()
pub_date = models.DateTimeField(default=datetime.now)
creator = models.ForeignKey(User)

How do I come up with something like this:

from blog.models import Blogfrom status.models import Status

blog = Blog.objecs.all()
status = Status.objects.all()
all = blog | status

And display all the updates for the user in the template.

updates = user.all_set.all()

So that in the templates I can do, something like this:

{% for each in all %}
{% endfor %}

What I wan't is that, in the home page, I would like to display the updates
of all the user's activity in the latest order,

Eg:

'User updated with new status: blah blah''User published a new
Blog''User published a new Blog'

like in many other social networking sites. And not to display them both
separately. And similarly in the user's profile, display all the activities
of that particular User.

-- 
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/CA%2B4-nGoMQWG0dhwVTbyJnW6O%2BZaJr4Qvrci1aMGYpZrtbTUukw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Transcode video using celery and ffmpeg in django

2015-02-20 Thread Robin Lery
I would like to transcode user uploaded videos using celery. I think first
I should upload the video, and spawn a celery task for transcoding.

Maybe something like this in the tasks.py:

subprocess.call('ffmpeg -i path/.../original path/.../output')
>

Just completed First steps with celery
,
so confused how to do so in the `views.py` and `tasks.py`. Also is it a
good solution? I would really appreciate your help and advice. Thank you.

models.py:

class Video(models.Model):
> user = models.ForeignKey(User)
> title = models.CharField(max_length=100)
> original = models.FileField(upload_to=get_upload_file_name)
> mp4_480 = models.FileField(upload_to=get_upload_file_name)
> mp4_720 = models.FileField(upload_to=get_upload_file_name)
> privacy = models.CharField(max_length=1,choices=PRIVACY,
> default='F')
> pub_date = models.DateTimeField(auto_now_add=True, auto_now=False)
>

my incomplete views.py:


@login_required
> def upload_video(request):
> if request.method == 'POST':
> form = VideoForm(request.POST, request.FILES)
> if form.is_valid():
> if form.cleaned_data:
> user = request.user
> #
> #
> # No IDEA WHAT TO DO NEXT
> #
> #
> return HttpResponseRedirect('/')
>
> else:
> form = VideoForm()
> return render(request, 'upload_video.html', {
> 'form':form
> })
>

-- 
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/CA%2B4-nGoz%3D_qCx%2BbSnOfNFLYiufqUUES3S3T9y4GXoZiaBV9tyw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Transcode video using celery and ffmpeg in django

2015-02-20 Thread Robin Lery
So mp4_480 and mp4_720 should be blank=True and null=True. And then pass
the video instance object to the delay() ???

And also, could you please show me how to write the tasks.py, so that I can
use ffmpeg code (subprocess.call('ffmpeg -i path/.../original
path/.../mp4_720') to transcode.

Thank you.

On Fri, Feb 20, 2015 at 6:49 PM, Vijay Khemlani  wrote:

> Then in your task function you can get the file from the video model
> instance, trascode it, and store it in the corresponding fields of the
> object (mp4_480, mp4_720)
>
> On Fri, Feb 20, 2015 at 10:18 AM, Vijay Khemlani 
> wrote:
>
>> I would do something like this
>>
>> video = Video()
>> video.original = form.cleaned_data['video']  # Assuming the form field is
>> "video"
>> video.user = user
>> video.title = form.cleaned_data['title']  # Assuming the form field is
>> "title"
>> video.save()  # You might need to make the mp4_480 and
>> mp4_720 fields "nullable" on the model
>> yourapp.tasks.transcode_video.delay(video)   # Assuming the task is the
>> "transcode_video" function.
>>
>> return HttpResponseRedirect('/')
>>
>> Then
>>
>>
>> On Fri, Feb 20, 2015 at 10:04 AM, Robin Lery  wrote:
>>
>>> I would like to transcode user uploaded videos using celery. I think
>>> first I should upload the video, and spawn a celery task for transcoding.
>>>
>>> Maybe something like this in the tasks.py:
>>>
>>> subprocess.call('ffmpeg -i path/.../original path/.../output')
>>>>
>>>
>>> Just completed First steps with celery
>>> <http://docs.celeryproject.org/en/latest/getting-started/first-steps-with-celery.html#first-steps>,
>>> so confused how to do so in the `views.py` and `tasks.py`. Also is it a
>>> good solution? I would really appreciate your help and advice. Thank you.
>>>
>>> models.py:
>>>
>>> class Video(models.Model):
>>>> user = models.ForeignKey(User)
>>>> title = models.CharField(max_length=100)
>>>> original = models.FileField(upload_to=get_upload_file_name)
>>>> mp4_480 = models.FileField(upload_to=get_upload_file_name)
>>>> mp4_720 = models.FileField(upload_to=get_upload_file_name)
>>>> privacy = models.CharField(max_length=1,choices=PRIVACY,
>>>> default='F')
>>>> pub_date = models.DateTimeField(auto_now_add=True,
>>>> auto_now=False)
>>>>
>>>
>>> my incomplete views.py:
>>>
>>>
>>> @login_required
>>>> def upload_video(request):
>>>> if request.method == 'POST':
>>>> form = VideoForm(request.POST, request.FILES)
>>>> if form.is_valid():
>>>> if form.cleaned_data:
>>>> user = request.user
>>>> #
>>>> #
>>>> # No IDEA WHAT TO DO NEXT
>>>> #
>>>> #
>>>> return HttpResponseRedirect('/')
>>>>
>>>> else:
>>>> form = VideoForm()
>>>> return render(request, 'upload_video.html', {
>>>> 'form':form
>>>> })
>>>>
>>>  --
>>> 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/CA%2B4-nGoz%3D_qCx%2BbSnOfNFLYiufqUUES3S3T9y4GXoZiaBV9tyw%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CA%2B4-nGoz%3D_qCx%2BbSnOfNFLYiufqUUES3S3T9y4GXoZiaBV9tyw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group 

Add multiple objects of same model at the same time in admin

2015-06-13 Thread Robin Lery
I have a model to upload pictures:

models.py:


> class Snap(models.Model):
> image = models.ImageField(upload_to=get_upload_file_name)
> caption = models.CharField(max_length=150, blank=True, null=True)
> date = models.DateField(default=date.today)
>

admin.py:

class SnapAdmin(admin.ModelAdmin):
> class Meta:
> model = Snap
>
> admin.site.register(Snap, SnapAdmin)
>

In the admin it contains all the Snap's field (i.e. one field to upload an
image ,its caption and the pubdate) which is as expected. How do I add
multiple record of Snap's in one go, without having to save it one by one.
I hope I was clear, if not please ask. Your help and guidance will be very
much appreciated. 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/CA%2B4-nGqOazpPRAhafULpN4HW1ohPAoHUoxne6vyK02s53O21PQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Get the first image src from a post

2015-06-15 Thread Robin Lery
I have a model to write blogs. In that I'm using a wysiwyg editor for the
Blog's descritpion, through which I can insert an image within the
description.

class Blog(models.Model):
title = models.CharField(max_length=150, blank=True)
description = models.TextField()
pubdate = models.DateTimeField(default=timezone.now)
publish = models.BooleanField(default=False)

In the admin it looks like this:

[image: enter image description here]

What I want is to get first image inside the description of the blog, and
present it in the template like this:

[image: enter image description here]

How do get the img src from the description of the blog to use it in the
template? Your help and guidance will be very much appreciated. Thank you.

views.py:

def blog(request):
blogs = Blog.objects.all()

return render(request, 'blogs.html', {
'blogs':blogs
})

template:

  {% for blog in blogs %}
  
   {{blog.pubdate}} 
   {{blog.title}} 
  


  Read more
  
  ***
  
  
  {% endfor %}

-- 
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/CA%2B4-nGo4ZJmArnQ2nvF5f0tp83HA7LJTxdywtO8%2BxsBVp2211g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Add multiple objects of same model at the same time in admin

2015-06-15 Thread Robin Lery
Thank you.

On Mon, Jun 15, 2015 at 10:37 PM, carlos  wrote:

> Hello, use two model and the second model inline one model example
>
> class ModelA(...):
> name = charfield(...)
>
> class ModelB():
> fk(ModelA)
>image = imagefiel(...)
>caption = bla bla bla
>   date = datefield
>
> and them in admin.py
>
> class ModelBInline(admin.TabularInline):
> model = ModelB
> extra = 1
>
> class ModelAAdmin(admin.ModelAdmin):
> inlines = [ModelBInline]
>
> admin.site.register(ModelA, ModelAAdmin)
>
> Cheers
>
>
>
>
>
>
> On Sun, Jun 14, 2015 at 1:08 AM, Carlos Arturo Sanchez Rivera <
> ing.c...@gmail.com> wrote:
>
>> It is easier with decorators
>>
>> @admin.register(Transfer)
>> class TransferAdmin(admin.ModelAdmin):
>> pass
>>
>>
>>
>> El sábado, 13 de junio de 2015, 4:28:38 (UTC-5), Robin Lery escribió:
>>>
>>> I have a model to upload pictures:
>>>
>>> models.py:
>>>
>>>
>>>> class Snap(models.Model):
>>>> image = models.ImageField(upload_to=get_upload_file_name)
>>>> caption = models.CharField(max_length=150, blank=True, null=True)
>>>> date = models.DateField(default=date.today)
>>>>
>>>
>>> admin.py:
>>>
>>> class SnapAdmin(admin.ModelAdmin):
>>>> class Meta:
>>>> model = Snap
>>>>
>>>> admin.site.register(Snap, SnapAdmin)
>>>>
>>>
>>> In the admin it contains all the Snap's field (i.e. one field to upload
>>> an image ,its caption and the pubdate) which is as expected. How do I add
>>> multiple record of Snap's in one go, without having to save it one by
>>> one. I hope I was clear, if not please ask. Your help and guidance will be
>>> very much appreciated. 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/5f3a3841-6605-4250-9299-ff4922c8421f%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/5f3a3841-6605-4250-9299-ff4922c8421f%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> 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/CAM-7rO3ubHWOHVJT6wMjxrPag9G1-OBXDGev9g-RG8PWakzUtQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAM-7rO3ubHWOHVJT6wMjxrPag9G1-OBXDGev9g-RG8PWakzUtQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CA%2B4-nGrbmmOrgCxjSUGdmwhBbbugvk%3DOYEBi-SXfswiNm5nS%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Celery to process task and modify the model fields

2015-07-14 Thread Robin Lery
I would like to convert video into mp4 using ffmpeg and celery for the
asynchronous task. When user uploads a video, it will be for the
original_video and save it. After that I want celery to convert it into a
different version for the mp4_720 field. However I am confused on how to
apply that logic using celery.

app.models.py:

class Video(models.Model):
title = models.CharField(max_length=75)
pubdate = models.DateTimeField(default=timezone.now)
original_video = models.FileField(upload_to=get_upload_file_name)
mp4_720 = models.FileField(upload_to=get_upload_file_name,
blank=True, null=True)
converted = models.BooleanField(default=False)

app.views.py:

def upload_video(request):
if request.POST:
form = VideoForm(request.POST, request.FILES)
if form.is_valid():
video = form.save(commit=False)
video.save()

// Celery to convert the video
convert_video.delay(video)

return HttpResponseRedirect('/')
else:
form = VideoForm()
return render(request, 'upload_video.html', {
'form':form
})

app.tasks.py:

@app.task
def convert_video(video):

// Convert the original video into required format and save it in
the mp4_720 field using the following command:
//subprocess.call('ffmpeg -i (path of the original_video) (video
for mp4_720)')

// Change the converted boolean field to True

// Save

Basically my question is how to save the converted video in mp4_720. Your
help and guidance will be very much appreciated. 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/CA%2B4-nGrKucaFSi7oZoOcHtOXdSsnPEac2_LXLZ2TccRCaWUhzA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Celery to process task and modify the model fields

2015-07-14 Thread Robin Lery
Yes. That time you were the one to guide me. I was looking at other
projects after that.

I am just confused on how to get the video.mp4_720 to be the converted
video. Will you please help.

Thank you.

On Wed, Jul 15, 2015 at 1:15 AM, Vijay Khemlani  wrote:

> I remember this question from... february I think, what's changed since
> then?
>
> On Tue, Jul 14, 2015 at 3:29 PM, Robin Lery  wrote:
>
>> I would like to convert video into mp4 using ffmpeg and celery for the
>> asynchronous task. When user uploads a video, it will be for the
>> original_video and save it. After that I want celery to convert it into
>> a different version for the mp4_720 field. However I am confused on how
>> to apply that logic using celery.
>>
>> app.models.py:
>>
>> class Video(models.Model):
>> title = models.CharField(max_length=75)
>> pubdate = models.DateTimeField(default=timezone.now)
>> original_video = models.FileField(upload_to=get_upload_file_name)
>> mp4_720 = models.FileField(upload_to=get_upload_file_name,
>> blank=True, null=True)
>> converted = models.BooleanField(default=False)
>>
>> app.views.py:
>>
>> def upload_video(request):
>> if request.POST:
>> form = VideoForm(request.POST, request.FILES)
>> if form.is_valid():
>> video = form.save(commit=False)
>> video.save()
>>
>> // Celery to convert the video
>> convert_video.delay(video)
>>
>> return HttpResponseRedirect('/')
>> else:
>> form = VideoForm()
>> return render(request, 'upload_video.html', {
>> 'form':form
>> })
>>
>> app.tasks.py:
>>
>> @app.task
>> def convert_video(video):
>>
>> // Convert the original video into required format and save it in
>> the mp4_720 field using the following command:
>> //subprocess.call('ffmpeg -i (path of the original_video) (video
>> for mp4_720)')
>>
>> // Change the converted boolean field to True
>>
>> // Save
>>
>> Basically my question is how to save the converted video in mp4_720. Your
>> help and guidance will be very much appreciated. 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/CA%2B4-nGrKucaFSi7oZoOcHtOXdSsnPEac2_LXLZ2TccRCaWUhzA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CA%2B4-nGrKucaFSi7oZoOcHtOXdSsnPEac2_LXLZ2TccRCaWUhzA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> 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/CALn3ei3nZcbL5REM75Q1DVgoQud5oUMf%3Dhv3qLxuzJT1EiJ4wg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CALn3ei3nZcbL5REM75Q1DVgoQud5oUMf%3Dhv3qLxuzJT1EiJ4wg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CA%2B4-nGonX%2BQf7KuHE495AsAmBWto0X8UpSSYy8cNWJYFEXiz6w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Thumbnails In Django

2015-07-21 Thread Robin Lery
Yes. I would like to add easy-thumbnails too. Both are great!
On 22 Jul 2015 01:05, "Sadaf Noor"  wrote:

> In one of my projects I used sorl (
> https://github.com/mariocesar/sorl-thumbnail) instead, it was super easy
> and best fit for my project. Every time it asks for a new thumbnail BUT
> if it exists in its cache, then that one is returned. If it doesn't, a
> new one is generated and stored, then returned. So ultimately it saves. I
> don't know your use case. I am just saying it can be an option.
>
> 2015-07-22 1:22 GMT+06:00 divyanshi kathuria 
> :
>
>> I am using Django Rest framework. I have three fields in my Pin Model :
>> image,thumbnail_medium and thumbnail_small. I want to create two thumbnails
>> from the image. How to do that? I tried the following code : But it's not
>> working.
>> from django.db import models
>> from django.contrib.auth.models import User
>> from thumbs import ImageWithThumbsField
>> #from taggit.managers import TaggableManager
>> from PIL import Image
>> from cStringIO import StringIO
>> from django.core.files.uploadedfile import SimpleUploadedFile
>> import os
>>
>>
>> class Pin(models.Model):
>>
>> url = models.SlugField(blank=True, null=True)
>> title = models.TextField(blank=False,null=False,default='Untitled')
>> description = models.TextField(blank=True, null=True)
>> is_pro = models.BooleanField(default=False)
>> is_hidden = models.BooleanField(default=False)
>> is_for_sale = models.BooleanField(default=False)
>> is_pro = models.BooleanField(default=False)
>> price = models.DecimalField(blank=True, null=True, max_digits=10,
>> decimal_places=2 ,default=0)
>> price_in_rs = models.BooleanField(default=False)
>> size_in_inches = models.BooleanField(default=True)
>> medium = models.TextField(blank=True, null=True)
>> length = models.DecimalField(blank=True, null=True, max_digits=10,
>> decimal_places=2 ,default=0)
>> width = models.DecimalField(blank=True, null=True, max_digits=10,
>> decimal_places=2 ,default=0)
>> hearts = models.IntegerField(blank=True, null=True, default=0)
>> image = models.ImageField(upload_to='pins/pin/originals/')
>> thumbnail = models.ImageField(upload_to='pins/pin/thumbnails/')
>> published = models.DateTimeField(auto_now_add=True)
>> #tags = TaggableManager()
>>
>> def __unicode__(self):
>> return self.url
>>
>> def save(self):
>> from PIL import Image
>> from cStringIO import StringIO
>> from django.core.files.uploadedfile import SimpleUploadedFile
>>
>> # Set our max thumbnail size in a tuple (max width, max height)
>> THUMBNAIL_SIZE = (50, 50)
>>
>> # Open original photo which we want to thumbnail using PIL's Image
>> # object
>> image = Image.open(self.image.name)
>>
>> # Convert to RGB if necessary
>> # Thanks to Limodou on DjangoSnippets.org
>> # http://www.djangosnippets.org/snippets/20/
>> if image.mode not in ('L', 'RGB'):
>> image = image.convert('RGB')
>>
>> # We use our PIL Image object to create the thumbnail, which
>> already
>> # has a thumbnail() convenience method that contrains proportions.
>> # Additionally, we use Image.ANTIALIAS to make the image look
>> better.
>> # Without antialiasing the image pattern artifacts may result.
>> image.thumbnail(THUMBNAIL_SIZE, Image.ANTIALIAS)
>>
>> # Save the thumbnail
>> temp_handle = StringIO()
>> image.save(temp_handle, 'png')
>> temp_handle.seek(0)
>>
>> # Save to the thumbnail field
>> suf = SimpleUploadedFile(os.path.split(self.image.name)[-1],
>> temp_handle.read(), content_type='image/png')
>> self.thumbnail.save(suf.name+'.png', suf, save=False)
>>
>> # Save this photo instance
>> super(Pin, self).save()
>>
>> Can anyone figure out the problem here? Why is it not creating thumbnails?
>>
>> --
>> 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/13e46569-3641-438d-9201-fa079f7f89b2%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
>   Md. Sadaf Noor (@sadaf2605 )
>  www.sadafnoor.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop re

Re: Allow users to submit django form once per day

2015-07-23 Thread Robin Lery
You can save the datetime of the last form submission and check whether its
oneday or not in the view. If its one day then show pass the form or else
dont.

Hope this helps.
On 23 Jul 2015 20:38, "Nkansah Rexford"  wrote:

> I want to allow users to submit a django form once, and only once
> everyday. After submitting the form, the form wouldn't even show
> (server-side checkings, I don't want to use JS or client side thing; easily
> 'tamper-able')
>
> What is the best way to do so in Django?
>
> --
> 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/b310e40f-8baa-449a-bcef-36052d0256a5%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CA%2B4-nGpU8Pmc7ypxZaGACLY1Y34jLsfr75o_Pq2k4-xo35pV%2Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Guidance needed - Real time and django

2014-09-02 Thread Robin Lery
Thank you Amirouche! I will surely look onto that. And I saw many tutorials
on django + node.js and socket.io, and was just curious as to what your
thoughts are on this as the new version of socket.io has also been released?


On Mon, Sep 1, 2014 at 3:09 AM, Amirouche Boubekki <
amirouche.boube...@gmail.com> wrote:

> Hello,
>
>
> 2014-08-29 17:26 GMT+02:00 Aamu Padi :
>
>  Hello,
>> I would like to build a real time web application, but have little idea
>> of where to start to from. It will have notification and feed system like
>> facebook or instagram. Would really appreciate if anyone who have already
>> done this type of web application could kindly guide me through. I will be
>> very grateful.
>>
>
> I never done such things besides small experiments and research...
>
> Here are some pointers:
>
> - search://django+gevent
> - search://django+asyncio among other things django-c10k-demo
>  created by Aymeric
> Augustin django core contributor which use websockets
> - search://tornado
> - search://django+SSE
> - search://django+webRTC
> - search://django+pjax
>
> HTH,
>
> Amirouche
>
>>
>> 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/CAHSNPWuiOJ5m%3DcCUFOc-j%3DRR3LHSAOyhd4Uk7HOaR78cQB-V4A%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> 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/CAL7_Mo9Tfqi_BsM2KCLX7aVNZFZcC0vMO6eu1tMtrY-H6L8GKg%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CA%2B4-nGpvDaKasrw_f-Bj6-B7UW6WRtDd17b%2BMk9BJ-WbKtwDJg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Return to the requested page after successfull @login_required by the next variable

2015-01-08 Thread Robin Lery
Suppose this is the url after
`@login_required(login_url='/accounts/required_login/')`:

http://ngoksy.com/accounts/login_required/?next=/article/

view for the login_require:


*def required_login(request):return render(request,
'required_login.html')*

I tried adding 'next', like it [here][1]:



*def required_login(request):c = {'next' :
request.GET.get('next', '/')}return render(request,
'login_required.html', c)*

But it didn't help.

I have different template for login and another template for anonymous user
which is redirected by `@login_required`.

required_login.html:
















*   Login required! You must login to view the content.{%
if form.error %}Sorry, invalid
username/password!{% endif %}{%csrf_token%}
Username:Password:*

I want to pass the `next` variable after successful login of
`login_required()`, and land into Articles page after that. How do I do
that? Please help me understand. Your help will be greatly appreciated.
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/CA%2B4-nGqds1Ex9Rrw9temyN2D7utJ0FkF7b_sTcOyO7strxt2nw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Signals not working as expected

2013-11-29 Thread Robin Lery
Do i put the codes to all the app's -  models.py?


On Fri, Nov 29, 2013 at 9:44 PM, Tom Evans  wrote:

> On Fri, Nov 29, 2013 at 4:06 PM, Aamu Padi  wrote:
> > Thank you for the answer. I am a newbie, would be very grateful if you
> could
> > please show me how to do that?
>
> Put the code in signals.py at the bottom of models.py and delete signals.py
>
> Cheers
>
> Tom
>
> --
> 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/CAFHbX1%2Bz_MYkfWvmDG1PvuY%3Doy7OG%2BJvK9xmq_PNh%3DprpUhwxA%40mail.gmail.com
> .
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGqvJuwuC%2Ba7HM2EsKdfUQiS4DDikrmYUXHZeh%2BfJKOG3g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Signals not working as expected

2013-11-29 Thread Robin Lery
Yes.


On Fri, Nov 29, 2013 at 9:55 PM, Robin Lery  wrote:

> Do i put the codes to all the app's -  models.py?
>
>
> On Fri, Nov 29, 2013 at 9:44 PM, Tom Evans wrote:
>
>> On Fri, Nov 29, 2013 at 4:06 PM, Aamu Padi  wrote:
>> > Thank you for the answer. I am a newbie, would be very grateful if you
>> could
>> > please show me how to do that?
>>
>> Put the code in signals.py at the bottom of models.py and delete
>> signals.py
>>
>> Cheers
>>
>> Tom
>>
>> --
>> 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/CAFHbX1%2Bz_MYkfWvmDG1PvuY%3Doy7OG%2BJvK9xmq_PNh%3DprpUhwxA%40mail.gmail.com
>> .
>> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGpQ5TMu6rRrCfE%2BL5y%2Bj3QciZR9NjeBwajh1mJMkswxXA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Signals not working as expected

2013-11-29 Thread Robin Lery
Ok, thank you all!


On Fri, Nov 29, 2013 at 9:56 PM, Robin Lery  wrote:

> Yes.
>
>
> On Fri, Nov 29, 2013 at 9:55 PM, Robin Lery  wrote:
>
>> Do i put the codes to all the app's -  models.py?
>>
>>
>> On Fri, Nov 29, 2013 at 9:44 PM, Tom Evans wrote:
>>
>>> On Fri, Nov 29, 2013 at 4:06 PM, Aamu Padi  wrote:
>>> > Thank you for the answer. I am a newbie, would be very grateful if you
>>> could
>>> > please show me how to do that?
>>>
>>> Put the code in signals.py at the bottom of models.py and delete
>>> signals.py
>>>
>>> Cheers
>>>
>>> Tom
>>>
>>> --
>>> 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/CAFHbX1%2Bz_MYkfWvmDG1PvuY%3Doy7OG%2BJvK9xmq_PNh%3DprpUhwxA%40mail.gmail.com
>>> .
>>> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGrdhogxd3DBgC2ZeebQFHsqQfex5PogRFdeKA0KGBN10g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Difference between signals and celery

2013-11-29 Thread Robin Lery


This may be a lame question, but I am really confused with these two. I 
know *signals* are used to do some task when something has happened. But 
what about celery? In the documentation it says:

*Celery is an asynchronous task queue/job queue based on distributed 
message passing.*

Will someone please explain to me of what celery is? What's the difference 
between these two and when to use them? Will be much appreciated! 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/62298d12-02ab-4d34-b8f7-2c4c9bace561%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Difference between signals and celery

2013-11-30 Thread Robin Lery
Thank all so much for you replies. Just one more question though. Does this
means Celery needs a different server?


On Sat, Nov 30, 2013 at 12:41 AM, Carlos Daniel Ruvalcaba Valenzuela <
clsdan...@gmail.com> wrote:

> Signals are like events, for example, when the ORM has done an update.
> Celery is more like a Task queue, you define code to execute certain task,
> load it on celery task server which is running separately from your django
> process, then when you need to execute it in the background you tell it,
> which usually means sending a message through a broker such as redis or
> rabbitmq to the task server, then it gets executed.
>
> Celery is for background tasks, such as processing images, doing updates
> without blocking the main function return, etc. Also celery task can run in
> another machine, while signals are executed locally.
>
> Regards,
> Carlos Ruvalcaba
>
>
> On Fri, Nov 29, 2013 at 11:52 AM, Robin Lery  wrote:
>
>> This may be a lame question, but I am really confused with these two. I
>> know *signals* are used to do some task when something has happened. But
>> what about celery? In the documentation it says:
>>
>> *Celery is an asynchronous task queue/job queue based on distributed
>> message passing.*
>>
>> Will someone please explain to me of what celery is? What's the
>> difference between these two and when to use them? Will be much
>> appreciated! 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/62298d12-02ab-4d34-b8f7-2c4c9bace561%40googlegroups.com
>> .
>> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAEF3qbkT2tzvHUcqLsTbg_gxY-%2BtdFinn%2BER5F-PdEf_QV-zHg%40mail.gmail.com
> .
>
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGqoCrLoc7BY0Le-7izz7w0qO9-LWWzMZixjWPt5_ZGqCw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Difference between signals and celery

2013-12-01 Thread Robin Lery
oh..ok. Thank you so much! :)



Its really great to learn something new.


On Sun, Dec 1, 2013 at 7:42 AM, Avraham Serour  wrote:

> No, you can run celery from the same server, the problem is you won't be
> able to do that on many cheap shared hostings
>
>
> On Sat, Nov 30, 2013 at 7:35 PM, Robin Lery  wrote:
>
>> Thank all so much for you replies. Just one more question though. Does
>> this means Celery needs a different server?
>>
>>
>> On Sat, Nov 30, 2013 at 12:41 AM, Carlos Daniel Ruvalcaba Valenzuela <
>> clsdan...@gmail.com> wrote:
>>
>>> Signals are like events, for example, when the ORM has done an update.
>>> Celery is more like a Task queue, you define code to execute certain task,
>>> load it on celery task server which is running separately from your django
>>> process, then when you need to execute it in the background you tell it,
>>> which usually means sending a message through a broker such as redis or
>>> rabbitmq to the task server, then it gets executed.
>>>
>>> Celery is for background tasks, such as processing images, doing updates
>>> without blocking the main function return, etc. Also celery task can run in
>>> another machine, while signals are executed locally.
>>>
>>> Regards,
>>> Carlos Ruvalcaba
>>>
>>>
>>> On Fri, Nov 29, 2013 at 11:52 AM, Robin Lery wrote:
>>>
>>>> This may be a lame question, but I am really confused with these two. I
>>>> know *signals* are used to do some task when something has happened.
>>>> But what about celery? In the documentation it says:
>>>>
>>>> *Celery is an asynchronous task queue/job queue based on distributed
>>>> message passing.*
>>>>
>>>> Will someone please explain to me of what celery is? What's the
>>>> difference between these two and when to use them? Will be much
>>>> appreciated! 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/62298d12-02ab-4d34-b8f7-2c4c9bace561%40googlegroups.com
>>>> .
>>>> 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.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAEF3qbkT2tzvHUcqLsTbg_gxY-%2BtdFinn%2BER5F-PdEf_QV-zHg%40mail.gmail.com
>>> .
>>>
>>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CA%2B4-nGqoCrLoc7BY0Le-7izz7w0qO9-LWWzMZixjWPt5_ZGqCw%40mail.gmail.com
>> .
>>
>> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAFWa6tL29fSivUpzoT-cYL2qQDFj%2Bv5gmepEN%3DWF0du8SJaJSA%40mail.gmail.com
> .
>
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGq4DisC7wZKgPou4%2BspPiUGBngTHAfqHrJ%2BmsM8863png%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


collectstatic is not working

2014-02-27 Thread Robin Lery
Hello,
I have been trying to collect statics from the static folder but, its not
collecting any files. But it did collect the admin files. What's wrong.
Please help me.

Thank you.

*settings:*

import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))

STATIC_URL = '/static/'

# Template location
TEMPLATE_DIRS = (
os.path.join(os.path.dirname(BASE_DIR), "static", "templates"),
)

if DEBUG:
MEDIA_URL = '/media/'
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static",
"static-only")
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static", "media")
STATIC_DIRS = (
os.path.join(os.path.dirname(BASE_DIR), "static", "static-only"),
)

-- 
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/CA%2B4-nGrMV-y3YnSGnDVstKMu9h4f0kLH4qjSjwfQJOyGPxV5qw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: collectstatic is not working

2014-02-27 Thread Robin Lery
if DEBUG:
MEDIA_URL = '/media/'
STATIC_ROOT = os.path.join(os.path.dirname(
BASE_DIR), "static", "static-only")
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static", "media")
STATIC_DIRS = (
*os.path.join(os.path.dirname(**BASE_DIR), "static", "static"),*
)


On Thu, Feb 27, 2014 at 6:35 PM, Robin Lery  wrote:

> Hello,
> I have been trying to collect statics from the static folder but, its not
> collecting any files. But it did collect the admin files. What's wrong.
> Please help me.
>
> Thank you.
>
> *settings:*
>
> import os
> BASE_DIR = os.path.dirname(os.path.dirname(__file__))
>
> STATIC_URL = '/static/'
>
> # Template location
> TEMPLATE_DIRS = (
> os.path.join(os.path.dirname(BASE_DIR), "static", "templates"),
> )
>
> if DEBUG:
> MEDIA_URL = '/media/'
> STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static",
> "static-only")
> MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static", "media")
> STATIC_DIRS = (
> os.path.join(os.path.dirname(BASE_DIR), "static", "static-only"),
> )
>

-- 
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/CA%2B4-nGp7QhKE%2BE7zPiBmj3TZTYB4Ph3CYcfM5AFL16SM%2BHh-_A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: collectstatic is not working

2014-02-27 Thread Robin Lery
ohh my god..it should be

STATICFILES_DIRS

! And not STATIC_DIRS? Thank you so much!!!


On Thu, Feb 27, 2014 at 6:38 PM, Robin Lery  wrote:

>
> if DEBUG:
> MEDIA_URL = '/media/'
> STATIC_ROOT = os.path.join(os.path.dirname(
> BASE_DIR), "static", "static-only")
> MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static", "media")
> STATIC_DIRS = (
> *os.path.join(os.path.dirname(**BASE_DIR), "static", "static"),*
> )
>
>
> On Thu, Feb 27, 2014 at 6:35 PM, Robin Lery  wrote:
>
>> Hello,
>> I have been trying to collect statics from the static folder but, its not
>> collecting any files. But it did collect the admin files. What's wrong.
>> Please help me.
>>
>> Thank you.
>>
>> *settings:*
>>
>> import os
>> BASE_DIR = os.path.dirname(os.path.dirname(__file__))
>>
>> STATIC_URL = '/static/'
>>
>> # Template location
>> TEMPLATE_DIRS = (
>> os.path.join(os.path.dirname(BASE_DIR), "static", "templates"),
>> )
>>
>> if DEBUG:
>> MEDIA_URL = '/media/'
>> STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static",
>> "static-only")
>> MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static",
>> "media")
>> STATIC_DIRS = (
>> os.path.join(os.path.dirname(BASE_DIR), "static", "static-only"),
>> )
>>
>
>

-- 
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/CA%2B4-nGrT8TcVF9Wr4F%3Di3yq7PG4iKAc-SqypvL1A7cFg0QHhVw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


django and amazon web services

2014-03-01 Thread Robin Lery
Hello.
I have a very basic noob question, which I don't know. Please help me
understand this concepts. When I use *ec2* for my application web server,
and if I use the services like *autoscale *and *elastic load balancer*, do
I always have to sync the database with the new *ec2* instances that are
created? Or its not required? Your help and guidance will be greatly
appreciated.

Thank you!
Robin

-- 
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/CA%2B4-nGpSoxqr6ff5-D%2B-%2BGvLEADU8RW%3D%3DTSdepk9daWSY6zFNw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django and amazon web services

2014-03-01 Thread Robin Lery
Very nicely explained! I was actually hoping to use Amazon RDS  with
postgresql. Your help was very useful. Thank you!



On Sat, Mar 1, 2014 at 3:03 PM, Russell Keith-Magee  wrote:

> Hi Robin,
>
> In the simplest deployment case, your entire Django (or, for that matter,
> any other framework) website will run on a single server. That single
> server will contain the web server, the database, any files that have been
> uploaded, any any other services your site needs (such as memcache, a mail
> server, or anything else)
>
> Amazon EC2 is essentially selling you "a server". So, if you spool up a
> single EC2 instance, you could install all the bits you need to run your
> site on that single server.
>
> If you're using autoscale and elastic load balancer, what you're getting
> is the ability to spool up new web servers as traffic increases.
>
> However, when you move to having more than one server, you have a problem.
> What do you do with your database? No matter how many web servers you have,
> your application still needs to have a *single* database.
>
> Django's syncdb command is the step of creating the database schema (i.e.,
> the collection of tables) that your application will run. You should only
> be running it once for your application -- on the single database.
>
> If you're setting up load balancing and autoscaling for your web app, you
> have three options for your database.
>
> Firstly, you can set up a *separate* EC2 instance for your database. The
> idea here is that you would have multiple small EC2 instances serving web
> traffic (scaling up and down as required), but a single large EC2 instance
> running your database.
>
> Secondly, if you're looking for redundancy, you might set up *multiple*
> large EC2 instances for your database, and link them in a master-slave
> configuration. This provides some redundancy (in case one of the database
> servers goes down), and also provides some load balancing capability.
> Again, these instances are independent of your web server instances, and
> aren't affected by any load balancing behaviour.
>
> Thirdly, and probably the best option if you're looking to deploy on
> Amazon - use Amazon RDS. This is Amazon's autoscaling
> database-as-a-service. You create a database on RDS, and get charged for
> how much data you store, and how much you serve. Amazon worries about
> scaling, backup, and all the rest.
>
> In any of these three cases, you only run syncdb once -- you only ever
> have *one* User table, and you only need to run syncdb once to get it.
>
> I hope that clarifies things.
>
> Yours,
> Russ Magee %-)
>
> Hello.
>> I have a very basic noob question, which I don't know. Please help me
>> understand this concepts. When I use *ec2* for my application web
>> server, and if I use the services like *autoscale *and *elastic load
>> balancer*, do I always have to sync the database with the new *ec2*instances 
>> that are created? Or its not required? Your help and guidance
>> will be greatly appreciated.
>>
>> Thank you!
>> Robin
>>
>> --
>> 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/CA%2B4-nGpSoxqr6ff5-D%2B-%2BGvLEADU8RW%3D%3DTSdepk9daWSY6zFNw%40mail.gmail.com
>> .
>> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAJxq84_miF9N8r1e5gMC-Ee3dq0m-vwkc0%3DDzVv1Dt9%2BWFS7vQ%40mail.gmail.com
> .
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGrJmMhRiwoXYA4-XXE2_%3DRE_Tmuq5u%2B6SyfvHz5v%2B%2B%3D4A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


memcached and redis

2014-03-01 Thread Robin Lery
Hello,
Another noob question. Please bear with me. I am really very confused
between memcached and redis. I know they both are used for caching. But I
don't know how much does they help. And lastly, I would like know what
would you use for a site with users uploaded pictures and videos too? I
hope I was clear. If not please ask. Your help and guidance will be very
much appreciated.

Thank you.
Robin.

-- 
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/CA%2B4-nGqoYH24%2BSLzM8Jx3dN_xiPFYpZ90-gqfRNVpcWUEK%3DVsw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: memcached and redis

2014-03-01 Thread Robin Lery
Hello,
Thank you for your answer. Would you please elaborate a little more about
the use cases with these? And can I use them together?

Thank you.


On Sun, Mar 2, 2014 at 1:01 AM, Andreas Kuhne wrote:

> Hi,
>
> In response to your question about memcache and redis, they are extremely
> useful, if you use them correctly. For example if you are generating a
> query to your database that takes 1 second to finish, and you cache the
> results in memcache or redis, then you would be able to get the second
> request down to 50 ms instead. Thats the difference in response time. Redis
> and memcache are in memory databases and are extremely fast!
>
> Regarding your second question, if you need to store alot of pictures and
> videos, I would use Amazon S3 with the django storages backend for S3.
>
> Regards,
>
> Andréas
>
>
> 2014-03-01 17:28 GMT+01:00 Robin Lery :
>
>> Hello,
>> Another noob question. Please bear with me. I am really very confused
>> between memcached and redis. I know they both are used for caching. But I
>> don't know how much does they help. And lastly, I would like know what
>> would you use for a site with users uploaded pictures and videos too? I
>> hope I was clear. If not please ask. Your help and guidance will be very
>> much appreciated.
>>
>> Thank you.
>> Robin.
>>
>> --
>> 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/CA%2B4-nGqoYH24%2BSLzM8Jx3dN_xiPFYpZ90-gqfRNVpcWUEK%3DVsw%40mail.gmail.com
>> .
>> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALXYUbmmkXRQE8m92S7NncYg4BN18VCbhVm13hgUbYrq1H5B%3Dw%40mail.gmail.com
> .
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGrHb_QH1YbXA4wOnW-nVJ-sVfTWfxUOxH%2Bvz%2BihxjC2XQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: memcached and redis

2014-03-01 Thread Robin Lery
Use cases with memcached and redis please.


On Sun, Mar 2, 2014 at 1:45 AM, Andreas Kuhne wrote:

> Hi again,
>
> Do you mean use cases with redis and memcache or with S3?
>
> Regards,
>
> Andréas
>
> 2014-03-01 21:00 GMT+01:00 Robin Lery :
>
>> Hello,
>> Thank you for your answer. Would you please elaborate a little more about
>> the use cases with these? And can I use them together?
>>
>> Thank you.
>>
>>
>> On Sun, Mar 2, 2014 at 1:01 AM, Andreas Kuhne > > wrote:
>>
>>> Hi,
>>>
>>> In response to your question about memcache and redis, they are
>>> extremely useful, if you use them correctly. For example if you are
>>> generating a query to your database that takes 1 second to finish, and you
>>> cache the results in memcache or redis, then you would be able to get the
>>> second request down to 50 ms instead. Thats the difference in response
>>> time. Redis and memcache are in memory databases and are extremely fast!
>>>
>>> Regarding your second question, if you need to store alot of pictures
>>> and videos, I would use Amazon S3 with the django storages backend for S3.
>>>
>>> Regards,
>>>
>>> Andréas
>>>
>>>
>>> 2014-03-01 17:28 GMT+01:00 Robin Lery :
>>>
>>>>  Hello,
>>>> Another noob question. Please bear with me. I am really very confused
>>>> between memcached and redis. I know they both are used for caching. But I
>>>> don't know how much does they help. And lastly, I would like know what
>>>> would you use for a site with users uploaded pictures and videos too? I
>>>> hope I was clear. If not please ask. Your help and guidance will be very
>>>> much appreciated.
>>>>
>>>> Thank you.
>>>> Robin.
>>>>
>>>> --
>>>> 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/CA%2B4-nGqoYH24%2BSLzM8Jx3dN_xiPFYpZ90-gqfRNVpcWUEK%3DVsw%40mail.gmail.com
>>>> .
>>>> 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.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CALXYUbmmkXRQE8m92S7NncYg4BN18VCbhVm13hgUbYrq1H5B%3Dw%40mail.gmail.com
>>> .
>>>
>>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CA%2B4-nGrHb_QH1YbXA4wOnW-nVJ-sVfTWfxUOxH%2Bvz%2BihxjC2XQ%40mail.gmail.com
>> .
>>
>> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALXYUbmBhXY%2BJcC2ghmL5%3DcEeMhjdnqj7XB3tWAacVxt99XBuw%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CALXYUbmBhXY%2BJcC2ghmL5%3DcEeMhjdnqj7XB3tWAacVxt99XBuw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGpmxLcJQignKqP%3DPK1h7V0n5-953mSF%3D%2Bd%3DE53w9P2xZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: memcached and redis

2014-03-01 Thread Robin Lery
Ok, I think I get it now. Thank you so much! Just one more question though,
does redis has feature similar to *getidentifiable()* and *putifuntouched()
*like memcache, I think these are for consistency?


On Sun, Mar 2, 2014 at 2:09 AM, Andreas Kuhne wrote:

> Ok,
>
> Redis and Memcache really solve the same problems. The main difference is
> that you can use redis as a session cache for django (save the session
> objects to memory instead of the database), which I haven't found a
> solution for memcache yet. Also redis CAN be persisted (saved to disk), if
> you setup your own redis server.
>
> But otherwise, you can use both memcache and redis for your cache.
> Examples where a cache can be useful:
> 1. You want to do a complex database query that takes a long time to run,
> but doesn't update often. Just cache the results and use the result if it
> is present.
> 2. You can also cache the result of a view. If the view takes a long time
> to render AND is the same for all users, then cache the entire view result.
> 3. There is also the possibility to  create portions of a template and
> cache just those portions.
>
> Thats what I can think of off the top of my head. You can find more
> information about it here:
> https://docs.djangoproject.com/en/dev/topics/cache/
> http://memcached.org/
> http://redis.io/
>
> The main thing to remember is that both memcache and redis are in memory
> databases (key-value store) (even though redis can be persisted) and if the
> server is rebooted, then the cache is empty. Also being a in memory
> database means that getting information back from the key-value store is
> more or less instantanious especially if you compare to a standard sql
> database.
>
> Regards,
>
> Andréas
>
>
> 2014-03-01 21:27 GMT+01:00 Robin Lery :
>
>> Use cases with memcached and redis please.
>>
>>
>> On Sun, Mar 2, 2014 at 1:45 AM, Andreas Kuhne > > wrote:
>>
>>> Hi again,
>>>
>>> Do you mean use cases with redis and memcache or with S3?
>>>
>>> Regards,
>>>
>>> Andréas
>>>
>>> 2014-03-01 21:00 GMT+01:00 Robin Lery :
>>>
>>>>  Hello,
>>>> Thank you for your answer. Would you please elaborate a little more
>>>> about the use cases with these? And can I use them together?
>>>>
>>>> Thank you.
>>>>
>>>>
>>>> On Sun, Mar 2, 2014 at 1:01 AM, Andreas Kuhne <
>>>> andreas.ku...@suitopia.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> In response to your question about memcache and redis, they are
>>>>> extremely useful, if you use them correctly. For example if you are
>>>>> generating a query to your database that takes 1 second to finish, and you
>>>>> cache the results in memcache or redis, then you would be able to get the
>>>>> second request down to 50 ms instead. Thats the difference in response
>>>>> time. Redis and memcache are in memory databases and are extremely fast!
>>>>>
>>>>> Regarding your second question, if you need to store alot of pictures
>>>>> and videos, I would use Amazon S3 with the django storages backend for S3.
>>>>>
>>>>> Regards,
>>>>>
>>>>> Andréas
>>>>>
>>>>>
>>>>> 2014-03-01 17:28 GMT+01:00 Robin Lery :
>>>>>
>>>>>>  Hello,
>>>>>> Another noob question. Please bear with me. I am really very confused
>>>>>> between memcached and redis. I know they both are used for caching. But I
>>>>>> don't know how much does they help. And lastly, I would like know what
>>>>>> would you use for a site with users uploaded pictures and videos too? I
>>>>>> hope I was clear. If not please ask. Your help and guidance will be very
>>>>>> much appreciated.
>>>>>>
>>>>>> Thank you.
>>>>>> Robin.
>>>>>>
>>>>>> --
>>>>>> 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.
>>>&g

Re: memcached and redis

2014-03-02 Thread Robin Lery
Thank you Andy and Russel! I guess I know a lot about those two cache
methods.


On Sun, Mar 2, 2014 at 5:23 AM, Andy McKay  wrote:

> On Sat, Mar 1, 2014 at 12:39 PM, Andreas Kuhne  > wrote:
>
>> The main difference is that you can use redis as a session cache for
>> django (save the session objects to memory instead of the database), which
>> I haven't found a solution for memcache yet.
>>
>
> Memcache works just fine as a session backend:
>
>
> https://docs.djangoproject.com/en/dev/topics/http/sessions/#using-cached-sessions
>
> Andy
>
>  --
> 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/CAOjXX8aCOZXQcVkb%3Dfk%2BcJtgphAJdY%2BrUAC7aDVnMEDWFq2Vgg%40mail.gmail.com
> .
>
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGrhMyEVcO1A59gFdKmxDeag%3D10He0tme%3D62fnsCFLdq%3Dg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


django - commenting app for all other apps

2014-03-02 Thread Robin Lery
I have an app for forum. It has three classes *Tag*, *Question* and *Answer*
.

*models*:

class Tag(models.Model):
tag_name = models.CharField(max_length=100)
timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
updated = models.DateTimeField(auto_now_add=True, auto_now=False)
description = models.TextField()

def __unicode__(self):
return smart_unicode(self.tag_name)

class Question(models.Model):
short_description = models.CharField(max_length=250)
description = models.TextField()
asked_by = models.ForeignKey(User)
tags = models.ManyToManyField(Tag)
timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
updated = models.DateTimeField(auto_now_add=True, auto_now=False)

def __unicode__(self):
return smart_unicode(self.short_description)

class Answer(models.Model):
description = models.TextField()
for_question = models.ForeignKey(Question)
timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
updated = models.DateTimeField(auto_now_add=True, auto_now=False)

def __unicode__(self):
return smart_unicode(self.description)

I also want to have comments for *Question*, *Answers* and also for *other
parts* of my apps. What is the best way to achieve this? I mean, what is
the right way to design the django models for this use case? Do I have to
use *content types* for this? Please guide me how to achieve the above
mentioned. Your help will be much appreciated. 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/CA%2B4-nGrBVHz9TKr_cPHfyw-488rohdp8bdMV7H844NkLeRytKA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: memcached and redis

2014-03-02 Thread Robin Lery
Hello,
Its no bother. Thank you! I have learnt a lot from you guyz!


On Sun, Mar 2, 2014 at 5:27 PM, Andreas Kuhne wrote:

> Hi,
>
> I really don't know if they exist. Check redis.io, you should be able to
> see them there.
>
> Regards,
>
> Andréas
>
>
> 2014-03-01 21:48 GMT+01:00 Robin Lery :
>
>> Ok, I think I get it now. Thank you so much! Just one more question
>> though, does redis has feature similar to *getidentifiable()* and 
>> *putifuntouched()
>> *like memcache, I think these are for consistency?
>>
>>
>> On Sun, Mar 2, 2014 at 2:09 AM, Andreas Kuhne > > wrote:
>>
>>> Ok,
>>>
>>> Redis and Memcache really solve the same problems. The main difference
>>> is that you can use redis as a session cache for django (save the session
>>> objects to memory instead of the database), which I haven't found a
>>> solution for memcache yet. Also redis CAN be persisted (saved to disk), if
>>> you setup your own redis server.
>>>
>>> But otherwise, you can use both memcache and redis for your cache.
>>> Examples where a cache can be useful:
>>> 1. You want to do a complex database query that takes a long time to
>>> run, but doesn't update often. Just cache the results and use the result if
>>> it is present.
>>> 2. You can also cache the result of a view. If the view takes a long
>>> time to render AND is the same for all users, then cache the entire view
>>> result.
>>> 3. There is also the possibility to  create portions of a template and
>>> cache just those portions.
>>>
>>> Thats what I can think of off the top of my head. You can find more
>>> information about it here:
>>> https://docs.djangoproject.com/en/dev/topics/cache/
>>> http://memcached.org/
>>> http://redis.io/
>>>
>>> The main thing to remember is that both memcache and redis are in memory
>>> databases (key-value store) (even though redis can be persisted) and if the
>>> server is rebooted, then the cache is empty. Also being a in memory
>>> database means that getting information back from the key-value store is
>>> more or less instantanious especially if you compare to a standard sql
>>> database.
>>>
>>> Regards,
>>>
>>> Andréas
>>>
>>>
>>> 2014-03-01 21:27 GMT+01:00 Robin Lery :
>>>
>>>>  Use cases with memcached and redis please.
>>>>
>>>>
>>>> On Sun, Mar 2, 2014 at 1:45 AM, Andreas Kuhne <
>>>> andreas.ku...@suitopia.com> wrote:
>>>>
>>>>> Hi again,
>>>>>
>>>>> Do you mean use cases with redis and memcache or with S3?
>>>>>
>>>>> Regards,
>>>>>
>>>>> Andréas
>>>>>
>>>>> 2014-03-01 21:00 GMT+01:00 Robin Lery :
>>>>>
>>>>>>  Hello,
>>>>>> Thank you for your answer. Would you please elaborate a little more
>>>>>> about the use cases with these? And can I use them together?
>>>>>>
>>>>>> Thank you.
>>>>>>
>>>>>>
>>>>>> On Sun, Mar 2, 2014 at 1:01 AM, Andreas Kuhne <
>>>>>> andreas.ku...@suitopia.com> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> In response to your question about memcache and redis, they are
>>>>>>> extremely useful, if you use them correctly. For example if you are
>>>>>>> generating a query to your database that takes 1 second to finish, and 
>>>>>>> you
>>>>>>> cache the results in memcache or redis, then you would be able to get 
>>>>>>> the
>>>>>>> second request down to 50 ms instead. Thats the difference in response
>>>>>>> time. Redis and memcache are in memory databases and are extremely fast!
>>>>>>>
>>>>>>> Regarding your second question, if you need to store alot of
>>>>>>> pictures and videos, I would use Amazon S3 with the django storages 
>>>>>>> backend
>>>>>>> for S3.
>>>>>>>
>>>>>>> Regards,
>>>>>>>
>>>>>>> Andréas
>>>>>>>
>>>>>>>
>>>>>>> 2014-03-01 17:28 GMT+01:00 Robin Lery :
>>>>

Re: django and amazon web services

2014-03-04 Thread Robin Lery
Thank you Clifford for the heads up and your advice!


On Sun, Mar 2, 2014 at 1:32 AM, CLIFFORD ILKAY
wrote:

> On 03/01/2014 11:21 AM, Robin Lery wrote:
> > Very nicely explained! I was actually hoping to use Amazon RDS  with
> > postgresql. Your help was very useful. Thank you!
>
> There is another issue if your application has to deal with user
> uploaded files, such as photos, PDFs, etc. You must consider the
> instances in an autoscaling cluster to be volatile because they can come
> and go automatically. Consequently, you must have a way of ensuring that
> either the filesystems of those instances are synchronized or store user
> contributed files on Amazon S3. Fortunately, we have pluggable storage
> in Django so it's easy to do the latter.
>
> If you ever have to deploy an application that doesn't have that, as we
> did, we ended up creating an NFS cluster in a VPC (Virtual Private
> Cloud) and the instances in the autoscaling group mounted the exported
> NFS filesystem. The autoscale instances had two network interfaces, one
> for the public Internet and another for the internal network in the VPC,
> so the NFS cluster was not exposed to the Internet.
>
> --
> Regards,
>
> Clifford Ilkay
>
> 647-778-8696
>
> Dinamis
>
> <http://dinamis.com>
>
> --
> 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/53123CF0.9030005%40dinamis.com
> .
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGpSS5oj5SrL-%3DV21ODWvOi3v%3DTJoHQJTgOdPn-n29M%3D-w%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


confused about sql in django

2014-03-04 Thread Robin Lery
Hello,

I am really being confused. How to use sql in django? I found two:
1. Performing raw queries.
2.Executing custom SQL directly.

Does it have better performance than the django's orm? And how is the
performance the same between those two?

And lastly, what is sqlalchemy? Are sqlalchemy and django's orm the same?
In the website of sqlalchemy it says "*SQLAlchemy is the Python SQL toolkit
and Object Relational Mapper that gives application developers the full
power and flexibility of SQL*".

So I am confused. I will really appreciate very much, if you could help me
understand the above.

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/CA%2B4-nGqCeFpw77DnoZ_uykEb1PMisv0Z6GcxPpj_WHU7LhLC6w%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: confused about sql in django

2014-03-05 Thread Robin Lery
Thank you Alex and Tom! Its great to know something new. I think I will
stick with django orm for now! Thanks again!


On Wed, Mar 5, 2014 at 2:48 AM, Tom Evans  wrote:

> On Tue, Mar 4, 2014 at 8:08 PM, Robin Lery  wrote:
> > Hello,
> >
> > I am really being confused. How to use sql in django? I found two:
> > 1. Performing raw queries.
> > 2.Executing custom SQL directly.
> >
> > Does it have better performance than the django's orm? And how is the
> > performance the same between those two?
>
> 1 and 2 are the same thing. Running the same query using the ORM and
> running the same query directly will take the same time - the clue is
> in the name, it is the *same* query.
>
> Running queries that return model instances is slower using the ORM
> than simply fetching the data row at a time, simply because django
> will construct model instances from each row of data, which costs
> time.
>
> There are queries that django's ORM cannot express, for those
> obviously you must use SQL directly.
>
> The ORM will not write "bad" or slow queries, there is always a
> possibility that a query could be written better by hand. The ORM is
> powerful, but this power does allow you to write queries that look
> simple in code, but actually do complex and unexpected things when
> run. Of course, the same is true of writing SQL by hand.
>
> I think it is important to understand that the two do different
> things. ORM stands for Object Relational Mapper, which means it is
> perfect for extracting objects that are related to each other. SQL
> stands for Structured Query Language, which means it can be used to
> extract almost any data in whatever format you require. If you want
> objects, use the ORM, if you want arbitrary data, use SQL.
>
> Using an ORM does not mean that you no longer have to design and
> optimise your database and the queries you run on it. You still need
> to check your queries to ensure that your DB engine is optimising them
> correctly, that you have the correct indices on the columns you are
> querying on - probably also that you aren't repeating the same read
> queries over and over again within one request.
>
> >
> > And lastly, what is sqlalchemy? Are sqlalchemy and django's orm the
> same? In
> > the website of sqlalchemy it says "SQLAlchemy is the Python SQL toolkit
> and
> > Object Relational Mapper that gives application developers the full power
> > and flexibility of SQL".
>
> sqlalchemy is a different ORM to django. All ORMs do basically the
> same thing under the hood, so there are obvious similarities between
> the two. sqlalchemy has a few more features than django's ORM, at the
> cost of being more complex.
>
> You can use sqlalchemy in django instead of django's ORM/models, but
> you lose the ability to use anything based on django models - the
> admin site, authentication, basically anything that touches the
> database. You can still use templates, i18n, some session backends,
> forms (but not model forms), views and url handling.
>
> Cheers
>
> Tom
>
> --
> 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/CAFHbX1%2B7nkk-4Mh1MD03aHZyJnoNwAFOi%3DHiie7ahpg6iCBHUQ%40mail.gmail.com
> .
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGpGPLpTP7uRv7PrNRp1CwEiCLy-p1O9BUuU0Yc%3DDCLfOA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Confused about ContentType

2014-03-05 Thread Robin Lery
Hello,

Suppose this is a model for a user's photo:

class Photo(models.Model):
user = models.ForeignKey(User)
title = models.CharField()
image = models.ImageField()
pub_date = models.DateTimeFied(auto_now=True, auto_now_add=pub_date)
update = models.DateTimeFied(auto_now=False, auto_now_add=True)

This is another model for user's status:

class Status(models.Model):
user = models.ForeignKey(User)
tweet = models.TextFied()
pub_date = models.DateTimeFied(auto_now=True, auto_now_add=pub_date)

Now, this is a model for all the feeds of a user:

class StreamItem(models.Model):
user = models.ForeignKey(User)
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey('content_type','object_id')

1. In the above class '*StreamItem*', is the *content_type *the data_type
of the instance?

2. What is *object_id*? Is it the pk of the instance or the pk for that
StramItem instance?

3. Lastly, is how do I get the pub_date of the above two class instance
(Photo and Status) and initialize it to the StreamItem instance?

I hope I made myself clear. I really need to know about content types. I
will really appreciate if you could help me understand.

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/CA%2B4-nGqh4phgzjbiGpZ4SQpn356L6CwebGrd%3DPSGaHMnP1imkg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Newbie: ImportError during syncdb

2014-03-05 Thread Robin Lery
What the name of the app folder? I think its just django_bookmarks.


On Thu, Mar 6, 2014 at 6:43 AM, David  wrote:

> Dear django users,
>
> I am new to django and have an ImportError: No module named bookmarks
> problem.
>
> It seems that as I tried to syncdb django does not recognize the
> bookmarks module I have created before. In the past I was able to
> syncdb, hence my confusion.
>
> I am trying to teach myself by following "Learning Website Development
> with Django" by Ayman Hourieh.
>
> I am not working in a virtualenv.
>
> Thanks for your guidance and hints!
>
> David
>
>
> settings.py:
>
> INSTALLED_APPS = (
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'django_bookmarks.bookmarks',
> )
>
> david@ubuntu:~/Tools/Python/Code/myCode/Django/django_bookmarks$ python
> manage.py syncdb
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File
>
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
> line 399, in execute_from_command_line
> utility.execute()
>   File
>
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
> line 392, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> line 242, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> line 280, in execute
> translation.activate('en-us')
>   File
>
> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py",
> line 130, in activate
> return _trans.activate(language)
>   File
>
> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
> line 188, in activate
> _active.value = translation(language)
>   File
>
> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
> line 177, in translation
> default_translation = _fetch(settings.LANGUAGE_CODE)
>   File
>
> "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py",
> line 159, in _fetch
> app = import_module(appname)
>   File
> "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line
> 40, in import_module
> __import__(name)
> ImportError: No module named bookmarks
>
> --
> 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/5317CBCC.4060908%40gmx.net.
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGorOGF10TOCuYAWohS%2B3nHjrL-DRpkj%2BDGTtmHDq4u00A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: "Authenticating Users" where should I put the code?

2014-03-06 Thread Robin Lery
This should be in your views.py.


On Thu, Mar 6, 2014 at 8:15 PM, Jack Yan  wrote:

> in the tutorial and section "Authenticating Users":
> https://docs.djangoproject.com/en/1.6/topics/auth/default/
>
> where can I put code:
>
> from django.contrib.auth import authenticateuser = 
> authenticate(username='john', password='secret')if user is not None:
> # the password verified for the user
> if user.is_active:
> print("User is valid, active and authenticated")
> else:
> print("The password is valid, but the account has been 
> disabled!")else:
> # the authentication system was unable to verify the username and password
> print("The username and password were incorrect.")
>
> in what file or what folder?
>
>  --
> 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/0654812d-74d5-48a1-a977-26958f417a61%40googlegroups.com
> .
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGoLSsJTSL5GmnGBgmij1dYD-44CLjv0zeVw9soqJR6JyA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Different content type objects in django template

2014-03-06 Thread Robin Lery
I am having a hard time to understand ContentType. I am learning from a
tutorial, this is the link . I have synced the database, and its working in
the admin. But when I try to load the ContentType objects in the template,
I get nothing. When I see the page source, the get_rendered_method is not
loading the rendered template in the homepage.html.

*These are my models:*


class Photo(models.Model):

user = models.ForeignKey(User)

description = models.TextField()

image = models.ImageField(upload_to=get_upload_file_name)

photo_upload = models.DateTimeField(auto_now=True, auto_now_add=False)

is_public = models.BooleanField(default=True)


class Meta:

verbose_name = 'Photo'

verbose_name_plural = 'Photos'

ordering = ['-photo_upload']


class Status(models.Model):

user = models.ForeignKey(User)

state = models.CharField(max_length=200)

status_upload = models.DateTimeField(auto_now=True, auto_now_add=False)

is_public = models.BooleanField(default=True)


class StreamItem(models.Model):

content_type = models.ForeignKey(ContentType)

object_id = models.PositiveIntegerField()

pub_date = models.DateTimeField()

content_object = generic.GenericForeignKey('content_type','object_id')


# The get_rendered_html method simply passes the retrieved object to a
template with that object's name

def get_rendered_html(self):

template_name = 'stream_item_%s.html' % (self.content_type.name)

return render(request, template_name,
{'object':self.content_object})


*These are the template for content_type.name :*

*stream_item_Photo.html:*






{{ object.pub_date|date:"F jS Y, P" }}

{{ object.user }}




*stream_item_Status.html:*




{{ object.state }}

{{ object.time|date:"F jS Y, P" }}

User: {{ object.user }}




Where am I doing the mistake? How do I load different content_type objects
in the template? I would really appreciate if you could help me solve 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGpg3-btzb5r9en9MVipb9zY_O2_B989%3DxE0sm3VgT8Lyg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


problem in setting up gunicorn and django

2014-03-17 Thread Robin Lery
I am trying to set up gunicorn for Django by following this
blog.
I created the *gunicorn_start* script and gave it permission:

*$ sudo chown -R hello:users /webapps/hello_django*
*$ sudo chmod -R g+w /webapps/hello_django*

Made it executable:

*$ sudo chmod u+x bin/gunicorn_start*

But when I run this comman:

*advenio@advenio-VirtualBox:~$ sudo su - hello*
*$ bin/gunicorn_start*

It gives me an error:

*advenio@advenio-VirtualBox:~$ sudo su - hello*
*$ bin/gunicorn_start*
*Starting hello_app as hello*
*bin/gunicorn_start: line 26:
/webapps/hello_django/hello/../bin/gunicorn: No such file or directory*

This the `gunicorn_start` script:

#!/bin/bash

*NAME="hello_app" * # Name of the
application
*DJANGODIR=/webapps/hello_django/hello* # Django project
directory
*SOCKFILE=/webapps/hello_django/run/gunicorn.sock * # we will communicte
using this unix socket
*USER=hello*# the user to run as
*GROUP=webapps *# the group to run as
*NUM_WORKERS=3 *# how many worker
processes should Gunicorn spawn
*DJANGO_SETTINGS_MODULE=hello.settings *# which settings file
should Django use
*DJANGO_WSGI_MODULE=hello.wsgi *# WSGI module name

*echo "Starting $NAME as `whoami`"*

# Activate the virtual environment
*cd $DJANGODIR*
* source ../bin/activate*
* export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE*
* export PYTHONPATH=$DJANGODIR:$PYTHONPATH*

# Create the run directory if it doesn't exist
*RUNDIR=$(dirname $SOCKFILE)*
* test -d $RUNDIR || mkdir -p $RUNDIR*

# Start your Django Unicorn
# Programs meant to be run under supervisor should not daemonize themselves
(do not use --daemon)
*exec ../bin/gunicorn ${DJANGO_WSGI_MODULE}:application \*
*  --name $NAME \*
*  --workers $NUM_WORKERS \*
*  --user=$USER --group=$GROUP \*
*  --log-level=debug \*
*  --bind=unix:$SOCKFILE*

-- 
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/CA%2B4-nGrvPupeBbA_tRgqitFcaKgRcRUKkmiPPCDxrYzV_L7QpQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Custom Login page in Django

2014-03-20 Thread Robin Lery
do you have {% csrf_token % } in your forms?


On Thu, Mar 20, 2014 at 7:36 PM, Aryak Sengupta wrote:

> I am new to Django (but not new to python) and I am looking forward to
> create a customized  page using django.  I have read about django's inbuilt
> authentication system but I want build it from scratch So here are the few
> ideas I am stumbling upon :
>
>
>1. Creating a *users* class in the models.py with username and
>password as the fields (both are CharField)
>
>2. Creating  two views one named *LoginView*, which will depict the
>initial login page (such as a *form* imported from a *module named
> forms.py*) and another view named *LoggedInView* which will show only
>the username of the logged user
>
>3. Mapping them into corresponding URLs
>
> I tried creating it with above mentioned thoughts but I got stuck with an
> error as follows:
>
> Forbidden (403)
>
> CSRF verification failed. Request aborted.
> Help
>
> Reason given for failure:
>
> CSRF cookie not set.
>
>
> I couldn't figure out why possibly I am getting this error for
> incorporating such a simple(and basic) functionality.
>
> *I want to understand the best way/approach to go about this (for
> implementing this functionality). I am not worrying about the error for the
> time being since I didn't spend much time thinking about it (So I am not
> posting any code). I want to get my approach right first. I want to be
> flawless while implementing such basic and elementary stuffs.  *
>
> --
> 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/4f18d65c-8e85-434f-b584-0ab7017f6cf9%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CA%2B4-nGq8taHb%2B9%2Bz3%3DxJq-Qitnuf0%3D127O9esk8LZygSQLeSZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django and Long Polling

2014-03-22 Thread Robin Lery
Hello,
I need to implement long polling in my application to retrieve the events.
But I have no idea how to do it. I know the concept of long polling, i.e to
leave the connection open, until an event occurs. But how do I do implement
this in my project. If you could give me a simple long polling example of
client side and the views i guess, I would really appreciate.

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/CA%2B4-nGpvKHcMg-mMRbf7%2BVceCAkRwipt_8NvojEw43ALhC2YBw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Multiple websocket connection vs single websocket connection when using django channels

2018-04-06 Thread Robin Lery
Hi,

Suppose an application has features like Chat, Notification and Activity
feeds.

I would like to know whether its recommended to have different   websocket
connection for different  feautues for each user. Meaning for chat purpose
a separate socket connection, for notification another separate connection?

Or is it better to have only one websocket connection for a user, and work
around that single connection for different features?

Sincerely,
Robin

-- 
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/CA%2B4-nGotWh6waiNPdTbH85%3DM0mPPKnh1%3DHR4BdYBsrUCFB6WPg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple websocket connection vs single websocket connection when using django channels

2018-04-07 Thread Robin Lery
Yes, I guess that's how to work around per connection for a user. Thank you
for your input!

On Fri, Apr 6, 2018 at 9:49 PM, Ken Whitesell 
wrote:

> Hi Robin,
>
> I can't speak to any generalized situations, or what might be considered
> "best practices" or most optimal.
>
> What I can say is that we have gone with the single websocket connection
> for each client - whether it's a real person at a browser or an
> application. All our communications through the channel are JSON objects,
> and we include a key named "app" in the object which identifies the
> specific "feature" or "application" to which a message is directed. It's
> done in both directions - submissions through the channel from the browsers
> to the server and from the server to the browser all have that key in the
> JSON.
>
> About the most I can say is that it works well for us.
>
> Ken
>
>
> On Friday, April 6, 2018 at 5:10:41 AM UTC-4, Robin Lery wrote:
>>
>> Hi,
>>
>> Suppose an application has features like Chat, Notification and Activity
>> feeds.
>>
>> I would like to know whether its recommended to have different
>>  websocket connection for different  feautues for each user. Meaning for
>> chat purpose a separate socket connection, for notification another
>> separate connection?
>>
>> Or is it better to have only one websocket connection for a user, and
>> work around that single connection for different features?
>>
>> Sincerely,
>> Robin
>>
> --
> 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/0bf0d083-1bb3-4963-905c-9e8bfce6c765%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/0bf0d083-1bb3-4963-905c-9e8bfce6c765%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CA%2B4-nGqLx9FH9FBAbdVP_EtogctGQZPRKx0PnmETEptW-FJVOQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Allow users to vote up, down or nothing

2016-06-06 Thread Robin Lery
Hello,
I have made an app to create article. This is the model:

class Article(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL)
title = models.CharField(max_length=150)
body = models.TextField()
pub_date = models.DateTimeField(default=timezone.now)
tags = models.ManyToManyField(Tag)
article_image = models.ImageField(upload_to=get_upload_file_name,
blank=True)

Here I want to setup a voting system for each app. There I would the user
to vote up, or vote down, or do nothing. Boolean field would have been
great, but since an article can have 3 choices of votes  (vote up / vote
down / no vote ), how should I go about doing this? Your help and guidance
will be very much appreciated.

Thank you.


Virus-free.
www.avast.com

<#DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

-- 
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/CA%2B4-nGo-pNLjsEoE5bVT%3DaGxcJGcCm9nvx%2Bqjj8J6rT2J%3Dgq%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Cannot login with user credentials

2016-07-23 Thread Robin Lery
I have a made custom user model.

class CustomUserManager(BaseUserManager):
def _create_user(self, email, username, password, first_name,
last_name, date_of_birth, gender, mobile_number,
 is_active, is_admin, is_superuser):
"""
Creates and saves a user with given email and password
"""
if not email:
raise ValueError('Email must be set')

email = self.normalize_email(email)
now = timezone.now()

user = self.model(
email=email,
username=username,
first_name=first_name,
last_name=last_name,
date_of_birth=date_of_birth,
gender=gender,
mobile_number=mobile_number,
date_joined=now,
is_active=is_active,
is_admin=is_admin,
is_superuser=is_superuser,
)
user.set_password(password)
user.save(using=self._db)
return user

def create_user(self, email, username, password, first_name, last_name,
date_of_birth, gender, mobile_number, **extra_fields):
user = self._create_user(email, username, password, first_name,
last_name, date_of_birth, gender, mobile_number, True, False, False,
**extra_fields)
user.save(using=self._db)
return user

def create_superuser(self, email, username, password, first_name,
last_name, date_of_birth, gender, mobile_number, **extra_fields):
user = self._create_user(email, username, password, first_name,
last_name, date_of_birth, gender, mobile_number, True, True, True,
**extra_fields)
user.save(using=self._db)
return user


class CustomUser(AbstractBaseUser, PermissionsMixin):
email = models.EmailField(_('email address'), max_length=254,
unique=True)
username = models.CharField(_('user name'), max_length=254, unique=True)
first_name = models.CharField(_('first name'), max_length=30)
last_name = models.CharField(_('last name'), max_length=30)
date_of_birth = models.DateField()
gender = models.CharField(choices=GENDERTYPE, max_length=1)
mobile_number = models.IntegerField(unique=True)
date_joined = models.DateTimeField(_('date joined'),
default=timezone.now)
is_active = models.BooleanField(default=True)
is_admin = models.BooleanField(default=False)

objects = CustomUserManager()

USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['username', 'first_name', 'last_name',
'date_of_birth', 'gender', 'mobile_number']
...
...

And to process the model, I have a custom user creation forms.py

class UserCreationForm(forms.ModelForm):
password = forms.CharField(label='Password', widget=forms.PasswordInput)

class Meta:
model = CustomUser
fields = ('email', 'username', 'first_name', 'last_name',
'date_of_birth', 'gender', 'mobile_number')

def save(self, commit=True):
# Save the provided password in hashed format
user = super(UserCreationForm, self).save(commit=False)
user.set_password(self.cleaned_data["password"])
print self.cleaned_data["password"]
if commit:
user.save()
return user


class UserChangeForm(forms.ModelForm):
password = ReadOnlyPasswordHashField()

class Meta:
model = CustomUser
fields = (
'email', 'username', 'first_name', 'last_name',
'date_of_birth', 'gender', 'mobile_number', 'is_active',
'is_admin'
)

def clean_password(self):
return self.initial["password"]

I can save and create a new user. Also I can see the hashed password in the
admin. However when I try to login with the `email` and `password` of the
new user, I am not being authenticated. To check if I am actually getting
any password, I tried printing the *self.cleaned_data["password"] *in the
UserCreationForm, and in the console I can see the password I gave. What am
I doing wrong here? Please help 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGpF5MBCa3n182UKQcgDiAu1L_GKw1Q0uUyh6EQBaQQz%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Cannot login with user credentials

2016-07-23 Thread Robin Lery
 But again, with the superuser's credentials, I can login

On Sat, Jul 23, 2016 at 12:47 PM, Robin Lery  wrote:

> I have a made custom user model.
>
> class CustomUserManager(BaseUserManager):
> def _create_user(self, email, username, password, first_name,
> last_name, date_of_birth, gender, mobile_number,
>  is_active, is_admin, is_superuser):
> """
> Creates and saves a user with given email and password
> """
> if not email:
> raise ValueError('Email must be set')
>
> email = self.normalize_email(email)
> now = timezone.now()
>
> user = self.model(
> email=email,
> username=username,
> first_name=first_name,
> last_name=last_name,
> date_of_birth=date_of_birth,
> gender=gender,
> mobile_number=mobile_number,
> date_joined=now,
> is_active=is_active,
> is_admin=is_admin,
> is_superuser=is_superuser,
> )
> user.set_password(password)
> user.save(using=self._db)
> return user
>
> def create_user(self, email, username, password, first_name,
> last_name, date_of_birth, gender, mobile_number, **extra_fields):
> user = self._create_user(email, username, password, first_name,
> last_name, date_of_birth, gender, mobile_number, True, False, False,
> **extra_fields)
> user.save(using=self._db)
> return user
>
> def create_superuser(self, email, username, password, first_name,
> last_name, date_of_birth, gender, mobile_number, **extra_fields):
> user = self._create_user(email, username, password, first_name,
> last_name, date_of_birth, gender, mobile_number, True, True, True,
> **extra_fields)
> user.save(using=self._db)
> return user
>
>
> class CustomUser(AbstractBaseUser, PermissionsMixin):
> email = models.EmailField(_('email address'), max_length=254,
> unique=True)
> username = models.CharField(_('user name'), max_length=254,
> unique=True)
> first_name = models.CharField(_('first name'), max_length=30)
> last_name = models.CharField(_('last name'), max_length=30)
> date_of_birth = models.DateField()
> gender = models.CharField(choices=GENDERTYPE, max_length=1)
> mobile_number = models.IntegerField(unique=True)
> date_joined = models.DateTimeField(_('date joined'),
> default=timezone.now)
> is_active = models.BooleanField(default=True)
> is_admin = models.BooleanField(default=False)
>
> objects = CustomUserManager()
>
> USERNAME_FIELD = 'email'
> REQUIRED_FIELDS = ['username', 'first_name', 'last_name',
> 'date_of_birth', 'gender', 'mobile_number']
> ...
> ...
>
> And to process the model, I have a custom user creation forms.py
>
> class UserCreationForm(forms.ModelForm):
> password = forms.CharField(label='Password',
> widget=forms.PasswordInput)
>
> class Meta:
> model = CustomUser
> fields = ('email', 'username', 'first_name', 'last_name',
> 'date_of_birth', 'gender', 'mobile_number')
>
> def save(self, commit=True):
> # Save the provided password in hashed format
> user = super(UserCreationForm, self).save(commit=False)
> user.set_password(self.cleaned_data["password"])
> print self.cleaned_data["password"]
> if commit:
> user.save()
> return user
>
>
> class UserChangeForm(forms.ModelForm):
> password = ReadOnlyPasswordHashField()
>
> class Meta:
> model = CustomUser
> fields = (
> 'email', 'username', 'first_name', 'last_name',
> 'date_of_birth', 'gender', 'mobile_number', 'is_active',
> 'is_admin'
> )
>
> def clean_password(self):
> return self.initial["password"]
>
> I can save and create a new user. Also I can see the hashed password in
> the admin. However when I try to login with the `email` and `password` of
> the new user, I am not being authenticated. To check if I am actually
> getting any password, I tried printing the *self.cleaned_data["password"]
> *in the UserCreationForm, and in the console I can see the password I
> gave. What am I doing wrong here? Please help 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGocC6r9zwG0a6niNM7DRtnnEOyRhnk0cV8U_tQy8nyzqg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Happy New Year 2017

2016-12-31 Thread Robin Lery
Happy new year!

On 1 Jan 2017 12:05 a.m., "pradam programmer" 
wrote:

> Happy New Year Guys, i hope this year fill with alot of love, happiness
> and Joy to everyone.
>
>
> --
> 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/CAGGVXBOiUZcsYMyu237t2nirG%3DrzOD_v68b1AqYVkijk-fDk5Q%
> 40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CA%2B4-nGr%2BajFGPFssTO9nKr94AECOiBSJ1KTiatgHDTzZJdd1fg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Filter a contenttype with the content object's field

2017-01-03 Thread Robin Lery
I creating an app where users can post with its related tags:

class Tag(models.Model):
name = models.CharField(max_length=255, unique=True)

class Post(models.Model):
user = models.ForeignKey(User)
body = models.TextField()
tags = models.ManyToManyField(Tag)
pub_date = models.DateTimeField(default=timezone.now)
activity = GenericRelation(Activity)

class Activity(models.Model):
actor = models.ForeignKey(User)
verb = models.PositiveIntegerField(choices=VERB_TYPE)
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey('content_type', 'object_id')
pub_date = models.DateTimeField(default=timezone.now)

What I want to do is filter the Activity with the a list of users, and a
list of tags of the from list of Post objects.

Eg:

UserA created a new Post obect with tags(#class, #school)
UserB created a new Post object with tags(#professor, #teacher)
UserC created a new Post object with tags(#school, #university)
UserD created a new Post object with tags(#university, #school)


So say I want to filter Activity with user_list=[UserA, UserC] and tag_list
= [#class, #teacher]

It should return:

UserA created a new Post obect with tags(#class, #school)
UserC created a new Post object with tags(#school, #university)
UserB created a new Post object with tags(#professor, #teacher)

To filter the Activity with users, I can query this way:
Activity.objects.filter(actor__in=user_list)

But, how do I filter Activity with the content_object's (i.e.Post) field
(i.e. Post.tags)? Is this even possible? I cannot figure it out. And your
help will be very much helpful. 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/CA%2B4-nGobHqLNHShkBpFopO-w%3DHhjgzahqcbRhJoitRSy%3D66rWA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Filter a contenttype with the content object's field

2017-01-03 Thread Robin Lery
I forgot to mention, there is another class:


class Photo(models.Model):
user = models.ForeignKey(User)
file = models.ImageField()
tags = models.ManyToManyField(Tag)
pub_date = models.DateTimeField(default=timezone.now)
activity = GenericRelation(Activity)

So, filtering would be with the list of content_object's (i.e. Post of
Photo) field (i.e. Post.tags or Photo.tags).

On Wed, Jan 4, 2017 at 12:43 AM, Robin Lery  wrote:

> I creating an app where users can post with its related tags:
>
> class Tag(models.Model):
> name = models.CharField(max_length=255, unique=True)
>
> class Post(models.Model):
> user = models.ForeignKey(User)
> body = models.TextField()
> tags = models.ManyToManyField(Tag)
> pub_date = models.DateTimeField(default=timezone.now)
> activity = GenericRelation(Activity)
>
> class Activity(models.Model):
> actor = models.ForeignKey(User)
> verb = models.PositiveIntegerField(choices=VERB_TYPE)
> content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
> object_id = models.PositiveIntegerField()
> content_object = GenericForeignKey('content_type', 'object_id')
> pub_date = models.DateTimeField(default=timezone.now)
>
> What I want to do is filter the Activity with the a list of users, and a
> list of tags of the from list of Post objects.
>
> Eg:
>
> UserA created a new Post obect with tags(#class, #school)
> UserB created a new Post object with tags(#professor, #teacher)
> UserC created a new Post object with tags(#school, #university)
> UserD created a new Post object with tags(#university, #school)
>
>
> So say I want to filter Activity with user_list=[UserA, UserC] and
> tag_list = [#class, #teacher]
>
> It should return:
>
> UserA created a new Post obect with tags(#class, #school)
> UserC created a new Post object with tags(#school, #university)
> UserB created a new Post object with tags(#professor, #teacher)
>
> To filter the Activity with users, I can query this way:
> Activity.objects.filter(actor__in=user_list)
>
> But, how do I filter Activity with the content_object's (i.e.Post) field
> (i.e. Post.tags)? Is this even possible? I cannot figure it out. And your
> help will be very much helpful. 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/CA%2B4-nGp2P_jATzFC7qqcKPgRtZF6cP9ixHa-zAAUr%2BX13Rp%2BNw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Filter a contenttype with the content object's field

2017-01-04 Thread Robin Lery
Yes, this works. Thank you. But, as there are or will be more than one
ContentType objects (i.e., Post model and Photo model), how do I iterate
over it? Should I query them separately? Like
post_activities = Activity.objects.filter(post__tags__in=tags).distinct()
photos_activities = Activity.objects.filter(photo__tags__in=tags).distinct()

Or is there any better solution?

On Wed, Jan 4, 2017 at 6:28 PM, Michel Rodrigues 
wrote:

> Sorry, the point is a list of tags as argument, you can do this:
>
> >>> Activity.objects.filter(tags_act__tags__name__in=['tag1','
> tag3']).distinct()
> , , ]>
>
>
> Without .distinct() django return duplicated objects:
>
> >>> Activity.objects.filter(tags_act__tags__name__in=['tag1','tag3'])
> , , ,
> ]>
>
> --
> 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/62094107-f03e-40ea-874f-d99f7a6dbcc7%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CA%2B4-nGp3s%3DBDbar8bEcN94rps2VoVwMGbP5NCPa8TR-WBOTG%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Override save method to add list in the many to many field

2017-01-04 Thread Robin Lery
I have this model to save post from the users:

class Tag(models.Model):
name = models.CharField(max_length=255, unique=True)

def add_tags(obj_id, body):
object = Post.objects.get(id=obj_id)
tag_list = [Tag.objects.create(name=word) for word in body.split()]
for tag in tag_list:
object.tags.add(tag)

class Post(models.Model):
user = models.ForeignKey(User)
body = models.TextField()
tags = models.ManyToManyField(Tag, blank=True)
pub_date = models.DateTimeField(default=timezone.now)
activity = GenericRelation(Activity, related_query_name="posts")

def save(self, *args, **kwargs):
super(Post, self).save(*args, **kwargs)
if self.body:
body = self.body
obj_id = self.id
add_tags(obj_id, body)

So whenever a user post something, I would like to check if there's any
hash-tag used inside the body. If there are tags, then fetch the tags
inside the list.

But when I am posting, the tag objects are created, but they are not adding
for the Post.tags fields.

post.body example = Check #from the http://somesitedotcom/page#idtop #hell
yeah!

What am I doing wrong here?

-- 
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/CA%2B4-nGrj%3DoK2Vmj7%2BqiDMJie8rQGFbQsjbbDAmj3vKrLGYx5qA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Cannot install channels

2017-02-09 Thread Robin Lery
Hi,

I already had a django channels in my other virtual env. But since its an
older version of channels (0.7.0) I am trying to install a new channel
version into my project which is in a different virtual environment inside
a a vagrant box.

I created a new virtualenv

> $ mkvirtualenv newsapp
>

Install django

> $ pip install django
>

Install channels

> $ pip install -U channels
>

Then I am getting error:

Command "/home/vagrant/Envs/newsapp/bin/python -u -c "import setuptools,
> tokenize;__file__='/tmp/pip-build-IrzQ_E/twisted/setup.py';f=getattr(tokenize,
> 'open', open)(__file__);code=f.read().replace('\r\n',
> '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record
> /tmp/pip-ArjPse-record/install-record.txt
> --single-version-externally-managed --compile --install-headers
> /home/vagrant/Envs/newsapp/include/site/python2.7/twisted" failed with
> error code 1 in /tmp/pip-build-IrzQ_E/twisted/


Here is link for the full error

Can you please help how to solve this issue?

-- 
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/CA%2B4-nGpCy3g5KD9Q-UctFF3oKuVqtdfTjkW6XuTLBPiH%2BpyTsw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Cannot install channels

2017-02-09 Thread Robin Lery
Yes that was it. Thank you. Could you please help me understand why this
might have worked before in a earlier different virtual env in the same
vagrant machine?

On Fri, Feb 10, 2017 at 12:28 PM, Andrew Godwin  wrote:

> You don't have the Python development headers installed for your system -
> you can tell this because of this line in the error:
>
> src/twisted/test/raiser.c:4:20: fatal error: Python.h: No such file or
> directory
>
> If you install your distribution's python header package (e.g. on ubuntu
> it's python-dev) it should resolve the error.
>
> Andrew
>
> On Thu, Feb 9, 2017 at 10:51 PM, Robin Lery  wrote:
>
>> Hi,
>>
>> I already had a django channels in my other virtual env. But since its an
>> older version of channels (0.7.0) I am trying to install a new channel
>> version into my project which is in a different virtual environment inside
>> a a vagrant box.
>>
>> I created a new virtualenv
>>
>>> $ mkvirtualenv newsapp
>>>
>>
>> Install django
>>
>>> $ pip install django
>>>
>>
>> Install channels
>>
>>> $ pip install -U channels
>>>
>>
>> Then I am getting error:
>>
>> Command "/home/vagrant/Envs/newsapp/bin/python -u -c "import setuptools,
>>> tokenize;__file__='/tmp/pip-build-IrzQ_E/twisted/setup.py';f=getattr(tokenize,
>>> 'open', open)(__file__);code=f.read().replace('\r\n',
>>> '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record
>>> /tmp/pip-ArjPse-record/install-record.txt 
>>> --single-version-externally-managed
>>> --compile --install-headers 
>>> /home/vagrant/Envs/newsapp/include/site/python2.7/twisted"
>>> failed with error code 1 in /tmp/pip-build-IrzQ_E/twisted/
>>
>>
>> Here is link for the full error
>> <https://gist.github.com/robinlery/36c1cc0efbfe485500191d60e33b62b4>
>> Can you please help how to solve this issue?
>>
>> --
>> 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/ms
>> gid/django-users/CA%2B4-nGpCy3g5KD9Q-UctFF3oKuVqtdfTjkW6XuTL
>> BPiH%2BpyTsw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CA%2B4-nGpCy3g5KD9Q-UctFF3oKuVqtdfTjkW6XuTLBPiH%2BpyTsw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> 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/CAFwN1urVA5dAAKX2M06Ftny8BE8e9
> uVWTXKr6LFs-5xVim6j-Q%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAFwN1urVA5dAAKX2M06Ftny8BE8e9uVWTXKr6LFs-5xVim6j-Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CA%2B4-nGpddiY2fxD7papAQEP42f%2B43ZYOuCpXj7fjx_jCpzABXQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Cannot install channels

2017-02-09 Thread Robin Lery
Yes. That might have been the problem. Thank you once again!

On Fri, Feb 10, 2017 at 12:43 PM, Andrew Godwin  wrote:

> I'm afraid I can't help without looking at the machine directly - I would
> suspect that either it had a version of Twisted pre-installed on the system
> that it was happy with (the more recent releases increased the Twisted
> version requirement), or the version of Twisted it downloaded did not
> require compilation.
>
> Andrew
>
> On Thu, Feb 9, 2017 at 11:10 PM, Robin Lery  wrote:
>
>> Yes that was it. Thank you. Could you please help me understand why this
>> might have worked before in a earlier different virtual env in the same
>> vagrant machine?
>>
>> On Fri, Feb 10, 2017 at 12:28 PM, Andrew Godwin 
>> wrote:
>>
>>> You don't have the Python development headers installed for your system
>>> - you can tell this because of this line in the error:
>>>
>>> src/twisted/test/raiser.c:4:20: fatal error: Python.h: No such file or
>>> directory
>>>
>>> If you install your distribution's python header package (e.g. on ubuntu
>>> it's python-dev) it should resolve the error.
>>>
>>> Andrew
>>>
>>> On Thu, Feb 9, 2017 at 10:51 PM, Robin Lery  wrote:
>>>
>>>> Hi,
>>>>
>>>> I already had a django channels in my other virtual env. But since its
>>>> an older version of channels (0.7.0) I am trying to install a new channel
>>>> version into my project which is in a different virtual environment inside
>>>> a a vagrant box.
>>>>
>>>> I created a new virtualenv
>>>>
>>>>> $ mkvirtualenv newsapp
>>>>>
>>>>
>>>> Install django
>>>>
>>>>> $ pip install django
>>>>>
>>>>
>>>> Install channels
>>>>
>>>>> $ pip install -U channels
>>>>>
>>>>
>>>> Then I am getting error:
>>>>
>>>> Command "/home/vagrant/Envs/newsapp/bin/python -u -c "import
>>>>> setuptools, tokenize;__file__='/tmp/pip-bu
>>>>> ild-IrzQ_E/twisted/setup.py';f=getattr(tokenize, 'open',
>>>>> open)(__file__);code=f.read().replace('\r\n',
>>>>> '\n');f.close();exec(compile(code, __file__, 'exec'))" install
>>>>> --record /tmp/pip-ArjPse-record/install-record.txt
>>>>> --single-version-externally-managed --compile --install-headers
>>>>> /home/vagrant/Envs/newsapp/include/site/python2.7/twisted" failed
>>>>> with error code 1 in /tmp/pip-build-IrzQ_E/twisted/
>>>>
>>>>
>>>> Here is link for the full error
>>>> <https://gist.github.com/robinlery/36c1cc0efbfe485500191d60e33b62b4>
>>>> Can you please help how to solve this issue?
>>>>
>>>> --
>>>> 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/ms
>>>> gid/django-users/CA%2B4-nGpCy3g5KD9Q-UctFF3oKuVqtdfTjkW6XuTL
>>>> BPiH%2BpyTsw%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/CA%2B4-nGpCy3g5KD9Q-UctFF3oKuVqtdfTjkW6XuTLBPiH%2BpyTsw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>> --
>>> 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/ms
>>> gid/django-users/CAFwN1urVA5dAAKX2M06Ftny8BE8e9uVWTXKr6LFs-5
>>> xVim6j-Q%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAFwN1urVA5dAAKX2M06Ftny

Django rest framework cannot deal with multple objects in model viewset

2017-04-20 Thread Robin Lery
I have a very simple model and its related serializer and views:

class Page(models.Model):
user = models.ForeignKey(User)
title = models.CharField(max_length=255)
pub_date = models.DateTimeField(default=timezone.now)

class PageSerializer(serializers.ModelSerializer):
class Meta:
model = Page
fields = ('user', 'title', 'pub_date')

class PageViewSet(viewsets.ModelViewSet):
queryset = Page.objects.all()
serializer_class = PageSerializer
Now I can post like this:

{
"user": 1,
"title": "Lorem ipsum"
}
This works fine. But I would like to post multiple objects like this:

[
{
"user": 1,
"title": "Lorem ipsum one"
},
{
"user": 1,
"title": "Lorem ipsum two"
}
]
But this gives me an error:

"non_field_errors": [

"Invalid data. Expected a dictionary, but got list."
]
So to accept multple objects I modified the view as per the doc:

class PageViewSet(viewsets.ModelViewSet):
queryset = Page.objects.all()
serializer_class = PageSerializer(queryset, many=True)

But I am getting an error:

TypeError at /api/blog/pages/

'ListSerializer' object is not callable
What am I missing here?

-- 
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/CA%2B4-nGqCNu-03O7%3DvDO5G%3DSOA1jW7ef3%3Dfm%3DV1SNbX%2BX9sAtZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django rest framework JWT and custom authentication backend

2017-05-26 Thread Robin Lery
I have a custom user model and have created a custom authentication
backend. I am using django rest framework JWT

for token authentication.

User model:

class User(AbstractBaseUser, PermissionsMixin):
email = models.EmailField(
unique=True,
max_length=254,
)
first_name = models.CharField(max_length=15)
last_name = models.CharField(max_length=15)
mobile = models.IntegerField(unique=True)
date_joined = models.DateTimeField(default=timezone.now)
is_active = models.BooleanField(default=True)
is_admin = models.BooleanField(default=False)
objects = UserManager()
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['first_name', 'last_name', 'mobile']

Auth backend:

class EmailOrMobileAuthBackend(object):
def authenticate(self, username=None, password=None):
try:
user = get_user_model().objects.get(email=username)
if user.check_password(password):
return user
except User.DoesNotExist:
if username.isdigit():
try:
user = get_user_model().objects.get(mobile=username)
if user.check_password(password):
return user
except User.DoesNotExist:
return None
else:
return None

def get_user(self, user_id):
try:
return get_user_model().objects.get(pk=user_id)
except User.DoesNotExist:
return None
And have added in the settings.py:

AUTHENTICATION_BACKENDS =
('accounts.email_mobile_auth_backend.EmailOrMobileAuthBackend',)

While to log in to django admin site, both the email and mobile number
works fine in authenticating the user. However, when I try get the token
for the user using django rest framework JWT
, I get an
error:

curl -X POST -d "email=ad...@gmail.com&password=123123"
http://localhost/api-token-auth/

"non_field_errors": [
"Unable to log in with provided credentials."
  ]

What am I missing? Why is it that its working while loggin to the django
admin site, but get error when getting token with django rest framework jwt?

-- 
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/CA%2B4-nGqs8vvev5Y13Q2q1rtoL%3DHzUOhsfOkwV_aSOtS9jinXYw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django runserver not working after installing redis for django channels

2017-09-11 Thread Robin Lery
I am learning the Django-channels
 concepts and I am
stuck when after install the asgi_redis and the redis server
.
If I have the CHANNEL_LAYERS configured for the *in-memory backend*. The
server runs okay, and the web page is displayed.However, if I run the
server after configuring the CHANNEL_LAYERS for the *redis backed*, the web
page is not displayed, and I get an error in the terminal:

Channel layer default (asgi_redis.core.RedisChannelLayer)
Quit the server with CONTROL-C.
2017-09-11 12:34:07,259 - INFO - worker - Listening on channels
http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-09-11 12:34:07,260 - INFO - worker - Listening on channels
http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-09-11 12:34:07,261 - INFO - worker - Listening on channels
http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-09-11 12:34:07,263 - INFO - server - HTTP/2 support not enabled
(install the http2 and tls Twisted extras)
2017-09-11 12:34:07,263 - INFO - server - Using busy-loop synchronous mode
on channel layer
2017-09-11 12:34:07,265 - INFO - server - Listening on endpoint
tcp:port=8000:interface=127.0.0.1
2017-09-11 12:34:07,267 - ERROR - server - Error trying to receive
messages: unknown command 'EVALSHA'
2017-09-11 12:34:07,268 - INFO - worker - Listening on channels
http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-09-11 12:34:12,270 - ERROR - server - Error trying to receive
messages: unknown command 'EVALSHA'
2017-09-11 12:34:17,272 - ERROR - server - Error trying to receive
messages: unknown command 'EVALSHA'

I have installed the asgi_redis in my virtualenv, and also installed Redis
server. What am I doing wrong here?

Here are the useful versions that I am using:

   - channels==1.1.6
   - asgi-redis==1.4.2
   - daphne==1.3.0
   - Django==1.11.5


Sincerely

Robin

-- 
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/CA%2B4-nGrqHGfAbZ7R1pjb528DwJz4gBn81dc4dZk%2BJrm6Pii51Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django runserver not working after installing redis for django channels

2017-09-12 Thread Robin Lery
Yes, i think just running `sudo apt-get install redis-server` installs the
old version of redis, instead of the latest one.

On Mon, Sep 11, 2017 at 6:40 PM, Artem Malyshev 
wrote:

> Hi,
>
> Please check your redis installation. It should be at least minimum
> required version by redis-py.
>
> Regards, Artem.
>
> --
> 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/beab5ba8-b6db-44f6-b211-bce721259e90%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CA%2B4-nGphFTcqM9DFO-JSyGh4xaycuu%3DVM5sJ4CMqRhXAriC6JA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to authenticate a user in websocket connection in django channels when using token authentication

2017-09-14 Thread Robin Lery
I am using a frontend framework (Vuejs ) and
django-rest-framework  for the REST
API in my project. Also, for JSON web token authentication I am using
django-rest-framework-jwt
. After a successful
login, the user is provided with a token. This token is passed into every
request to fetch any API related stuff.

Now I would like to integrate django channels
 into my project. So,
after successful login, when the token is received in the client side, I
would like to initiate a websocket connection. Then on the server
(consumer), I would like to check if the requested user is not anonymous.
If the requested user is anonymous, I would like to close the connenction
or else accept it.

This is how I have till now:

client side:

const socket = new WebSocket("ws://" + "dev.site.com"+ "/chat/");

routing.py:

channel_routing = [
route("websocket.connect", ws_connect),
...
...]

consumers:

def ws_connect(message):

# if the user is no anonymous
message.reply_channel.send({
"accept": True
})

# else
message.reply_channel.send({
"close": True
})

In the documentation

there's a decorator @channel_session_user_from_http which will provide a
message.user. But I am using a token instead of a session. How can I check
a user on connection when using token authentication, so that I can accept
or close connection. Or, if there is a better way could you please advise
me with 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/CA%2B4-nGp5KhvYKdhD%3Dufus-jmHz%2BN%2BLPzOuX1R3V%2BPOYt8U4QXA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Validate and get the user using the jwt token inside a view

2017-09-14 Thread Robin Lery
I am using django-rest-framework 
for the REST API and django-rest-framework-jwt
 for JSON web token
authentication. After a successful login, the user is provided with a
token. I have found how to verify a token
 with
the api call, but is there any way to validate the token inside a view and
get the user of that token, similar to request.user?

-- 
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/CA%2B4-nGopatOzbDz4HZmZwPOTVpv5whYBpW-%3DgPdG%2BFhDcmUJsQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


  1   2   >