Re: Using query set in views.py

2012-02-26 Thread Ian Clelland
On Sunday, February 26, 2012, Stanwin Siow wrote:

> Ok disregard my previous question.
>
> Here's the latest one.
>
>
> I have the following form in my HTML:
> * *
> * Keyword: *
> * *
>

Your immediate problem here is that your  element has an id, but no
name attribute. That is why you are getting None when you try to retrieve
it from the POST dictionary -- the browser never sent it to the server.

I'm certain that you have additional issues with your view function, but
this is the reason for the error that you are seeing right now.

Ian




> * *
> * *
> * *
>
> when the user presses the submit button, it will go to the method
> keyword_subscribe in views.py
>
>
> The method is as shown:
>
> *def keyword_subscribe(request):*
> *if request.POST:*
> * username = UserProfile.objects.all()*
> * #userid = username.objects.all()*
> *subscription_days = "7"*
> * new_keyword = request.POST.get('myTextField')*
> * print new_keyword*
> *new_keyword_subscribed =
> subscribe_keyword(username,subscription_days,new_keyword)*
> **
> *response = simplejson.dumps({'new_keyword':
> new_keyword_subscribed})   *
> * print new_keyword_subscribed  *
> *else:*
> *   # html = form.errors.as_ul()*
> *response = simplejson.dumps({'success':'False'})*
> * return HttpResponseRedirect("/accounts/login/")*
> *#if request.is_ajax():*
> * #   return HttpResponse(response, mimetype='application/json')*
> *#else:*
> * #   return HttpResponseRedirect("/")*
>
> Once in this method, i'm supposed to extract the word which the user
> entered in the textfield and store it in a variable called new_keyword
>
> However, i've been getting NONE which means there's something wrong
> somewhere and i do hope someone can help me.
>
> In addition, i would like to get the username which is stored in the
> UserProfile table in my database to be passed as a parameter to the next
> function too.
>
> How then do i implement the queryset needed?
>
> This should be clearer.
>
> Thank you.
>
>
> Best Regards,
>
> Stanwin Siow
>
>
>
> On Feb 26, 2012, at 6:25 PM, Daniel Roseman wrote:
>
> Your question is not at all clear. You can use whatever you like in your
> view. What problem are you having?
> --
> DR.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/1N2Cz2nv9wQJ.
> To post to this group, send email to 
> django-users@googlegroups.com 'django-users@googlegroups.com');>
> .
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com  'django-users+unsubscr...@googlegroups.com');>.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to 
> django-users@googlegroups.com 'django-users@googlegroups.com');>
> .
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com  'django-users%2bunsubscr...@googlegroups.com');>.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>


-- 
Regards,
Ian Clelland


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



Re: internationalization makemessage don't work

2012-02-26 Thread Ian Clelland
On Sunday, February 26, 2012, nicolas HERSOG wrote:

> Hi folks !
>
> I'm trying for hours to internationalize my django website.
>
> I added to my settings.py this few lines :
>
> TIME_ZONE = 'Europe/Paris'
> LANGUAGE_CODE = 'fr-FR'
>
> I added to all templates i want to translate the tag trans for the
> sentence I want to  internationalize exemple :
>
> {% trans "article écrit :"%}
> {% trans "Nom :"%}
>
> And then at my root project i run django-admin.py makemessages -l en


Why are you running django-admin.py, rather than manage.py? manage.py knows
how to fund your settings files, and import all of your apps and check all
of your template dirs.

Try first running "manage.py makemessages -l fr" (since I suspect that your
site is already in French, you won't have to actually do anything with that
po file right now, but it's good to have)

Ian


> This command created a django.po file which contains the translations key
> for django debug tool bar, but none key of my webapp.
>
> Did I do something wrong, or miss something ?
>
> Thank you :)
>
> Nicolas
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to 
> django-users@googlegroups.com 'django-users@googlegroups.com');>
> .
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com  'django-users%2bunsubscr...@googlegroups.com');>.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>


-- 
Regards,
Ian Clelland


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



Re: question about "\d" in url pattern

