Re: Admin Settings

2009-10-14 Thread justquick

try using 'foreign_key__field1' instead

On Oct 14, 12:04 pm, freeav8r  wrote:
> Is it possible to do something like this:
>
> class MyModelAdmin(admin.ModelAdmin):
>     list_display = (‘field1’, field2’, ‘foreign_key’, ‘foreign_key.field1’, 
> foreign_key.field2’,)
>
> admin.site.register(MyModel, MyModelAdmin)
>
> ‘foreign_key’ works just fine, but ‘foreign_key.field1’ and 
> ‘foreign_key.field2’ error out.  Any suggestions?
--~--~-~--~~~---~--~~
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: When would you use Context instead of RequestContext?

2009-10-14 Thread justquick

it helps performance slightly since it does not include the request
itself or any of the other goodies in TEMPLATE_CONTEXT_PROCESSORS

On Oct 14, 12:39 pm, ringemup  wrote:
> Is there ever a reason to pass a plain Context rather than a
> RequestContext when rendering a template?
--~--~-~--~~~---~--~~
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: lighttpd and admin

2009-10-14 Thread justquick

I have lighty setup for several of my projects using fastcgi and to
make them work, i had to set

FORCE_SCRIPT_NAME = ''

instead of

FORCE_SCRIPT_NAME = '/'

give that a try and see if {% url %} et al are still working

On Oct 14, 11:22 am, "Mark (Nosrednakram)" 
wrote:
> Hello All,
>
> I setup lighttpd and fastcgi the other day and everything seemed good
> until I tried to log into admin.  It posts to "//admin" which in the
> browser is http:///admin without a host.  I believe this is due to
> adding FORCE_SCRIPT_NAME="/" in my setting file which was required to
> make {% url %} and reverse work I believe.  Is there a fix I haven't
> found?  my lighttpd.conf with [CAPS] placeholders.  Any thoughts on
> where to look?
>
> server.modules              = ( "mod_rewrite",
>                                 "mod_redirect",
>                                 "mod_fastcgi",
>                                 "mod_alias",
>                                 "mod_access",
>                                 "mod_accesslog" )
>
> server.errorlog             = "/opt/django/fastcgi/error.log"
> accesslog.filename          = "/opt/django/fastcgi/access.log"
>
> server.document-root       = "/opt/django/html/"
> server.port                = 8080
>
> mimetype.assign             = (
>   ".pdf"          =>      "application/pdf",
>   ".jpg"          =>      "image/jpeg",
>   ".jpeg"         =>      "image/jpeg",
>   ".png"          =>      "image/png",
>   ".js"           =>      "text/javascript",
>   ".css"          =>      "text/css",
>   ".html"         =>      "text/html",
>   ".htm"          =>      "text/html",
>   ".gif"          =>      "image/gif",
>   ""              =>      "application/octet-stream",
>  )
>
> $HTTP["url"] =~ "^/media($|/)" {
>      dir-listing.activate = "enable"
>    }
>
> $HTTP["host"] == "[HOSTNAME]" {
>   url.redirect = ( "^/(.*)" => "http://[SERVER]/$1"; )}
>
> $HTTP["host"] == "[SERVER]" {
>
>     fastcgi.server = (
>         "/mysite.fcgi" => (
>             "main" => (
>                 "socket" => "/opt/django/fastcgi/[SERVER].socket",
>                 "check-local" => "disable",
>             )
>         )
>     )
>     alias.url = (
>         "/media" => "/opt/django/[PROJECT]/site_media/",
>     )
>
>     url.rewrite-once = (
>         "^(/media.*)$" => "$1",
>         "^(/.*)$" => "/mysite.fcgi$1"
>     )
>
> }
>
> Thank you,
> Mark
--~--~-~--~~~---~--~~
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: advice on template shortcomings

2007-11-18 Thread justquick

> {% for item in mydict.items %}
>the key: {{ item.0 }}
>the value: {{ item.1 }}
>{% for subitem in item.1 %}
>{{ subitem }}
>{% endfor %}
> {% endfor %}

UGH! How come django can make things so simple and complicated at the
same time? I personally dont use the django templating engine cause i
think its lame. Instead, i use Cheetah, which is a much more powerful
and fully developed python templating engine. The code to adapt this
into django is available here http://code.google.com/p/django-cheetahtemplate/

On Nov 17, 4:00 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> You don't need the development version. You should be able to do
> something like:
>

>
> While not as pretty as the development version of dictionary
> iteration, it's still useful.
--~--~-~--~~~---~--~~
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: design Q: where to put peoples names

