Re: Admin Image upload control disabled?

2009-08-07 Thread Danielb

The app of mine that is having this issue was creating using Django
1.0 and I've since upgraded to 1.1.  Could that be the issue?  If it
is how do I upgrade an app to the new version?

Daniel

On Aug 6, 8:35 am, Daniel Brown  wrote:
> Good morning list,
>
> I've been working on a simple Django blog as a learning exercise and
> today I've been following this blog post about a simple way to add
> images to blog posts. My changes run fine on Django's test server
> without errors, however the image related part of the BlogPost's admin
> page seems to be disabled, its visible but not interactive. I've made
> sure the images folder exists and I've even deleted and rebuilt the
> database but I cannot seem to get the images part of the admin form to
> be enabled in Firefox (I'm on Mac OS X and using Django 1.1 with the
> latest release of PIL).
>
> The complete contents of my models.py is as follows:
>
> from django.db import models
> from django.contrib import admin
> from markdown import markdown
>
> class Image( models.Model ):
>     name = models.CharField( max_length=100 )
>     image = models.ImageField( upload_to="images" )
>
>     def __unicode__( self ):
>         return self.name
>
> class BlogPost( models.Model ):
>     title = models.CharField( max_length = 150 )
>     body = models.TextField()
>     body_html = models.TextField(editable=False, blank=True, null=True)
>     images = models.ManyToManyField( Image, blank=True )
>     timestamp = models.DateTimeField()
>
>     def save(self):
>         # Save first to get keys (etc) created
>         super( BlogPost, self).save()
>         # Now process images and markdown
>         image_ref = ""
>         for image in self.images.all():
>             image_url = settings.MEDIA_URL + image.image.url
>             image_ref = "%s\n[%s]: %s" % ( image_ref, image, image_url )
>
>         mdText = "%s\n%s" % ( self.body, image_ref )
>         self.body_html = markdown( mdText, ['codehilite(force_linenos=True)'] 
> )
>         # Save again to save processed Markdown
>         super( BlogPost, self).save()
>
>     class Meta:
>         ordering = ( '-timestamp', )
>
> class BlogPostAdmin( admin.ModelAdmin ):
>     list_display = ( 'title', 'timestamp' )
>
>     class Media:
>         js = ( 'js/wmd/wmd.js', )
>
> admin.site.register(BlogPost, BlogPostAdmin)
>
> I've also tried disabling the Markdown related parts and that save
> function without success.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Problem of installing django-tagging

2009-08-07 Thread Steven Nien

Hi,
I have installed the django tagging either by the using the setup.py
or
copying the "tagging" directory.
But when I import tagging in the python shell it raised:
IDLE 2.6.2   No Subprocess 
>>> import tagging
Traceback (most recent call last):
  File "", line 1, in 
import tagging
  File "/usr/local/lib/python2.6/dist-packages/tagging/__init__.py",
line 3, in 
from tagging.managers import ModelTaggedItemManager, TagDescriptor
  File "/usr/local/lib/python2.6/dist-packages/tagging/managers.py",
line 5, in 
from django.contrib.contenttypes.models import ContentType
  File "/usr/local/lib/python2.6/dist-packages/django/contrib/
contenttypes/models.py", line 1, in 
from django.db import models
  File "/usr/local/lib/python2.6/dist-packages/django/db/__init__.py",
line 10, in 
if not settings.DATABASE_ENGINE:
  File "/usr/local/lib/python2.6/dist-packages/django/utils/
functional.py", line 269, in __getattr__
self._setup()
  File "/usr/local/lib/python2.6/dist-packages/django/conf/
__init__.py", line 38, in _setup
raise ImportError("Settings cannot be imported, because
environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.

I have used the eric's method mentioned in this page
http://code.google.com/p/django-tagging/issues/detail?id=110
But it just didn't work.

Can someone help me? Thanks!
My environment is Django (1, 1, 0, 'final', 0)


--~--~-~--~~~---~--~~
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: subclassed ModelForms initial values behavior changed from 1.1beta to 1.1

2009-08-07 Thread Russell Keith-Magee

On Sat, Aug 8, 2009 at 10:17 AM, David Haas wrote:
>
> Fair enough.  I've got some style questions about the best way to do
> what I want to do, but they're probably not so relevant here.
> Something that might be relevant is this . . . is it worth submitting
> a documentation patch for this issue?  I was thinking something on
> this page:
>
> http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a-subset-of-fields-on-the-form
>
> ... in the note box along the lines of "If you specify fields or
> exclude when creating a form with ModelForm, then the fields that are
> not in the resulting form will not be initialized by an
> model instance or  set by the form's save() method.

Absolutely. We aren't striving for ambiguity, so any suggestions on
how we can clarify the docs in this regard are most welcome. Please
open a ticket for the general suggestion (perhaps with a summary of
the problem so we know what it is we're trying to explain); if you
have some draft text, drop it in a patch or a comment.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Continuing problems running Django when not site Root.

2009-08-07 Thread Malcolm Tredinnick

On Fri, 2009-08-07 at 14:44 -0700, Streamweaver wrote:
[...]
> Is there anyway around this?  Anyone know if fixing this on the Django
> roadmap?

It was fixed over a year ago (before Django 1.0 came out). If you are
using anything later than that, you don't have to do *anything* to worry
about SCRIPT_NAME, although the variable is set in the request.META
dictionary so you can use it to construct URLs if you want to do that
manually.

Regards,
Malcolm


--~--~-~--~~~---~--~~
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: Javascript with built-in templates tags

2009-08-07 Thread Luke Seelenbinder

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Wilson,

Are you referring to rendering JS with template tags, or actual
template tags in JS?

In the first case, you use them like any other template tag.
The second case is only possible if there is some JS library that uses
Django-like templates.

Luke

On Fri, Aug 7, 2009 at 10:31 PM, WilsonOfCanada wrote:
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkp85c8ACgkQXQrGVCncjPyvtACfdp1MNDbfcA4FVXCEBA6vAlAs
NGgAnjlGepehXauPkVf20eW2wGtKiqfa
=29IC
-END PGP SIGNATURE-

>
> Hellos,
>
> I was wondering how to use {{ }} variables in javascript functions.
>
> ex. onchange = "changeArea({{ mooman |safe|escapejs}});"
>
> 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
-~--~~~~--~~--~--~---



Re: Bug with model get_*_display() methods?

2009-08-07 Thread Malcolm Tredinnick

On Fri, 2009-08-07 at 11:40 -0700, Margie wrote:
> I see inconsistencies in how get_*_display() works based on whether
> the object is a recently saved object.  Probably an example describes
> this best:
> 
> My model contains this:
> 
> class Task(models.Model):
> 
> STATUS_CHOICES = (
> (OPEN_STATUS, 'Open'),
> (CLOSED_STATUS, 'Closed'),
> (STALLED_STATUS, 'Stalled'),)
> 
> status = models.IntegerField(choices=STATUS_CHOICES, blank=True,
> null=True)

I'm assuming OPEN_STATUS and friends are integers here (and not '1' or
other strings that contain integers).

[...]
> However, if I have recently saved a modelForm associated with my Task
> model and now have a handle to the object that that save() returned,
> the status is in unicode, and get_status_display() doesn't return a
> useful string:
> 
> (Pdb) type(self)
> 
> (Pdb) self.status
> u'3'
> (Pdb) self.get_status_display()
> u'3'

If I create a standard ModelForm subclass for your task model and then
submit some data to it (just using {"status": "1"} as the POST data
dictionary), I cannot replicate your problem.

The devil is in the details here. What does your ModelForm look like?

The results you are seeing are consistent with the form somehow saving a
string value for the "status" field. Which means (a) you're using
SQLite, since other databases will complain about the type mismatch, and
(b) something is going funky in your particular ModelForm.

The get_FOO_display() method requires an exact match the choice value
and the value of the field, otherwise it just returns the field value.
Since 3 != u'3' in Python, it is returning the correct result, given the
value of the status field. The question is how did you manage to get a
string into the status field.

Regards,
Malcolm


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



Javascript with built-in templates tags

2009-08-07 Thread WilsonOfCanada

Hellos,

I was wondering how to use {{ }} variables in javascript functions.

ex. onchange = "changeArea({{ mooman |safe|escapejs}});"

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



Re: subclassed ModelForms initial values behavior changed from 1.1beta to 1.1

2009-08-07 Thread David Haas

Fair enough.  I've got some style questions about the best way to do
what I want to do, but they're probably not so relevant here.
Something that might be relevant is this . . . is it worth submitting
a documentation patch for this issue?  I was thinking something on
this page:

http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a-subset-of-fields-on-the-form

... in the note box along the lines of "If you specify fields or
exclude when creating a form with ModelForm, then the fields that are
not in the resulting form will not be initialized by an
model instance or  set by the form's save() method.

Thanks,

- D

On Aug 4, 11:28 pm, Malcolm Tredinnick 
wrote:
> On Tue, 2009-08-04 at 22:23 +0800, Russell Keith-Magee wrote:
> > On Mon, Aug 3, 2009 at 3:46 AM, DavidHaas wrote:
>
> > > It looks like the change happened between rev. 10189 & 10190: 10189
> > > displays the value, 10190 doesn't.
>
> > > Unfortunately, I don't think I can give you a completely unbiased
> > > answer as to what behavior I think
> > > is more correct, because of history and personal use :)
>
> > > With that out on the table, though, it seems to me that if you are
> > > using a model form, and you're initializing
> > > it with a model instance, and that model instance has a current value
> > > for a field on your form, the form
> > > ought to get initialized with that value, regardless of whether or not
> > > you plan on eventually saving the
> > > field in the database or not.  If you're going to display it, it ought
> > > to reflect what's currently in the database.
> > > I think I've read some stuff about eventually making 'read only'
> > > forms, or marking fields on a form as 'read only', which seems like it
> > > could tie into this somehow, eventually, maybe.
>
> > > If you agree with that, though, then currently both ModelForms &
> > > ModelFormsets initialization is broken, because
> > > neither fills in the values.
>
> > Thanks for taking the time to do the analysis and explanation. I've
> > now had a closer look at this - unfortunately, I'm inclined to say the
> > exact opposite. I think ModelForm is doing the right thing.
> > My reasoning stems from the fact that we are dealing with a ModelForm,
> > not just a Form, and the 'Meta' definition is the highest source of
> > authority.
>
> > DataParentForm defines a Meta relationship with the DataParent model,
> > and explicitly defines that only the 'name' field is to be exposed.
>
> > DataChildForm inherits from DataParentForm, and while it overrides the
> > model relationship, it doesn't override the fields definition - so at
> > this point, we have a ModelForm on DataChild that only exposes the
> > 'name' field.
>
> > Then, you have added a 'value' field to the model. While this does
> > share the name of a field on the model, this is a coincidence - you
> > have explicitly stated that you don't want the 'value' field from the
> > model to be involved on the form. The 'value' FloatField could be
> > called anything else without error - by virtue of the inherited Meta
> > definition, it bears no relationship to the underlying model.
>
> > If, on DataChildForm, you add a fields definition:
>
> >     fields = ['name','value']
>
> > the explicitly defined FloatField becomes an override of the default
> > form element rather than a standalone form element, and as a result
> > the initial data is populated.
>
> > The behaviour for ModelFormSet is then consistent with that seen in
> > the ModelForm.
>
> > So - to my mind, the v1.1 behaviour of ModelForm is doing the right
> > thing. I agree that this is a nasty edge case though, and I'd be
> > interested to hear if anyone has any differing opinions or reasoning.
>
> For what it's worth, I agree with Russell's analysis here. If you're
> inheriting from a parent class, you are saying your subclass "is-a"
> instance of the parent and you can't put back things from the model the
> parent has already excluded. That isn't "is-a", it's
> "same-but-different".
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Customizing vs. Rewriting Admin UI

2009-08-07 Thread Amir Habibi

Hi All,

I'm writing a web application using Django and have not been able to
customize the admin interface to provide the desired UI.

Now I'm trying to write the UI using ExtJS. Do I need to rewrite the
Group and User management or I should take the route of customizing
the corresponding templates first.

Finally, where in admin code does Django deal with automation of
saving records and HTTP parsing.

Thanks
Amir

--~--~-~--~~~---~--~~
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: Date-based generic view not working

2009-08-07 Thread Malcolm Tredinnick

On Fri, 2009-08-07 at 13:36 -0700, Thomas Jaggi wrote:
> Well, after setting 'allow_future' to true everything works fine.
> Since the entries were created today I don't really get this. I'm
> using the 'pub_date' as 'date_field' and it's definitely NOT in the
> future...

Did you set the timezone correctly in your settings file? If you forget
to specify anything, it sadly defaults to Chicago's timezone (when we
all know the correct answer is Australia/Sydney), which means "now" is
in the past for most of us.

Secondly, if you make a typo in the timezone setting or specify one that
isn't know to your system, it will end up appearing to be UTC, which is
also in the past for more the majority of the planet's population.

Regards,
Malcolm


--~--~-~--~~~---~--~~
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: Continuing problems running Django when not site Root.

2009-08-07 Thread Graham Dumpleton

Django since 1.0 onwards is usually fine with SCRIPT_NAME. Quite
possibly you have tweaked something in settings or setup urls.py wrong
to cause the issue. I would suggest you start over with a fresh Django
installation and create the most minimal working example of what you
are trying to do and which demonstrates the problem. Then come back
and post what your Apache/mod_wsgi configuration is, what you changed
in settings, what you have in urls.py and the details of what and what
the template contains.

In short, it is impossible to help when others don't have a problem
and we have no idea of what you have set your configuration to or how
you are trying to do what you are doing.

Graham

