Re: Problems using mptt

2008-03-10 Thread Pete Crosier

Are you using 0.96 (you're using __str__ so I'd guess you are)?
Django's ugettext was introduced in the unicode merge that occured
after 0.96's release.

On Mar 10, 12:18 am, Tim Adler <[EMAIL PROTECTED]> wrote:
> Hey everybody,
>
> I'm trying to added mptt to my django project for managing a simple
> page-tree. It doesn't seem to work, as it is supposed too.
>
> My model looks like this:
>
> from django.db import models
> import mptt
>
> class Page(models.Model):
>         title = models.CharField(maxlength=200)
>         body = models.TextField()
>         parent = models.ForeignKey('self', null=True, blank=True,
> related_name='pages')
>
>         class Meta:
>                 ordering = ['parent']
>
>         class Admin:
>                 pass
>
>         def __str__(self):
>                 indent = ""
>                 for i in range(self.lvl()):
>                         indent += "-"
>
>                 return '%s %s' % (indent,self.title)
>
>         def level(self):
>                 if(self.parent == None):
>                         return 0
>                 else:
>                         return self.parent.lvl() + 1;
>
> But even in this stage, without the mptt.register, my development
> server gives me a
>
> > Validating models...
> > djangotree.content: cannot import name ugettext
> > 1 error found.
>
> I guess that is related to the mptt, but I have no idea, what might be
> causing this.
> Can somebody help out?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using primary key ID in file upload location?

2008-03-10 Thread Pete Crosier

Currently, Django won't overwrite uploaded files, it'll append a "_"
to the filename until it's unique. Django does let you organise files
by strftime formatting - 
http://www.djangoproject.com/documentation/model-api/#filefield
- it might be worth checking djangosnippets.org or searching in the
bug tracker to see if someone's already proposed a solution to
organising uploads by things other than date/time.

On Mar 9, 9:51 pm, Nick Day <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm quite new to Django so apologies if this is a really easy
> question!
>
> I have a model with several fields, some of which are ImageFields. To
> help prevent files overwriting others (if they are uploaded with the
> same name), and for organisational reasons, I would like to upload the
> images to a folder using the ID of the record.  For example - I'm
> adding a record with an autogenerated primary key ID of "12" - so I
> would like my photos to be uploaded to "/media/12/" when I click the
> Save button for that record.
>
> Hope somebody here can suggest a solution!
>
> Cheers,
> Nick
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: UTF-8 encoding

2008-03-10 Thread Pete Crosier

It's worth reading the notes on the database backends, which go into
detail about how to setup your database for Django / Django for your
database - http://www.djangoproject.com/documentation/databases/

On Mar 10, 5:51 am, "M.Ganesh" <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I am using MySQL. How to select UTF-8 encoding for the CharFields  and  
> TextFields in the models I create?
>
> Regards Ganesh
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: upload progress bar #2070

2008-03-08 Thread Pete Crosier

All the fun of middleware can be found here -
http://www.djangoproject.com/documentation/middleware/

On Mar 8, 6:38 pm, binaryj <[EMAIL PROTECTED]> wrote:
> hi group,
> i have patched my cvs build of django with patch #2070. the patch
> works well and is great except that it throws very little light on how
> to build a progress bar for the upload!
>
> i read this line in the patch
>
>         1       """
>         2       MultiPart parsing for file uploads.
>         3       If both a progress id is sent (either through 
> ``X-Progress-ID``
>         4       header or ``progress_id`` GET) and ``FILE_UPLOAD_DIR`` is set
>         5       in the settings, then the file progress will be tracked using
>         6       ``request.file_progress``.
>         7
>         8       To use this feature, consider creating a middleware with an
> appropriate
>         9       ``process_request``::
>         10
>         11          class FileProgressTrack(object):
>         12              def __get__(self, request, HttpRequest):
>         13                  progress_id = request.META['UPLOAD_PROGRESS_ID']
>         14                  status = # get progress from progress_id here
>         15
>         16                  return status
>         17
>         18              def __set__(self, request, new_value):
>         19                  progress_id = request.META['UPLOAD_PROGRESS_ID']
>         20
>         21                  # set the progress using progress_id here.
>         22
>         23          # example middleware
>         24          class FileProgressExample(object):
>         25              def process_request(self, request):
>         26                  request.__class__.file_progress =
> FileProgressTrack()
>         27
>         28
>         29       """
>
> this is just a DOC-STRING where is the middle ware and what the hell
> is a middle where.
>
> pls excuse my lang, i am just a django nubee and to me all this feels
> like adding sqrt(7.23) + log(32). lol hope u understand my problem.
>
> looking forward to ur replys. code sample would be greatly
> appreciated!
>
> thanks
> binary-j
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: MEDIA_ROOT, what am I doing wrong?

2008-03-05 Thread Pete Crosier

I think you're over-estimating Django a little when it comes to
serving media - check out 
http://www.djangoproject.com/documentation/static_files/
for details, it requires a little more work.