2007-11-16 Thread justquick


> Can the username be Null?
>From the help text on username attr:
"Required. 30 characters or fewer. Alphanumeric characters only
(letters, digits and underscores)."

> What if it was 1,000,000 names, like if I was publishing a phone book?
Then using the user model, which does keep track of a lot more
information than you need (username,email,etc.) and does not keep
track of information you do need (phone,address,etc.). You should
probably come up with your own model/storage mechanism for keeping
track of this data.


On Nov 16, 9:54 am, Carl Karsten <[EMAIL PROTECTED]> wrote:
> Marty Alchin wrote:
> > My first question would be: Are you absolutely certain that none of
> > those 1000 other people will ever need a login?
>
> anything is possible.
>
> I would think at some point it isn't a good idea to use the User table.  What 
> if
> it was 1,000,000 names, like if I was publishing a phone book?
>
>
>
> > Basically, if any of those users would ever need to be promoted to
> > login status, the User model is your best bet. As Samuel mentioned,
> > just set "is_active" to False and probably set the password field to
> > "!" since they wouldn't be expected to supply a password. As for
> > username, you can probably just make a slug out of their real name and
> > use that.
>

>
> Carl 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: MySqldb error:

2007-11-14 Thread justquick

You do not have the MySQLdb module installed and this can be tricky to
setup on a hosted site. If you do not have shell access, contact your
administrator and ask for this module. Otherwise either get the
package or source from here http://sourceforge.net/projects/mysql-python
and install it through the terminal.

On Nov 14, 4:02 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> I'm receiving this error as I work thru Tutorial 1 
> (http://www.djangoproject.com/documentation/tutorial01/):
>
> [EMAIL PROTECTED] mysite]# python manage.py syncdb
> Traceback (most recent call last):
>   File "manage.py", line 11, in ?
> execute_manager(settings)
>   File "/usr/lib/python2.3/site-packages/django/core/management.py",
> line 1672, in execute_manager
> execute_from_command_line(action_mapping, argv)
>   File "/usr/lib/python2.3/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.3/site-packages/django/core/management.py",
> line 486, in syncdb
> from django.db import connection, transaction, models,
> get_creation_module
>   File "/usr/lib/python2.3/site-packages/django/db/__init__.py", line
> 11, in ?
> backend = __import__('django.db.backends.%s.base' %
> settings.DATABASE_ENGINE, {}, {}, [''])
>   File "/usr/lib/python2.3/site-packages/django/db/backends/mysql/
> base.py", line 12, in ?
> raise ImproperlyConfigured, "Error loading MySQLdb module: %s" % e
> django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
> module: No module named MySQLdb
>
> What am I missing or is mis-configured?  My site is hosted by
> mediatemple, and it's a dv3 plan... if that helps.


--~--~-~--~~~---~--~~
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: Form Field Question from python noob

2007-11-14 Thread justquick

Python does not have static/public/private objects like java does.
Whats happening is that self.date_form is referencing date_form and
that happens in the __init__ method

On Nov 14, 2:31 pm, johnny <[EMAIL PROTECTED]> wrote:
> I have seen forms without the "self" in front of the fields, eg. more
> like this date_from = forms.DateField() and never self.date_form
> =forms.DateField().  If you include self.date_form, then date_form
> becomes an attribute of an instance rather than a attribute of a
> class.
>
> What confusing me is that, when you define form field without self,
> like date_from = forms.DateField() , then are you creating only one
> date_from field as in java static class or java static variable?


--~--~-~--~~~---~--~~
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: how to get auto recoder id?

2007-11-14 Thread justquick

Do a select statement on the values