2012-02-26 Thread Masklinn
On 27 févr. 2012, at 07:23, Zheng Li  wrote:
> url(r'^friend_page/cheer/confirm/(?P\w+)/(?P\d+)/(?P\d+)/$', 
> 'cheer_confirm', name = 'friend_page'),
> 
> def cheer_confirm(request, fid, key, point):
> data = {
> 'point' : 10 + point,
> }
> ...
> 
> i got 
> TypeError: unsupported operand type(s) for +: 'int' and 'unicode'
> 
> i did "print type(point)", and got type(unicode)
> apparently, point is not int.
> 
> i thought "\d+" in url promises i can get an int point in cheer_confirm, and 
> am i wrong?

\d+ ensures you will only get naturals, but django will not perform any 
conversion automatically. Especially not here as it would require introspecting 
the regular expression to see which pattern was matched and whether it is 
convertible. 

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



question about "\d" in url pattern

2012-02-26 Thread Zheng Li
url(r'^friend_page/cheer/confirm/(?P\w+)/(?P\d+)/(?P\d+)/$', 
'cheer_confirm', name = 'friend_page'),

def cheer_confirm(request, fid, key, point):
data = {
'point' : 10 + point,
}
...

i got 
TypeError: unsupported operand type(s) for +: 'int' and 'unicode'

i did "print type(point)", and got type(unicode)
apparently, point is not int.

i thought "\d+" in url promises i can get an int point in cheer_confirm, and am 
i wrong?

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



Re: Anyone want to take over maintaining Instant Django?

2012-02-26 Thread Victor Hooi
Hi,

Whatever happened to this?

@sidmitra - did you manage to take over maintainership of this project?

If not, @cjl - do you still have the scripts for this?

Cheers,
Victor

On Thursday, 15 July 2010 23:25:44 UTC+10, sidmitra wrote:
>
>
> I would be willing to take it on or we can also do it as a community 
> effort? 
> Instant Django is how i got started into web dev and now i'm a full 
> time django freelancer so would love to give some love back. 
>
> -Sid 
> http://sidmitra.com 
>
>

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



Re: Question on unknown error

2012-02-26 Thread Andy McKay
You can return whatever you want. All depends how you are using the result.

On Sun, Feb 26, 2012 at 5:48 PM, Stanwin Siow  wrote:
> It's ok guys!
>
>
> I figured out the error.
>
> At the end of the method we were returning 0 and 1 that will throw the
> error.
>
> Is there some rule in django that we are not supposed to return integers?
>
>
> Best Regards,
>
> Stanwin Siow
>
>
>
> On Feb 27, 2012, at 5:38 AM, Mario Gudelj wrote:
>
> In print 'time' what's time? Should you not have print exp_datetime?
>
> On 27 February 2012 01:27, Stanwin Siow  wrote:
>>
>> Hello,
>>
>> I have the following method:
>>
>> def subscribe_keyword(userid,subDay =7,KEYWORD_SET=frozenset()):
>>     try:
>> ...
>>
>>         sub_datetime = datetime.datetime.now()
>>         exp_datetime = sub_datetime + timedelta(days=subDay)
>> print 'time'
>>
>> However when i try to run my app,
>>
>> The following error throws at those two lines.
>>
>> Err: sequence item 0: expected string, int found
>>
>> Is there something wrong with the module?
>>
>>
>>
>>
>>
>> Best Regards,
>>
>> Stanwin Siow
>>
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



models.TimeField returning string rather than datetime.time with MySQL backend

2012-02-26 Thread smcoll
i need to interact with an existing MySQL database table, so i built a
models.py file in a new app via introspection and then cleaned it up a
bit.  For the TIME types, i am using models.TimeField, which maps to a
TIME type when using the MySQL backend.

Here's a sample from that models.py file:

http://dpaste.com/hold/708356/

What's strange is that when i'm accessing that `time_of_day` field,
it's returning as a string rather than a datetime.time:

>>> from reporting.models import FooModel
>>> m = FooModel.objects.latest()
>>> m.time_of_day
'09:19:00'

