Re: convert str to datetime

2012-06-25 Thread Jim Thaxton
The parseutil module is very handy when converting a formatted string into 
a datetime object.

Here's the module:
http://labix.org/python-dateutil

And here is a stackoverflow post with a number of examples:
http://stackoverflow.com/questions/127803/how-to-parse-iso-formatted-date-in-python

On Monday, June 25, 2012 3:42:27 AM UTC-5, armagan wrote:
>
> Hi,
>
> I'm trying to convert to str to datetime. "date object" must be datetime 
> object. Can you help me?
>
>  def item_pubdate(self, item): # Yayinlanma Tarihi
>
> if item.delivery_date:
>
> date = item.delivery_date
>
> dt = datetime.combine(date, time())
>
> return dt
>
> else:
>
> return ' '
>

-- 
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/-/TwagqVTzU-0J.
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: Custom jQuery in admin

2013-01-11 Thread Jim Thaxton
I'm not sure about your original problem but prefixing it with django will 
make use of Django's jquery namespace:
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-media-definitions

Django admin Javascript makes use of the jQuery  library. 
> To avoid conflicts with user-supplied scripts or libraries, Django's jQuery 
> is namespaced as django.jQuery. If you want to use jQuery in your own 
> admin JavaScript without including a second copy, you can use the 
> django.jQuery object on changelist and add/edit views.
> If you require the jQuery library to be in the global namespace, for 
> example when using third-party jQuery plugins, or need a newer version of 
> jQuery, you will have to include your own copy of jQuery.


On Friday, January 11, 2013 4:26:19 AM UTC-6, Daniele Procida wrote:
>
> I had a custom widget, which broke after some other things were updated. 
>
> It was saying: 
>
> TypeError: 'undefined' is not a function (evaluating '$('#id_conta 
> cts_and_people-phonecontact-content_type-object_id-0-label').combo 
> box()') 
>
> Last night, I finally managed to fix it, after noticing that this script 
> (which is injected into the HTML body as many times as required for each 
> widget) began: 
>
> $(document).ready(function(){ 
>
> while others I had seen began: 
>
> jQuery(document).ready(function($){ 
>
> Changing it to the latter form made it work. 
>
> The only thing is, I don't really understand what was wrong, or how doing 
> that fixed it. 
>
> I understand that a jQuery conflict of some kind meant that jQuery was 
> unable to find the function "combobox()" and that probably this was because 
> of the way the admin template was loading JavaScript files. 
>
> But I don't understand what the changes actually mean, or what they do. 
>
> I also found that: 
>
> django.jQuery(document).ready(function($){ 
>
> worked. Again, I don't know what that is doing. 
>
> If someone can explain what is going on in this example, that would be 
> really helpful. 
>
> More generally, this sort of thing (jQuery conflicts) seems to be an 
> almost constant issue for Django developers who create custom widgets. Is 
> there a more general strategy for dealing with it? 
>
> Thanks, 
>
> Daniele 
>
>

-- 
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/-/dd7dlwe4ZJcJ.
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: Defining global names

2011-03-18 Thread Jim Thaxton
Can you set it in the settings.py file for your project? You can then import 
the Django settings in your views with:

from django.conf import settings

and call the variable with settings.my_var_name when needed.

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