> > i just use this code:
> > cursor = connection.cursor()
> > sql = "insert into popo_status( author_id , body , time, type ) VALUES
> > (%s, %s, now(), '2')"
> > cursor.execute( sql,(str(row[0]),msg) )
cursor.execute("select id from popo_status where author_id = '%s' and
body = '%s' and type='%s'")
print cursor.fetchone()[0]
> > connection.commit()

That should do it, if author_id,body and type are not enough to
distinguish the record you will have to muck with the datetime stuff.
Im not sure what module you are using, but some return the ids from an
insert statement upon execution. like when you do this
> > cursor.execute( sql,(str(row[0]),msg) )


--~--~-~--~~~---~--~~
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: Multi Engine Template System (Django/Cheetah/Mako/Myghty/Genshi)

2007-11-14 Thread justquick

I am not talking about replacing the whole builtin template system so
that framework wide requires changes. Django is the default rendering
system, but others should be enabled. Django should continue to ship
its template system, which is a great system and has loads practical
tools for web design. I am learning to like it despite the fact that I
learned Cheetah first. But Django should also have the easy option of
using another system, even if it does not have to enable them by
default. At the very least I am interested in doing this on my sites
and will want to further investigate the differences in usage and
performance of these engines in a Django environment. I will implement
what I am proposing which is not meta-template API based, but instead
a set of replacements to the Template class and render_to_response
shortcut. Each engine will require its own particular syntax for
rendering, since the APIs are slightly different among them. As far as
integrating them into the main trunk?  Not so sure now, still trying
to think of the best way to easily allow authors access to the
component replacements. Of course you can always just import the
engine in your views and template away from there; these changes I am
making are merely an easy way to integrate Django's template loaders
and contexts with the other rendering engines. The end goal is not to
have to muck with steps like:

from django.template.loaders import find_template_source
import engine module
response = HttpResponse()
template = template(find_template_source('index.tmpl')[0])
template.render(context, out_file=response)
return response

Instead that all would become:

return render_to_response('index.tmpl', context, engine='cheetah')

See? Much nicer, no mucking with template loaders, search directories,
or rendering

On Nov 14, 1:18 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote:
> I'm generally with James on this, that users are already able to use
> whatever they like; after all, it's just Python.
>
> The one potential concern I have is, what about generic views? As far
> as I can tell, if you want to change template systems, you'd have to
> abandon the existing generic views. Either just go with custom views
> or rewrite the existing ones to use the new engine, but the shipped
> ones become useless.
>
> Of course, I don't really see that as a bad thing, since I don't plan
> on switching template engines, but it's at least a bigger problem than
> just importing your own in your custom views. That said, if speed is
> really that big of a concern, most sites can safely cache the rendered
> output and avoid the overhead of the template engine *and* all the
> database queries.
>
> And if you need that speed and you *can't* cache the output (live data
> view, for example), then you're probably in a special enough case that
> it's worth abandoning generic views anyway, since custom views could
> be written to work a lot faster than generic ones.
>
> -Gul


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



Multi Engine Template System (Django/Cheetah/Mako/Myghty/Genshi)

2007-11-14 Thread justquick

Recently I have been in search of an alternative to the Django
templating engine. Sure the engine is well produced and has many
features, but it lacks certain functionality that other engines
provide, like direct python syntax and parameter passing. Allowing
Django to use these other engines would increase its extensibility
beyond custom templatetags and filters. The author of a website might
be more comfortable with a template system that they are already
familiar with instead of Django's, however handy it may be. That being
said, I have investigated the implementation and efficiency of
rendering templates with different engines inside the Django
environment.

I conducted a set of trials to examine rendering speed for each of
five engines; Django/Cheetah/Mako/Myghty/Genshi. The tests were run in
a timed thread and the resulting speed of rendering was measured.

For each engine a template was created that contained 1) a string
variable ('hello world') 2) iteration over a list (range(100)) 3) a
random number 4) iteration over a Django model, yielding the
attributes. This template was loaded and rendered using the
appropriate Django context. Time was measured with the timeit module
and only represents the rendering time of the engine.

For this simple test Django did OK, coming in 3rd at the middle of the
pack. Genshi did horribly mostly because it is XML based which does
not conform to the Django design philosophies. The one that was
consistently the best by a noticeable amount was Cheetah.

Here are the average times (in milliseconds) for 100 trials of 5 sets
of measurement.
cheetah 0.827
mako 1.328
django 2.207
myghty 2.712
genshi 8.212

I also used pylab and the chart is available here
http://i239.photobucket.com/albums/ff209/justquick/template_bench.png
Email me if you wish to see the raw csv output or source code for this
test.

These results mean that in some cases Django does not render templates
the fastest. Developers should have the option to use whatever engine
they want for their template system. At the same time it should still
have all the compatible functionality of Django so that the
extensibility of the templatetags and filters can transfer over. I am
currently working on a project like this to adapt the winner (Cheetah)
into a Django compatible templating engine which is available here
http://code.google.com/p/django-cheetahtemplate/.

What are peoples' thoughts on the issue of having a multi engine
template system for Django? Does it violate the design philosophies?
Is it worth trying to make this adaption now?


--~--~-~--~~~---~--~~
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: Does Hostmonster support Django?

2007-11-12 Thread justquick

I have the same problem. They sent me the same notice with a couple
links to their forums with suggestions as how to keep your memory
(RSS) down, like regular restarts of apache and setting DEBUG = False
in the settings. Follow these tips and your memory usage should be
within acceptable limits.