To be sure of the expected behavior, i set up a mock project with a
corresponding MySQL database on the same server.  models.py:

http://dpaste.com/hold/708357/

Now, when i grab that `time` field, i get a datetime.time, which is
the expected behavior (note the final line):

>>> from timetest.models import Widget
>>> w = Widget.objects.latest()
>>> w.now
datetime.datetime(2012, 2, 25, 18, 45, 8)
>>> w.datetime
datetime.datetime(2012, 1, 1, 1, 23, 45)
>>> w.date
datetime.date(2012, 2, 2)
>>> w.time
datetime.time(12, 34, 56)

i haven't been able to explain the difference in behavior.  The only
differences between the two databases and their respective tables that
i can think of are:
 - the introspected database and tables weren't created by the Django
ORM
 - the introspected tables are InnoDB and the Django-generated tables
are MyISAM
 - introspected table row format are "compact" and Django-generated
row format are "fixed"

Using 1.3.X. Any idea what's going on?

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



Re: internationalization makemessage don't work

2012-02-26 Thread Diego Schulz
On Sun, Feb 26, 2012 at 2:22 PM, nicolas HERSOG  wrote:
> Hi folks !
>
> I'm trying for hours to internationalize my django website.
>
> I added to my settings.py this few lines :
>
> TIME_ZONE = 'Europe/Paris'
> LANGUAGE_CODE = 'fr-FR'
>
> I added to all templates i want to translate the tag trans for the sentence
> I want to  internationalize exemple :
>
> {% trans "article écrit :"%}
> {% trans "Nom :"%}
>
> And then at my root project i run django-admin.py makemessages -l en
>
> This command created a django.po file which contains the translations key
> for django debug tool bar, but none key of my webapp.
>
> Did I do something wrong, or miss something ?
>

{% load i18n %}

at the top of your template file?



> Thank you :)
>
> Nicolas
>

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



Re: Any Singaporean Django developers out there?

2012-02-26 Thread Setiaman
Hi Kolbe,

I'm a Singaporean and has been using Django for almost a year to
develop Web Mobile which run on IPhone Android, etc.
You can contact me at setiaman@gmail.com if you need help.

Cheers,
Setiaman Lee

On Feb 26, 12:21 pm, Kolbe  wrote:
> It's like Django is nonexistent in Singapore!

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



Re: Question on unknown error

2012-02-26 Thread Stanwin Siow
It's ok guys!


I figured out the error.

At the end of the method we were returning 0 and 1 that will throw the error.

Is there some rule in django that we are not supposed to return integers?


Best Regards,

Stanwin Siow



On Feb 27, 2012, at 5:38 AM, Mario Gudelj wrote:

> In print 'time' what's time? Should you not have print exp_datetime?
> 
> On 27 February 2012 01:27, Stanwin Siow  wrote:
> Hello,
> 
> I have the following method:
> 
> def subscribe_keyword(userid,subDay =7,KEYWORD_SET=frozenset()):
> try:
>   ...
> 
> sub_datetime = datetime.datetime.now()
> exp_datetime = sub_datetime + timedelta(days=subDay)
>   print 'time'
> 
> However when i try to run my app,
> 
> The following error throws at those two lines.
> 
> Err: sequence item 0: expected string, int found
> Is there something wrong with the module?
> 
> 
> 
> 
> 
> Best Regards,
> 
> Stanwin Siow
> 
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

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



Re: Any Singaporean Django developers out there?

2012-02-26 Thread konatufe
I'm staying in Singapore, for a few days, but I'm not singaporean, I'm
from Chile. Anyway if you need something. Happy to help you if I can.

On Feb 26, 12:21 pm, Kolbe  wrote:
> It's like Django is nonexistent in Singapore!

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



Re: Question on unknown error

2012-02-26 Thread Andy McKay
Please give us the full traceback and exact line of code it occurred
on. There isn't enough information right now.