On Mar 5, 6:19 pm, "Monica Leko" <[EMAIL PROTECTED]> wrote:
> In settings.py I have:
> MEDIA_ROOT = 'C:/Documents and
> Settings/Monica/Desktop/aab/projekt/templates/media/'
>
> Media folder is in 'templates', and 'images' folder is in 'media'.
> angry.gif is in 'images'.  Following page, when requested, doesn't
> show the image, only text "No image"?!  I don't understand.
>
> 
> 
>
> 
> No image
>
> 
> 
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: initial value not working when used with SelectDateWidget

2008-03-05 Thread Pete Crosier

Ganesh - http://groups.google.com/group/django-users/post - try
again ;D

On Mar 5, 2:32 pm, "M.Ganesh" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I want to show the current date in the Date field. It works
> 'SelectDateWidget' when I use the default widget. If I use
> 'SelectDateWidget' then I always get 1st January 2008. Is there a way to
> use 'SelectDateWidget' and still get current date in the input box? The
> code is pasted in the link below:http://dpaste.com/hold/38055/
>
> Thanks in advance
> Regards Ganesh
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with SYNCDB

2008-03-05 Thread Pete Crosier

You need to make sure MySQL is up and running, and that the database
settings in your settings file are correct - I've seen this error when
I've simply forgotten to start MySQL.