On Aug 8, 7:44 am, Streamweaver  wrote:
> There's been some discussion here about what to do when you're trying
> to run a Django site not under the root domain.
>
> So for a site likehttp://mysite.com/django/
>
> Django (or WSGI?) doesn't seem to be able to be able to handle the
> SCRIPT_NAME ('/django' in this example) portion of the url well.  You
> have to add the request context to the application and views as well
> as account for it in the templates.
>
> Fair enough I guess and I refactored my application to handle this so
> far.
>
> I'm running into pretty big problems with using Django's login
> framework in this context.
>
> First there are the various login settings of 'LOGIN_URL' and such,
> and these can't be passed a context.  I got around this by adding
> another variable to the settings file I can see in addition to having
> to read the SCRIPT_NAME in the views and templates.
>
> I continue to have a problem though in that the generic login
> functions seem to have no way to handle SCRIPT_NAME and I suspect this
> problem extends to generic views in general.
>
> Is there anyway around this?  Anyone know if fixing this on the Django
> roadmap?
--~--~-~--~~~---~--~~
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: very interesting query... i need some help

2009-08-07 Thread Malcolm Tredinnick

On Fri, 2009-08-07 at 06:15 -0700, talpay...@gmail.com wrote:
> i have come up with one of the most interesting query i have ever
> seen.
> 
> I want to do this :
> 
> products = products.filter(productdetail__detail_value__gte =
> first_value)
> products = products.filter(productdetail__detail_value__lte =
> second_value)
> 
> where first_value and second_value are integers and
> "productdetail__detail_value" are stored as a char.
> 
> it is a very simple sql query but how can i do this using django
> queryset. the problem is that i need the products to stay as a
> queryset... because i need to filter it again if that is the case.

So what is the problem you are seeing? At the end of the above two
statements, "product" is a queryset, so that part of your problem is
solved.

> 
> taking the easy way out and changing the way the table is constructed
> is not an option. i have to store any kind of data in "detail_value"
> and filter the information. it's a generic filter and this is the only
> problem i don't have a solution to. please help.

You have a modelling problem, in that you're using "<=" on a character
field, which doesn't make sense for generic data. That's not something
Django can help you with out of the box. You say you can't change the
field type to something numeric type because have to store "anything" in
that field, but what do you expect to happen in the filter if
detail_value is "elephant", say? It is neither less than, nor greater
than, nor equal to a number. It's incomparable. So you're asking Django
to read your mind a bit there.

Since you're wanting to do something that is highly SQL specific here,
you'll want to first work out what the query will look like in raw SQL.
I suspect there's going to be either a nested query to only extract
numeric values or maybe a coallesce statement or maybe something else. I
can't visualise how you might do this, since it's very data dependent.

Work out the SQL query directly, perhaps on a simplified model and then
let us know what that might be and then we might be able to help convert
it into something you can use in the ORM. Or maybe not -- there are
(intentionally) limits on what you can do directly in the ORM and the
answer for edge-cases is often to write the query directly in SQL. Which
means you cannot use it further as a queryset (you could create
something that could be used to extra results, easily enough, but
further filter() calls, etc, are much harder to inject correctly).

Regards,
Malcolm



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

2009-08-07 Thread Margie

Ok, gotcha, thanks!  One final question - on your web page you have a
tutorial and it references a link to the final product of the tutorial
at:

http://www.eflorenzano.com/threadedcomments/example/

However that link seems to be broken.  If this is something easy to
fix, that would be nice!

Margie



On Aug 7, 3:02 pm, Eric Florenzano  wrote:
> >   * Does the .5 version work with django 1.1?
>
> Yes, it should work just fine.
>
> >   * Do you have any sort of ETA on when you think the GitHub version
> > will be ready for public use?  Is it in a form now that it could
> > actually be used?  IE, if I am willing to dive in and look at the
> > code, does the GitHub code have a reasonable level of functionality or
> > is it completley torn up and non-working?
>
> It is in working condition right now, and can be used, but no I'm
> sorry I don't have an ETA on when it will be in a releasable state
> right now with docs and examples.
>
> > Just trying to get an idea if I should go for the new or stick with
> > the old.  I'm fine with diving in and trying to fix bugs as needed,
> > but obviously it is better if there is a base level of functionality
> > working.
>
> Don't worry, the base functionality is working just fine.  I haven't
> used it in production yet, but I got some prototypes up and running
> and I think it's pretty solid.
>
> > Thanks very much for the package, it seems very nice.  My goal is to
> > provide a comment interface to my users that is similar to the google
> > groups interface - it seems that threadedcomments is very well suited
> > to that, do you agree?
>
> Seems like a good fit to me!
>
> For what it's worth, I recommend just using the 0.5.X release for now,
> because it works just fine and other people in the community have
> familiarity with it besides just myself (for example, most people
> using the comments in Pinax use threadedcomments 0.5.X).  When I do
> finally release the new version, I'll definitely provide a migration
> script.
>
> Thanks,
> Eric Florenzano
--~--~-~--~~~---~--~~
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: user.objects.create is not checking for duplicate emails

2009-08-07 Thread Malcolm Tredinnick

On Fri, 2009-08-07 at 17:02 +0300, Mirat Bayrak wrote:
> no i am talking about User model in django!

The Django user model does not enforce unique email addresses, since
email addresses aren't necessarily one-to-one with real-world people:
there are various legitimate situations where different users of your
site will have the same email address.

If you want email addresses to be unique, you should make that check a
part of the form validation in the form you're using to create users, as
indicated earlier in the thread.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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: apps that relate to each other

2009-08-07 Thread Milan Andric



On Aug 7, 3:00 pm, Masklinn  wrote:
> On 7 Aug 2009, at 23:33 , Milan Andric wrote:
>
>
>
>
>
> > Hello I have two apps that have foreign keys to each other.  Like:
>
> > people.models:
>
> >  class Profile(Model):
> >     secondary_email = CharField()
>
> >  class Staff(Profile):
> >     office = ForeignKey(Room)
>
> > resources.models:
>
> >  class Room(Model):
> >     name = CharField()
>
> >  class Reservation(Model):
> >     profile = ForeignKey(Profile)
>
> > Runserver seems to work fine but when i do ./manage.py sqlall people I
> > get a "Error: App with label people could not be found. Are you sure
> > your INSTALLED_APPS setting is correct?" error.
>
> > Is there a way around this or do I need to rip my apps apart so I can
> > foreign key to my rooms model?
>
> > Thanks,
>
> > Milan
>
> To the other comments I'd add that… does it really make sense to make  
> two apps which completely depend on one another that way? Apps are  
> supposedly independent blocks of function, making one depend on/extend  
> another one makes sense but two apps mutually requiring each other  
> should probably be merged into a single app, as they're always going  
> to be used together…
>
> No?

Hi Masklinn,  this is a good point and also crossed my mind.  The two
apps definitely don't belong as one because they serve very different
purposes.  All I was trying to do is minimize data replication since a
profile can point to room object rather than a charfield.   One idea I
had was to create an Office model in the resources app that would link
a Profile to a Room, and remove the office field from the profile.
Then this relation would be in the resources app and the circular
dependency would go away.  But that doesn't sit with me well either,
seems unnatural.

--
Milan
--~--~-~--~~~---~--~~
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: apps that relate to each other

2009-08-07 Thread Milan Andric



On Aug 7, 2:56 pm, Peter Herndon  wrote:
> On 08/07/2009 05:33 PM, Milan Andric wrote:
>
>
>
> > Hello I have two apps that have foreign keys to each other.  Like:
>
> > people.models:
>
> >    class Profile(Model):
> >       secondary_email = CharField()
>
> >    class Staff(Profile):
> >       office = ForeignKey(Room)
>
> > resources.models:
>
> >    class Room(Model):
> >       name = CharField()
>
> >    class Reservation(Model):
> >       profile = ForeignKey(Profile)
>
> > Runserver seems to work fine but when i do ./manage.py sqlall people I
> > get a "Error: App with label people could not be found. Are you sure
> > your INSTALLED_APPS setting is correct?" error.
>
> > Is there a way around this or do I need to rip my apps apart so I can
> > foreign key to my rooms model?
>
> > Thanks,
>
> > Milan
>
> Hi Milan,
>
> It sounds like your 'people' and 'resources' packages aren't being found
> by manage.py.  That means they aren't on your PYTHONPATH.  There's a
> little bit of explanation in the first couple of paragraphs here:  
> http://docs.djangoproject.com/en/dev/ref/django-admin/
>
> Assuming that 'people' and 'resources' are both Python packages that
> started life as the result of django-admin.py startapp, then the easiest
> thing to do is to make sure both modules are accessible to Python's
> site-packages.  That way, you can use people and resources in your
> current app, and use them again later in another app without having to
> move them from their current location on the file system.
>
> There are two ways to go about this.  The first way is to (assuming you
> are running Linux or OS X) link to the package directory from within
> site-packages.  That is, "cd /usr/lib/python2.6/site-packages" and then
> "sudo ln -s /home/milan/projects/people ."  for each package.  (Needless
> to say, modify the paths to reflect your system.)  This method is quick
> and easy, but places these modules in your system's Python install.  You
> may need to be cautious in doing so, as you may run into a namespace
> clash with existing packages.
>
> The second method is to learn all about virtualenv and use that
> wonderful tool to do what it does best.  Virtualenv allows you to create
> a sandboxed Python installation per project, separate from your system's
> Python installation.  With each project in its own sandbox, you don't
> need to worry about interfering with your system, or with version
> conflicts between the needs of one project and the next.  Use virtualenv
> with pip and virtualenvwrapper to make your life even easier, as pip
> allows you to install packages to your virtualenv similar to
> easy_install.  The downside, of course, is that you have to learn a few
> more tools, and use them with discipline.  Happily, they aren't hard to
> learn and are reasonably well documented.
>
> Hope that helps,

Hi Peter,  thanks for all the helpful information but I don't think
this is an import problem because everything works fine until I add
the circular dependency/foreign key.

--
Milan
--~--~-~--~~~---~--~~
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: apps that relate to each other

2009-08-07 Thread Milan Andric



On Aug 7, 2:54 pm, Daniel Roseman  wrote:
> On Aug 7, 10:33 pm, Milan Andric  wrote:
>
>
>
>
>
> > Hello I have two apps that have foreign keys to each other.  Like:
>
> > people.models:
>
> >   class Profile(Model):
> >      secondary_email = CharField()
>
> >   class Staff(Profile):
> >      office = ForeignKey(Room)
>
> > resources.models:
>
> >   class Room(Model):
> >      name = CharField()
>
> >   class Reservation(Model):
> >      profile = ForeignKey(Profile)
>
> > Runserver seems to work fine but when i do ./manage.py sqlall people I
> > get a "Error: App with label people could not be found. Are you sure
> > your INSTALLED_APPS setting is correct?" error.
>
> > Is there a way around this or do I need to rip my apps apart so I can
> > foreign key to my rooms model?
>
> > Thanks,
>
> > Milan
>
> You don't show it, but I'm guessing that each of these models.py files
> have import statement that import each other. This will lead to a
> circular dependency which will make one of them unimportable.
>
> To avoid this, don't import them at all, in either one. In the foreign
> key reference, use the string format to refer to the foreign model:
> office = ForeignKey('resources.Room')
>

Daniel, thanks for the suggestion, I tried doing this in one of the
models.py files, but not both.  Will give that a shot.

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



Dynamic/complex forms

2009-08-07 Thread Adi Andreias

Hello Django-ists,

I'm looking for a Django component that solves this problem:
In real life forms are often more complex than just displaying some
fields and doing validation on them. Often fields are required or not,
they appear or not, have different validation rules based on other
fields values, or even based on out-of the form conditions.

The obvious solution is to code all this in JavaScript AND in Python.

This has two problems:
- redundancy (Python code + JavaScript code)
- reinventing the wheel on every form. Some fields dependencies rules
are pretty frequent and some general code could be reused. While some
times custom code is still needed.

Do you know such a component that generally solves field-dependencies
form logic and validation?
That can also generate JavaScript code based on Python-defined rules?

Thank you




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

2009-08-07 Thread Eric Florenzano

>   * Does the .5 version work with django 1.1?

Yes, it should work just fine.

>   * Do you have any sort of ETA on when you think the GitHub version
> will be ready for public use?  Is it in a form now that it could
> actually be used?  IE, if I am willing to dive in and look at the
> code, does the GitHub code have a reasonable level of functionality or
> is it completley torn up and non-working?

It is in working condition right now, and can be used, but no I'm
sorry I don't have an ETA on when it will be in a releasable state
right now with docs and examples.

> Just trying to get an idea if I should go for the new or stick with
> the old.  I'm fine with diving in and trying to fix bugs as needed,
> but obviously it is better if there is a base level of functionality
> working.

Don't worry, the base functionality is working just fine.  I haven't
used it in production yet, but I got some prototypes up and running
and I think it's pretty solid.

> Thanks very much for the package, it seems very nice.  My goal is to
> provide a comment interface to my users that is similar to the google
> groups interface - it seems that threadedcomments is very well suited
> to that, do you agree?

Seems like a good fit to me!

For what it's worth, I recommend just using the 0.5.X release for now,
because it works just fine and other people in the community have
familiarity with it besides just myself (for example, most people
using the comments in Pinax use threadedcomments 0.5.X).  When I do
finally release the new version, I'll definitely provide a migration
script.

Thanks,
Eric Florenzano
--~--~-~--~~~---~--~~
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: apps that relate to each other

2009-08-07 Thread Masklinn