On Sun, Feb 26, 2012 at 1:38 PM, Mario Gudelj  wrote:
> In print 'time' what's time? Should you not have print exp_datetime?
>
>
> On 27 February 2012 01:27, Stanwin Siow  wrote:
>>
>> Hello,
>>
>> I have the following method:
>>
>> def subscribe_keyword(userid,subDay =7,KEYWORD_SET=frozenset()):
>>     try:
>> ...
>>
>>         sub_datetime = datetime.datetime.now()
>>         exp_datetime = sub_datetime + timedelta(days=subDay)
>> print 'time'
>>
>> However when i try to run my app,
>>
>> The following error throws at those two lines.
>>
>> Err: sequence item 0: expected string, int found
>>
>> Is there something wrong with the module?
>>
>>
>>
>>
>>
>> Best Regards,
>>
>> Stanwin Siow
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: How to come to #anchor After Form Submit with message rendering..

2012-02-26 Thread doniyor
oh okay, i will try it... there are jquery ajax form submit versions
too, but it is a good idea

thanks

On 26 Feb., 15:30, bb6xt  wrote:
> Hi,
> You could also pass a variable in the response's dictionary and use
> javascript to check this variable and navigate appropriately. This
> variable should indicate if postback or new request.

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



Re: Django and models with multiple foreign keys

2012-02-26 Thread akaariai
On Feb 26, 4:03 am, trudoe  wrote:

> In brief, can someone please help me to get a summary of all the trips
> and activities? What's the best way to accomplish that? Is the model
> correct?

>From the looks of it, you might benefit if the m2m relation would be
hand-defined, and activities then relate to that model. Something
like:

class Trip:
...
class Destination:
...

class TripDestination:
trip = models.ForeignKey(Trip, related_name='destination')
destination = models.ForeignKey(Destination)
class Meta:
unique_together = ('trip', 'destination')

class Activity:
at = models.ForeignKey(TripDestination, related_name='activities')

Now, the correct way to display all this data is to do (pseudo-code):
{% for trip_dest in trip.destinations %}
   {{ trip_dest.destination }}
   {% for act in trip_dest.activities %}
 {{ act }}
   ...

Be careful, the above generates a lot of queries. You would benefit a
lot by using 1.4 beta and its prefetch_related feature. In 1.3 you can
do the prefetching by hand in your view code by something similar to
what you do currently. However I usually assign the prefetched list
directly to the related model. Something like:

trips = list(Trip.objects.all())
# Make sure every trip has a list of destinations
[setattr(trip, 'trip_dest_lst', []) for trip in trips]
# This will allow fast joining, we can find the trip by its PK fast...
trip_dict = dict([(trip.pk, trip) for trip in trips])
trip_dests =
TripDestination.objects.filter(trip__in=trips).select_related('destination')
 # Here we append the trip destinations fetched above to related
trip's trip_dest_lst
[trip_dict[td.trip_id]trip_dest_lst.append(td) for td in trip_dests]

Now every trip should have (possibly empty) list of trip destinations.
You will still need to do the same for the activities per trip
destination, exactly same logic applies. Note that the above is not
tested, it is almost guaranteed to not work correctly.

In the template you would of course use the trip.trip_dest_list
instead of trip.destinations.all().

 - Anssi

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



Re: Question on unknown error

2012-02-26 Thread Mario Gudelj
In print 'time' what's time? Should you not have print exp_datetime?

On 27 February 2012 01:27, Stanwin Siow  wrote:

> Hello,
>
> I have the following method:
>
> def subscribe_keyword(userid,subDay =7,KEYWORD_SET=frozenset()):
> try:
> ...
>
> sub_datetime = datetime.datetime.now()
> exp_datetime = sub_datetime + timedelta(days=subDay)
> print 'time'
>
> However when i try to run my app,
>
> The following error throws at those two lines.
>
> Err: sequence item 0: expected string, int found
>
> Is there something wrong with the module?
>
>
>
>
>
> Best Regards,
>
> Stanwin Siow
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: method for checking logged in user

2012-02-26 Thread Denis Darii
This is for you:
https://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.models.User.is_authenticated

On Sun, Feb 26, 2012 at 6:55 PM, rafiee.nima  wrote:

> Hi
> I want to know is there any built in function to check if a user is
> logged in
> actually I want to check if a user from a request is logged in or not
> tnx
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
This e-mail and any file transmitted with it is intended only for the
person or entity to which is addressed and may contain information that is
privileged, confidential or otherwise protected from disclosure. Copying,
dissemination or use of this e-mail or the information herein by anyone
other than the intended recipient is prohibited. If you are not the
intended recipient, please notify the sender immediately by return e-mail,
delete this communication and destroy all copies.

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



method for checking logged in user

2012-02-26 Thread rafiee.nima
Hi
I want to know is there any built in function to check if a user is
logged in
actually I want to check if a user from a request is logged in or not
tnx

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



internationalization makemessage don't work

2012-02-26 Thread nicolas HERSOG
Hi folks !

I'm trying for hours to internationalize my django website.

I added to my settings.py this few lines :

TIME_ZONE = 'Europe/Paris'
LANGUAGE_CODE = 'fr-FR'

I added to all templates i want to translate the tag trans for the sentence
I want to  internationalize exemple :

{% trans "article écrit :"%}
{% trans "Nom :"%}

And then at my root project i run django-admin.py makemessages -l en

This command created a django.po file which contains the translations key
for django debug tool bar, but none key of my webapp.

Did I do something wrong, or miss something ?

Thank you :)

Nicolas

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



a new pluggable voting system for django

2012-02-26 Thread M. Can Bayrak
hi,

i created a pluggable voting system for django. check out it's 
features from here: https://github.com/miratcan/qhonuskan-votes

i'm waiting for your reviews, bug reports and other contributions.

thanks.

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



Re: Any Singaporean Django developers out there?

2012-02-26 Thread Denis Darii
 Is there some demand for django programmers?

On Sun, Feb 26, 2012 at 5:21 AM, Kolbe  wrote:

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


-- 
This e-mail and any file transmitted with it is intended only for the
person or entity to which is addressed and may contain information that is
privileged, confidential or otherwise protected from disclosure. Copying,
dissemination or use of this e-mail or the information herein by anyone
other than the intended recipient is prohibited. If you are not the
intended recipient, please notify the sender immediately by return e-mail,
delete this communication and destroy all copies.

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



Re: How to come to #anchor After Form Submit with message rendering..

2012-02-26 Thread bb6xt
Hi,
You could also pass a variable in the response's dictionary and use
javascript to check this variable and navigate appropriately. This
variable should indicate if postback or new request.

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



Re: How to come to #anchor After Form Submit with message rendering..

2012-02-26 Thread bb6xt
Hi,
You could also pass a variable in the response's dictionary and use
javascript to check this variable and navigate appropriately. This
variable should indicate if postback or new request.

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



Question on unknown error

2012-02-26 Thread Stanwin Siow
Hello,

I have the following method:

def subscribe_keyword(userid,subDay =7,KEYWORD_SET=frozenset()):
try:
...

sub_datetime = datetime.datetime.now()
exp_datetime = sub_datetime + timedelta(days=subDay)
print 'time'

However when i try to run my app,

The following error throws at those two lines.

Err: sequence item 0: expected string, int found
Is there something wrong with the module?





Best Regards,

Stanwin Siow



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



Re: Using query set in views.py

2012-02-26 Thread Daniel Roseman

>
> On Sunday, 26 February 2012 10:33:32 UTC, St@n wrote:
>
> Sorry if i have misled anyone.
>
> Here's a better view on what i'm asking.
>
> def get_keyword():
>return Keyword.objects.all() 
>
> That method above returns me a list of Keyword items correct?
>
> How then do i get a specific item from that list?
>
> Keyword is a table in my database but i need a specific column's 
> information in my views.py.
>
> Hope that makes it clearer.
>
> Best Regards,
>
> Stanwin Siow
>

Presuming you mean a specific row rather than a specific column, you use 
one of the queryset filtering or slicing options.

eg to get the Keyword whose name field is 'foo':
Keyword.objects.get(name='foo')

