Re: i need a unlimited subcategories

2009-04-27 Thread Paul Nema
Modified Preorder Tree Traversal (mptt)

http://code.google.com/p/django-mptt/

On Mon, Apr 27, 2009 at 9:52 AM, joker  wrote:

>
> how can i use unlimited category?
>
> like
>
> category1
>subcategory1-1
> subcategory1-1-1
> subcategory1-1-2
> subcategory1-1-3
>   subcategory1-1-3-1
>   subcategory1-1-3-2
>subcategory1-2
>
> category2
>subcategory2-1
>subcategory2-2
>
>
> >
>

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



Newbie to Novice – Using Admin DateTime Picker in your Form

2009-03-19 Thread Paul Nema
I've noticed many people new to Django (and sometimes also new to Python)
often post the same/similar questions in various forums. How to I get
something to work and/or do you have an example for X. As I've also
experienced this problem I've decided to post my little solution. Its not
the only way to do this, just the way I did it. Hopefully this will provide
the answer people are searching for or at least get them started. I guess it
will also serve as a quick code review by those so inclined to comment.


 You've probably heard of DRY but I think something is missing. There should
also be a Don't Repeat Other's Work (DROW) when they already solved the
problem. Thus another motivation to post this.  On a side note there is a
bit of debate out there about using the Django AdminDateWidget verse other
solutions (Jquery, etc). Your decision to make but why increase dependencies
when you don't have to.


 As I'm still learning Django everything in the code below may not be
required but I'm listing it anyway. You may need to modify to your
particular environment.  As I don't have a blog to post this I'm sending it
to this group. I'm open to any suggestions for a better place to post this.


 For this example I will focus on adding a date picker for date of birth
(dob) and a date time picker for sponsor sign date (sponsor_sign_date). Key
items are in *Bold*.


 Another reference to adding the AdminDateTime widget is here:
http://stackoverflow.com/questions/38601/using-django-time-date-widgets-in-custom-form




 ---

My top level (django-admin.py startproject izbo) directory Structure:

mylo...@lx-d620:~/dev/izbo$ ll

drwxrwxr-x 2 mylogin mylogin 4096 2009-03-17 10:52 account/

drwxr-xr-x 2 mylogin mylogin 4096 2009-03-17 10:53 add/

drwxr-xr-x 2 mylogin mylogin 4096 2009-03-18 04:34 adjudicator/

drwxrwxr-x 2 mylogin mylogin 4096 2009-03-18 09:43 application/

drwxr-xr-x 2 mylogin mylogin 4096 2009-03-18 10:06 contract/

drwxrwxrwx 2 mylogin mylogin 4096 2009-03-18 09:49 DB/

drwxr-xr-x 2 mylogin mylogin 4096 2009-03-17 10:51 employer/

drwxr-xr-x 2 mylogin mylogin 4096 2009-03-18 04:34 entity/

-rw-r--r-- 1 mylogin mylogin 207 2009-03-08 04:54 exclude

drwxrwxrwx 2 mylogin mylogin 4096 2009-03-18 10:06 gzbo/

-rw-r--r-- 1 mylogin mylogin 0 2009-01-06 04:55 __init__.py

-rw-r--r-- 1 mylogin mylogin 546 2009-01-06 04:55 manage.py

drwxrwxrwx 5 mylogin mylogin 4096 2009-02-08 12:35 media/

drwxr-xr-x 2 mylogin mylogin 4096 2009-03-17 10:53 member/

drwxr-xr-x 2 mylogin mylogin 4096 2009-03-17 10:52 note/

drwxr-xr-x 2 mylogin mylogin 4096 2009-02-20 12:47 search/

-rw-r--r-- 1 mylogin mylogin 4192 2009-03-05 23:39 settings.py

drwxrwxrwx12 mylogin mylogin 4096 2009-03-16 11:48 templates/

-rw-r--r-- 1 mylogin mylogin 2118 2009-03-16 11:16 urls.py


 --

Media directory Listing:

mylo...@lx-d620:~/dev/izbo/media$ ll

total 12

drwxr-xr-x 5 mylogin mylogin 4096 2009-03-18 10:56 admin/

drwxrwxrwx 2 mylogin mylogin 4096 2009-02-07 15:45 css/

drwxrwxrwx 2 mylogin mylogin 4096 2009-01-27 10:07 images/

lrwxrwxrwx 1 mylogin mylogin 36 2009-03-18 11:07 img ->
/home/mylogin/dev/izbo/media/admin/img/


 * Note: admin/ is 'cp -r' of directory
/usr/lib/python2.5/site-packages/django/contrib/admin/media.  Then I linked
the img directory.



 