On 7 Aug 2009, at 23:33 , Milan Andric wrote:
>
> Hello I have two apps that have foreign keys to each other.  Like:
>
> people.models:
>
>  class Profile(Model):
> secondary_email = CharField()
>
>  class Staff(Profile):
> office = ForeignKey(Room)
>
>
> resources.models:
>
>  class Room(Model):
> name = CharField()
>
>  class Reservation(Model):
> profile = ForeignKey(Profile)
>
> Runserver seems to work fine but when i do ./manage.py sqlall people I
> get a "Error: App with label people could not be found. Are you sure
> your INSTALLED_APPS setting is correct?" error.
>
> Is there a way around this or do I need to rip my apps apart so I can
> foreign key to my rooms model?
>
> Thanks,
>
> Milan
To the other comments I'd add that… does it really make sense to make  
two apps which completely depend on one another that way? Apps are  
supposedly independent blocks of function, making one depend on/extend  
another one makes sense but two apps mutually requiring each other  
should probably be merged into a single app, as they're always going  
to be used together…

No?


--~--~-~--~~~---~--~~
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: apps that relate to each other

2009-08-07 Thread Peter Herndon

On 08/07/2009 05:33 PM, Milan Andric wrote:
> Hello I have two apps that have foreign keys to each other.  Like:
>
> people.models:
>
>class Profile(Model):
>   secondary_email = CharField()
>
>class Staff(Profile):
>   office = ForeignKey(Room)
>
>
> resources.models:
>
>class Room(Model):
>   name = CharField()
>
>class Reservation(Model):
>   profile = ForeignKey(Profile)
>
> Runserver seems to work fine but when i do ./manage.py sqlall people I
> get a "Error: App with label people could not be found. Are you sure
> your INSTALLED_APPS setting is correct?" error.
>
> Is there a way around this or do I need to rip my apps apart so I can
> foreign key to my rooms model?
>
> Thanks,
>
> Milan
>
Hi Milan,

It sounds like your 'people' and 'resources' packages aren't being found 
by manage.py.  That means they aren't on your PYTHONPATH.  There's a 
little bit of explanation in the first couple of paragraphs here:  
http://docs.djangoproject.com/en/dev/ref/django-admin/

Assuming that 'people' and 'resources' are both Python packages that 
started life as the result of django-admin.py startapp, then the easiest 
thing to do is to make sure both modules are accessible to Python's 
site-packages.  That way, you can use people and resources in your 
current app, and use them again later in another app without having to 
move them from their current location on the file system.

There are two ways to go about this.  The first way is to (assuming you 
are running Linux or OS X) link to the package directory from within 
site-packages.  That is, "cd /usr/lib/python2.6/site-packages" and then 
"sudo ln -s /home/milan/projects/people ."  for each package.  (Needless 
to say, modify the paths to reflect your system.)  This method is quick 
and easy, but places these modules in your system's Python install.  You 
may need to be cautious in doing so, as you may run into a namespace 
clash with existing packages.

The second method is to learn all about virtualenv and use that 
wonderful tool to do what it does best.  Virtualenv allows you to create 
a sandboxed Python installation per project, separate from your system's 
Python installation.  With each project in its own sandbox, you don't 
need to worry about interfering with your system, or with version 
conflicts between the needs of one project and the next.  Use virtualenv 
with pip and virtualenvwrapper to make your life even easier, as pip 
allows you to install packages to your virtualenv similar to 
easy_install.  The downside, of course, is that you have to learn a few 
more tools, and use them with discipline.  Happily, they aren't hard to 
learn and are reasonably well documented.

Hope that helps,

---Peter

--~--~-~--~~~---~--~~
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: apps that relate to each other

2009-08-07 Thread Daniel Roseman

On Aug 7, 10:33 pm, Milan Andric  wrote:
> Hello I have two apps that have foreign keys to each other.  Like:
>
> people.models:
>
>   class Profile(Model):
>      secondary_email = CharField()
>
>   class Staff(Profile):
>      office = ForeignKey(Room)
>
> resources.models:
>
>   class Room(Model):
>      name = CharField()
>
>   class Reservation(Model):
>      profile = ForeignKey(Profile)
>
> Runserver seems to work fine but when i do ./manage.py sqlall people I
> get a "Error: App with label people could not be found. Are you sure
> your INSTALLED_APPS setting is correct?" error.
>
> Is there a way around this or do I need to rip my apps apart so I can
> foreign key to my rooms model?
>
> Thanks,
>
> Milan

You don't show it, but I'm guessing that each of these models.py files
have import statement that import each other. This will lead to a
circular dependency which will make one of them unimportable.

To avoid this, don't import them at all, in either one. In the foreign
key reference, use the string format to refer to the foreign model:
office = ForeignKey('resources.Room')

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



Continuing problems running Django when not site Root.

2009-08-07 Thread Streamweaver

There's been some discussion here about what to do when you're trying
to run a Django site not under the root domain.

So for a site like http://mysite.com/django/

Django (or WSGI?) doesn't seem to be able to be able to handle the
SCRIPT_NAME ('/django' in this example) portion of the url well.  You
have to add the request context to the application and views as well
as account for it in the templates.

Fair enough I guess and I refactored my application to handle this so
far.

I'm running into pretty big problems with using Django's login
framework in this context.

First there are the various login settings of 'LOGIN_URL' and such,
and these can't be passed a context.  I got around this by adding
another variable to the settings file I can see in addition to having
to read the SCRIPT_NAME in the views and templates.

I continue to have a problem though in that the generic login
functions seem to have no way to handle SCRIPT_NAME and I suspect this
problem extends to generic views in general.

Is there anyway around this?  Anyone know if fixing this on the Django
roadmap?
--~--~-~--~~~---~--~~
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 deploy Django on the web server?

2009-08-07 Thread Daniel Roseman

On Aug 7, 9:56 pm, justin jools  wrote:
> thanks for the reply but I have access to a server for free so I wanted to
> set it up myself, how can it be so difficult? Django is renowned as an easy
> rapid development framework so why is it so difficult to deploy?
>
You haven't said why you think it's difficult. The documentation is
clear, and most people here have found it fairly easy to deploy. What
has been your problem? Why has the Django book not told you want you
want?
--
DR.
--~--~-~--~~~---~--~~
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 deploy Django on the web server?

2009-08-07 Thread Peter Herndon

On 08/07/2009 05:25 PM, Milan Andric wrote:
> Justin, it's not.  Have you seen the deployment docs?
>
> http://docs.djangoproject.com/en/dev/howto/deployment/#howto-deployment-index
>
> --
> Milan
>
> On Aug 7, 1:56 pm, justin jools  wrote:
>
>> thanks for the reply but I have access to a server for free so I wanted to
>> set it up myself, how can it be so difficult? Django is renowned as an easy
>> rapid development framework so why is it so difficult to deploy?
>>
>>  

More to the point, tell us what you are doing and where it's failing.  
Maybe then we can help you solve the problem.

Hmm, looking at the 000webhost.com site, their free offering does not 
include Python.  And I can't get heliohost.com to resolve.  Perhaps your 
problem starts there.


---Peter

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



apps that relate to each other

2009-08-07 Thread Milan Andric

Hello I have two apps that have foreign keys to each other.  Like:

people.models:

  class Profile(Model):
 secondary_email = CharField()

  class Staff(Profile):
 office = ForeignKey(Room)


resources.models:

  class Room(Model):
 name = CharField()

  class Reservation(Model):
 profile = ForeignKey(Profile)

Runserver seems to work fine but when i do ./manage.py sqlall people I
get a "Error: App with label people could not be found. Are you sure
your INSTALLED_APPS setting is correct?" error.

Is there a way around this or do I need to rip my apps apart so I can
foreign key to my rooms model?

Thanks,

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



syncdb and runserver fails -- related to trans_real.py

2009-08-07 Thread mike

Hi all-

I am using Django 1.1 (the latest stable release, installed from the
tarball), and
upon issuing a "python manage.py syncdb" or "python manage.py
runserver" from my
project, I get the same error.  I'm running this from within a pinax
virtualenv, and I am on Mac OSX version 10.4.

I've pasted in the error output below this message.

I have already spent a lot of time looking into this, and so far the
only thing that
seemed relevant is a bug where the django/conf/locale directory is
empty (see http://code.google.com/p/django-hotclub/issues/detail?id=213).
Unfortunately, I hit a dead end there when I saw that my django/conf/
locale is not empty.

I'm hoping someone else has experienced this and found a fix!

Thanks in advance,

Mike

Traceback (most recent call last):
  File "manage.py", line 28, in 
execute_from_command_line()
  File "/Users/wisz/Django-1.1/build/lib/django/core/management/
__init__.py", line
353, in execute_from_command_line
utility.execute()
  File "/Users/wisz/Django-1.1/build/lib/django/core/management/
__init__.py", line
303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/wisz/Django-1.1/build/lib/django/core/management/
base.py", line 195,
in run_from_argv
self.execute(*args, **options.__dict__)
  File "/Users/wisz/Django-1.1/build/lib/django/core/management/
base.py", line 213,
in execute
translation.activate('en-us')
  File "/Users/wisz/Django-1.1/build/lib/django/utils/translation/
__init__.py", line
73, in activate
return real_activate(language)
  File "/Users/wisz/Django-1.1/build/lib/django/utils/translation/
__init__.py", line
43, in delayed_loader
return g['real_%s' % caller](*args, **kwargs)
  File "/Users/wisz/Django-1.1/build/lib/django/utils/translation/
trans_real.py",
line 205, in activate
_active[currentThread()] = translation(language)
  File "/Users/wisz/Django-1.1/build/lib/django/utils/translation/
trans_real.py",
line 195, in translation
current_translation = _fetch(language,
fallback=default_translation)
  File "/Users/wisz/Django-1.1/build/lib/django/utils/translation/
trans_real.py",
line 160, in _fetch
res._info = res._info.copy()
AttributeError: 'NoneType' object has no attribute '_info'


--~--~-~--~~~---~--~~
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 deploy Django on the web server?

2009-08-07 Thread Milan Andric


Justin, it's not.  Have you seen the deployment docs?

http://docs.djangoproject.com/en/dev/howto/deployment/#howto-deployment-index

--
Milan

On Aug 7, 1:56 pm, justin jools  wrote:
> thanks for the reply but I have access to a server for free so I wanted to
> set it up myself, how can it be so difficult? Django is renowned as an easy
> rapid development framework so why is it so difficult to deploy?
>
>
>
> On Fri, Aug 7, 2009 at 8:34 PM, lzantal  wrote:
>
> > On Aug 7, 12:06 pm, justin jools  wrote:
> > > This has been driving me nuts for a month.
>
> > > I wanted to use a free web server to do development testing and have
> > > found : 000webhost.com and heliohost.com which apparently support
> > > Python, but what about Django? Do I install that myself?
>
> > > I have read the django book on deployment chapter but find it doesnt
> > > tell me what I want.
>
> > > Could someone please just tell me simply how I can get my scripts
> > > running on the webserver.
>
> > Tryhttp://webfaction.com.
> > They have super easy install for django through their control panel
>
> > hope that helps
>
> > lzantal
> >http://twitter.com/lzantal
>
> > > justinjo...@googlemail.com
--~--~-~--~~~---~--~~
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 deploy Django on the web server?

2009-08-07 Thread Vitaly Babiy
Also you may want to look in to slice host. Awesome service.

Vitaly Babiy


On Fri, Aug 7, 2009 at 4:30 PM, Dan Harris  wrote:

>
> I just wanted to give a shout out as well to webfaction. I used to use
> my own virtual private server for hosting django stuff, but to cut
> costs i switched to a webfaction account and it is pretty fantastic.
> Super easy to set up, if you decide to go that way just drop me and
> email and i'd be happy to help you get set up and running.
>
> Cheers,
>
> Dan
>
> On Aug 7, 3:34 pm, lzantal  wrote:
> > On Aug 7, 12:06 pm, justin jools  wrote:>
> This has been driving me nuts for a month.
> >
> > > I wanted to use a free web server to do development testing and have
> > > found : 000webhost.com and heliohost.com which apparently support
> > > Python, but what about Django? Do I install that myself?
> >
> > > I have read the django book on deployment chapter but find it doesnt
> > > tell me what I want.
> >
> > > Could someone please just tell me simply how I can get my scripts
> > > running on the webserver.
> >
> > Tryhttp://webfaction.com.
> > They have super easy install for django through their control panel
> >
> > hope that helps
> >
> > lzantalhttp://twitter.com/lzantal
> >
> >
> >
> > > justinjo...@googlemail.com
> >
>

--~--~-~--~~~---~--~~
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 deploy Django on the web server?

2009-08-07 Thread justin jools
thanks for the reply but I have access to a server for free so I wanted to
set it up myself, how can it be so difficult? Django is renowned as an easy
rapid development framework so why is it so difficult to deploy?

On Fri, Aug 7, 2009 at 8:34 PM, lzantal  wrote:

>
>
>
> On Aug 7, 12:06 pm, justin jools  wrote:
> > This has been driving me nuts for a month.
> >
> > I wanted to use a free web server to do development testing and have
> > found : 000webhost.com and heliohost.com which apparently support
> > Python, but what about Django? Do I install that myself?
> >
> > I have read the django book on deployment chapter but find it doesnt
> > tell me what I want.
> >
> > Could someone please just tell me simply how I can get my scripts
> > running on the webserver.
> >
> Try http://webfaction.com .
> They have super easy install for django through their control panel
>
> hope that helps
>
> lzantal
> http://twitter.com/lzantal
>
> > justinjo...@googlemail.com
> >
>

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



Feed arguments

2009-08-07 Thread When ideas fail

Hello, i've trying to do an rss feed. I've had alook at the docs and i
have the feeds set as:


feeds = {
'latest': LatestEntries,
'categories': LatestEntriesByCategory,
}

but it doesn't say much about LatestEntriesByCategory, is this if i
have multiple catergories?
Is it possible to just have " 'latest': LatestEntries,", i tried that
but i got:

feed() takes at least 2 non-keyword arguments (1 given)

I don't really feel i need a feed for individual catergories although
i could do that way

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



Re: Date-based generic view not working

2009-08-07 Thread Thomas Jaggi

Well, after setting 'allow_future' to true everything works fine.
Since the entries were created today I don't really get this. I'm
using the 'pub_date' as 'date_field' and it's definitely NOT in the
future...
--~--~-~--~~~---~--~~
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 deploy Django on the web server?

2009-08-07 Thread Dan Harris

I just wanted to give a shout out as well to webfaction. I used to use
my own virtual private server for hosting django stuff, but to cut
costs i switched to a webfaction account and it is pretty fantastic.
Super easy to set up, if you decide to go that way just drop me and
email and i'd be happy to help you get set up and running.

Cheers,

Dan

On Aug 7, 3:34 pm, lzantal  wrote:
> On Aug 7, 12:06 pm, justin jools  wrote:> This 
> has been driving me nuts for a month.
>
> > I wanted to use a free web server to do development testing and have
> > found : 000webhost.com and heliohost.com which apparently support
> > Python, but what about Django? Do I install that myself?
>
> > I have read the django book on deployment chapter but find it doesnt
> > tell me what I want.
>
> > Could someone please just tell me simply how I can get my scripts
> > running on the webserver.
>
> Tryhttp://webfaction.com.
> They have super easy install for django through their control panel
>
> hope that helps
>
> lzantalhttp://twitter.com/lzantal
>
>
>
> > justinjo...@googlemail.com
--~--~-~--~~~---~--~~
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: default blank choice on form.Form select widget

2009-08-07 Thread jheasly

Paulo -

Just to follow-up, I tried the patch (4092_9912_nullselect.diff), but
it being about 1500 checkins out of date, it only half worked.

In my forms.py, I ended up overriding the USStateSelect with a hack:

class HackedUSStateSelect(Select):
def __init__(self, attrs=None):
from django.contrib.localflavor.us.us_states import
STATE_CHOICES
STATE_CHOICES = (('',u'-'),) + STATE_CHOICES
super(HackedUSStateSelect, self).__init__(attrs,
choices=STATE_CHOICES)

Unless someone has a better suggestion, I think I'll live with it and
try to help with getting ticket 4092 into trunk ...

- John

On Aug 5, 1:49 pm, Paulo Almeida  wrote:
> Did you see this ticket?
>
> http://code.djangoproject.com/ticket/4092
>
> Maybe you can use the patch code to customize your field.
>
> - Paulo
>
> On Wed, Aug 5, 2009 at 8:01 PM, JHeasly  wrote:
>
> > The doc page "Creating forms from models"
> > (http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#topics-
> > forms-modelforms
> > )
> > describes how
> > "If the model field has choices set ... [snip] ... The choices will
> > normally include the blank choice which is selected by default. ... "
>
> > I have a form that's not associated with a database model (i.e.,
> > form.Form) and I'm using the USStateSelect widget, but the blank
> > choice isn't included in the STATE_CHOICE list. When the form loads,
> > what I get is "Alabama" selected by default. I'd like to get the
> > forms.ModelForm-style blank choice default selection behavior.
>
> > I'm guessing some sort of super() def __init__ trickery is called for
> > but am stumped so far ...
>
> > Thanks,
> > John
>
>
--~--~-~--~~~---~--~~
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 deploy Django on the web server?