Justin

On Nov 12, 4:23 am, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 12-Nov-07, at 1:26 PM, Mike Cantelon wrote:
>
> >> I personally use webfaction for public hosting, but its a major pain
>
> >> Just buy your own box
>
> > ...or go the VPS route. Any hosting company offering Xen-based virtual
> > servers (I used provps.com, who have been great) can give you the
> > flexibility of your own server without the cost of a dedicated server.
>
> I have a site on webfaction - 40MB. After much tweaking I got each
> django instance down to 15 mb and things were ok. Today I got a
> notice saying I am using 105 mb - look at the stats and find that
> each instance is using 35 MB. I have made no change. The rest of my
> apps are on my own vps, so no problem. But how did 15mb become 35mb
> over time?
>
> --
>
> regards
> kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/web/


--~--~-~--~~~---~--~~
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: Does Hostmonster support Django?

2007-11-11 Thread justquick

It is possible to install Django (of any version) onto a webserver if
you own it and have shell access, like a dedicated server. Other
webhosts have these features already installed and are "easily"
configurable. The complete list is here: 
http://code.djangoproject.com/wiki/DjangoFriendlyWebHosts

I personally use webfaction for public hosting, but its a major pain

Just buy your own box
Justin

On Nov 11, 8:50 pm, Hannus <[EMAIL PROTECTED]> wrote:
> Hi guys,
> I am going to buy the host services in host monster,does it support
> Django? If not, plz advice me some other hosting companies.
> Thank you very much
>
> Kind regards,
> Hannus


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

2007-11-11 Thread justquick