or to get all the Keywords whose name field starts with 'bar'
Keyword.objects.filter(name__startswith='bar')

or to get the first Keyword in the database:
Keyword.objects.all()[0]

etc.
As always, all this is explained in the tutorial and fully documented in 
the query method reference.
--
DR.

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



Re: Using query set in views.py

2012-02-26 Thread Stanwin Siow
Ok disregard my previous question.

Here's the latest one.


I have the following form in my HTML:

Keyword: 





when the user presses the submit button, it will go to the method 
keyword_subscribe in views.py


The method is as shown:

def keyword_subscribe(request):
if request.POST:
username = UserProfile.objects.all()
#userid = username.objects.all()
subscription_days = "7"
new_keyword = request.POST.get('myTextField')
print new_keyword
new_keyword_subscribed = 
subscribe_keyword(username,subscription_days,new_keyword)

response = simplejson.dumps({'new_keyword': new_keyword_subscribed})
   
print new_keyword_subscribed  
else:
   # html = form.errors.as_ul()
response = simplejson.dumps({'success':'False'})
return HttpResponseRedirect("/accounts/login/")
#if request.is_ajax():
 #   return HttpResponse(response, mimetype='application/json')
#else:
 #   return HttpResponseRedirect("/")

Once in this method, i'm supposed to extract the word which the user entered in 
the textfield and store it in a variable called new_keyword

However, i've been getting NONE which means there's something wrong somewhere 
and i do hope someone can help me.

In addition, i would like to get the username which is stored in the 
UserProfile table in my database to be passed as a parameter to the next 
function too.

How then do i implement the queryset needed?

This should be clearer. 

Thank you.


Best Regards,

Stanwin Siow



On Feb 26, 2012, at 6:25 PM, Daniel Roseman wrote:

> Your question is not at all clear. You can use whatever you like in your 
> view. What problem are you having? 
> -- 
> DR. 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/django-users/-/1N2Cz2nv9wQJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Raspberry Pi Live

2012-02-26 Thread Addy Yeow
Hey folks,

Just sharing a Django-powered page to get live status off raspberrypi.org:
http://dazzlepod.com/raspberrypi/

Raspberry Pi is an ARM GNU/Linux box for $25 (model A) / $35 (model B).
It is expected to be available for order in the next couple of days
but the first batch will only see release of 10,000 units.

Anyone looking forward to create first Django-powered site off the Raspi?

Cheers,
Addy

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



Re: Using query set in views.py

2012-02-26 Thread Stanwin Siow
Sorry if i have misled anyone.

Here's a better view on what i'm asking.

def get_keyword():
   return Keyword.objects.all() 

That method above returns me a list of Keyword items correct?

How then do i get a specific item from that list?

Keyword is a table in my database but i need a specific column's information in 
my views.py.

Hope that makes it clearer.



Best Regards,

Stanwin Siow



On Feb 26, 2012, at 6:25 PM, Daniel Roseman wrote:

> Your question is not at all clear. You can use whatever you like in your 
> view. What problem are you having? 
> -- 
> DR. 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/django-users/-/1N2Cz2nv9wQJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Using query set in views.py

2012-02-26 Thread Daniel Roseman
Your question is not at all clear. You can use whatever you like in your view. 
What problem are you having? 
-- 
DR. 

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



Using query set in views.py

2012-02-26 Thread Stanwin Siow
Hello,

I was wondering if we are able to use querysets in views.py so i can use one of 
the columns in my method below:


def keyword_subscribe(request):
keyword= ''
if request.method == 'POST':
subscription_days = "7"
new_keyword = request.POST.get('myTextField')
new_keyword_subscribed = subscribe_keyword(username,subDay 
=7,KEYWORD_SET=frozenset())

response = simplejson.dumps({'new_keyword': new_keyword_subscribed})
  
else:
html = form.errors.as_ul()
response = simplejson.dumps({'success':'False', 'html':html})
if request.is_ajax():
return HttpResponse(response, mimetype='application/json')
else:
return HttpResponseRedirect("/")

Best Regards,

Stanwin Siow



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