2009-08-07 Thread lzantal



On Aug 7, 12:06 pm, justin jools  wrote:
> This has been driving me nuts for a month.
>
> I wanted to use a free web server to do development testing and have
> found : 000webhost.com and heliohost.com which apparently support
> Python, but what about Django? Do I install that myself?
>
> I have read the django book on deployment chapter but find it doesnt
> tell me what I want.
>
> Could someone please just tell me simply how I can get my scripts
> running on the webserver.
>
Try http://webfaction.com .
They have super easy install for django through their control panel

hope that helps

lzantal
http://twitter.com/lzantal

> justinjo...@googlemail.com
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Proxy model only shows for superuser

2009-08-07 Thread lzantal

Hi,

I have a Client model and I created a BrokerClient model as a proxy of
client
class Client(models.Model):
...

class BrokerClient(Client):
class Meta:
proxy = True

Now in admin the BrokerClient only shows up if I am a superuser.
I even gice all the available User permissions to a user but not make
it to superuser
and BrokerClient did not show up in admin. But as soon as I make this
new user with all the permissions a super user it shows up.
Very strange.

Thank you for all the help

lzantal
http://twitter.com/lzantal
--~--~-~--~~~---~--~~
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: checking/using model data in form save

2009-08-07 Thread zayatzz

Ok it seems i either asked the wrong question or did not explain well
enough.

My view has such line:
pform = ProfileForm(instance=profile)

it creates the form instance and i thought that it also loads data
from database and sends it to form, so i can use this in form save
method. I do not know if i understand this right or wrong. Perhaps it
just does not work for ImageField, because if i do
path = self.instance.img.name
os.remove(path)

in form save method i get following error:
OSError at /profile/edit/

(2, 'No such file or directory')

Request Method: POST
Request URL:http://127.0.0.1/profile/edit/
Exception Type: OSError
Exception Value:

(2, 'No such file or directory')
Exception Location: /home/projects/tst/profile/forms.py in save,
line 24
--
bit more down on the samge page i can see that path is empty.

So what to do, if i wish to read old files name from databse and
delete it in the forms save method?

Do i need to pass the file name to form in a view too?

In addition to that problem. What do i need to do if i want that
ImageField has another link for removing existing image right next to
browse button in a view. What do i need to write for that?

Alan.

On Aug 7, 9:04 am, zayatzz  wrote:
> Thank you!
>
> Alan.
>
> On Aug 6, 10:51 pm, Daniel Roseman  wrote:
>
> > On Aug 6, 8:36 pm, zayatzz  wrote:
>
> > > Hello
>
> > > I am not entirely sure if i am asking the right question, but here is
> > > what am trying to do.
>
> > > I am saving user mugshot with form and it works just fine. I rename
> > > the uploaded file to mugshot.[insert imagefile extension here], but i
> > > want to do more in form save method than just that.
>
> > > 1) i want to check if the model, whos form im saving already has
> > > imagefile saved. I have this in view:
> > > pform = ProfileForm(instance=profile)
>
> > > but this in form save:
> > >                         os.remove(settings.MEDIA_ROOT+self.instance.img)
>
> > > returns me ImageFieldFile not the data that is saved in it... and i
> > > get typeerror:
> > > TypeError at /profile/edit/
>
> > > cannot concatenate 'str' and 'ImageFieldFile' objects
>
> > > 2) if it exists, then remove it - can do it os.remove(), but the
> > > problem is similar to last point - i need to know the name of existing
> > > file, that is saved in model data
> > > 3) if the file has been removed or did not exist in the first place
> > > then i want to save different sizes of the file - thumbnail, bigger
> > > pic and so on. i do not need the examples for that.
>
> > > Alan
>
> > self.instance.img.name will give you the relative path from
> > MEDIA_ROOT. 
> > See:http://docs.djangoproject.com/en/dev/ref/files/file/#django.core.file...
> > --
> > DR.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



how to deploy Django on the web server?

2009-08-07 Thread justin jools

This has been driving me nuts for a month.

I wanted to use a free web server to do development testing and have
found : 000webhost.com and heliohost.com which apparently support
Python, but what about Django? Do I install that myself?

I have read the django book on deployment chapter but find it doesnt
tell me what I want.

Could someone please just tell me simply how I can get my scripts
running on the webserver.

justinjo...@googlemail.com

--~--~-~--~~~---~--~~
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: Need help with a modelChoiceField

2009-08-07 Thread Bobby Roberts

> label_from_instance was added after that version. For now the only
> thing you can do is to define __unicode__ on the Upload model, and
> that will provide the value that is displayed.
> --
> DR.

worked like a charm Daniel... thanks again!
--~--~-~--~~~---~--~~
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: Need help with a modelChoiceField

2009-08-07 Thread Karen Tracey
On Fri, Aug 7, 2009 at 2:57 PM, Daniel Roseman wrote:

>
> On Aug 7, 7:33 pm, Bobby Roberts  wrote:
> > hi.  does anyone have any ideas why this is not working... we are
> > using django 0.96 on this particular server.
>
> label_from_instance was added after that version. For now the only
> thing you can do is to define __unicode__ on the Upload model, and
> that will provide the value that is displayed.
>

No __unicode__ in 0.96.  Probably __str__.

Karen

--~--~-~--~~~---~--~~
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: Need help with a modelChoiceField

2009-08-07 Thread Daniel Roseman

On Aug 7, 7:33 pm, Bobby Roberts  wrote:
> hi.  does anyone have any ideas why this is not working... we are
> using django 0.96 on this particular server.

label_from_instance was added after that version. For now the only
thing you can do is to define __unicode__ on the Upload model, and
that will provide the value that is displayed.
--
DR.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Bug with model get_*_display() methods?

2009-08-07 Thread Margie

I see inconsistencies in how get_*_display() works based on whether
the object is a recently saved object.  Probably an example describes
this best:

My model contains this:

class Task(models.Model):

STATUS_CHOICES = (
(OPEN_STATUS, 'Open'),
(CLOSED_STATUS, 'Closed'),
(STALLED_STATUS, 'Stalled'),)

status = models.IntegerField(choices=STATUS_CHOICES, blank=True,
null=True)


If I get a Task object from the database (via a .get() or .filter()),
then my status field contains an integer and I can call
the .get_status_display() method, ie:

(Pdb) type(t)

(Pdb) t.status
3
(Pdb) t.get_status_display()
u'Stalled'


However, if I have recently saved a modelForm associated with my Task
model and now have a handle to the object that that save() returned,
the status is in unicode, and get_status_display() doesn't return a
useful string:

(Pdb) type(self)

(Pdb) self.status
u'3'
(Pdb) self.get_status_display()
u'3'

Is this expected behavior?

Margie


--~--~-~--~~~---~--~~
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: Need help with a modelChoiceField

2009-08-07 Thread Bobby Roberts

hi.  does anyone have any ideas why this is not working... we are
using django 0.96 on this particular server.
--~--~-~--~~~---~--~~
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: Application decoupling - project architecture question

2009-08-07 Thread Andrin Riiet

Thanks for your replies,

I read the book and indeed I found what I needed.

For anyone who happens to read this and is wondering the same thing,
here's how it goes:

You extend the base form class (eg editProfileForm), add the avatar
field to it and you use the new form class by passing it as parameter
to the view function that displays it ( the view functions should be
designed to accept such parameters). You pass the correct values for
the parameters in the urlconf.
And you can decouple the form handling code by putting it all in the
form.save() method (as opposed to the view function) - that way when
you extend the base form you can extend the form handling code as
well.

Thanks everyone,

Andrin

On Aug 7, 5:08 pm, grElement  wrote:
> There is a good tutorial on this in Practical Django Projects
>
> http://www.amazon.com/Practical-Django-Projects-Pratical/dp/1590599969
>
> It goes a bit more into theory that I found helpful.
>
> On Aug 6, 8:07 am, Andrin Riiet  wrote:
>
> > Hi, I'd like to shed some light on the "the right way" to make
> > applications in django by an example and a few questions.
>
> > Let's say that I have a 'users' application (acting as "user profiles"
> > on the built-in user authentication system) and I want to add an
> > avatar image feature to it.
> > I'd like to have the avatars in a separate application in case my next
> > project doesn't require them (this is the right way to do things i
> > guess?)
>
> > Now I want to have the user to be able to upload an avatar image in
> > the "edit profile" form. The default edit-profile form is defined in
> > my 'users' application of course. I'd like to "add" the avatar feature
> > (form field) to it somehow. - This is part 1 of the problem
>
> > The 2nd part is in the form handling: the request object is going to
> > contain form field values from 2 different applications, none of which
> > should be responsible for processing the other's forms.
>
> > Obviously the 'avatars' application is dependent on the 'users'
> > application but the 'users' application should be oblivious of the
> > avatars...
>
> > How would I go about doing that?
>
> > Andrin
--~--~-~--~~~---~--~~
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 get this URI

2009-08-07 Thread David

I never know why I missed that part when I read it before.

Anyway, thanks DR for your clue.



On Aug 7, 10:23 am, Daniel Roseman  wrote:
> On Aug 7, 6:16 pm, David  wrote:
>
>
>
>
>
> > Hello,
>
> > My project is Web-based and I work in Django environment on Linux. Let
> > me give a Scenario first.
>
> > A user whose username is "peter" logins into "www.myfoo.com" online.
> > After his username/password get authenticated, he arrives this webpage
> > "www.myfoo.com/user_login".   On this page it looks like this.
>
> > Welcome Peter
> > (1.) Go to my profile
> > (2.) Check my total credit points
> > (3.) 
>
> > (1.), (2.), (3), etc, are all links. If peter clicks one of them, then
> > he will be redirected to a new webpage. For example, if he clicks
> > (1.), then he will be transferred to webpage "www.myfoo.com/peter/
> > profile/".  For this webpage there is a def (or module) "user_profile
> > (request)" in View. This module needs to get this URI (or at least "/
> > peter/profile/) and parse it so that peter's profile can be retrieved
> > from a database.
>
> > Now my question is: how can the module "user_profile(request)" get
> > "peter"? Or, how can the module get the URI?
>
> > os.environ[...] does not work here as this is not cgi. request.user is
> > not good either as it gives in-exact result.
>
> > Any ideas and suggestions?
>
> > Thanks so much.
>
> Surely the username is just the parameter to the user_profile
> function? Getting parameters from URLs is absolutely basic Django
> stuff, covered in the tutorial. I'd recommend reading that then
> posting here if you have any more questions.
> --
> DR.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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: upgraded to python2.5, but error-reports/traceback still references python2.3?