Try giving your model a get_absolute_url(self) method which returns
the absolute (http://...) url of the object for use in feed links. If
that does not work, reply with the complete traceback (usually found
by clicking 'Switch to copy-and-paste view' on a standard Django error
report)

Justin

On Nov 11, 9:03 pm, "Miguel Galves" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> i'm new to Django, and I'm warming up building a simple job board app.
> I'm trying to put a feed system to work using the middleware bundled with
> Django.
>
> - url.py:
>
> feeds = {
> 'ads': AdFeed,
>
> }
>
> urlpatterns = patterns('',
> (r'^admin/', include('django.contrib.admin.urls')),
> (r'^$', index),
> (r'^jobs/$', list),
> (r'^jobs/(?P\d*)/$', list),
> (r'^view/(?P\d*)/$', view),
> (r'^feeds/(.*)$', 'django.contrib.syndication.views.feed', {'feed_dict':
> feeds}),
> )
>
> - feeds.py file:
>
> class AdFeed(Feed):
> title = "Chicagocrime.org  site news"
> item_link = "http://job4dev.com";
> description = "Updates on changes and additions to chicagocrime.org."
>
> item_author_name='Joe Blow'
> item_author_email='[EMAIL PROTECTED]'
> item_author_link='http://www.example.com'
>
> def items(self):
> return Vaga.objects.all()[0:100]
>
> I've read the docs and lots of examples, and It seems to me that it's
> correct.
> But each time I try to acess /feeds/ads, I get an Attribute Error, with
> value
> "NoneType" object has no attribute startwith.
>
> The error is raised by
> python2.4/site-packages/django/contrib/syndication/feeds.py
> in get_feed
>
> I just can`t figure out where this None is coming from. Any idea?
>
> thanks,
>
> Miguel
>
> --
> Miguel Galves - Engenheiro de Computação
> Já leu meus blogs hoje?
> Para geekshttp://log4dev.com
> Pra pessoas normaishttp://miguelcomenta.wordpress.com
>
> "Não sabendo que era impossível, ele foi lá e fez..."


--~--~-~--~~~---~--~~
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: Django or Cheetah (why not both)?

2007-11-11 Thread justquick

Now the project is going under the name django_cheetahtemplates to
avoid contrib namespace confusion. Regardless of name, having cheetah
templates is very handy and increases the rendering times of your
templates. We are working on transferring over all the power of the
django tags/filters to cheetah syntax. More development, including
comparative benchmarks, will be available soon on our project site
http://code.google.com/p/django-cheetahtemplate/

Justin


--~--~-~--~~~---~--~~
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: Django or Cheetah (why not both)?

2007-11-11 Thread justquick

Thanks for the advise, we were a little up in the air about where to
put this module. I proposed a middleware module to process the
responses marked as cheetah templates with a provided context, but it
seemed more suited to put it in the contrib section so you could
process contexts/templates inside the view. What do you sugest we name
it? Dont want to step on your feet (or namespaces)

J

On Nov 12, 12:09 am, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 11/11/07, justquick <[EMAIL PROTECTED]> wrote:
>
> >I have been working with another developer to create a contrib
> > addon for cheetah template processing. The new django.contrib.cheetah
> > is now in production and can render django contexts and templates into
> > responses faster than django's builtin template engine.
>
> Just a minor procedural thing: unless something is committed to Django
> itself in the django/contrib directory, please don't label it
> 'django.contrib' or document it as if it lives in 'django.contrib';
> post-1.0 we plan to have an official process for submitting
> third-party applications as contrib candidates, and polluting that
> namespace right now with things that aren't actually distributed with
> Django will cause a lot of confusion down the road.
>
> Since Django applications can live anywhere that a Python module can
> live, and since Django will happily import components (including
> template loaders) from anywhere you specify, please consider giving
> this a more descriptive standalone name, and distributing it to be
> installed directly on the Python path instead of requiring people to
> insert it into their copies of Django.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."


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



Django or Cheetah (why not both)?

2007-11-11 Thread justquick

Hi all,

   I have been working with another developer to create a contrib
addon for cheetah template processing. The new django.contrib.cheetah
is now in production and can render django contexts and templates into
responses faster than django's builtin template engine. I want to see
if any of you think this is useful? I think that cheetah is a very
useful tool for templating; it has been maintained longer than
django's and has more functionality at the template level. Using
either one or the other should be up to you, the end users/developers,
but we all should have the option to choose. This contrib addon
package provides this functionality and can be used to render
contexts, or render responses by shortcut. Templatetag/filter
compatibility is coming soon, drop me a line if you are interested in
helping out. The project is available at 
http://code.google.com/p/django-cheetahtemplate/


Justin Quick


--~--~-~--~~~---~--~~
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: DateField() , AttributeError: 'str' object has no attribute 'strftime'

2007-08-06 Thread justquick

I have recently been working on a model and found this problem:

class Image(Model):
name = CharField(maxlength=255)
owner = ForeignKey('user')
file = ImageField(upload_to='Image/%Y-%m/', blank=True, null=True)
description = TextField()
datetime = DateTimeField(auto_now_add=True)

class Admin:
search_fields = ('description','name')
list_filter = ('datetime',)

def __str__(self): return self.name

Add the app to my installed apps list and then any attempt to run
manage.py results in:

Traceback (most recent call last):
  File "manage.py", line 11, in 
execute_manager(settings)
  File "/usr/lib/python2.5/site-packages/django/core/management.py",
line 1725, in execute_manager
execute_from_command_line(action_mapping, argv)
  File "/usr/lib/python2.5/site-packages/django/core/management.py",
line 1616, in execute_from_command_line
action_mapping[action](int(options.verbosity),
options.interactive)
  File "/usr/lib/python2.5/site-packages/django/core/management.py",
line 510, in syncdb
_check_for_validation_errors()
  File "/usr/lib/python2.5/site-packages/django/core/management.py",
line 1195, in _check_for_validation_errors
num_errors = get_validation_errors(s, app)
  File "/usr/lib/python2.5/site-packages/django/core/management.py",
line 1046, in get_validation_errors
for r in rel_opts.get_all_related_objects():
  File "/usr/lib/python2.5/site-packages/django/db/models/options.py",
line 146, in get_all_related_objects
if f.rel and self == f.rel.to._meta:
AttributeError: 'str' object has no attribute '_meta'


Seems to be only a problem with ImageField, FileField still works

Fedora Core 7
Django  (0, 97, 'pre') (SVN)
Python 2.5
MySql 5.0.37



On Aug 5, 8:27 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On 8/4/07, Frank Singleton <[EMAIL PROTECTED]> wrote:
>
>
>
> > AttributeError: 'str' object has no attribute 'strftime'
>
> Hi Frank,
>
> You're the second person in recent history to report this problem -
> however, I've been unable to replicate it. The last user was on
> Windows, and I had mentally put it down as a configuration issue; the
> fact that you're seeing it on Linux suggests that it might be a larger
> problem.
>
> The short version: The database backend (sqlite/pysqlite) should be
> returning datetime objects for records containing date fields, but for
> some reason, it seems to be returning strings for some users.
>
> If you can provide a simple test case that exhibits the problem (e.g.,
> minimal model, set of instructions for generating the error, complete
> set of version details for OS, database, etc), I'll have another look
> and see what I can see.
>
> Yours,
> Russ Magee %-)


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