In my “settings.py”


 import os.path

PROJECT_DIR = os.path.dirname(__file__)


 MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media')

MEDIA_URL = 'http://www.izbo.com/media/'

*ADMIN_MEDIA_PREFIX = '/media/admin/'*

TEMPLATE_DIRS = (

   os.path.join(PROJECT_DIR, 'templates'),

   ...

)


 

In my top level “urls.py” file

*from django.contrib import admin *


 urlpatterns = patterns('',

   # Uncomment the admin/doc line below and add 'django.contrib.admindocs'

   # to INSTALLED_APPS to enable admin documentation:

   (r'^admin/doc/', include('django.contrib.admindocs.urls')),


*# Add this to get widgets.AdminDateWidget() working for non is_staff,
is_superuser *

   *# This must be placed before (r'^admin/(.*)', admin.site.root), as that
gobals up everything *

   *(r'^admin/jsi18n/$', 'django.views.i18n.javascript_catalog'), *


# Uncomment the next line to enable the admin:

   (r'^admin/(.*)', admin.site.root),


# IZBO related URLs

   (r'^$', splash),

   .

)



 -

In “gzbo/models.py” I have my class


 #

# Application

#

class App (Record) :

# Personal Information

*dob = DateField(null=True, *

*verbose_name=_('Date of Birth'), *

*help_text=_('Enter Date of Birth Format: CCYY-MM-DD')) *

*sponsor_sign_date = DateTimeField(null=True, *

*blank=True, *

*verbose_name=_('Date Sponsor Electronically Signed')*)


 --

In “application/” I have a forms.py that describes the fields I want to have
a date time picker

So in application/forms.py


 #

# DJANGO Libraries

#

from django.forms import ModelForm

from django import forms

from django.contrib.admin import widgets

Re: getting started...with django

2009-03-04 Thread Paul Nema
After the tutorial and reading the docs, if you're the visual type, try
these screencasts.  Very helpful and illuminating.

http://thisweekindjango.com/screencasts/?page=3
and
http://showmedo.com/videos/django


On Wed, Mar 4, 2009 at 11:58 AM, CLIFFORD ILKAY
wrote:

> mseg...@gmail.com wrote:
> > hi  there !  am new in django and i  need help on getting started...
> > if you are the guy please email me
>
> Welcome! Start here:
> . Don't worry if
> it doesn't all make sense at first. Just follow the steps exactly and by
> the end of the tutorial, the pieces will fall into place.
> --
> Regards,
>
> Clifford Ilkay
> Dinamis
> 1419-3266 Yonge St.
> Toronto, ON
> Canada  M4N 3P6
>
> 
> +1 416-410-3326
>

--~--~-~--~~~---~--~~
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: Ignore Case Sensitive Property

2009-03-03 Thread Paul Nema
http://docs.djangoproject.com/en/dev/topics/db/queries/#topics-db-queries

to do case insensitive try
Application.objects.filter(name__iexact=searchText)

iexact

A case-insensitive match. So, the query:

>>> Blog.objects.get(name__iexact="beatles blog")

Would match a Blog titled "Beatles Blog", "beatles blog", or even "BeAtlES
blOG".
There are other case-insentive options too

On Tue, Mar 3, 2009 at 4:50 AM, burcu hamamcıoğlu wrote:

> I wrote a query like : applications =
> Application.objects.filter(name__contains=searchText)
> I want to get the applications filtered by searchText. If the app. name is
> "Guitar" and my serachText is "guitar", django can't find it, makes the
> query in case-sensitive format. How can i ignore this.?
>
> >
>

--~--~-~--~~~---~--~~
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 nube

2009-02-26 Thread Paul Nema
The error message provides the answer: "Please fill out DATABASE_NAME in the
settings module before using the database."
When using sqlite3 you are required to provide a path the target DB as per
comment: # Or path to database file if using sqlite3.
so

Add the full path to DATABASE_NAME.  I.E.
DATABASE_NAME = '/path/to/app/db_name.db'
On Thu, Feb 26, 2009 at 10:41 AM, john  wrote:

>
> I am trying to follow the Django | Writing your first Django ap part 1
> tutorial.  When I get to the python manage.py syncdb command I get the
> following:
>
> Traceback (most recent call last):
>  File "manage.py", line 11, in 
>execute_manager(settings)
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> __init__.py", line 340, in execute_manager
>utility.execute()
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> __init__.py", line 295, in execute
>self.fetch_command(subcommand).run_from_argv(self.argv)
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> base.py", line 192, in run_from_argv
>self.execute(*args, **options.__dict__)
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> base.py", line 219, in execute
>output = self.handle(*args, **options)
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> base.py", line 348, in handle
>return self.handle_noargs(**options)
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> commands/syncdb.py", line 51, in handle_noargs
>cursor = connection.cursor()
>  File "/usr/lib/python2.5/site-packages/django/db/backends/
> __init__.py", line 56, in cursor
>cursor = self._cursor(settings)
>  File "/usr/lib/python2.5/site-packages/django/db/backends/sqlite3/
> base.py", line 139, in _cursor
>raise ImproperlyConfigured, "Please fill out DATABASE_NAME in the
> settings module before using the database."
> django.core.exceptions.ImproperlyConfigured: Please fill out
> DATABASE_NAME in the settings module before using the database.
> j...@john-laptop:~/Django/mysite$ python manage.py syncdb
> Traceback (most recent call last):
>  File "manage.py", line 11, in 
>execute_manager(settings)
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> __init__.py", line 340, in execute_manager
>utility.execute()
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> __init__.py", line 295, in execute
>self.fetch_command(subcommand).run_from_argv(self.argv)
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> base.py", line 192, in run_from_argv
>self.execute(*args, **options.__dict__)
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> base.py", line 219, in execute
>output = self.handle(*args, **options)
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> base.py", line 348, in handle
>return self.handle_noargs(**options)
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> commands/syncdb.py", line 51, in handle_noargs
>cursor = connection.cursor()
>  File "/usr/lib/python2.5/site-packages/django/db/backends/
> __init__.py", line 56, in cursor
>cursor = self._cursor(settings)
>  File "/usr/lib/python2.5/site-packages/django/db/backends/sqlite3/
> base.py", line 139, in _cursor
>raise ImproperlyConfigured, "Please fill out DATABASE_NAME in the
> settings module before using the database."
> django.core.exceptions.ImproperlyConfigured: Please fill out
> DATABASE_NAME in the settings module before using the database.
>
>
> Here is how my settings. py file is settup.
>
> ADMINS = (
># ('Your Name', 'your_em...@domain.com'),
> )
>
> MANAGERS = ADMINS
>
> DATABASE_ENGINE = 'sqlite3'   # 'postgresql_psycopg2',
> 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
> DATABASE_NAME = '' # Or path to database file if using
> sqlite3.
> DATABASE_USER = '' # Not used with sqlite3.
> DATABASE_PASSWORD = '' # Not used with sqlite3.
> DATABASE_HOST = '' # Set to empty string for localhost.
> Not used with sqlite3.
> DATABASE_PORT = '' # Set to empty string for default. Not
> used with sqlite3.
>
> # Local time zone for this installation. Choices can be found here:
> # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
> # although not all choices may be available on all operating systems.
> # If running in a Windows environment this must be set to the same as
> your
> # system time zone.
> TIME_ZONE = 'Am
>
> My understanding is, that because I am using sqlite it will
> automatically create a database file when I run the syncdb command.  I
> had a slightly different experience with Turbogears.
>
> My thought is that my sqlite is not set up correctly, but I don't even
> know where to start looking.
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-

Re: Faster Database?

2009-02-25 Thread Paul Nema
One option is to create a new table that is a mirror of the target table
except the new table should NOT have any of the keys enabled.  Using a bulk
load tool add the data to the new table.  Then add the keys to the new
table.  Drop the old table and rename the new table to the original target
table name. This technique usually saves a bunch of time.

On Wed, Feb 25, 2009 at 1:00 PM, Sean  wrote:

>
> Hi,
>
> I am using django+MySql.
> My job involves to write a huge number of products codes into the
> MySql, code such as: ABCDEFGHI10, it is typically between 1 million up
> to 50 million codes within 1 file, which need to be uploaded/
> downloaded into MySql.
>
> The problem for this is it takestoo much time to insert data into the
> database, a typical 10 million code file will take 3 hours at least to
> load/download into MySql, it is even took a night time to process a 50
> million code file, which is a nightmare. So I want to make it faster.
>
> I got a powerful Core2 workstation and Xeron Server, which are almost
> the most powerful machin I can get in the market, so hardware is not a
> issue.
>
> I guess the slow down is caused by I/O to hard-disk.
>
> Anyone have any suggestion how can I make this process faster, or
> there is any other superfast database engine than MySql?
>
> Sean

--~--~-~--~~~---~--~~
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 can import the Widgets of Admin.

2009-02-07 Thread Paul Nema

How to I get the value from a class verbose_name in a models.Model
based generic list?

I.E. I want to use the value in a class element verbose_name for a table header

Thanks

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