2009-08-07 Thread Daniel Roseman

On Aug 7, 5:45 pm, Cody Django  wrote:
> This is weird: I used to use python2.3 on the mediatemple server, but
> recently upgraded to python2.5.  I've also installed mysqldb, pil, ect
> under python2.5.  I've updated my pythonpath so the python2.5 route is
> being used.  Everything works just fine, but I've noticed in the
> traceback that python2.3 is still being referenced.
>
> For example:
>
>  File "/usr/lib/python2.3/site-packages/django/core/handlers/base.py",
> line 92, in get_response
>    response = callback(request, *callback_args, **callback_kwargs)
>
> Could there still be a cache that is holding the old paths?  How can I
> completely rid django of python2.3?
>
> Thanks.
>
> Cody
>
> ps.  I never told modpython to use python2.5, but apparently python
> itself updates which version of python to use when you install a new
> version.  So I hear.

No, this isn't true. mod_python is compiled with a specific version of
Python, and will only use that version. So you'd need a new version of
mod_python for version 2.5.
--
DR.
--~--~-~--~~~---~--~~
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: Recursive request and page layout

2009-08-07 Thread Daniel Roseman

On Aug 7, 5:24 pm, SardarNL  wrote:
> Hi Folks
>
> Here is the problem, we have some pages that don't contain any
> content, but rather layout the blocks which are served by other views.
> Extending the template and overriding some blocks is not a solution,
> because there are many unrelated blocks, that can not be rendered by a
> single view.
>
> Naturally I would expect some {% dispatch "/some/path/here" %} tag,
> such that when template is being processed, the tag will issue
> recursive request and will be replaced by obtained content. The tag
> should be able to replace the base template of called view, so the
> header/footer and other markup will not be rendered if view is called
> as a block.
>
> Unfortunately there is no such tag. So my question is: how to give the
> control to independent blocks. The idea is:
>
>   - current request is being processed by some view, which knows how
> to fetch only its own content
>   - the designer may want to add other content/block, totally
> unrelated to current request, for example a poll/banner/menu etc.
>   - the block needs to be served by some view because there database
> fetch is needed along other processing. So simple include of a
> template is not a solution. Fetching all the content within the top-
> most view isn't a solution because the block can be used on many
> places.
>
> That is the reason why this should be implemented as recursive call,
> such that the block-view will not even know it is being called as a
> block and will simply render the content. Of course in real situation
> the view still needs to know it is being called as a block, such that
> more simplistic templates may be used.
>
> Please explain what is the django way and how would you solve this,
> maybe I'm digging in totally wrong direction.

Including blocks on a page is what custom template tags are for. See
here:
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/
particularly the section on 'inclusion tags'.

That's not exactly what you asked for in terms of recursive views, but
is probably better as it has less overhead - calling a view
recursively would involve instantiating an HttpResponse object each
time, then extracting the content and throwing the object away.
--
DR.

--~--~-~--~~~---~--~~
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: Threaded comments on django 1.1

2009-08-07 Thread Dan Harris

Have you checked out:

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

I think it is still being updated for 1.1, but it should still work
with 1.1. I haven't used it, just know of it's existence.

Cheers,

Dan

On Aug 7, 11:44 am, Alessandro Ronchi 
wrote:
> I must add threaded comments to my django 1.1 app.
> Is there anything already done I can use?
>
> Any advise?
>
> --
> Alessandro Ronchi
>
> SOASI
> Sviluppo Software e Sistemi Open Sourcehttp://www.soasi.com
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Custom manager and delete()

2009-08-07 Thread michael

Hi,

[Sorry, if this has been asked before]
I defined a model using a custom manager. However, this custom manager
is not used when I call "delete()" method on an instance object. The
reason
I use a custom manager is because the model represents objects in
another
legacy database (different from the normal database used by django).
So
I'm basically trying to emulate multi-db support.

Obviously, as delete() uses the default manager, it fails as the
corresponding
table is not in that database.

Is there a workaround for this, or do I have to overload delete() in
my model
and use raw SQL?

Thanks,
Michael.

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



2nd call, PostgreSQl Conference

2009-08-07 Thread Joshua D. Drake

Hey folks,

Let's get some Django + PostgreSQL love going on. This is the second
call for talks: http://www.postgresqlconference.org/

Joshua D. Drake
-- 
PostgreSQL - XMPP: jdr...@jabber.postgresql.org
   Consulting, Development, Support, Training
   503-667-4564 - http://www.commandprompt.com/
   The PostgreSQL Company, serving since 1997


--~--~-~--~~~---~--~~
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 should I organize my news site's backend - needing some feedback

2009-08-07 Thread chyea

The scale of this project isn't very large. It's a few models,
ideally. I'd just like my project to be as flexible, and scalable as
possible. I haven't done any use case scenarios, really. None of that
is really important to me right now. I just want to conceptualize how
a site like this would operate in the most scalable way.

I'd like to avoid using Wordpress. I was originally using TinyMCE,
which allowed me to embed images and video, but these images weren't
really 'tagged' to the article. There was no easy way to reuse these
images since they were just imbedded in the article. What if I wanted
to create some kind of resized, smaller icon of the first picture
related to the article? Situations like that are why a tagging system
would be nice, and is what I'm looking for.

On Aug 7, 7:45 am, zayatzz  wrote:
> Im not a very good django programmer (actually im just a beginner),
> but all this text makes me ask if you have done all the ground work
> before starting with a project of this scale? I mean, have you
> throught through user cases, drawn bunch of flow charts and
> wireframes, figured out and mapped database connections and so on.
>
> All that aside, if i understood you correctly, then system like you
> just described already works with CMS's like wordpress or edicy. I
> suggest you check out how either of them work. In any case, as i said,
> im not very good django programmer, but im quite good project manager
> and as far as i see, you do not need generic relations between
> different media and your content objects.
>
> I think you could do this with templatetags for example. Modify your
> wysiwyg editor interface, so that when you press button "insert
> media", it opens modal window where you can select the media object,
> that you want to insert. When object has been chosen, you insert
> either the HTML code or templatetag of the media object into your
> article. Save the article and the content will be loaded along with
> the inserted media on the public page.
>
> Quite easy in theory anyway :)
>
> Alan
>
> On Aug 7, 9:51 am, chyea  wrote:
>
>
>
> > Hi all,
>
> > I recently sent an email to another Django coder asking for some
> > possible feedback on my situation. I'll simply restate the email here,
> > because I figured why not ask a bunch of other Django coders, too!
> > Here it goes...
>
> > Hi,
>
> > I'm trying to design a django-based gaming news site, and have been
> > just confusing myself. I think I'm over-complicating it by trying to
> > make it highly dynamic/scalable. Perhaps I can just run my design
> > ideas by you and see if you have any feedback for me.
>
> > Conceptually, it's very simple. I want the site to revolve around
> > various types of articles - news, interviews, reviews. My thoughts
> > were that all of these articles are essentially, at the core, the same
> > set of data - a title, slug and the article text (simplified example).
> > So, with this in mind I created an abstract base class called Article,
> > with those essential elements. Then, I just created classes for News,
> > Interview and Review, that subclass the abstract Article base class.
> > So, now I've got the core article model classes for my site.
>
> > I'm starting to confuse myself, though, when trying to figure out what
> > to do with all the media involved with the site.
>
> > How I have it invisioned is a highly dynamic and scalable setup that
> > allows me to tag any number of pictures, videos, or any other model
> > really, to any type of Article object. This would result in media
> > objects that aren't exactly coupled to any specific Article, and can
> > therefor be tagged to any of them, none of them, all of them, etc.
>
> > With this in mind, I thought it'd make sense to create another
> > abstract base class for all types of media. Somehow, this abstract
> > base class for media objects would contain the proper code that'd
> > allow any classes that subclass it to be tagged to any other model.
>
> > The reason I'm thinking of it like this is because imagine a page on
> > my site for a News article object. Lets say this News article is about
> > how a game developer company is down in profits this year because they
> > haven't released a game they announced, yet. This News article would
> > have several things related, or 'tagged' to it - a Developer, a Game,
> > perhaps some Pictures, maybe a Movie. I'd have existing models for
> > Developer, Game, Picture and Movie (ideally). While creating this News
> > article, I'd have the ability to just select these related items in
> > the admin page. All of this related data would be available to the
> > News article object when you query for it, and then all passed to the
> > template where I can sort it out there.
>
> > What I've described above sounds like it'd be a very dynamic setup
> > that'd allow me to basically create some pretty interesting Articles
> > and tag them with relevant data. This 

Re: How to get this URI

2009-08-07 Thread Daniel Roseman

On Aug 7, 6:16 pm, David  wrote:
> Hello,
>
> My project is Web-based and I work in Django environment on Linux. Let
> me give a Scenario first.
>
> A user whose username is "peter" logins into "www.myfoo.com" online.
> After his username/password get authenticated, he arrives this webpage
> "www.myfoo.com/user_login".   On this page it looks like this.
>
> Welcome Peter
> (1.) Go to my profile
> (2.) Check my total credit points
> (3.) 
>
> (1.), (2.), (3), etc, are all links. If peter clicks one of them, then
> he will be redirected to a new webpage. For example, if he clicks
> (1.), then he will be transferred to webpage "www.myfoo.com/peter/
> profile/".  For this webpage there is a def (or module) "user_profile
> (request)" in View. This module needs to get this URI (or at least "/
> peter/profile/) and parse it so that peter's profile can be retrieved
> from a database.
>
> Now my question is: how can the module "user_profile(request)" get
> "peter"? Or, how can the module get the URI?
>
> os.environ[...] does not work here as this is not cgi. request.user is
> not good either as it gives in-exact result.
>
> Any ideas and suggestions?
>
> Thanks so much.

Surely the username is just the parameter to the user_profile
function? Getting parameters from URLs is absolutely basic Django
stuff, covered in the tutorial. I'd recommend reading that then
posting here if you have any more questions.
--
DR.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



How to get this URI

2009-08-07 Thread David

Hello,

My project is Web-based and I work in Django environment on Linux. Let
me give a Scenario first.

A user whose username is "peter" logins into "www.myfoo.com" online.
After his username/password get authenticated, he arrives this webpage
"www.myfoo.com/user_login".   On this page it looks like this.

Welcome Peter
(1.) Go to my profile
(2.) Check my total credit points
(3.) 

(1.), (2.), (3), etc, are all links. If peter clicks one of them, then
he will be redirected to a new webpage. For example, if he clicks
(1.), then he will be transferred to webpage "www.myfoo.com/peter/
profile/".  For this webpage there is a def (or module) "user_profile
(request)" in View. This module needs to get this URI (or at least "/
peter/profile/) and parse it so that peter's profile can be retrieved
from a database.

Now my question is: how can the module "user_profile(request)" get
"peter"? Or, how can the module get the URI?

os.environ[...] does not work here as this is not cgi. request.user is
not good either as it gives in-exact result.

Any ideas and suggestions?

Thanks so much.

--~--~-~--~~~---~--~~
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 define new permission

2009-08-07 Thread phan sarak
Ban co the lam dieu do mot cach de dang .Django  da co phan Admin de ban
quan li dieu do.
   theo cau hoi cua ban.la ban da dung admin cua django.ban chi can vao phan
quan li user roi ban tao theo user .va danh phan permission cho tung user ma
ban vua tao.
chuc ban thanh cong.

On Fri, Aug 7, 2009 at 3:15 PM, Toan Vu  wrote:

>
> Dear all,
>
> I've created a new application which used the default admin site of
> Django framework. I have a model which have these line of code:
> Class Meta:
> permissions = (('permission_name':'Readable human name'),)
>
> This line of code created a new permission in
> 'auth_user_user_permissions' table and I can set this new permission
> to a specified user. The problem is after I only set this permission
> to the user and I logged in by this username and the admin's home page
> shown 'You don't have permission to edit anything.'. When I set a add,
> change,. permission to this model and then It shown the app list.
>
> Could you mind show me how to add new permission like the defaul
> permission of the admin site like add, delete, change ?
>
> Cheers.
>
> >
>

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



upgraded to python2.5, but error-reports/traceback still references python2.3?

2009-08-07 Thread Cody Django

This is weird: I used to use python2.3 on the mediatemple server, but
recently upgraded to python2.5.  I've also installed mysqldb, pil, ect
under python2.5.  I've updated my pythonpath so the python2.5 route is
being used.  Everything works just fine, but I've noticed in the
traceback that python2.3 is still being referenced.

For example:

 File "/usr/lib/python2.3/site-packages/django/core/handlers/base.py",
line 92, in get_response
   response = callback(request, *callback_args, **callback_kwargs)

Could there still be a cache that is holding the old paths?  How can I
completely rid django of python2.3?

Thanks.

Cody


ps.  I never told modpython to use python2.5, but apparently python
itself updates which version of python to use when you install a new
version.  So I hear.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Recursive request and page layout

2009-08-07 Thread SardarNL

Hi Folks

Here is the problem, we have some pages that don't contain any
content, but rather layout the blocks which are served by other views.
Extending the template and overriding some blocks is not a solution,
because there are many unrelated blocks, that can not be rendered by a
single view.

Naturally I would expect some {% dispatch "/some/path/here" %} tag,
such that when template is being processed, the tag will issue
recursive request and will be replaced by obtained content. The tag
should be able to replace the base template of called view, so the
header/footer and other markup will not be rendered if view is called
as a block.

Unfortunately there is no such tag. So my question is: how to give the
control to independent blocks. The idea is:

  - current request is being processed by some view, which knows how
to fetch only its own content
  - the designer may want to add other content/block, totally
unrelated to current request, for example a poll/banner/menu etc.
  - the block needs to be served by some view because there database