On Mar 5, 1:25 pm, "Nicola Greco di Notsecurity.com"
<[EMAIL PROTECTED]> wrote:
> I'm using debian, with apache (not apache2), when i launch this
> command: python manage.py syncdb it appear:
>
> server:/home/admin/djbongo/aggregatore# python manage.py syncdb
> Traceback (most recent call last):
>   File "manage.py", line 11, in ?
>     execute_manager(settings)
>   File "/usr/lib/python2.4/site-packages/django/core/management.py",
> line 1672, in execute_manager
>     execute_from_command_line(action_mapping, argv)
>   File "/usr/lib/python2.4/site-packages/django/core/management.py",
> line 1571, in execute_from_command_line
>     action_mapping[action](int(options.verbosity),
> options.interactive)
>   File "/usr/lib/python2.4/site-packages/django/core/management.py",
> line 492, in syncdb
>     _check_for_validation_errors()
>   File "/usr/lib/python2.4/site-packages/django/core/management.py",
> line 1167, in _check_for_validation_errors
>     num_errors = get_validation_errors(s, app)
>   File "/usr/lib/python2.4/site-packages/django/core/management.py",
> line 990, in get_validation_errors
>     db_version = connection.get_server_version()
>   File "/usr/lib/python2.4/site-packages/django/db/backends/mysql/
> base.py", line 127, in get_server_version
>     self.cursor()
>   File "/usr/lib/python2.4/site-packages/django/db/backends/mysql/
> base.py", line 99, in cursor
>     self.connection = Database.connect(**kwargs)
>   File "/usr/lib/python2.4/site-packages/MySQLdb/__init__.py", line
> 75, in Connect
>     return Connection(*args, **kwargs)
>   File "/usr/lib/python2.4/site-packages/MySQLdb/connections.py", line
> 164, in __init__
>     super(Connection, self).__init__(*args, **kwargs2)
> _mysql_exceptions.OperationalError: (2002, "Can't connect to local
> MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")
>
> someone can help me?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: problems with url tag

2008-03-05 Thread Pete Crosier

More than one match for one {% url view args %} doesn't sound right,
you can name your patterns to clear up any ambiguity -
http://www.djangoproject.com/documentation/url_dispatch/#naming-url-patterns

On Mar 5, 2:30 am, msoulier <[EMAIL PROTECTED]> wrote:
> So, my urlconf is
>
> urlpatterns = patterns('teleworker.clients.views',
>     (r'create/$', 'create'),
>     (r'modify/(?P\d+)/$', 'modify'),
>     (r'delete/(?P\d+)/$', 'delete'),
>     (r'page/(?P\d+)/(?P\w+)/(?P\w+)/$',
> 'list'),
>     (r'page/(?P\d+)/$', 'list'),
>     (r'^$', 'list'),
> )
>
> The list function is
>
> def list(request, page=1, orderby='clientid', direction='forward',
> filter=None):
>
> When I try to use the url tag to get a url to this function, it only
> matches the last line of the urlconf.
>
> {% url teleworker.clients.views.list
> page=1,orderby=clientid,direction=forward %}
>
> What am I missing?
>
> Thanks,
> Mike
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: MEDIA_URL doesnt work

2008-02-22 Thread Pete Crosier

Have a look at the links below, I think you're over-estimating what
MEDIA_URL does for you -
http://www.djangoproject.com/documentation/static_files/
http://www.djangoproject.com/documentation/settings/#media-url

On Feb 22, 7:54 pm, troeten <[EMAIL PROTECTED]> wrote:
> Hi,
> i have a problem with the MEDIA_URL in django.
> My settings.py section looks like this:
>
> # Absolute path to the directory that holds media.
> # Example: "/home/media/media.lawrence.com/"
> MEDIA_ROOT = '/Users/stefan/Development/ju_amerang/media/'
>
> # URL that handles the media served from MEDIA_ROOT.
> # Example: "http://media.lawrence.com;
> MEDIA_URL = 'http://127.0.0.1:8000/media/'
>
> but, when i want to go tohttp://127.0.0.1:8000/media/with my browser
> i get every time a 404 Error with the following message:
> Using the URLconf defined in ju_amerang.urls, Django tried these URL
> patterns, in this order:
> ^mitglieder/
> ^admin/
> The current URL, /media/, didn't match any of these.
>
> can anyone help me?
>
> sorry for my bad englisch, but i hope you understand my
>
> regards stefan
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Two fields foreign key of same table

2008-02-13 Thread Pete Crosier

Read the message a little closer, it tells you what to do.. each
ForeignKey field needs a related_name to distinguish it from the
other.

On Feb 13, 10:33 am, "Sairam Krishnamurthy" <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> I have a table structure like this.
>
> class Componentdependencies(models.Model):
>     componentVersionID = models.ForeignKey(Componentversions)
>     depComponentVersionID = models.ForeignKey(Componentversions)
>     useFlagID = models.ForeignKey(Useflags, db_column='useFlagID')
>     class Meta:
>         db_table = 'ComponentDependencies'
>
> The two fields componentVersionID and depComponentVersionID refer foreign
> keys referring to another table 'Componentversions'. The class above is an
> entry from models.py. When to try to create the tables using syncdb it gives
> me the following error.
>
> Error: Couldn't install apps, because there were errors in one or more
> models:
> cdb.componentdependencies: Accessor for field 'componentVersionID' clashes
> with related field 'Componentversions.componentdependencies_set'. Add a
> related_name argument to the definition for 'componentVersionID'.
> cdb.componentdependencies: Accessor for field 'depComponentVersionID'
> clashes with related field 'Componentversions.componentdependencies_set'.
> Add a related_name argument to the definition for 'depComponentVersionID'.
>
> It is due to two fields of the same table declared as foreign keys of the
> same table. This is very common usage in any database. Can somebody help me
> how to resolve this problem?
>
> Thanks in advance,
>
> Sairam K
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: AssertionError on a model

2008-02-06 Thread Pete Crosier

A model can only use one field as its primary key and
Distributequeue.objects.get() should only return one object.

http://www.djangoproject.com/documentation/model-api/#primary-key
http://www.djangoproject.com/documentation/db-api/#get-kwargs

Cheers, Pete.

On Feb 6, 12:11 pm, Nader <[EMAIL PROTECTED]> wrote:
> Hallo,
>
> I have a model as following:
>
> class Distributequeue(models.Model):
>     datasetID = models.ForeignKey(Dataset, db_column="datasetID",
> primary_key=True)
>     filename = models.CharField(primary_key=True, maxlength=240)
>     fileVersion = models.CharField(primary_key=True, maxlength=48)
>     distributeModuleID = models.ForeignKey(Distributemodule,
> db_column="distributeModuleID")
>     timeOfEntry = models.DateTimeField()
>     status = models.CharField(blank=True, maxlength=240)
>     timeOfLastStatusUpdate = models.DateTimeField()
>     PID = models.IntegerField()
>
>     def __str__(self):
>         return self.filename
>
>     class Admin:
>         list_display = ('fileVersion', 'timeOfEntry', 'status')
>         list_per_page = 20
>         search_fields = ('filename', 'status')
>
>     class Meta:
>         db_table = 'distributeQueue'
>         unique_together = (("datasetID", "filename", "fileVersion"),)
>
> Unfortunately I can't understand the next message which I get from
> "Admin Intreface" for an application.
>
> AssertionError at /admin/distributequeues/distributequeue/SCIA_2F6.03/
> get() returned more than one Distributequeue -- it returned 763!
> Lookup parameters were {'pk': 'SCIA/6.03'}
>
> What does it mean?
>
> would somebody tell me how I can solve this problem?
>
> Regards,
> Nader
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Links not working after svn 6915

2007-12-14 Thread Pete Crosier

I'd have a read of 
http://www.djangoproject.com/documentation/middleware/#django-middleware-common-commonmiddleware
and http://code.djangoproject.com/changeset/6852/ - looks like it
could be a change of behaviour.

On Dec 14, 3:21 pm, "Matt Davies" <[EMAIL PROTECTED]> wrote:
> Hello everyone
>
> I've got some links in our site that do not end in a slash
>
> e.g.
>
> http://website/events/2007/12
>
> Since upgrading from 6838 to 6915 these links to do not work any more, the
> server tries to serve them as static files.
>
> Can anyone tell me why they're not working any more?
>
> In 6838 the link is automatically turned into one with a slash on the end.
>
> http://website/events/2007/12/
>
> I don't mind going through the site and ammending the links, although I'd
> rather not, but I'm more curious as to why it's happening.
>
> I've looked at the changeset description for 
> 6915,http://code.djangoproject.com/changeset/6915, but I can't see how that 
> would
> effect these links.
>
> Any help, greatly appreciated.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---