fetch is needed along other processing. So simple include of a
template is not a solution. Fetching all the content within the top-
most view isn't a solution because the block can be used on many
places.

That is the reason why this should be implemented as recursive call,
such that the block-view will not even know it is being called as a
block and will simply render the content. Of course in real situation
the view still needs to know it is being called as a block, such that
more simplistic templates may be used.

Please explain what is the django way and how would you solve this,
maybe I'm digging in totally wrong direction.

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



Threaded comments on django 1.1

2009-08-07 Thread Alessandro Ronchi
I must add threaded comments to my django 1.1 app.
Is there anything already done I can use?

Any advise?

-- 
Alessandro Ronchi

SOASI
Sviluppo Software e Sistemi Open Source
http://www.soasi.com

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



Date-based generic view not working

2009-08-07 Thread Thomas Jaggi

I'm having some problems with a date-based view (using Django 1.1):


Not working (no entries shown):

info_dict = {
'queryset': Entry.objects.all(),
'date_field': 'pub_date',
}
urlpatterns = patterns('django.views.generic.date_based',
(r'^$','archive_index', dict(info_dict, template_name='xy.html')),
)

{% for object in latest %}
{% endfor %}


Working:

info_dict = {
'queryset': Entry.objects.all(),
}
urlpatterns = patterns('',
(r'^$','django.views.generic.list_detail.object_list', dict
(info_dict, template_name='xy.html')),
)

{% for object in object_list %}
{% endfor %}



Is there an obvious solution to this?

I'm sorry if there is too few information. Since I'm new to Django I
probably don't know what basic information is needed to solve anything
like this.

Thanks,
Thomas

--~--~-~--~~~---~--~~
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 documentation site is SLOW

2009-08-07 Thread Karen Tracey
On Fri, Aug 7, 2009 at 10:06 AM, Jo  wrote:

>
> Ok, after a bit of tinkering I think I might have found the culprit.
>
> Seems fine in Opera, and much better in Firefox when I disable Adblock
> Plus (the only add-on I've got installed!)
>
> Still a little sluggish in Firefox, but they are big pages on quite an
> old machine. Goes from unusable to almost normal with ABP disabled.
>

Glad you've found something that makes it better, but it still sounds odd to
me.  I use Firefox 3.5.2 + AdBlock Plus 1.1 on my Ubuntu machine (P4 with
just 1G) and don't notice any particular sluggishness with the Django site.
Firefox does seem to go out to lunch periodically and become unresponsive
for stretches of time, but from some research I'm pretty sure that's due to
updating live bookmarks, and it's much improved in 3.5 compared to 3.0
(though I wouldn't call it fixed).

Karen

--~--~-~--~~~---~--~~
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 should I organize my news site's backend - needing some feedback

2009-08-07 Thread Noah

You are on the right track investigating the ContentType app.

-n

On Aug 6, 11:51 pm, chyea  wrote:
> Hi all,
>
> I recently sent an email to another Django coder asking for some
> possible feedback on my situation. I'll simply restate the email here,
> because I figured why not ask a bunch of other Django coders, too!
> Here it goes...
>
> Hi,
>
> I'm trying to design a django-based gaming news site, and have been
> just confusing myself. I think I'm over-complicating it by trying to
> make it highly dynamic/scalable. Perhaps I can just run my design
> ideas by you and see if you have any feedback for me.
>
> Conceptually, it's very simple. I want the site to revolve around
> various types of articles - news, interviews, reviews. My thoughts
> were that all of these articles are essentially, at the core, the same
> set of data - a title, slug and the article text (simplified example).
> So, with this in mind I created an abstract base class called Article,
> with those essential elements. Then, I just created classes for News,
> Interview and Review, that subclass the abstract Article base class.
> So, now I've got the core article model classes for my site.
>
> I'm starting to confuse myself, though, when trying to figure out what
> to do with all the media involved with the site.
>
> How I have it invisioned is a highly dynamic and scalable setup that
> allows me to tag any number of pictures, videos, or any other model
> really, to any type of Article object. This would result in media
> objects that aren't exactly coupled to any specific Article, and can
> therefor be tagged to any of them, none of them, all of them, etc.
>
> With this in mind, I thought it'd make sense to create another
> abstract base class for all types of media. Somehow, this abstract
> base class for media objects would contain the proper code that'd
> allow any classes that subclass it to be tagged to any other model.
>
> The reason I'm thinking of it like this is because imagine a page on
> my site for a News article object. Lets say this News article is about
> how a game developer company is down in profits this year because they
> haven't released a game they announced, yet. This News article would
> have several things related, or 'tagged' to it - a Developer, a Game,
> perhaps some Pictures, maybe a Movie. I'd have existing models for
> Developer, Game, Picture and Movie (ideally). While creating this News
> article, I'd have the ability to just select these related items in
> the admin page. All of this related data would be available to the
> News article object when you query for it, and then all passed to the
> template where I can sort it out there.
>
> What I've described above sounds like it'd be a very dynamic setup
> that'd allow me to basically create some pretty interesting Articles
> and tag them with relevant data. This beats just using TinyMCE and
> using the formatting it creates to link to YouTube videos, and images
> in my article, on a per-article basis. Does it sounds like I've
> thought this to death, or is what I'm describing possible at all?
>
> All day today I messed around with generic relationships and
> ContentType. I tried creating an abstract base classes with generic
> relations to other abstract base classes: Article <-> Media
>
> In the end I'm just high confused and wondering if I'm completely
> complicating this. I know this was long and if you read it this far
> then I greatly appreciate it. I'm looking forward to any insight, or
> advice/feedback you may have!
>
> Thank you,
> Ryan C

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



Need help with a modelChoiceField

2009-08-07 Thread Bobby Roberts

ok here's my form:

class ParseFileChoiceField (forms.ModelChoiceField):
def label_from_instance (self,obj):
return obj.ProcessFile

class FrmParser (forms.Form):
parsefile = ParseFileChoiceField(queryset=Upload.objects.filter
(numrecs__exact=0),empty_label='Choose',required=True,widget=forms.Select
())


The result is this:


  Choose
  Upload object


I need the visible text to be the ProcessFile value rather than Upload
Object


any ideas?
--~--~-~--~~~---~--~~
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: Admin, two links to different views ?

2009-08-07 Thread Karen Tracey
On Fri, Aug 7, 2009 at 8:26 AM, Asinox  wrote:

>
> No body? :(
>

Just a tip -- posts like this, which essentially translate to "!!ANSWER
ME NOW!!", sent just six hours after the original question, are going to
make some people less inclined to try to help you.  If you are in that much
of a hurry you might want to try on IRC.

Karen

--~--~-~--~~~---~--~~
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: Application decoupling - project architecture question

2009-08-07 Thread grElement

There is a good tutorial on this in Practical Django Projects

http://www.amazon.com/Practical-Django-Projects-Pratical/dp/1590599969

It goes a bit more into theory that I found helpful.





On Aug 6, 8:07 am, Andrin Riiet  wrote:
> Hi, I'd like to shed some light on the "the right way" to make
> applications in django by an example and a few questions.
>
> Let's say that I have a 'users' application (acting as "user profiles"
> on the built-in user authentication system) and I want to add an
> avatar image feature to it.
> I'd like to have the avatars in a separate application in case my next
> project doesn't require them (this is the right way to do things i
> guess?)
>
> Now I want to have the user to be able to upload an avatar image in
> the "edit profile" form. The default edit-profile form is defined in
> my 'users' application of course. I'd like to "add" the avatar feature
> (form field) to it somehow. - This is part 1 of the problem
>
> The 2nd part is in the form handling: the request object is going to
> contain form field values from 2 different applications, none of which
> should be responsible for processing the other's forms.
>
> Obviously the 'avatars' application is dependent on the 'users'
> application but the 'users' application should be oblivious of the
> avatars...
>
> How would I go about doing that?
>
> Andrin
--~--~-~--~~~---~--~~
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: Admin, two links to different views ?

2009-08-07 Thread Daniel Roseman

On Aug 7, 2:46 pm, Karen Tracey  wrote:
> On Fri, Aug 7, 2009 at 8:26 AM, Asinox  wrote:
>
> > No body? :(
>
> Just a tip -- posts like this, which essentially translate to "!!ANSWER
> ME NOW!!", sent just six hours after the original question, are going to
> make some people less inclined to try to help you.  If you are in that much
> of a hurry you might want to try on IRC.
>
> Karen

Or look at the answers you've received to the exact same question you
posted on StackOverflow.
--
DR.
--~--~-~--~~~---~--~~
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 documentation site is SLOW

2009-08-07 Thread Jo

Ok, after a bit of tinkering I think I might have found the culprit.

Seems fine in Opera, and much better in Firefox when I disable Adblock
Plus (the only add-on I've got installed!)

Still a little sluggish in Firefox, but they are big pages on quite an
old machine. Goes from unusable to almost normal with ABP disabled.
--~--~-~--~~~---~--~~
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: generic views - please bring me to the point

2009-08-07 Thread aschmid

i got it!! the app was not in the pythonpath... :)

On Aug 7, 3:00 pm, andreas schmid  wrote:
> hi all,
>
> im really going crazy now i cant figure out where the code is wrong...
> i have a really simple model:
>
> from django.db import models
> import datetime
>
>     class Post(models.Model):
>         title = models.CharField(max_length=250)
>         excerpt = models.TextField(blank=True)
>         body = models.TextField()
>         pub_date = models.DateTimeField(default=datetime.datetime.now)
>         slug = models.SlugField(unique_for_date='pub_date')
>
>         class Meta:
>           verbose_name_plural = "Posts"
>           ordering = ['-pub_date']
>
>         def __unicode__(self):
>           return self.title
>
>         def get_absolute_url(self):
>           return ('wynton_post_detail', (), {  'year':
>     self.pub_date.strftime("%Y"),
>                                                   'month':
>     self.pub_date.strftime("%b").lower(),
>                                                   'day':
>     self.pub_date.strftime("%d"),
>                                                   'slug': self.slug })
>         get_absolute_url = models.permalink(get_absolute_url)
>
> my urls file:
>
>     from django.conf.urls.defaults import *
>     from wynton.models import Post
>
>     post_info_dict = {
>             'queryset': Post.objects.all(),
>             'date_field': 'pub_date',
>             }
>
>     urlpatterns = patterns('django.views.generic.date_based',
>
>              (r'archive/^$', 'archive_index', post_info_dict,
>     'wynton_post_archive_index'),
>     ...
>     )
>
> my post_archive.html
>
>         {% for object in latest %}
>           {{ object.title }}
>         {% endfor %}
>
> but nothing is showing up in the page but the template is loaded
> correctly...
> please help me before i crash my head to the wall! ;)
>
> thx
--~--~-~--~~~---~--~~
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: user.objects.create is not checking for duplicate emails

2009-08-07 Thread Mirat Bayrak
no i am talking about User model in django!

--~--~-~--~~~---~--~~
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: user.objects.create is not checking for duplicate emails

2009-08-07 Thread zayatzz

If this is modelform, then it should automatically give you the error
you want.

If it is not modelform, then you can create the error message you want
yourself in your custom validation.

Alan.

On Aug 7, 4:33 pm, Mirat Bayrak  wrote:
> hmm you mean to use it on form? nice ill try it :)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



generic views - please bring me to the point

2009-08-07 Thread andreas schmid

hi all,

im really going crazy now i cant figure out where the code is wrong...
i have a really simple model:

from django.db import models
import datetime

class Post(models.Model):
title = models.CharField(max_length=250)
excerpt = models.TextField(blank=True)
body = models.TextField()
pub_date = models.DateTimeField(default=datetime.datetime.now)
slug = models.SlugField(unique_for_date='pub_date')
   
class Meta:
  verbose_name_plural = "Posts"
  ordering = ['-pub_date']
  
def __unicode__(self):
  return self.title
 
def get_absolute_url(self):
  return ('wynton_post_detail', (), {  'year':
self.pub_date.strftime("%Y"),
  'month':
self.pub_date.strftime("%b").lower(),
  'day':
self.pub_date.strftime("%d"),
  'slug': self.slug })
get_absolute_url = models.permalink(get_absolute_url)

my urls file:

from django.conf.urls.defaults import *
from wynton.models import Post
   
post_info_dict = {
'queryset': Post.objects.all(),
'date_field': 'pub_date',
}

urlpatterns = patterns('django.views.generic.date_based',
   
 (r'archive/^$', 'archive_index', post_info_dict,
'wynton_post_archive_index'),
...
)

my post_archive.html

{% for object in latest %}
  {{ object.title }}
{% endfor %}

but nothing is showing up in the page but the template is loaded
correctly...
please help me before i crash my head to the wall! ;)


thx

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



Custom set_password_form in password_reset_confirm

2009-08-07 Thread Dirk Eschler

Hello,

i'm trying to pass a custom set_password_form to the password_reset_confirm 
view. For some reason the set_password_form argument isn't honoured and i 
always end up with the original SetPasswordForm.

urls.py:
from foo.accounts.forms import KrSetPasswordForm
url(r'^accounts/password/reset/(?P[0-9A-Za-z]+)-(?P.
+)/$', 'django.contrib.auth.views.password_reset_confirm', 
{ 'set_password_form': KrSetPasswordForm, }),

I suppose something is wrong with my url pattern as set_password_form is still 
using SetPasswordForm when i check it in the view. Can anybody help me?

Best Regards,
Dirk Eschler

-- 
Dirk Eschler 

--~--~-~--~~~---~--~~
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: user.objects.create is not checking for duplicate emails

2009-08-07 Thread Mirat Bayrak
hmm you mean to use it on form? nice ill try it :)

--~--~-~--~~~---~--~~
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: user.objects.create is not checking for duplicate emails

2009-08-07 Thread Mirat Bayrak
i did it but django raises exception in this case, i want to re show form
page with a note *"hey this email taken"* as other errors. When you give
username that already taken you dont see exception page, you see it as form
error. I want 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
-~--~~~~--~~--~--~---



django-profiles/registration and conditional redirect

2009-08-07 Thread Léon Dignòn

Hello,

I struggle with the start of a little conditional request.

I installed django-profiles and got django-profiles working and I have
a small login form based on the django documentation.

django-profiles covers the accounts/login url in its urls.py. So I
only had to create the registration/login.html template. My goal is to
look up if the user which logged in has already created a profile and
redirect him either to the view profiles.views.create_profile or to
the url he comes from.

In the template is a {{ next }} variable.

But I don't know where to start. I think the best would be to change
{{next}}. But how should I do 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
-~--~~~~--~~--~--~---



very interesting query... i need some help

2009-08-07 Thread talpay...@gmail.com

i have come up with one of the most interesting query i have ever
seen.

I want to do this :

products = products.filter(productdetail__detail_value__gte =
first_value)
products = products.filter(productdetail__detail_value__lte =
second_value)

where first_value and second_value are integers and
"productdetail__detail_value" are stored as a char.

it is a very simple sql query but how can i do this using django
queryset. the problem is that i need the products to stay as a
queryset... because i need to filter it again if that is the case.

taking the easy way out and changing the way the table is constructed
is not an option. i have to store any kind of data in "detail_value"
and filter the information. it's a generic filter and this is the only
problem i don't have a solution to. please help.

--~--~-~--~~~---~--~~
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 should I organize my news site's backend - needing some feedback

2009-08-07 Thread zayatzz

Im not a very good django programmer (actually im just a beginner),
but all this text makes me ask if you have done all the ground work
before starting with a project of this scale? I mean, have you
throught through user cases, drawn bunch of flow charts and
wireframes, figured out and mapped database connections and so on.

All that aside, if i understood you correctly, then system like you
just described already works with CMS's like wordpress or edicy. I
suggest you check out how either of them work. In any case, as i said,
im not very good django programmer, but im quite good project manager
and as far as i see, you do not need generic relations between
different media and your content objects.

I think you could do this with templatetags for example. Modify your
wysiwyg editor interface, so that when you press button "insert
media", it opens modal window where you can select the media object,
that you want to insert. When object has been chosen, you insert
either the HTML code or templatetag of the media object into your
article. Save the article and the content will be loaded along with
the inserted media on the public page.

Quite easy in theory anyway :)

Alan

On Aug 7, 9:51 am, chyea  wrote:
> Hi all,
>
> I recently sent an email to another Django coder asking for some
> possible feedback on my situation. I'll simply restate the email here,
> because I figured why not ask a bunch of other Django coders, too!
> Here it goes...
>
> Hi,
>
> I'm trying to design a django-based gaming news site, and have been
> just confusing myself. I think I'm over-complicating it by trying to
> make it highly dynamic/scalable. Perhaps I can just run my design
> ideas by you and see if you have any feedback for me.
>
> Conceptually, it's very simple. I want the site to revolve around
> various types of articles - news, interviews, reviews. My thoughts
> were that all of these articles are essentially, at the core, the same
> set of data - a title, slug and the article text (simplified example).
> So, with this in mind I created an abstract base class called Article,
> with those essential elements. Then, I just created classes for News,
> Interview and Review, that subclass the abstract Article base class.
> So, now I've got the core article model classes for my site.
>
> I'm starting to confuse myself, though, when trying to figure out what
> to do with all the media involved with the site.
>
> How I have it invisioned is a highly dynamic and scalable setup that
> allows me to tag any number of pictures, videos, or any other model
> really, to any type of Article object. This would result in media
> objects that aren't exactly coupled to any specific Article, and can
> therefor be tagged to any of them, none of them, all of them, etc.
>
> With this in mind, I thought it'd make sense to create another
> abstract base class for all types of media. Somehow, this abstract
> base class for media objects would contain the proper code that'd
> allow any classes that subclass it to be tagged to any other model.
>
> The reason I'm thinking of it like this is because imagine a page on
> my site for a News article object. Lets say this News article is about
> how a game developer company is down in profits this year because they
> haven't released a game they announced, yet. This News article would
> have several things related, or 'tagged' to it - a Developer, a Game,
> perhaps some Pictures, maybe a Movie. I'd have existing models for
> Developer, Game, Picture and Movie (ideally). While creating this News
> article, I'd have the ability to just select these related items in
> the admin page. All of this related data would be available to the
> News article object when you query for it, and then all passed to the
> template where I can sort it out there.
>
> What I've described above sounds like it'd be a very dynamic setup
> that'd allow me to basically create some pretty interesting Articles
> and tag them with relevant data. This beats just using TinyMCE and
> using the formatting it creates to link to YouTube videos, and images
> in my article, on a per-article basis. Does it sounds like I've
> thought this to death, or is what I'm describing possible at all?
>
> All day today I messed around with generic relationships and
> ContentType. I tried creating an abstract base classes with generic
> relations to other abstract base classes: Article <-> Media
>
> In the end I'm just high confused and wondering if I'm completely
> complicating this. I know this was long and if you read it this far
> then I greatly appreciate it. I'm looking forward to any insight, or
> advice/feedback you may have!
>
> Thank you,
> Ryan C
--~--~-~--~~~---~--~~
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 

Re: Django documentation site is SLOW

2009-08-07 Thread Russell Keith-Magee

On Fri, Aug 7, 2009 at 8:06 PM, Léon Dignòn wrote:
>
> I have an Intel C2D E2200 with 4 GB RAM. The Django docs are killing
> my browser, it feels like FireSLUG instead of Firefox 3.5 .

I don't know what to say. Your experience in no way matches my own. I
use Safari and Firefox, and I certainly don't see any CPU load spike
loading the docs. The only significant delays I see are due to
download time, which are mostly caused by sitting on the tail end of a
fairly ordinary net connection in Australia (when you're a long way
from everything, _every_ page takes a while to download)

I can't even think what could be causing this. If you look at the
source code, we're not doing anything particularly intensive with
Javascript - we are using a Javascript widget to implement Google's
search, but other than that, it's fairly simple HTML all the way.

If you have any concrete suggestions, we're happy to entertain them,
but unless you can provide some concrete diagnosis as to the cause of
the problem, there isn't much we can do. We can't fix a problem that
we can't reproduce.

My only diagnosis advice would be that you disable any Firefox plugins
you may have installed. I have seen more than one page rendering
performance problem solved by disabling a badly behaved Firefox
plugin.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: user.objects.create is not checking for duplicate emails

2009-08-07 Thread zayatzz

you can add unique=True to the email field

Alan

On Aug 7, 1:14 pm, Mirat Bayrak  wrote:
> User.object.create is checking for username for duplicate usernames but not
> checking for emails.. can i force him to make users emails unique ? (becouse
> on else case i want to show i forgot my password screen to user i mean if
> mail is already taken) what should i do?
--~--~-~--~~~---~--~~
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 documentation site is SLOW

2009-08-07 Thread Sam Walters

Hi
Its probably not the browser. I am using firefox 3.5 on an eee pc and
the documentation is fine. This is with Javascript disabled using
noscript however i just turned it on again and no noticable difference
in top readings

*You should look at the install addons of firefox, eg: some plugin
which is slowing it.
*save the page and view it offline see if there is still an issue.
*CSS+cheap video card. This is unusual however some sites really run
slow on very old video cards. Try removing the css from a docs
page+save it runoffline.

I just cant see it being firefox unless its not configured properly.
Especially considering eee pc atom cpu is puny compared too even a p4.
:)



On Fri, Aug 7, 2009 at 10:09 PM, Mirat Bayrak wrote:
> without javascript ?
>
>
> >
>

--~--~-~--~~~---~--~~
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 documentation site is SLOW

2009-08-07 Thread Léon Dignòn

Without it's better, but still now good enough for three colors and a
little bit of text.

On Aug 7, 2:09 pm, Mirat Bayrak  wrote:
> without javascript ?
--~--~-~--~~~---~--~~
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: Admin, two links to different views ?

2009-08-07 Thread Asinox

No body? :(

On Aug 7, 2:11 am, Asinox  wrote:
> Hi guys, in django admin the views that show the register's just have
> a link to "edit", but what happen if a need an extra(S) links to
> another views?
>
> for example:
>
> i have view that my show list of registered People, the nick is
> linking to the Edit page (the normal way of Django), but i need
> another links that will show me the "articles" of the people and
> another the "comments" of the people.
>
> how ill make this with django admin?
>
> 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
-~--~~~~--~~--~--~---



Re: login with email backend result in URL rules doesn't work

2009-08-07 Thread Karen Tracey
On Fri, Aug 7, 2009 at 6:57 AM, Shuge Lee  wrote:

>
> For user could login with email or username,
> I did as what this page
> http://www.djangosnippets.org/snippets/74/
> said
>
> [snip]
>
> Then I found somthing wrong,
>
> first, admin view doesn't work well,
> http://127.0.0.1:8000/admin/logout/
> become
> http://127.0.0.1:8000/admin/admin/logout/
> user couldnt't logout as usual
>

I'm not quite following what your second problem is that you mention below,
but this one was the last big blocker to getting 1.1 out.  As you say you
are using 1.1 Beta the first thing you should do up update to 1.1 itself to
fix this problem.  Upgrading to the release level code may help with the 2nd
one as well, though I am not sure as I don't understand what your 2nd
problem is exactly.

Karen


>
> second, many url rules which in myproject.urls doesn't work
>
> ^admin/doc/
> ^admin/ ^$
> ^admin/ ^logout/$
> ^admin/ ^password_change/$
> ^admin/ ^password_change/done/$
> ^admin/ ^jsi18n/$
> ^admin/ ^r/(?P\d+)/(?P.+)/$
> ^admin/ ^(?P\w+)/$
> ^admin/ ^auth/user/
> ^admin/ ^auth/group/
> ^admin/ ^seed/seed/
> ^admin/ ^seed/format/
> ^admin/ ^seed/language/
> ^admin/ ^comments/comment/
> ^admin/ ^seed/right/
> ^admin/ ^sites/site/
> ^admin/ ^seed/category/
>
> Why prefix '^admin'/ will be added in the front of those url rules
> automatically after I
> add `login with email custom backend` ?
>
> How to fix it /
>
> l...@lab ~/online $ django-admin.py --version
> 1.1 beta 1
>
> >
>

--~--~-~--~~~---~--~~
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 documentation site is SLOW

2009-08-07 Thread Mirat Bayrak
without javascript ?

--~--~-~--~~~---~--~~
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 documentation site is SLOW

2009-08-07 Thread Léon Dignòn

I have an Intel C2D E2200 with 4 GB RAM. The Django docs are killing
my browser, it feels like FireSLUG instead of Firefox 3.5 .

Hate it!


On Aug 7, 1:46 pm, Jo  wrote:
> Surely can't only be me that finds the main Django site painfully
> slow? There is some javascript in there or something that just kills
> my browser.
>
> I'm using Firefox on Linux, on 1.5gig P4, OK not state of the art but
> it's fine for pretty much any other website, but when I try to look
> something up on the Django website, firefox jumps to 80% CPU and takes
> 10s of seconds to render each page, and even when the page is rendered
> the browser is so sluggish as to be almost unusable.
>
> Django might speed up development, but what it gives it takes away in
> time sitting waiting for the damn docs to load!
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



implementing a simple jquery function to an admin site

2009-08-07 Thread Hellnar

Greetings
I have extended my admin add screen (tabularinline) by using the
http://www.djangosnippets.org/snippets/1594/

Now I have a field in my model:
start = models.CharField(max_length=5)
this is intended as a special time format, it will be in a HH:MM
format such as 16:30 . Now I want to implement a way that site auto
assigns ":" between those numbers and for that I have found this
jquery application: http://digitalbush.com/projects/masked-input-plugin/

When I check my admin add panel by firebug, I see that the field that
I want to implement this masking function is:

where "id_outage_set-0-start" is increased each time I add new.

Now I am looking for a way to implement these 2 together, I am a
jquery newbie thus really lost at it.

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



DjangoCon: Call for Proposals Ends Today

2009-08-07 Thread Robert Lofthouse

This is the last day that the Call for Proposals will be open, it
closes at 12pm EST. Please ensure you get your talk in before the
deadline closes. You can find the talk submit form in the conference
section of the site.

The full schedule for the conference will be posted tomorrow
(Saturday, August 8th). The schedule will be found in the "conference"
section of the website, along with details on the talks and the
speakers.

http://www.djangocon.org/blog/2009/8/7/call-proposals/

Regards

Robert Lofthouse
DjangoCon Chairman
[http://www.djangocon.org/]
[http://djangocon09.eventbrite.com]
--~--~-~--~~~---~--~~
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 documentation site is SLOW

2009-08-07 Thread Mirat Bayrak
i am not expert but i thought that it can be about javascripts, can you
disable javascript support and retry it? i think you have to try opera too

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



Django documentation site is SLOW

2009-08-07 Thread Jo

Surely can't only be me that finds the main Django site painfully
slow? There is some javascript in there or something that just kills
my browser.

I'm using Firefox on Linux, on 1.5gig P4, OK not state of the art but
it's fine for pretty much any other website, but when I try to look
something up on the Django website, firefox jumps to 80% CPU and takes
10s of seconds to render each page, and even when the page is rendered
the browser is so sluggish as to be almost unusable.

Django might speed up development, but what it gives it takes away in
time sitting waiting for the damn docs to load!
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



How to change the option text in a form's select-tag?

2009-08-07 Thread Léon Dignòn

Hello,

I installed django-profiles and added an extended UserProfile. One
template displays all fields which are necessary to edit a users
profile. Every user can choose a favorite aeroplane. Every aeroplane
is built by one manufacturer.

I print the edit form in the template with {{ form }}. The form
dispays a select tag to chose a favorite aeroplane. Everything works
fine.

I want to make a little change on how the select field displays the
options. I would like to add the manufacturer to the option string. Is
there an easy way to insert the manufacturer to the option? I want to
avoid as much code as possible since the django-profiles app provides
views and forms. I hope not to write any own. Maybe I can change the
model so that it alwas displays Manufacturer+Aeroplane when called?

I just tried to insert the following code in the Aeroplane class:
def __unicode__(self):
return self.name + manufacturer.name



Here some detailed explanation and code:



My select field looks like this:

  Plane1
  Plane2
  Plane3


My select field *should* looks like this:

  Manufacturer1 Plane1
  Manufacturer2 Plane2
  Manufacturer3 Plane3




Here is the models.py

class Aeroplane(models.Model):
name = models.CharField(max_length=32, unique=True)
year_of_construction = models.PositiveSmallIntegerField()
manufacturer = models.ForeignKey(Manufacturer)

def __unicode__(self):
return self.name

class UserProfile(models.Model):
user = models.ForeignKey(User, unique=True)
favorite_aeroplane = models.ForeignKey(Aeroplane, blank=True)

def get_absolute_url(self):
return ('profiles_profile_detail', (), { 'username':
self.user.username })
get_absolute_url = models.permalink(get_absolute_url)



Here is the template:

{% extends "base.html" %}
{% block content %}

  {{ form.as_p }}
  

{% endblock content %}
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



login with email backend result in URL rules doesn't work

2009-08-07 Thread Shuge Lee

For user could login with email or username,
I did as what this page
http://www.djangosnippets.org/snippets/74/
said

# in settings.py
# ...
AUTHENTICATION_BACKENDS = (
'online.accounts.backends.EmailOrUsernameModelBackend',
'django.contrib.auth.backends.ModelBackend'
)
# ...

l...@lab ~/online $ tree accounts/
accounts/
├── __init__.py
├── __init__.pyc
├── backends.py
└── backends.pyc

l...@lab ~/online $ cat accounts/backends.py
from django.conf import settings
from django.contrib.auth.models import User

class EmailOrUsernameModelBackend(object):
def authenticate(self, username=None, password=None):
if '@' in username:
kwargs = {'email': username}
else:
kwargs = {'username': username}
try:
user = User.objects.get(**kwargs)
if user.check_password(password):
return user
except User.DoesNotExist:
return None

def get_user(self, user_id):
try:
return User.objects.get(pk=user_id)
except User.DoesNotExist:
return None


Then I found somthing wrong,

first, admin view doesn't work well,
http://127.0.0.1:8000/admin/logout/
become
http://127.0.0.1:8000/admin/admin/logout/
user couldnt't logout as usual

second, many url rules which in myproject.urls doesn't work

^admin/doc/
^admin/ ^$
^admin/ ^logout/$
^admin/ ^password_change/$
^admin/ ^password_change/done/$
^admin/ ^jsi18n/$
^admin/ ^r/(?P\d+)/(?P.+)/$
^admin/ ^(?P\w+)/$
^admin/ ^auth/user/
^admin/ ^auth/group/
^admin/ ^seed/seed/
^admin/ ^seed/format/
^admin/ ^seed/language/
^admin/ ^comments/comment/
^admin/ ^seed/right/
^admin/ ^sites/site/
^admin/ ^seed/category/

Why prefix '^admin'/ will be added in the front of those url rules
automatically after I
add `login with email custom backend` ?

How to fix it /

l...@lab ~/online $ django-admin.py --version
1.1 beta 1

--~--~-~--~~~---~--~~
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: My first Django project

2009-08-07 Thread Mirat Bayrak
Hi, i liked you project look slike simple cv center. May be you can think
about usability. For example creating items has too much steps. May be you
can put all that forms into one page. Or may be forms can by dynamicaly
shown above *create another foo item*  with jquery. In other sides i liked
it..

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



My first Django project

2009-08-07 Thread Ronghui Yu
The first project I do by using Django, http://www.cvcenter.cn, please take
a look, and enjoy.
Any feedback will be appreciated.

Thanks a lot


-- 
===
Regards
Ronghui Yu

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



user.objects.create is not checking for duplicate emails

2009-08-07 Thread Mirat Bayrak
User.object.create is checking for username for duplicate usernames but not
checking for emails.. can i force him to make users emails unique ? (becouse
on else case i want to show i forgot my password screen to user i mean if
mail is already taken) what should i do?

--~--~-~--~~~---~--~~
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: Can i rise 404 from my middleware ?

2009-08-07 Thread Mirat Bayrak
2009/8/5 Malcolm Tredinnick 

>
> On Wed, 2009-08-05 at 09:29 +0300, Mirat Can Bayrak wrote:
> > On Tue, 4 Aug 2009 16:47:37 -0500
> > Alex Gaynor  wrote:
> [...]
>
> > > Right now there is a bug in django's middleware where it doesn't
> > > correct catch exceptions: http://code.djangoproject.com/ticket/6094.
>
>
> > than... what should i do?
>
> Don't raise an exception. A 404 exception is eventually turned into an
> HttpResponse with the appropriate status code, so construct one manually
> and return that from the middleware. Once you return a response, no
> further processing happens (for request middleware). That's one of the
> major points about middleware.
>
> Regards,
> Malcolm
>
>
>
>
> >
>
Thank you, i did it the way you said. It's little weird but working, thank
you.

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



How to define new permission

2009-08-07 Thread Toan Vu

Dear all,

I've created a new application which used the default admin site of
Django framework. I have a model which have these line of code:
Class Meta:
permissions = (('permission_name':'Readable human name'),)

This line of code created a new permission in
'auth_user_user_permissions' table and I can set this new permission
to a specified user. The problem is after I only set this permission
to the user and I logged in by this username and the admin's home page
shown 'You don't have permission to edit anything.'. When I set a add,
change,. permission to this model and then It shown the app list.

Could you mind show me how to add new permission like the defaul
permission of the admin site like add, delete, change ?

Cheers.

--~--~-~--~~~---~--~~
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: post_save timeout with twitter

2009-08-07 Thread k88

You can create a model for messages to be sent and create entries to
that model on post_save. Then you'll just have to create a command to
send unsent messages and a cron to execute that command.

On Aug 7, 9:27 am, Kenneth Gonsalves  wrote:
> hi,
>
> I use a post_save signal to send a tweet on twitter. Just now I have had some
> ugly timeout crashes since twitter was not responding and my saves were
> getting b0rked. How does one get around that?
> --
> regards
> kghttp://lawgon.livejournal.com

--~--~-~--~~~---~--~~
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: Model field option "max_length" is not respected (Sqlite backend)?

2009-08-07 Thread Thierry

Indeed, I had been confused by this documentation excerpt ([1]):
"CharField.max_length: The maximum length (in characters) of the
field. The max_length is enforced at the database level and in
Django's validation."

Now your clear and quick explanation makes sense.
Fortunately most of my data is validated through forms, so I only have
to be cautious about my own manipulations of models.

Thanks a lot.

[1]: http://docs.djangoproject.com/en/dev/ref/models/fields/#charfield
--~--~-~--~~~---~--~~
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: Model field option "max_length" is not respected (Sqlite backend)?

2009-08-07 Thread Malcolm Tredinnick

On Fri, 2009-08-07 at 01:24 -0700, Thierry wrote:
> Hi,
> 
> I have a model roughly defined as such (FK fields do not appear for
> simplicity):
> 
> class FieldChange(models.Model):
> old_value = models.CharField(max_length=50)
> new_value = models.CharField(max_length=50)
> 
> Using SQLite, the table definition roughly translates to:
> 
> CREATE TABLE "fieldchange" (
> "id" integer NOT NULL PRIMARY KEY,
> "old_value" varchar(50) NOT NULL,
> "new_value" varchar(50) NOT NULL,
> )
> 
> However, it seems that the "max_length" condition is not respected,
> neither at Django level (when saving)

Django does not currently do model-level validation.

>  nor at database level:

SQLite respects SQL syntax, in that it accepts it without error, but
it's internal storage format doesn't enforce that. You can put a string
into a numeric field in SQLite and it won't complain. That's part of the
reason for its code simplicity: you have to behave nicely when giving it
data, because it isn't standing in the living room with a big stick
enforcing much.

> For instance, I managed to create a model instance with fields longer
> than 50 characters and save it.
> Worse, I managed to retrieve that instance with fields unchanged, i.e
> their size still exceeding 50 characters (in a separate "django shell"
> session).
> 
> I expected the operation to fail at validation or DB backend level, or
> at least that the fields would be truncated to comply with condition
> "max_length=50".

The latter behaviour would be very bad, since it would quietly lose data
(the fact that MySQL does it and only raises a warning and not an error
is, in my book, a design bug in MySQL).

>  Is there some kind of bad magic here? Or only related
> to SQLite?

No and yes, in that order.

> Now what had me spot the error is that I wanted to manually truncate
> 'old_value' and 'new_value' fields when data exceeds the 50 characters
> limit (adding trailing '...' characters when necessary). Where is the
> best location to do that? The model 'save()' method, I suppose?

Yes. That's the ideal place for any cleanups of this variety. Honza Kral
is working on model validation as part of his Django summer of code
project and that contains normalisation passes as well, so this will be
something that will be easier in a future version of Django (1.2, all
things going well). For now, the save() method is an ideal place for any
automatic translations.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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: multi-table inheritance and modification of OneToOneField options

2009-08-07 Thread Malcolm Tredinnick

On Fri, 2009-08-07 at 00:30 -0700, Jan Ostrochovsky wrote:
> Thank you, Malcolm.
> 
> In fact, our current design was, as you recommended:
> 
> Subject ---one-to-one-null-false--- Address ---one-to-one-null-true---
> Payment (Invoice)
> 
> I want to use generic views and to join Subject+Address in the same
> form, and model inheritance seemed to me as most straightforward
> solution for this need, but as you do not recommend it,

Bear in mind that there might be somebody who gives stricter
recommendations on not abusing model inheritance around here, but I'm
not sure who they would be. I very much view it as a Python equivalent
(with some abstraction leakage from DB -> Python), but my view isn't
universally held. In this case, though, what you're asking for isn't
possible in the way the code is implemented, so it's not just a matter
of preference.

>  I will look
> for another solution... e.g. form inheritance, as I found it here
> http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#form-inheritance
> or here http://www.djangosnippets.org/snippets/703/.

Hmm ... if you're doing this for the form result and you aren't
intermixing the fields from Subject and Address (or even if you are),
you might be better served by still making each on its own ModelForm and
just passing both into the template. Then layout both Django forms
inside a single HTML form element.

Regards,
Malcolm



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



Model field option "max_length" is not respected (Sqlite backend)?

2009-08-07 Thread Thierry

Hi,

I have a model roughly defined as such (FK fields do not appear for
simplicity):

class FieldChange(models.Model):
old_value = models.CharField(max_length=50)
new_value = models.CharField(max_length=50)

Using SQLite, the table definition roughly translates to:

CREATE TABLE "fieldchange" (
"id" integer NOT NULL PRIMARY KEY,
"old_value" varchar(50) NOT NULL,
"new_value" varchar(50) NOT NULL,
)

However, it seems that the "max_length" condition is not respected,
neither at Django level (when saving) nor at database level:
For instance, I managed to create a model instance with fields longer
than 50 characters and save it.
Worse, I managed to retrieve that instance with fields unchanged, i.e
their size still exceeding 50 characters (in a separate "django shell"
session).

I expected the operation to fail at validation or DB backend level, or
at least that the fields would be truncated to comply with condition
"max_length=50". Is there some kind of bad magic here? Or only related
to SQLite?

Now what had me spot the error is that I wanted to manually truncate
'old_value' and 'new_value' fields when data exceeds the 50 characters
limit (adding trailing '...' characters when necessary). Where is the
best location to do that? The model 'save()' method, I suppose?

Thanks for any clarification.
--~--~-~--~~~---~--~~
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: multi-table inheritance and modification of OneToOneField options

2009-08-07 Thread Jan Ostrochovsky

Thank you, Malcolm.

In fact, our current design was, as you recommended:

Subject ---one-to-one-null-false--- Address ---one-to-one-null-true---
Payment (Invoice)

I want to use generic views and to join Subject+Address in the same
form, and model inheritance seemed to me as most straightforward
solution for this need, but as you do not recommend it, I will look
for another solution... e.g. form inheritance, as I found it here
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#form-inheritance
or here http://www.djangosnippets.org/snippets/703/.

Jano

On Aug 7, 3:50 am, Malcolm Tredinnick 
wrote:
> On Thu, 2009-08-06 at 07:15 -0700, Jan Ostrochovsky wrote:
> > Hello,
>
> >http://docs.djangoproject.com/en/dev/topics/db/models/#multi-table-in...
> > says:
> > The inheritance relationship introduces links between the child model
> > and each of its parents (via an automatically-created OneToOneField).
>
> >http://docs.djangoproject.com/en/dev/ref/models/fields/#onetoonefield
> > says: Multi-table inheritance is implemented by adding an implicit one-
> > to-one relation from the child model to the parent model...
>
> > The question is: how can I set options of that implicit OneToOneField?
> > Most interesting is null=True / null=False.
>
> You don't. Model inheritance is a Python-level thing and things like
> "optional" inheritance doesn't existence for Python inheritance. It's a
> shortcut for emulating Python class inheritance as much as possible.
>
> If you want this level of control, model the relations explicitly and
> set the options on the OneToOneField to whatever you like.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



  1   2   >