Re: problem testing application named "core"

2008-10-22 Thread felix
most probably, yes.

core
contrib
db
dispatch
etc...

are all django's apps/modules
and that is probably what was running

surprisingly I don't see tests.py in core, db etc.
those tests must live elsewhere.
there are tests for some of the contrib apps

also don't name a templatetag the same name as a module.




On Tue, Oct 21, 2008 at 8:53 PM, reyjexter <[EMAIL PROTECTED]> wrote:

>
> When running manage.py test core, the test seem to run but no test
> suite is executed. but when using plain manage.py test its okay. Is
> this problem caused by the naming? thanks
>
>
> rey
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Creating a system with multiple types of users

2008-10-22 Thread felix
perhaps when you create-save the models (Providers, Customers etc.) it adds
that User to the appropriate group.

but I'm not sure I would use groups.  That would make the most sense if
there were people with overlapping roles.  somebody who is Agent + Provider

you could use the permissions system.  again, also saving it to the User at
the time you create the Agent, Provider etc.

I have a form that creates a Person and optionally creates a User account at
the same time linked to it.  you can also create a User (an account) later
for some person who is in the contact database.  so I do that action in the
Form.  its the form's responsibility (it represents/encapsulates the action
that the admin is taking)


I guess what you are asking is : how can you check on the template or in the
views what type of person the user is and show them certain things.

you can make use of the template tags that check for perms.

and some views are only accessible for certain types of peoples.  for that,
using perms is good.

@permission_required("app.provider.can_view")
def view_func(request):

also this way you can give the staff or Agents perms that the plebs also
have.

you could also set a cookie/session var on login for is_a
that would be less db hits

-f;lix



On Tue, Oct 21, 2008 at 10:39 PM, itsnotvalid <[EMAIL PROTECTED]> wrote:

>
> I am going to help some people making a website that has a few admins,
> a crowd of service providers (individuals) and customers. There could
> be agents who invites people to become service providers or customers
> as well.
>
> Looking at the user system provided by django, and as a new programmer
> to django, I am not sure how can I separate different kinds of user
> here. I actually want to make it look like that different people login
> in different location, and do not share the same view after they
> logged in.
>
> So I am thinking a model schema like this:
>
> Users (as usual)
>
> Providers(link to a specific user, one-to-one)
>
> Customers(link to a specific user, many-to-one, as one user may find
> services for more that one actual person)
>
> Agents(link to a specific user, one-to-one)
>
> But how effectively can I separate their views? By defining different
> apps? Any other suggestions?
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Permissions in template tags

2008-10-22 Thread felix
the easiest way is to pass in the context to the template tag :

@register.inclusion_tag("edit_link_tag.html",takes_context=True)
def edit_link_tag(context,obj,name=None):
"""returns a link to edit the model if you have permission to do so

"""
user = context['user']
 and so on ...
   d= {  vars here }
   # add the vars you need into the context
   context.update( d )
  # so the user, perms, etc. should all be in there
  #and return it for use in the included template
  return context


it would be nice if one could do that in a simple tag

@register.simple_tag(takes_context=True)
def displayfields(context,model):
  ... yada yada yada...


but we can't.  I looked at the django code to try to make that work but I
hit a snag and sadly was then distracted by my job.

-flix





On Tue, Oct 21, 2008 at 11:44 PM, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:

>
> Simple question: is it possible to access all user permissions in
> template tags just as in regular templates through the {{ perms }}
> context variable or do I need to manually pass the permissions are
> template tag params? By default the perms map does not seem to work in
> tags.
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: emulate existing session in automated test

2008-10-22 Thread felix
look at RequestFactory:

http://groups.google.com/group/django-developers/browse_thread/thread/db86050095ebe5db?pli=1

which would mean not calling post, but calling the view directly

I've written a custom Unit test class just for views that's proving quite
useful, but it doesn't yet do this request factory approach.

-f;lix




On Mon, Oct 20, 2008 at 6:59 PM, Bruno Zanchet <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> well, I'm new to django (coming from rails hehe), and I'm trying  to
> develop using a test-driven approach. I'm facing a problem trying to
> emulate an existing session in a "functional" test.
>
> There is a related problem here (http://groups.google.com/group/django-
> users/browse_thread/thread/701a39672fc274a9/a75ef6fb3813e5ad),
> but it
> seems to be a little bit outdated, and isn't exactly what I'm looking
> for.
>
> I simply want the Client to "fake" some values in the session. I want
> to write in my test:
>
>self.client.session['key'] = 'value'
>self.client.session.save()
>response = self.client.post('/my_url', {}) #here,
> request.session['key'] should have 'value'
>
> This code doesn't work. It needs some 'initialization'. What I ended
> up doing looks like this:
>
>#a view that only sets request.session.modified = True in
> order to save the session
>#and get the session_cookie
>self.client.get('')
>engine = __import__(settings.SESSION_ENGINE, {}, {}, [''])
>session_cookie =
> self.client.cookies.get(settings.SESSION_COOKIE_NAME).value
>self.client.session =
> engine.SessionStore(session_cookie)
>
> After this "initialization" (I put this on the setUp), the first
> snippet works like expected. Is there a better way to do it? I
> couldn't figure out anything simpler.
>
> Thanks,
> Bruno
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Different settings.py files for server and development

2008-10-23 Thread felix
at the very bottom of settings.py :

from local_settings import *


this overwrites just the imported keys/values

-flx



On Thu, Oct 23, 2008 at 11:55 PM, Dana <[EMAIL PROTECTED]> wrote:

>
> Hello everyone,
>
> I know a form of this question has been asked before on this group but
> I can't for the life of me find the thread.
>
> I am wondering how I can have a generic settings.py file that contains
> all my basic settings and then have a settings-local.py (or
> whatever...) and have that contain custom settings such as DEBUG=True,
> etc... Ideally the settings-local.py file would *only* have the custom
> settings, and nothing else, but I cannot seem to get this to work. For
> example:
>
> In settings.py I would have default settings:
>
> settings.py
> ---
> DEBUG = False
>
> DATABASE_ENGINE = 'mysql'
>
> DATABASE_NAME = 'something'
>
> DATABASE_USER = 'root'
> DATABASE_PASSWORD = ''
>
> MEDIA_ROOT = '/home/user/media/'
> MEDIA_URL = 'http://media.example.com/'
>
> ADMIN_MEDIA_PREFIX = '/admin_media/'
>
> INSTALLED_APPS = (
>
> )
>
> .. etc
>
> ---
> and in settings-local.py I would override the settings:
>
> # settings-local.py
> ---
> DEBUG = True
>
> DATABASE_USER = 'username'
> DATABASE_PASSWORD = 'somethinghere123'
> ---
>
> I would like some way to have settings-local import my settings.py
> file and then override specific settings. Anyone know how to do this
> cleanly?
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: wrong redirect from admins "View on site" link

2008-10-25 Thread felix
its gets the domain value from the Site object.  I'm guessing that you have
that domain set to "localhost"

the view that actually does the relocation is at
django.contrib.contenttypes.views shortcut

site = Site.objects.all()[0]

site.name

site.domain

site.domain = "127.0.0.0:8000"
site.save()


-flx



On Fri, Oct 24, 2008 at 11:15 PM, Adi Jörg Sieker <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> I just noticed that the "View on site" link on the Admin change entry
> page redirects to localhost/. The dev server is running on
> localhost:8000 though.
> The model being used is the Entry model from coltrane_blog[1] which has
> a get_absolut_url method that looks like:
> from django.db import models
>
> def get_absolute_url(self):
> return ('coltrane_entry_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)
>
>
> Is this a config issue on my side?
>
> adi
>
> [1] http://code.google.com/p/coltrane-blog/
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multi-Table Inheritance

2008-10-25 Thread felix
yes, it should work fine.
use the admin of the forms just as for any single table model

-flix



On Fri, Oct 24, 2008 at 7:47 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

>
> Does anyone have any suggestions on how to use mutli-table inheritance
> with model forms or some other way of creating it.  For example if I
> have a model setup like this:
>
> class MetaData(models.Model):
>  date = models.DateField()
>  subject = models.CharField()
>
> class Body(MetaData):
>  body = models.TextField()
>
> Basically I want create or edit all the fields for both models at the
> same time.
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Receiving emails via app

2008-10-26 Thread felix
In general I agree with Jeff's suggestion.

but OTOH you might be able to get pop to work
and using the pop interface maybe you can get the headers in a clean
pythonic fashion.

it sounds like you will also have to deal with attachments, so maybe the pop
library can handle that nicely.


the script way is this:

In a hosted environment you often have the possibility to set up (using the
host company's control panel) a recipe or similar that sends an email to a
python shell script.  the script then receives the whole raw email on STDIN
standard in.
If you control the server yourself, then you should be able to use postfix
or whatever your email MTA is and again send the email to a shell script.

so the recipe or command to execute is something like:

/Library/Frameworks/Python.framework/Versions/Current/bin/python
/full/path/to/yourhandler.py


yourhandler.py can then get the entire body of the email (with all headers)
via STDIN standard in.

lines = sys.stdin.readlines()

it then can use pattern matching to find the from address in the headers
etc.
there's probably some nice libraries that do this parsing already.

alternatively you might be able to just dump the email to a file in a
directory
and later process the mails.

or access the Maildir/new for that account directly.

and then have a regular process that checks for new mails in the directory
and processes them.

either write a command that can be executed from manage.py (so you'll have
the whole django stack and all of your apps avail to you)
or import the settings and the most minimal amount of django that you'll
need.

or if you are really lazy, just write a view that processes the mails and
set a cron to fetch the page every once in a while ( just wget or curl it )


-felix



On Sun, Oct 26, 2008 at 8:13 PM, AndyB <[EMAIL PROTECTED]> wrote:

>
> This sounds like exactly what I need to do. However my Unix-fu isn't
> up to coping with the sentence 'We have an alias set up in postfix
> that sends the e-mail to our script via a pipe.'... :(
>
> My naive assumption is that one could use something like poplib in the
> standard library to connect to a POP3 server and process incoming
> emails that way. Does that sound a sensible route to take?
>
> Andy Baker
>
> On Oct 25, 7:09 pm, Jeff Anderson <[EMAIL PROTECTED]> wrote:
> > umit wrote:
> > > Hi, i am trying to build a quick blog system. But i want users can
> > > send emails to submit messages with pictures.
> > > How can i receive emails and process them? What should i use?
> >
> > We use Python's email module.
> >
> > We have an alias set up in postfix that sends the e-mail to our script
> > via a pipe.
> >
> > The python script imports our Django models, and parses the e-mail
> > message with the email module, and does what it needs to.
> >
> > This should give you a decent starting point.
> >
> > Cheers!
> >
> > Jeff Anderson
> >
> >  signature.asc
> > < 1KViewDownload
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Can python/django match the features of php/zend framework?

2008-10-26 Thread felix
python libraries are in general much much better than php libraries.
besides django itself, there's a wealth of usable and well maintained
libraries.

I've been working with gdata, and its very nice:

_youtubeGDataHost = 'gdata.youtube.com'
_youtubeFeedBase  = '/feeds/api/'

import gdata
import gdata.youtube
import gdata.youtube.service

feed_url = str('http://' + _youtubeGDataHost + _youtubeFeedBase +
'playlists/%s' % playlist.playlist_id)

yt = gdata.youtube.service.YouTubeService()
feed = yt.GetYouTubeVideoFeed(feed_url)

for entry in feed.entry:
# we are now stepping through my youtube playlist ...





On Sun, Oct 26, 2008 at 10:24 PM, walterbyrd <[EMAIL PROTECTED]> wrote:

>
> I was going to go with zend framework, then I read about php using "\"
> character as it's namespace separator.
>
> A few things I like about the zend framework:
>
> 1) APIs to integrate with Google Apps. Although, I think I could do
> the same with python using gdata-python-client.
>
> 2) There is a fairly good library of php routines to connect on online
> php app with quickbooks. I am not sure if python has anything like
> that.
>
> The heavy-weight zend framework (18MB I think) has a lot of powerful
> features. But, I tend to prefer python to php.
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Model inheritance question

2008-11-02 Thread felix
see also this:
http://www.djangosnippets.org/snippets/1031/

for a tumblelog I have been actually fetching queries for each item type,
concatenating them as lists, then sorting by date.
that's much simpler since its usually mostly display.

I mostly use model inheritance in situations where I need to search shared
fields (contacts, companies, location).



On Sun, Nov 2, 2008 at 1:52 AM, void <[EMAIL PROTECTED]> wrote:

>
> Can someone point to the correct way to do this?
>
> Suppose i'm working in a tumblelog, it's basically , 4 o 5 tipes of
> "post item" that share some cmmon information.
>
> So the first approach i would go is:
>
> cllass Post(models.Model):
>   here goes common metada of all things that can be "posted" like
> taggin , dates, etc
>
> class TextPost(Post)
>  This model inherits all the metadata of the "normal" posteable
> objects and add some of it's own like
>
>  text = TexField()
>
> also we can provide a ImagePost(Post) with the same characteristics as
> textpost,
>
> The caveat folllow:
>
> Inheritance gives me a reference in the "child" model to the pk of the
> parent, that's ok.
> But i have no way of iterating to Posts elements and instantiating
> them osr seeing their attrs without knowing the correct nadme.
>
> Is any correct way to do this? will i have to hack django (or add a
> field) that backreferences the reference?
>
> The idea is traverse only the Posts objects instead o N tables (1 for
> each kinkd of post)
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Logout- Back Button

2008-11-14 Thread felix
this is not a django issue, but a browser issue.

you can solve it only with javascript.

either clear the browser history (so that there is no back)

or put something on the page(s) that checks for the auth cookie either
whenever the page is loaded/fronted or checks it periodically.
if the auth cookie is vanished, then relocate to the login page.

gmail is a javascript application.  all of its display and activity is part
of that application.
they simply check the login status whenever anything happens, so they
quickly notice that you are no longer logged in.

-flix


On Fri, Nov 7, 2008 at 5:21 AM, jai_python <[EMAIL PROTECTED]> wrote:

>
> But closing browser after logout in not a proper solution for this
> issue right? just take gmail as example, after logout from gmail
> accont and hit back button, it will prompt to login page, this is one
> proper method for secure our data. Does django supports this
> methodology ?
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



get_or_create and foreign keys

2008-12-06 Thread felix

this is not the issue previously posted by somebody else.

I think I found a bug with Manager get_or_create and foreign key
fields when specifying with foreigntable__id

class ObjectPermission(models.Model):

permission = models.CharField(blank=False, max_length=20)

user = models.ForeignKey(User,blank=True,null=True)

objects = ObjectPermissionManager()

note that user may be null

class ObjectPermissionManager(models.Manager):

def set_perm(self,permission,user_id):
import pdb; pdb.set_trace()

(perm,created) = self.get_or_create
(permission=permission,user__id=user_id)


(Pdb) user_id
17L

# user_id is incorrect when using get_or_create
(Pdb) self.get_or_create(permission=permission,user_id=user_id)
*** FieldError: Cannot resolve keyword 'user_id' into field. Choices
are: id, permission, user

# using user__id
(Pdb) (op,created) = self.get_or_create
(permission=permission,user__id=user_id)
(Pdb) op


# but user_id was set to null
(Pdb) op.user_id
(Pdb) op.user

here is the crux of the issue :

# if using create, then user_id is correct
(Pdb) self.create(permission=permission,user_id=user_id)

# if using get, then user__id is correct
(Pdb) self.get(permission=permission,user__id=user_id)
*** DoesNotExist: ObjectPermission matching query does not exist.

If someone else can confirm or deny that its a bug then I'll
investigate further and maybe cure it.

thanks

-flix

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: TextMate Django Bundle

2008-12-17 Thread felix
its called Python Django Templates but actually its an HTML mode

look under the HTML alphabetically

and thanks to whoever made this !  very useful.



On Wed, Dec 17, 2008 at 11:11 PM, Adam Nelson  wrote:

>
> Does anybody have this working in TextMate?
>
> "Python Django Templates.tmbundle"
>
> From http://macromates.com/svn/Bundles/trunk/Bundles/
>
> I've installed other bundles and the Python Django.tmbundle, but the
> Templates one simply doesn't appear in the Bundles menu.
>
> Thanks,
> Adam
> >
>

--~--~-~--~~~---~--~~
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 and favicon.ico problem

2008-12-17 Thread felix
you can put it directly in your http-vhosts.conf file


 ServerName crucial-systems.com
 DocumentRoot /home/crucial/crucial-stack/crucialwww
... etc...

Alias /favicon.ico "/home/crucial/crucial-stack/crucialwww/favicon.ico"

...

WSGIScriptAlias / /home/crucial/crucial-stack/crucial/crucial.wsgi



note that even though the document root appears to be mapped to the
crucialwww directory, in practice the WSGIScriptAlias / means that
everything is directed to django.

all image and css directories I also use Alias (before the WSGIScriptAlias)
to map those to the correct directories.

I used to do a lot of symlinks and juggling of my directories.  I'm
preferring this method now as its much easier to change and move things.


-fx


On Wed, Dec 17, 2008 at 6:31 PM, 3lancer.eu  wrote:

>
> HI,
>
> > I haven't bothered to try fixing it yet, but I wonder if a redirect
> > from /favicon.ico to /media/images/favicon.ico might solve that issue.
> >  If I get a chance I'll test it today, see if works.  Has anyone else
> > experimented with this?
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: MySpace clone using Django? Is it possible?

2008-12-20 Thread felix
oh for that you will need to use Fusebox


On Fri, Dec 19, 2008 at 7:41 PM, lekvar...@gmail.com wrote:

>
> Hi, I wanna know wich of the well known frameworks is the best choice
> for myspace-clone community website.
>
> CakePHP ? Zend Framework? Symfony?
> Django :)?
> RubyOnRails?
>
> or maybe
> Kohana? Prado? or something else?
>
> Is it better to use PHP or Ruby or Python? I will pay a webdesigner
> for this job, but I want to know which lang and framework is in your
> opinion the best for this kind of application.
> I expect about 10 000 or more unique visitors each day so I want to
> know words from You, the professionals.
>
> It is important that the user can change the css, like on myspace.com.
>
> Then I want to know if is it better to provide for users profile page
> this URL
> /I have 4 letters in my domain name./
> -
>
> username..com
>
> or
>
> .com/username
>
>
> thanks in advance
>
> >
>

--~--~-~--~~~---~--~~
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: Restricting add in the admin

2008-12-20 Thread felix
just a thought:

you might consider allowing multiple front page objects and having a way to
select the current one.
this could come in handy to switch what is currently the front page (or to
audition the new front page).

otherwise : create one using initial_data so that your application
automatically creates it
and then set the add permissions to false for everybody.  you can only edit
The One.
a super user could still add one, but don't set your client/end-user to
super user.
check on save and throw an error if you like.

-fx




On Fri, Dec 19, 2008 at 6:21 PM, Peter  wrote:

>
> >
> > >  What I was looking for was a global permission that could be set on a
> > >  model when it was defined which set
> > >  default permissions for 'staff' on the model (or even for superuser)
> > >  on that model.
> >
> > Why not just create another group?
>
> Because being a singleton (and not removable) should be, I think, an
> *attribute* of the
> class/model not of  a particular user or a group.
>
> Cheers, 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: SyncDB failure

2008-12-20 Thread felix
On Fri, Dec 19, 2008 at 2:29 PM, James PIC  wrote:

>
> On 12/17/08, Russell Keith-Magee  wrote:
> >
>


> >  A better solution would be to come up with a name munging scheme that
> >  guaranteed to give unique permission names that will always fit into
> >  the available space. 50 characters is plenty to establish a unique
> >  name; we already perform a similar munging with the names for database
> >  constraints.
>
> That would be much smarter indeed!



here, btw. is a bug I found, confirmed and submitted regarding that munging:
http://code.djangoproject.com/ticket/9253

the hash munging may vary depending on the OS you are on, and in my case on
the deployment server it overflowed MySQL's allowable constraint identifier
size.

just FYI

munging the constraint name is fine IMO, but I the the foreign keys to be
readable.

the easiest thing to do is 


> >  Of course, the simplest solution is for you to pick shorter class
> >  names, and for us to document the limitation.
>




Just for kidding:
> class Lot(Mandat, Bien, PourLocation, PourVente, LotAddresse,
>  AvecEquipementsAnnexes, Textes, Immeuble):
> It was that, or models with thousands of similar fields, high WTF/hour :)


just be thankful you aren't coding in german :)

--~--~-~--~~~---~--~~
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: SyncDB failure

2008-12-20 Thread felix
here's the exact ticket you are looking for:

http://code.djangoproject.com/ticket/1820



On Sat, Dec 20, 2008 at 2:19 PM, felix  wrote:

>
> On Fri, Dec 19, 2008 at 2:29 PM, James PIC  wrote:
>
>>
>> On 12/17/08, Russell Keith-Magee  wrote:
>> >
>>
>
>
>> >  A better solution would be to come up with a name munging scheme that
>> >  guaranteed to give unique permission names that will always fit into
>> >  the available space. 50 characters is plenty to establish a unique
>> >  name; we already perform a similar munging with the names for database
>> >  constraints.
>>
>> That would be much smarter indeed!
>
>
>

--~--~-~--~~~---~--~~
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: memory use in django database queries

2008-12-25 Thread felix
I don't have the answer to the cache question, but ...

you can of course use SomeModel.objects.values('value')

http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-fields

or get the db to sum(value) it (most efficient)

-fx




On Wed, Dec 24, 2008 at 6:42 PM, garyrob  wrote:

>
> I am getting the impression that when I do a django database query
> that iterates through all the rows of the table, django stores every
> model instance in memory.
>
> For instance, just doing
>
> sumValues = 0
> for someModel in SomeModel.objects.all():
> sumValues += someModel.value
> print sumValues
>
> can eat up gigabytes of memory if the table is large.
>
> But in this example, I don't have any need for the SomeModel instances
> that have already been processed once the value has been retrieved. So
> this is a huge amount of wasted memory.
>
> Is there any way to make django not behave this way? I.e., when
> iterating through a query request, I'd like to be able to tell django
> to just retrieve a row at a time from the database, and  release the
> memory that was used for previously-retrieved rows.
>
>
> >
>

--~--~-~--~~~---~--~~
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: Best practices for multiple sites

2009-01-12 Thread felix
I'm running 3 sites on a shared db right now.

I would say your option 2

I keep most of the functionality in the apps (shared),
each of those apps have views, so the views are certainly shared / not
duplicated

in my case each site is quite distinct and has specific models and views on
top of the shared content/models.
my main requirement has been differing permissions / visibility
similar to yours : I have a backdoor intranet for a group of people and then
2 public sites showing some of the content.

but even if you thought you would be 100% identical and have no need of a
separate project, you would find one day that you did need somewhere to put
a site specific form or view.

the only reason I can see to not have a project folder is if the sites were
created dynamically or very often and they really are clones and there won't
be any coding done per site.


initially I developed these 3 as separate databases and was quite pleased
that combining them was easy.

I could just add:

Posts
site =
models.ForeignKey(Site,editable=True,default=lambda:Site.objects.get_current().id)

Category
site = models.ForeignKey(Site,editable=True,default= lambda:
Site.objects.get_current().id)

to a model and that was it.  they kept separated.  these Posts and
Categories don't mix across sites.


the stuff that is shared are contact databases, Labels, Artists, Releases

the visibility is handled differently on each site.

on one site it only shows a Release if its in a collection ( featured
releases )

on another there is a  user - object - permission system:
  ObjectPermission.objects.has_perm("view",release,user)
  ObjectPermission.objects.has_perm("download",release,user)

so each user is granted permissions per object

I hope to get that app ready for sharing soon.  I'm finding it very useful.



here's a gotcha: if your settings.SITE_ID is other than 1 some tests will
fail.
the test runner always creates a Site object with id : 1
it looks like it was fixed and the bug has now regressed.


On Mon, Jan 12, 2009 at 11:39 PM, shacker  wrote:

>
> We're setting up both an intranet and a public site that will sit on
> top of the same database. The two sites will share much content, but
> will have different designs, different media, and different overall
> purposes. There won't be much in the way of truly shared views,
> despite the need for shared data (for example, students might enter
> their stories on the intranet, but stories will be displayed on the
> public site - data is shared, not the view).
>
> We're debating whether to :
>
> 1) Use the Django "Sites" framework, where the whole thing is one
> project with two settings files and two urls files.
>
> or
>
> 2) To build them as two separate projects pointing to the same
> database, with a set of shared apps between them.
>
> In other words, if the main point of the "Sites" framework is for view
> sharing, we may not need to use it in order to deploy multiple sites
> on a shared database.
>
> Which approach is considered best practice? Any gotchas either way we
> should be aware of before deciding on an architecture?
>
> Thanks,
> Scot
> >
>

--~--~-~--~~~---~--~~
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: Decoupling between projects and app in 4-part tutorial.

2009-01-13 Thread felix
this was for me also a slight trick to learn.  I got more from blog posts
than the docs
(and I love the django docs)

the trick is that your PYTHONPATH (and don't forget the python path of your
deployment server)
should point to the dir above your project dir and the dir above your apps
dir.


I have
echo $PYTHONPATH
/Users/crucial/Sites/gitpo.git/djapps:/Users/crucial/Sites/gitpo.git/pluggables

djapps
   app1
   app2
pluggables
   thirdpartyapp1
   thirdpartyapp2

site1
   manage.py
site2
   manage.py

site1www
   images


so in development when I run site1, due to PYTHONPATH I also have djapps and
pluggables in my path

from app1.models import *



(I agree keeping the intro tutorial very simple is best.
perhaps it could then link to a best practices of folder layout so that you
can grow
  when I try out a system I am really on a first date.
I don't want to know about the maintenance issues. )




On Sun, Jan 11, 2009 at 10:41 PM, dahpgjgamgan wrote:

>
> Hi,
>
> In the 4-part tutorial on Django's main site, there's a lot of advice
> on how to decouple apps and projects, but when I look at the import
> statements in most of the tutorial's files, it's always "from
> projectname.appname import ." - not very decoupled for me. Am
> I missing something, is there a good reason why those imports look
> like that and not simply "from appname... import ..."?
>
> 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: Django Continuous Integration

2009-01-13 Thread felix
On Tue, Jan 13, 2009 at 7:45 PM, mguthrie  wrote:

>
> Revision Control: How do you layout your development repository?  I'm
> using Subversion for my setup but would be interested in hearing what
> else others are using (Mercurial, Bazaar, Git, etc)



I have django and third party apps checked out via svn into my development
folder.
so I can update those when I want to.

then I git that whole stack

I push that to a (bare) git repos on one of my servers
(bare means that it isn't a working copy, its just the files, like an svn
server)

and use fab / fabric to do the deployment.

that means on my local machine:

fab pushpull

does a git push (from local checked in changes up to the repository)
does a git pull (from the respository on the remote server into my actual
deployment folder incidentally on the same server)
and then restarts apache


does the deployment.
fab is in alpha and is changing, but I like its direct simplicity.


later I will probably do different branches on the git stack that include /
exclude different sites / apps

so that whatever I'm deploying is just the code that that site (or cluster
of sites) needs

I'm still not completely at peace with this solution but it has worked quite
well so far.

-fx





>
>
> Packaging:  Django has an aversion to using setuptools and opts to
> stick with the basics in distutils.  What are you using for packaging
> your application?  What's the best way to deploy a Django project that
> would make it easy on the end user to install and configure?  I don't
> really care about providing individual apps.  I wish to deploy my
> application in it's entirety.  It would be nice if this could be
> worked into the development process.  Pylons and Turbogears seem to
> have a nice process setup using Paste and virtualenv that works well
> for the development and testing process.  Do Django users have
> something similar?
>
> Buildbot:  Do you use Buildbot or something similar for your Django
> development?  How does that work for you?  What other options are
> there that would work well?
>
> Versioning: How do you mark versions of your Django project?  Meaning,
> how can you create your Django app so it has a version that you can
> track within the application itself as well as for setting up
> upgrades, etc?  I can create something in __init__.py in the root of
> my project but how does that work with the SCM?  Since trunk is always
> in development it would make sense to have something in there.  Do you
> keep it is a tag or branch?  I'm new to this so hopefully I'm making
> sense.
>
> Migrations: What do you use to track database migrations?  I know of
> django-evolution, South and a few others but I really have no idea how
> these function and which is the most mature.  What do you have
> experience with?
>
> That's probably plenty for this post.  Sorry it's so long but this is
> difficult stuff and it's spread out across the internet.  Not to
> mention that it's not specific to Django development.
>
> I've recently worked with a Java developer and got a chance to see his
> development process and was really impressed.  Java seems to have more
> tools available that tie in nicely with each other for continuous
> integration.  He was using Trac, Buildbot, Unit testing (JUnit) and
> had scripts to deploy to a new server immediately.  It was pretty
> impressive and I would like to know if anyone has something similar
> setup for their Django projects.
>
> Thanks in advance for any input.
> >
>

--~--~-~--~~~---~--~~
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: Help with m2m relationships through intermediary tables

2009-01-14 Thread felix
open a shell with ./manage.py shell

from models import *

fetch one of your Authors (one that has a job already)

dir(author)

that will list all the ways you can poke at it.
always useful


you should see some way to access the AuthorNewspaper directly from the
Author object

to display a whole page of these positions you can fetch them directlly

AuthorNewspaper.objects.all()

an.author an.newspaper an.date


-felix
http://crucial-systems.com



On Mon, Jan 12, 2009 at 11:35 AM, Asif  wrote:

>
> I've created a few models that have m2m relationships with
> intermediary tables.  I'm storing some extra data in the fields of the
> intermediary tables.  For example, I have a model called Author and
> model called Newspaper that are related to each other through a model
> called AuthorNewspaper.  In AuthorNewspaper, I am storing the date for
> which that author joined the newspaper.
>
> I'd like to create a view that can display those dates and I can't
> seem to figure out a way to do it elegantly.  The only way I've
> figured out is by using the extra method to add a bunch SQL that
> includes the fields from the intermediary table.  Am I missing
> something really obvious?
>
> Thanks in advance for your help,
>
> Asif
>
> P.S. If you haven't figured out already, I'm a Django newbie.
>
> >
>

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



reverse not working with (r'^comments/(.*)', include('django.contrib.comments.urls')),

2008-09-07 Thread felix

This should be dirt simple, but isn't working:

main urls.py :
 (r'^comments/(.*)', include('django.contrib.comments.urls')),

comments.urls.py :

urlpatterns = patterns('django.contrib.comments.views',
url(r'^post/$',  'comments.post_comment',
name='comments-post-comment'),
  etc.

in the shell:

>>> from django.core.urlresolvers import reverse

# neither by the function
>>> reverse("django.contrib.comments.views.comments.post_comment")
Traceback (most recent call last):
  File "", line 1, in 
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/core/urlresolvers.py", line 252, in
reverse
*args, **kwargs)))
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/core/urlresolvers.py", line 241, in
reverse
"arguments '%s' not found." % (lookup_view, args, kwargs))
NoReverseMatch: Reverse for ''
with arguments '()' and keyword arguments '{}' not found.


# nor by named URL
>>> reverse('comments-post-comment')
Traceback (most recent call last):
  File "", line 1, in 
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/core/urlresolvers.py", line 252, in
reverse
*args, **kwargs)))
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/core/urlresolvers.py", line 241, in
reverse
"arguments '%s' not found." % (lookup_view, args, kwargs))
NoReverseMatch: Reverse for 'comments-post-comment' with arguments
'()' and keyword arguments '{}' not found.

by copying and pasting the comments/urls directly into my site's URLs,
the lookups work correctly.

today's update, django svn trunk
Revision: 8977

thanks for any help.
-f;lix

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Determining the type of object with model inheritance

2008-09-07 Thread felix

class Contact(models.Model):

content_type =
models.ForeignKey(ContentType,editable=False,null=True)

def save(self):
if(not self.content_type):
self.content_type =
ContentType.objects.get_for_model(self.__class__)
self.save_base()

def as_leaf_class(self):
content_type = self.content_type
model = content_type.model_class()
if(model == Contact):
return self
return model.objects.get(id=self.id)

note that this would reload the object from database.
if you merely want to find out what animal it is, then you can just
check animal.content_type

use a debug middleware footer so that you can check what queries are
actually performed.

http://www.djangosnippets.org/snippets/1031/


On Sep 7, 1:54 pm, dozo <[EMAIL PROTECTED]> wrote:
> I've run into the following problem with model inheritance, and I
> can't find a reasonable way to solve it:
>
> Let's say I have an Animal model, with a few subclasses: Lion, Tiger,
> Zebra and so on. The Animal model is not abstract, because I want to
> be able to, say, select all the animals in the database.
>
> So now I want to go over a collection of animals and determine whether
> each one is a Lion or a Tiger (or an Elephant, a Zebra and so on...)
>
> If I do this:
>     animals = Animal.objects.all()
> I get a list of objects of type Animal. Each one will have a .tiger
> attribute or a .lion attribute according to its subclass, so
> apparently it "knows" what subclass it belongs to. But I can find no
> way of determining its subclass in a generic manner.
>
> To clarify, I would like to be able to do something like this:
>
> animals = Animal.objects.all()
> for animal in animals:
>     animal_type = ...
>     print "I am a", animal_type
>
> and get:
>     I am a Zebra
>     I am a Lion
> etc.
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: reverse not working with (r'^comments/(.*)', include('django.contrib.comments.urls')),

2008-09-07 Thread felix

let me just explain the problem more clearly:

reverse is failing to match a url when an application's urls are
included into the site urls

match fails when using a named url and with the function name fully
specified.

reverse('comments-post-comment')
reverse("django.contrib.comments.views.comments.post_comment")

this also means that the contrib comments app cannot work at all,
because any of its methods that use reverse fail.



On Sep 7, 3:18 pm, felix <[EMAIL PROTECTED]> wrote:
> This should be dirt simple, but isn't working:
>
> main urls.py :
>  (r'^comments/(.*)', include('django.contrib.comments.urls')),
>
> comments.urls.py :
>
> urlpatterns = patterns('django.contrib.comments.views',
>     url(r'^post/$',          'comments.post_comment',
> name='comments-post-comment'),
>   etc.
>
> in the shell:
>
> >>> from django.core.urlresolvers import reverse
>
> # neither by the function>>> 
> reverse("django.contrib.comments.views.comments.post_comment")
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
> python2.5/site-packages/django/core/urlresolvers.py", line 252, in
> reverse
>     *args, **kwargs)))
>   File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
> python2.5/site-packages/django/core/urlresolvers.py", line 241, in
> reverse
>     "arguments '%s' not found." % (lookup_view, args, kwargs))
> NoReverseMatch: Reverse for ''
> with arguments '()' and keyword arguments '{}' not found.
>
> # nor by named URL>>> reverse('comments-post-comment')
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
> python2.5/site-packages/django/core/urlresolvers.py", line 252, in
> reverse
>     *args, **kwargs)))
>   File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
> python2.5/site-packages/django/core/urlresolvers.py", line 241, in
> reverse
>     "arguments '%s' not found." % (lookup_view, args, kwargs))
> NoReverseMatch: Reverse for 'comments-post-comment' with arguments
> '()' and keyword arguments '{}' not found.
>
> by copying and pasting the comments/urls directly into my site's URLs,
> the lookups work correctly.
>
> today's update, django svn trunk
> Revision: 8977
>
> thanks for any help.
> -f;lix
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: reverse not working with (r'^comments/(.*)', include('django.contrib.comments.urls')),

2008-09-09 Thread felix


ah, got it. thanks malcolm !

just to think it out further :

now I understand that

(r'^something/(?P[-\w]+)/', include('some.where.urls')),

would pass the captured param to to all the urls in the included
urls.py

I think I was copying from this:
# Uncomment the next line for to enable the admin:
(r'^admin/(.*)', admin.site.root),

and in that case the rest of the url is passed into the AdminSite.root
function :

def root(self, request, url):


I've had the most hold-ups so far due to configuring the urls.
named urls has helped significantly.



On Sep 8, 7:23 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2008-09-07 at 06:18 -0700, felix wrote:
> > This should be dirt simple, but isn't working:
>
> > main urls.py :
> >  (r'^comments/(.*)', include('django.contrib.comments.urls')),
>
> This pattern says you want to *capture* anything after the "comments/"
> piece. So calling reverse with no parameters won't match this (you must
> pass the correct parameters for the capturing groups). Maybe you don't
> really want to capture that, in which case you could write either
>
>         ^comments/.*
>
> or
>
>         ^comments/(?:.*)
>
> The former would be obviously shorter.
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Customized ManyToMany in Admin

2008-09-12 Thread felix


now this will hit the database for each item in the select, to go
fetch the language object to get the language name.

so for extra credit, where do we add a select_related() for the
widget ?



On Sep 12, 7:43 pm, TiNo <[EMAIL PROTECTED]> wrote:
> Probably more like:
> def __unicode__(self):
>     return u'%s | %s' % (self.title, self.language.name)
>
> because self.language is the language object, not the name (or title)
> string.
>
> On Fri, Sep 12, 2008 at 7:32 PM, phred78 <[EMAIL PROTECTED]> wrote:
>
> > Oh, I see!
> > You mean something like
>
> > def __unicode__(self):
> >                return self.title + ' | ' + self.language
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



apache PythonPath problem + solution

2008-09-28 Thread felix


Hello,
I wrote up this big problem to ask you kind folx for help, and in the
course of that I figured it out.
But I'm still going to post it just to share the experience.

I have an apache config problem, maybe someone can help.

I am setting up the production version on my site :

apache conf


PythonPath "['/home/crucial/gitpo/djapps','/home/crucial/gitpo/
pluggables','/home/crucial/gitpo/sustain'] + sys.path"

Order allow,deny
Allow from all
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE sustain.settings_sus_live
PythonOption django.root /sustain/
PythonDebug On

PythonAutoReload On




the files:

/home/crucial/gitpo/sustain
settings_sus_live.py
urls.py
etc. ...

This gives :
ImportError: Could not import settings 'sustain.settings_sus_live' (Is
it on sys.path? Does it have syntax errors?): No module named
sustain.settings_sus_live


The python path appears to be correct, right ? (hint ... no )


But if I change:
SetEnv DJANGO_SETTINGS_MODULE sustain.settings_sus_live
to
SetEnv DJANGO_SETTINGS_MODULE settings_sus_live

django will run !

but then it fails (with that soothing django exception display):

No module named sustain.urls

it does show that the python path is correct:

Python Path: ['/home/crucial/gitpo/djapps', '/home/crucial/gitpo/
pluggables', '/home/crucial/gitpo/sustain', etc

The solution is that '/home/crucial/gitpo/sustain' is not the
immediate PARENT of the sustain module, it IS the sustain module

'/home/crucial/gitpo/' is the correct path to add.  that's the
immediate parent folder of the module.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: apache PythonPath problem + solution

2008-09-28 Thread felix


well yes, I have to admit that I've been doing quite a bit of django
and I hadn't yet realized that it must always be the direct parent.

but in this case I was kind of just staring at the problem and not
seeing it.

and I think my dev environment python path is too loose or something.
now that its ready to be deployed I'm getting all kinds of differences
in the way modules are resolved.

I would have to say these issues have been the largest time wasters
for me.

when you get a 404  you then see a very helpful display of all the url
patterns.

maybe when a module fails to be found it could print a tree of
reachable modules.
(could be a lot)
you would have to isolate it to an area of interest.

say urls.py fails to resolve,
so since it only has one level, list out all top level modules
then I would have seen each of my djapps, each of my pluggables, but
would have noticed that all the files in the root level of my website
were missing and only the next level down were visible.



On Sep 29, 2:44 am, Graham Dumpleton <[EMAIL PROTECTED]>
wrote:
> Your solution was what the documentation tells you to do.
>
> I still contend that the documentation could better explain this, but
> when I pushed that in the past others felt it was clear enough
> already. Despite that, people still have problems, that or people
> don't actually read the documentation. :-)
>
> Graham
>
> On Sep 29, 10:39 am, felix <[EMAIL PROTECTED]> wrote:
>
> > Hello,
> > I wrote up this big problem to ask you kind folx for help, and in the
> > course of that I figured it out.
> > But I'm still going to post it just to share the experience.
>
> > I have an apache config problem, maybe someone can help.
>
> > I am setting up the production version on my site :
>
> > apache conf
>
> > 
> >     PythonPath "['/home/crucial/gitpo/djapps','/home/crucial/gitpo/
> > pluggables','/home/crucial/gitpo/sustain'] + sys.path"
>
> >     Order allow,deny
> >     Allow from all
> >     SetHandler python-program
> >     PythonHandler django.core.handlers.modpython
> >     SetEnv DJANGO_SETTINGS_MODULE sustain.settings_sus_live
> >     PythonOption django.root /sustain/
> >     PythonDebug On
>
> >     PythonAutoReload On
>
> > 
>
> > the files:
>
> > /home/crucial/gitpo/sustain
> >         settings_sus_live.py
> >         urls.py
> >         etc. ...
>
> > This gives :
> > ImportError: Could not import settings 'sustain.settings_sus_live' (Is
> > it on sys.path? Does it have syntax errors?): No module named
> > sustain.settings_sus_live
>
> > The python path appears to be correct, right ? (hint ... no )
>
> > But if I change:
> >     SetEnv DJANGO_SETTINGS_MODULE sustain.settings_sus_live
> > to
> >     SetEnv DJANGO_SETTINGS_MODULE settings_sus_live
>
> > django will run !
>
> > but then it fails (with that soothing django exception display):
>
> > No module named sustain.urls
>
> > it does show that the python path is correct:
>
> > Python Path: ['/home/crucial/gitpo/djapps', '/home/crucial/gitpo/
> > pluggables', '/home/crucial/gitpo/sustain', etc
>
> > The solution is that '/home/crucial/gitpo/sustain' is not the
> > immediate PARENT of the sustain module, it IS the sustain module
>
> > '/home/crucial/gitpo/' is the correct path to add.  that's the
> > immediate parent folder of the module.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: unable to resolve URL in template

2008-09-28 Thread felix

is it actually called url.py or urls.py ?

maybe you don't have the urls file in there that you are assuming you
do.

try inserting an egregious syntax error in there just to see if its
even being loaded.


On Sep 27, 8:21 pm, Chuck Bai <[EMAIL PROTECTED]> wrote:
> In my url.py, I define the root my site is like this:
> urlpatterns = patterns('',
>     url(r'^$', 'views.index', name="index"),
>     ...)
>
> in my template, I have a link defined as follows:
> Home
>
> I got this error:
>
>   TemplateSyntaxError at /
>
> Home
>
> Caught an exception while rendering: Reverse for 'testproject.index' with 
> arguments '()' and keyword arguments '{}' not found.
>
> It seems that Django can not resolve the URL index. Can anyone point to
> me what is wrong and how to fix 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: relating auth user to company model

2008-09-29 Thread felix


since you can't add fields to User, you should add it to Company

Company
employees = models.ManyToManyField(User,editable=False)

# a user can actually be in several companies
user.company_set.all()

this is because the Company model is allowed to contribute to the User
class

company.employees

by making editable=False it will not show up in the admin
because you might have too many users, it would get too messy.

the other thing I would suggest is using a Profile or Person class for
the User and associating that with the Company

this is what I do.  a Person may not or may not (yet) have a user
account.  that can be created on demand later.




On Sep 29, 6:58 am, MilesTogoe <[EMAIL PROTECTED]> wrote:
> I've seen the docs on how to relate the user with a 1-1 relationship (ie
> profile) but is there a way to have another model relate in a 1:many  
> (ie one company with many users) - this would require user to have a
> company field.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



egregiously long model names, hashes, constraints

2008-09-29 Thread felix

syncdb fails on my deployment server (mysql 5.0.67 on ubuntu) with :

  File "./manage.py", line 11, in 
execute_manager(settings)
...
_mysql_exceptions.OperationalError: (1059, "Identifier name
'releasesnewsletter_id_refs_abstractmailing_ptr_id_62770683bbc11c0b'
is too long")

the same codebase succeeds on my development server (mysql 5.0.51a on
OS X)

its a contraint being added.

ubuntu:
ALTER TABLE `website_releasesnewsletter_additional_recipients` ADD
CONSTRAINT
releasesnewsletter_id_refs_abstractmailing_ptr_id_14a73856b276acd4
FOREIGN KEY (`releasesnewsletter_id`) REFERENCES
`website_releasesnewsletter` (`abstractmailing_ptr_id`);

mac:
ALTER TABLE `website_artistnewsletter_additional_recipients` ADD
CONSTRAINT artistnewsletter_id_refs_abstractmailing_ptr_id_4326e0be
FOREIGN KEY (`artistnewsletter_id`) REFERENCES
`website_artistnewsletter` (`abstractmailing_ptr_id`);

the ticket I guess is here:
http://code.djangoproject.com/ticket/1820

so the constraint generates a hash now, and the mac happened to get a
shorter hash.
egregiously long table name + hash = TILT !


Besides renaming the class with a shorter name, I could just use a
shorter db_table name

BUT in all cases in django it builds the related fields using the
class name to lower, not the db_table name.
that could/should be changed I think.  oh that would be really
backwards incompatible, wouldn't it.

even though AbstractMailing uses a db_table of AbsMail

CREATE TABLE `AbsMail` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`subject` varchar(100) NOT NULL,
`from_email` varchar(75) NOT NULL,
`status` varchar(32) NOT NULL,
`created_on` datetime NOT NULL,
`created_by_id` integer NOT NULL,
`sent_on` datetime NULL,
`content_type_id` integer NULL
)

the subclasses still use the class name:

CREATE TABLE `mailings_contactmailing` (
`abstractmailing_ptr_id` integer NOT NULL PRIMARY KEY,
`body` longtext NOT NULL
);

ALTER TABLE `mailings_contactmailing` ADD CONSTRAINT
abstractmailing_ptr_id_refs_id_5468a0a0 FOREIGN KEY
(`abstractmailing_ptr_id`) REFERENCES `AbsMail` (`id`);


the case of related fields its quite easy to offer

related_field="%s(db_table)_rel"

just offer it both the class and the db_table :

if not cls._meta.abstract and self.rel.related_name:
self.rel.related_name = self.rel.related_name % {'class':
cls.__name__.lower(),'db_table':cls._meta.db_table}


inheritance could be done the same way











--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using forloop counter to index into a query set

2008-09-29 Thread felix

it might be easiest to write a custom tag there

{% vendor_of_product product forloop.counter %}

is product an array ?


On Sep 30, 2:31 am, SnappyDjangoUser <[EMAIL PROTECTED]> wrote:
> Hi Folks,
>
> How can I use a forloop counter to index into a query set as in the
> example below?
>
> (I know this code does not work, but I want to do something of the
> sort):
>
> {% for form in quote_product_formset.forms %}
>     
>         {{ product.(forloop.counter).Vendor }}
>     
>
>     {{ form }}
> {% endfor %}
>
> (in the above case, Vendor is a field in product. So if I want to
> access the first product when forloop counter is 1, the variable would
> expland to "{{ product.1.Vendor }}")
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



accessing the http conf setting: PythonOption django.root

2008-09-29 Thread felix

I'm trying to fix some urls in my templates

these are urls linking to the admins site that cannot use the {% url
%} tag or reverse.

these urls are "absolute" in that they don't use reverse (which is
preferable, god bless django)
but the admin urls are not addressable by name, so I link to them
"absolute"ly

but but if you have installed your django not on the root of your
website:


...
PythonOption django.root /sustain
...


questions:

then how can I access this django.root var  in python code  ?
what in general are these PythonOptions and where do they get put ?


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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ManyToMany relationship on self through other table

2008-09-30 Thread felix

are you actually getting a runtime error or an error when trying to
syncdb ?


On Sep 30, 10:52 am, chris <[EMAIL PROTECTED]> wrote:
> Hi there,
>
> Just starting to use django, so forgive me if this has been answered
> before (a quick search at djanog-search did not turn up something
> useful).
> What I am trying to do is similar to this 
> (fromhttp://www.djangoproject.com/documentation/models/m2m_recursive/):
> 
> from django.db import models
>
> class Person(models.Model):
>     name = models.CharField(max_length=20)
>     friends = models.ManyToManyField('self')
>     idols = models.ManyToManyField('self', symmetrical=False,
> related_name='stalkers')
>
> 
> The difference is that I wanted to add additional information to the
> link, so need a separate table.  According to the documentation 
> herehttp://docs.djangoproject.com/en/dev/topics/db/models/#intermediary-m...
> this is done with the additional through argument, so I get:
>
>     idols = models.ManyToManyField('self', symmetrical=False,
> related_name='stalkers' through="Relationship")
>
> and then define
>
> class Relationship(models.Model):
>     source = models.ForeignKey(Person, related_name="%
> (class)s_related_source")
>     target = models.ForeignKey(Person, related_name="%
> (class)s_related_target")
>     desc = models.CharField(max_length=20)
>
> However, when I do this, I get a runtime error complaining about the
> two foreign keys.
>
> I wonder how to solve this problem?
>
> Any help appreciated,
>
> Chris
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: accessing the http conf setting: PythonOption django.root

2008-09-30 Thread felix


ah right, WSGI requests won't have this django_root environ var.

so its the completely non-intuitive SCRIPT_NAME
(I know, its the server that refers to it as this)

this works :

{% django_root %}

@register.tag
def django_root(parser,token):
return DjangoRootNode()

class DjangoRootNode(template.Node):

def render(self, context):
return context['request'].META['SCRIPT_NAME']



thanks Graham



On Sep 30, 4:28 am, Graham Dumpleton <[EMAIL PROTECTED]>
wrote:
>
> But when you do go looking, don't think that accessing 'django.root'
> from mod_python PythonOption dictionary is the correct way. Look for
> 'SCRIPT_NAME' instead, how it is set and how you might access it. By
> using 'SCRIPT_NAME' you will be portable to other hosting mechanisms
> for Django as well.
>
> Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ManyToMany relationship on self through other table

2008-09-30 Thread felix


post the traceback.  I may not be able to help you since I haven't
tried to do person-to-person at all.

it might be simpler to just do Friends and Idols (without using
through and without friends and idols being fields on Person)

and then add methods to Person that fetch those relationships.
or better, add methods to Friends or Idols to fetch them for a given
person.
this way also you can add more of types of relationships or deprec
some of them later without messing with Person.

person.friends_set should be there auto-magically anyway even without
the friends field on Person

and you probably don't want people to edit a Person on a form anyway
and select from a long list.
it would be an "add" or something, right ?




On Sep 30, 1:31 pm, chris <[EMAIL PROTECTED]> wrote:
> On Sep 30, 8:07 pm, felix <[EMAIL PROTECTED]> wrote:
>
> > are you actually getting a runtime error or an error when trying to
> > syncdb ?
>
> syncdb  works fine, but then I get a runtime error when I want to edit
> such a record in the admin interface.  The traceback complains about
> the two foreign keys in the Relationship table.
> BTW, I forgot to say that this is using the 1.0 release of django.
>
> Chris
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: overwrite get_absolute_url /contrib/auth/User

2008-09-30 Thread felix


and related to this:

if your django site needs to be running at someplace besides '/' (say
for a beta installation or a subsite)
then permalinks and reverse will work correctly,
but user.get_absolute_url() will not
it will return

/user/username/
rather than
/subsite/user/username/

so,

def _user_get_absolute_url(user):
from django.core.urlresolvers import reverse
return reverse('account',kwargs={'username':user.username})

ABSOLUTE_URL_OVERRIDES = {
'auth.user' : _user_get_absolute_url
}



On Sep 16, 11:34 pm, Sven Richter <[EMAIL PROTECTED]> wrote:
> On Tue, 2008-09-16 at 15:11 -0300, Eduardo O. Padoan wrote:
> > On Tue, Sep 16, 2008 at 2:59 PM, Sven Richter <[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > i am wondering if the "users" path inget_absolute_url
> > > from the User class is hardcoded?
> > > I mean this line:
> > > return "/users/%s/" % urllib.quote(smart_str(self.username))
>
> > > I have the problem that all my profiles want to reside
> > > under /profile/username and not /users/username.
>
> > > Can i subclass this Model and overwrite the function
> > > somehow?
> > > Or is there another way to get my profiles path
> > > without a dirty hack?
>
> > Jannis Leidel have written about it:
> >http://jannisleidel.com/2008/08/easy-overrides-absolute-urls-reusable...
>
> Thank you, this pointed me into the right direction.
> Just in case somebody is interested in the solution.
>
> In the settings file of the project you have to define the option:
> ABSOLUTE_URL_OVERRIDES = {
>         'auth.user' : lambda o:'/profile/%s/' % o.username,
>
> }
>
> to overwrite theget_absolute_urlfunction.
> This works for any installed model in the project.
>
> Docs can be found 
> here:http://docs.djangoproject.com/en/dev/ref/settings/#absolute-url-overr...
>
> Greetings
> Sven
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using forloop counter to index into a query set

2008-09-30 Thread felix


malcom is suggesting this:

def view(request):
blah blah blah
...
zipped = []
for p in products:
  v = find the vendor for this product
  zipped.append( ( p, v) ) # add them as a tuple

   # or more pythonically if its easy to find your vendor:
   zipped = [ (p, vendor for product) for p in products ]
   context = { 'products': zipped }


{% for product, vendor in products %}
  {{product}} {{vendor}}
{% endfor %}





On Sep 30, 5:05 pm, SnappyDjangoUser <[EMAIL PROTECTED]> wrote:
> Hi Malcolm,
>
> You suggested:
>
> > set up the data structures
> > you pass to your view a bit differently so that you can loop over the
> > forms and the products simultaneously (that is, pull apart the formset
> > forms and zip them together with the product entries in the view).
>
> This is exactly what I like to do!  I am still a bit confused on exact
> implementation, however, because I have not found a way in Django to
> loop through 2 structures at once in a template.  The forloop.counter
> seems that it is mostly used for printing the iteration through the
> loop (not for indexing) and the "for loop" tag in Django is built only
> to iterate through one structure at a time.  Do you have any examples
> how how to loop through 2 strucutres simultaneously?
>
> Thanks!
>
> -Brian
>
> On Sep 30, 12:10 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
> wrote:
>
> > On Mon, 2008-09-29 at 17:31 -0700, SnappyDjangoUser wrote:
> > > Hi Folks,
>
> > > How can I use a forloop counter to index into a query set as in the
> > > example below?
>
> > > (I know this code does not work, but I want to do something of the
> > > sort):
>
> > > {% for form in quote_product_formset.forms %}
> > >     
> > >         {{ product.(forloop.counter).Vendor }}
> > >     
>
> > >     {{ form }}
> > > {% endfor %}
>
> > > (in the above case, Vendor is a field in product. So if I want to
> > > access the first product when forloop counter is 1, the variable would
> > > expland to "{{ product.1.Vendor }}")
>
> > You can't do indirect variable references like this in Django's
> > templating language. The reasoning is that it ends up complicating the
> > template structure when you wander down that path. Instead, factor it
> > out into a template tag (that can be passed the current context, so it
> > will have access to the forloop counter) or set up the data structures
> > you pass to your view a bit differently so that you can loop over the
> > forms and the products simultaneously (that is, pull apart the formset
> > forms and zip them together with the product entries in the view).
>
> > Usually the second approach works a bit more nicely, but either is
> > possible.
>
> > 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: egregiously long model names, hashes, constraints

2008-09-30 Thread felix


whoops, you are right. those weren't the same tables.
two with the exact same tables are posted in the ticket:

http://code.djangoproject.com/ticket/9253



On Sep 30, 3:23 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:

> Please open a new ticket about this. Looks like there is an assumption
> in the code that hash() will return things of a certain length and that
> isn't necessarily correct.
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using forloop counter to index into a query set

2008-09-30 Thread felix



On Sep 30, 9:36 pm, SnappyDjangoUser <[EMAIL PROTECTED]> wrote:
>  In the example
> above you assume that both p and v belong to products.  

I just put them into a combined array called "products"


> In my case,
> that is not the case.  I have a queryset of products that contains the
> vendor name, model name and model number.  I also have a formset
> containing forms.  I am trying to combine these 2 lists of objects
> into the tuple so I can iterate over both in the template.

I don't know how the forms are indexed.

but I would suggest iterating through the product queryset in the
view,
and storing each result in a dict indexed by id.  or look at queryset
in_bulk

then when building the tuples you can look up the vendor or product or
whatever it is in the dict.




another trick that I've done recently is to create a quick class

def view(request):
  # this class just exists for use in this view
  class Combo(object):
def __init__(self,form,product):
 self.form = form
 self.product = product

then instead of zipping together tuples, you make a list of these
Combos
and pass those in.
{{ combo.form }}
{{ combo.product }}

then I can add methods for things that I will need in that specific
view.
its much simpler than writing a template_tag.




>
>     # or more pythonically if its easy to find your vendor:
>     zipped = [ (form, << NEED HELP HERE product_queryset>>) for form
> in formset.forms ]
>     context = { 'products': zipped }
>
>  {% for form, product in products %}
>    {{product.vendor}} {{product.model_name}} {{product.model_num}}
> {{form}}
>  {% endfor %
>
> Any suggestions?
>
> On Sep 30, 9:45 am, felix <[EMAIL PROTECTED]> wrote:
>
> > malcom is suggesting this:
>
> > def view(request):
> >     blah blah blah
> >     ...
> >     zipped = []
> >     for p in products:
> >       v = find the vendor for this product
> >       zipped.append( ( p, v) ) # add them as a tuple
>
> >    # or more pythonically if its easy to find your vendor:
> >    zipped = [ (p, vendor for product) for p in products ]
> >    context = { 'products': zipped }
>
> > {% for product, vendor in products %}
> >   {{product}} {{vendor}}
> > {% endfor %}
>
> > On Sep 30, 5:05 pm, SnappyDjangoUser <[EMAIL PROTECTED]> wrote:
>
> > > Hi Malcolm,
>
> > > You suggested:
>
> > > > set up the data structures
> > > > you pass to your view a bit differently so that you can loop over the
> > > > forms and the products simultaneously (that is, pull apart the formset
> > > > forms and zip them together with the product entries in the view).
>
> > > This is exactly what I like to do!  I am still a bit confused on exact
> > > implementation, however, because I have not found a way in Django to
> > > loop through 2 structures at once in a template.  The forloop.counter
> > > seems that it is mostly used for printing the iteration through the
> > > loop (not for indexing) and the "for loop" tag in Django is built only
> > > to iterate through one structure at a time.  Do you have any examples
> > > how how to loop through 2 strucutres simultaneously?
>
> > > Thanks!
>
> > > -Brian
>
> > > On Sep 30, 12:10 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
> > > wrote:
>
> > > > On Mon, 2008-09-29 at 17:31 -0700, SnappyDjangoUser wrote:
> > > > > Hi Folks,
>
> > > > > How can I use a forloop counter to index into a query set as in the
> > > > > example below?
>
> > > > > (I know this code does not work, but I want to do something of the
> > > > > sort):
>
> > > > > {% for form in quote_product_formset.forms %}
> > > > >     
> > > > >         {{ product.(forloop.counter).Vendor }}
> > > > >     
>
> > > > >     {{ form }}
> > > > > {% endfor %}
>
> > > > > (in the above case, Vendor is a field in product. So if I want to
> > > > > access the first product when forloop counter is 1, the variable would
> > > > > expland to "{{ product.1.Vendor }}")
>
> > > > You can't do indirect variable references like this in Django's
> > > > templating language. The reasoning is that it ends up complicating the
> > > > template structure when you wander down that path. Instead, factor it
> > > > out into a template tag (that can be passed the current context, so it
> > > > will have access to t

Re: ManyToMany relationship on self through other table

2008-10-01 Thread felix


Exception Value:  has more
than 1 ForeignKey to 

hmm.  I'm not sure.
you might be able to get it to work by fudging something or other.

but when it gets complicated like this, and it gets complicated for
django's ORM, then I think its better to rearrange the approach.



On Oct 1, 2:18 pm, chris <[EMAIL PROTECTED]> wrote:
> Dear Felix,
>
> Thanks for following up on this.  I put the traceback up 
> here:http://paste.pocoo.org/show/86707/
>
> I will try to follow your advice to work around the error and define
> the tables differently, since you are right about the way this should
> work in the admin interface.   But I still think this is a bug,
> insofar as it does not work the way it is described in the docs.
>
> All the best,
>
> Chris
>
> On Sep 30, 9:12 pm, felix <[EMAIL PROTECTED]> wrote:
>
> > post the traceback.  I may not be able to help you since I haven't
> > tried to do person-to-person at all.
>
> > it might be simpler to just do Friends and Idols (without using
> > through and without friends and idols being fields on Person)
>
> > and then add methods to Person that fetch those relationships.
> > or better, add methods to Friends or Idols to fetch them for a given
> > person.
> > this way also you can add more of types of relationships or deprec
> > some of them later without messing with Person.
>
> > person.friends_set should be there auto-magically anyway even without
> > the friends field on Person
>
> > and you probably don't want people to edit a Person on a form anyway
> > and select from a long list.
> > it would be an "add" or something, right ?
>
> > On Sep 30, 1:31 pm, chris <[EMAIL PROTECTED]> wrote:
>
> > > On Sep 30, 8:07 pm, felix <[EMAIL PROTECTED]> wrote:
>
> > > > are you actually getting a runtime error or an error when trying to
> > > > syncdb ?
>
> > > syncdb  works fine, but then I get a runtime error when I want to edit
> > > such a record in the admin interface.  The traceback complains about
> > > the two foreign keys in the Relationship table.
> > > BTW, I forgot to say that this is using the 1.0 release of django.
>
> > > Chris
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Custom fields (a repost)

2008-10-01 Thread felix


did you look through this:
http://www.djangosnippets.org/snippets/1097/

which is similar

> Now this is where I lose the plot:
> a. How to get it to validate. (clean and co.)

when you select the desired whatever it should put it into the form's
hidden field as an id
or text field
so that's what should be cleaned.

> b. How to get it to save an author object on form.save()

the form probably doesn't need to know about the particulars of the
widget

the Field cleans it (just to be safe)

>
> I am going to re-code today without using modelForms because I think hooking
> into that voodoo is too complex for my light-weight brain.

yes, that twists my brain too


On Oct 1, 10:22 am, Donn <[EMAIL PROTECTED]> wrote:
> Hi,
> I asked a little earlier, but this is a busy list and perhaps my post was too
> obscure. Here is an edited repost in the hopes of catching someone who can
> help out:
>
> I am trying to create a custom field (and/or widget) that 'looks up' a foreign
> key relation -- i.e. lists the other table and allows a pick of an item.
>
> It's about books and authors.
>
> 1. A 'book' has a title (string) and an author (foreign key).
> 2. I use a ModelForm from the model.
> 3. I want the 'author' form-control to look like this:
> Author:__ [click here to choose or add an author]
> 4. When you click the link it opens a div.
> 5. The div shows all the authors (and has an add form)
> 6. When you click on an author it fetches the pk from the link (all done with
> jquery)
> 7. It then (should) leave the control something like:
> Author:38 Bear, Greg [click here to ...]
>
> Step 3 is a problem. I have tried various combinations of things. A new field
> type, a new widget etc. The other steps (bleev it or not) are working!
>
> Now this is where I lose the plot:
> a. How to get it to validate. (clean and co.)
> b. How to get it to save an author object on form.save()
>
> I am going to re-code today without using modelForms because I think hooking
> into that voodoo is too complex for my light-weight brain. I still hope for a
> few tips tho!
>
> \d
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Boosting your productivity when debugging Django apps

2008-10-06 Thread felix


yes, I get this all the time.
the input that I type isn't echoed to the screen/output but it does
work.
its really annoying.

has anyone figured out why or if there's a cure ?

otherwise I love using pdb, its invaluable.

On Aug 22, 9:33 pm, Tim Chase <[EMAIL PROTECTED]> wrote:
>
>     importpdb;pdb.set_trace()
>
>  The only trouble I've
> had is that something in the mix of dev-server + screen +pdb
> occasionally gets confused and I losepdboutput (it sits waiting
> for input, but the output vanishes).  Usually this happens to me
> when I've enteredpdb, resumed running, and then fall back intopdb.  Not 100% 
> of the time, and just restarting the dev-server is
> usually enough to give it the kick it needs.
>
> -tim
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



bug?: get_%s_display on CharField with choices (select field)

2008-10-09 Thread felix

bug?: get_%s_display on CharField with choices (select field)

I think I found a bug.

I'm using a select input type widget by passing in 'choices' to a
CharField

given:

class ReleaseFeedback(models.Model):

RATINGS = ( (1,'*'),(2,'**'),(3,'***'),(4,''),(5,'*') )

rating = models.CharField(choices =
RATINGS,max_length=4,blank=True)


rf = ReleaseFeedback(rating=u'4')

# direct access returns the db contents which is a string with the
key :
rf.rating
u'4'

it looks like we should get this automagically added method:

rf.get_rating_display()

which should return the display value, right ?

# but that also returns just the key
(Pdb) rf.get_rating_display()
u'4'


I think the problem would be in here, but I haven't yet unscrambled
it.

Am I correct that this is incorrect ?

db.models.fields.__init__.py

in class Field
...
   def contribute_to_class(self, cls, name):
   self.set_attributes_from_name(name)
   cls._meta.add_field(self)
   if self.choices:
   setattr(cls, 'get_%s_display' % self.name,
curry(cls._get_FIELD_display, field=self))





--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: bug?: get_%s_display on CharField with choices (select field)

2008-10-10 Thread felix



On Oct 10, 3:08 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> > I think I found a bug.
> You have, but it's in your code, not Django. :-)

brilliant :)  yeah I wasn't entirely sure.  it smelled like a bug.

> If you look at ReleaseFeedback.get_rating_display at the
> interactive prompt, you would see something like  ReleaseFeedback._curried> .

yeah I drilled down the code that generates the method but couldn't
yet figure it all out.

thanks malcolm !


>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Why does MySql gives warning? Incorrect string value: '\xE6\x9D\xB1\xE8\xA8\xBC...' for column 'title' at row 1

2008-10-12 Thread felix


thanks too for this.

rather than alter the table manually of course, it should have been
created correctly the first time.

mysql will create new tables with the character encoding of the
database.

you can set that this way:

alter database cruxxial_md CHARACTER SET = utf8;

now tables created with syncdb will have the correct encoding.

mysql will create new DATABASES with the charset that was used to
start the server

mysqld --character-set-server=utf8;

which is often out of our control on hosted environments, or even when
using handy os x control panels to start the db.

so I guess a tip is : when you create the database, make sure to alter
the charset before running syncdb.

but what does the unittest runner do ?? (since it creates its own
database)

it also creates a latin1 db:

CREATE TABLE `website_releasefeedback` (
...
) ENGINE=MyISAM DEFAULT CHARSET=latin1


I wonder if django should create all tables with UTF-8 regardless of
how the db is configured.




On Oct 6, 11:14 am, tamonash <[EMAIL PROTECTED]> wrote:
> Thanks Malcolm,
> You solved my problem. These tables were something that I was using
> from a previous application so all the mess..
>

> mysql> alter table ac_project_messages modify title varchar(100)
> character setutf8default NULL;
> Query OK, 81 rows affected (0.20 sec)
> Records: 81  Duplicates: 0  Warnings: 0
>
> mysql> alter table ac_project_messages modify text text character setutf8;
> Query OK, 81 rows affected (0.05 sec)
> Records: 81  Duplicates: 0  Warnings: 0
>
> And WOW!! it worked. 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Possible pug with Model inheritence - Inserts instead of Update

2008-10-12 Thread felix


well this is interesting and curious what you are trying to do.
why are you trying to do this self.id= None ?

what is the real world purpose ?  can you give a non abstract
example ?

in any case since Bar is a subclass of Foo there are two database
tables.
you set Bar id to None,
but the object still has a Foo ptr id, so ultimately there is still
only one object.
that is, I think, the primary key that is accessed when using
Bar.objects.all()

really, you have broken it by this self.id = None,
so I would expect more problems



On Oct 12, 9:16 am, shabda <[EMAIL PROTECTED]> wrote:
> My models.py
>
> class Foo(models.Model):
>     name = models.CharField(max_length = 100)
>
>     def save(self):
>         self.id = None
>         super(Foo, self).save()
>
> class Bar(Foo):
>     created = models.DateTimeField(auto_now_add = 1)
>
> This gives me,
>
> In [1]: from djcalendar.models import Foo
>
> In [2]: shabda  = Foo(name = 'Shabda')
>
> In [3]: shabda.save()
>
> In [4]: Foo.objects.all()
> Out[4]: []
>
> In [5]: shabda.name = 'Shabda Raaj'
>
> In [6]: shabda.save()
>
> In [7]: Foo.objects.all()
> Out[7]: [, ]
>
> Which is what I expect. Now doing the same thing to Bar
>
> In [1]: from djcalendar.models import Bar
>
> In [2]: shabda  = Bar(name = 'Shabda')
>
> In [3]: shabda.save()
>
> In [4]: shabda.name = 'Shabda Raaj'
>
> In [5]: shabda.save()
>
> In [6]: Bar.objects.all()
> Out[6]: []
>
> Here I am expecting two objects, similar to what happened with Foo,
> but I get only one.
>
> Am I missing something, or is this a bug?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Possible pug with Model inheritence - Inserts instead of Update

2008-10-12 Thread felix


ah ok.  you will have problems here because the parent class also has
a database record and an id.

it would be messy I think to try to fool django.

better would be to make a kind of save_as

or  maybe you can copy the object and it will also copy its parent
class.

or make a specific method for this class that returns a clone with
just the fields you want to copy for the history.

there is some pluggable app called "django-versions".  check this out
and see if it works for you.

-f;lix


On Oct 12, 8:23 pm, shabda <[EMAIL PROTECTED]> wrote:
> As long as model_obj.id is None, Django does an Insert, I want an
> insert to happen all the time. (Sort of like trying to get
> FullHistory, wherein I can roll back my object to a previous state. I
> can do save(force_insert = True), but that also gives me an
> Exception.)
>
> On Oct 12, 6:32 pm, felix <[EMAIL PROTECTED]> wrote:
>
> > well this is interesting and curious what you are trying to do.
> > why are you trying to do this self.id= None ?
>
> > what is the real world purpose ?  can you give a non abstract
> > example ?
>
> > in any case since Bar is a subclass of Foo there are two database
> > tables.
> > you set Bar id to None,
> > but the object still has a Foo ptr id, so ultimately there is still
> > only one object.
> > that is, I think, the primary key that is accessed when using
> > Bar.objects.all()
>
> > really, you have broken it by this self.id = None,
> > so I would expect more problems
>
> > On Oct 12, 9:16 am, shabda <[EMAIL PROTECTED]> wrote:
>
> > > My models.py
>
> > > class Foo(models.Model):
> > >     name = models.CharField(max_length = 100)
>
> > >     def save(self):
> > >         self.id = None
> > >         super(Foo, self).save()
>
> > > class Bar(Foo):
> > >     created = models.DateTimeField(auto_now_add = 1)
>
> > > This gives me,
>
> > > In [1]: from djcalendar.models import Foo
>
> > > In [2]: shabda  = Foo(name = 'Shabda')
>
> > > In [3]: shabda.save()
>
> > > In [4]: Foo.objects.all()
> > > Out[4]: []
>
> > > In [5]: shabda.name = 'Shabda Raaj'
>
> > > In [6]: shabda.save()
>
> > > In [7]: Foo.objects.all()
> > > Out[7]: [, ]
>
> > > Which is what I expect. Now doing the same thing to Bar
>
> > > In [1]: from djcalendar.models import Bar
>
> > > In [2]: shabda  = Bar(name = 'Shabda')
>
> > > In [3]: shabda.save()
>
> > > In [4]: shabda.name = 'Shabda Raaj'
>
> > > In [5]: shabda.save()
>
> > > In [6]: Bar.objects.all()
> > > Out[6]: []
>
> > > Here I am expecting two objects, similar to what happened with Foo,
> > > but I get only one.
>
> > > Am I missing something, or is this a bug?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How can I check which view is being called in response to a specific Url?

2008-10-12 Thread felix


another way is to use the javascript Bookmarklet.  go to Documentation
> Bookmarklets


also the debug footer
http://www.djangosnippets.org/snippets/766/
is very useful,

I just added in the code erik allik posted:

from django.core.urlresolvers import resolve
view_func, args, kwargs = resolve(request.META['PATH_INFO'])
view =  '%s.%s' % (view_func.__module__, view_func.__name__)


now the debug footer always shows the view used



On Oct 12, 8:38 pm, shabda <[EMAIL PROTECTED]> wrote:
> One of my views is returning a Http404, and I think it is calling a
> view function diffrent from what I am expecting to be called.
>
> So How can I check which view is being called in response to a
> specific Url?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Keeping track of song play count in django and flash

2008-10-12 Thread felix


i'm looking at this problem too.

1. either the flash player can send a javascript/ajax ping to a url
where it can be logged

2. or the songfile can  be a django served url which logs and then
redirects to the actual static URL.

probably the second is easiest.


On Oct 10, 9:28 pm, M Godshall <[EMAIL PROTECTED]> wrote:
> Is anyone familiar with any techniques or tutorials that would allow
> me to keep track of a song's play count using django and a flash
> player?  I realize this might be a question more directed toward flash
> users, but I figured I'd try here in case any django users have had
> experience with this.  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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: get_object_or_404 error

2008-10-15 Thread felix

you are doing it correctly for normal django.
its something to do with the Poll model that you are getting from
google app engine

sorry I can't help more than that.

-felix


jseleuco wrote:
> Hi all,
>
> Just started today with the Python, Django and Google app engine and
> having some novice problems as well :)
>
>
> def detail(request, poll_id):
> p = get_object_or_404(Poll, pk=poll_id)
> return render_to_response('polls/detail.html', {'poll': p})
>
>
> The get_object_or_404 method is crashing, which i really dont
> understand why.
>
>
>
>
> Traceback (most recent call last):
> File "C:\Program Files\Google\google_appengine\lib\django\django\core
> \handlers\base.py" in get_response
>   77. response = callback(request, *callback_args, **callback_kwargs)
> File "D:\monopolio\polls\views.py" in detail
>   13. p = get_object_or_404(Poll, pk=poll_id)
> File "C:\Program Files\Google\google_appengine\lib\django\django
> \shortcuts\__init__.py" in get_object_or_404
>   20. return manager.get(*args, **kwargs)
>
>   TypeError at /polls/1/
>   get() got an unexpected keyword argument 'pk'
>
>
>
>
>
> I've tried to rename 'pk' to other things but always getting the same
> TypeError..
> Im using the Django helper for the 0.96 version, running it on the
> Google app SDK.
>
> What Im missing?
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



html in feed description

2008-10-15 Thread felix

For either RSS and Atom feeds, I want to return html in the feed
item's description:

post_feed_description.html


but the content including the CDATA tag is escaped:

...
Mark Mothersbaugh (devo) did a beautiful art show of antique photos that he
transforms by digitally making them symmetrical.  Seeing a symmetrical
face is very strange.  His attached article is well
worth reading too.  Rorsarch.

I tried this too:

{% autoescape off %} {%
endautoescape %}

 ...
Mark Mothersbaugh (devo) did a beautiful art show of antique photos that he
transforms by digitally making them symmetrical.  Seeing a symmetrical
face is very strange.  His attached article is well
worth reading too.  Rorsarch.

I have searched this group and the internets and not yet figured it
out.

should I be writing a custom feedgenerator ?  that' doesn't sound
likely.

thanks in advance,

f;lix


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Custom template tag problem: "No module named models"

2008-10-15 Thread felix


this gets me every time.

the error is yes because the template tag is called bookmarks.py
and its inside a module called bookmarks.py

rename it to bookmarks_tags.py ...

and now 

DELETE THE DAMNED OLD bookmarks.pyc file !

python is still finding the old compiled file.

its happened to me twice already in the exact same fashion.

-f;lix


On Oct 15, 7:17 pm, Chris Amico <[EMAIL PROTECTED]> wrote:
> The templatetag file is indeed called bookmarks.py. I thought of that,
> tried renaming it as bookmark_tags.py, and got the same error. I'll
> add that the bookmarks app lives on my python path, not in any
> particular project, since I'm trying to make this as reusable as
> possible.
>
> At one point, I tried just removing the line 'from bookmarks.models
> import Bookmark', and the library loaded, but it hit an error
> (correctly) when I tried use it, saying Bookmark wasn't defined.
>
> On Oct 14, 11:45 pm, Daniel Roseman <[EMAIL PROTECTED]>
> wrote:
>
> > On Oct 15, 7:38 am, Chris Amico <[EMAIL PROTECTED]> wrote:
>
> > > I have a simple bookmarks model based on the one in James Bennett's  > > href="http://code.google.com/p/cab/source/browse/trunk/models.py?
> > > r=130">Cab application. I'm using a generic relation so it can
> > > live in its own app and a user can bookmark any object on the site
> > > (I'm planning on reusing this app on a couple projects). I'm running
> > > into a problem creating an {% if_bookmarked %}templatetag.
>
> > > When I load the tag library I get this error: 'bookmarks' is not a
> > > valid tag library: Could not loadtemplatelibrary from
> > > django.templatetags.bookmarks,Nomodulenamedmodels
>
> > > Here's what the tagmodulelooks like:
>
> > 
>
> > > The bookmarking model works fine on its own, and I've gotten the
> > > functions in thetemplatetag to work in isolation in the interpreter,
> > > but when I load the tag library it breaks thetemplate. What am I
> > > missing here?
>
> > Is the templatetag file itself called bookmarks.py, by any chance? If
> > so, the code may be trying to import that rather than the top-level
> > bookmarks directory. Try renaming the file, although I would also
> > recommend using full paths when importing (ie from
> > projectname.bookmarks.models).
> > --
> > 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Custom template tag problem: "No module named models"

2008-10-16 Thread felix
oh well.

check that you have an __init__.py file in the templatetags directory

try this:
in bookmark_tags.py  (and do keep the name that way, or later you will be
caught by this)

right before the import line throw it in into the debugger:

import pdb; pdb.set_trace()

in the debugger try:

>>> import bookmarks
>>> dir(bookmarks)
>>> bookmarks.__file__

if you can't even import bookmarks then its not actually on your python
path.  remember that your python path needs to include the directory
directly above the bookmarks app.

f;lix


On Thu, Oct 16, 2008 at 4:53 AM, Chris Amico <[EMAIL PROTECTED]> wrote:

>
> Tried that. Still no good. I renamed the file as bookmark_tags.py and
> deleted every .pyc file in the app. Nothing in my templatetags
> directory actually compiled--neither __init__.py nor bookmarks.py
> (even after being renamed).
>
> Like I said before, when I take out the import line (from
> bookmarks.models import Bookmark) the library loads (even when called
> bookmarks.py) and only hits an error when it tries to access
> Bookmark.objects.all().
>
>
>
> On Oct 15, 6:22 pm, felix <[EMAIL PROTECTED]> wrote:
> > this gets me every time.
> >
> > the error is yes because the template tag is called bookmarks.py
> > and its inside a module called bookmarks.py
> >
> > rename it to bookmarks_tags.py ...
> >
> > and now 
> >
> > DELETE THE DAMNED OLD bookmarks.pyc file !
> >
> > python is still finding the old compiled file.
> >
> > its happened to me twice already in the exact same fashion.
> >
> > -f;lix
> >
> > On Oct 15, 7:17 pm, Chris Amico <[EMAIL PROTECTED]> wrote:
> >
> > > The templatetag file is indeed called bookmarks.py. I thought of that,
> > > tried renaming it as bookmark_tags.py, and got the same error. I'll
> > > add that the bookmarks app lives on my python path, not in any
> > > particular project, since I'm trying to make this as reusable as
> > > possible.
> >
> > > At one point, I tried just removing the line 'from bookmarks.models
> > > import Bookmark', and the library loaded, but it hit an error
> > > (correctly) when I tried use it, saying Bookmark wasn't defined.
> >
> > > On Oct 14, 11:45 pm, Daniel Roseman <[EMAIL PROTECTED]>
> > > wrote:
> >
> > > > On Oct 15, 7:38 am, Chris Amico <[EMAIL PROTECTED]> wrote:
> >
> > > > > I have a simple bookmarks model based on the one in James Bennett's
>  > > > > href="http://code.google.com/p/cab/source/browse/trunk/models.py?
> > > > > r=130">Cab application. I'm using a generic relation so it can
> > > > > live in its own app and a user can bookmark any object on the site
> > > > > (I'm planning on reusing this app on a couple projects). I'm
> running
> > > > > into a problem creating an {% if_bookmarked %}templatetag.
> >
> > > > > When I load the tag library I get this error: 'bookmarks' is not a
> > > > > valid tag library: Could not loadtemplatelibrary from
> > > > > django.templatetags.bookmarks,Nomodulenamedmodels
> >
> > > > > Here's what the tagmodulelooks like:
> >
> > > > 
> >
> > > > > The bookmarking model works fine on its own, and I've gotten the
> > > > > functions in thetemplatetag to work in isolation in the
> interpreter,
> > > > > but when I load the tag library it breaks thetemplate. What am I
> > > > > missing here?
> >
> > > > Is the templatetag file itself called bookmarks.py, by any chance? If
> > > > so, the code may be trying to import that rather than the top-level
> > > > bookmarks directory. Try renaming the file, although I would also
> > > > recommend using full paths when importing (ie from
> > > > projectname.bookmarks.models).
> > > > --
> > > > 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: everything works except apache seeing django app

2008-10-16 Thread felix
possibly it may be on YOUR pythonpath but it won't be on apache's
pythonpath.

here is my /etc/apache2/extra/httpd-vhosts.conf

# SUSTAIN
BETA


PythonPath
"['/home/crucial/gitpo/djapps','/home/crucial/gitpo/pluggables','/home/crucial/gitpo','/home/crucial/gitpo/sustain']
+ sys.path"

Order allow,deny
Allow from all
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE sustain.settings

PythonOption django.root /sustain
PythonDebug Off

PythonAutoReload Off



same gear as you, slicehost

I hope that helps somehow

-f;lix



On Thu, Oct 16, 2008 at 2:57 PM, delfick755 <[EMAIL PROTECTED]> wrote:

>
> hello.
>
> I'm trying out django atm, and I've got it working using the manage.py
> runserver, but I'm having difficulty making my apache server use it
> properly, getting the ImportError: Could not import settings problem
>
> I have it so that the django app is in my home directory, and I've
> added an appropiate .pth to my /usr/lib/python2.5/site-packages
> directory pointing to /home/iambob/web (the django app is inside /home/
> iambob/web/testSite)
>
> in the normal python console (and python manage.py shell) "import
> testSite.settings" works
>
> but when I run it on the apache server, it tells me
> ImportError: Could not import settings 'testSite.settings' (Is it on
> sys.path? Does it have syntax errors?): No module named
> testSite.settings
>
> I've also made a test.py script residing in /var/www that I've got
> mod_python to successfully execute.
> the test.py then prints out sys.path which the same as sys.path from
> the python console except that it doesn't have ['/home/iambob/web', '/
> home/iambob/web/testSite'] (or /home/iambob/svn/pyamf as well)
>
> so in the test.py I added the appropiate sys.path.append() to add
> those two, so that the sys.path outputted from the test.py and the
> python console are the same and yet it still has problems importing
> testSite.settings (even in the test.py)
>
> if anyone could help me make my server see the django app, that'd be
> great :)
>
> thankyou
>
> btw, I'm running the following :
> Ubuntu 8.04
> Python 2.5
> Django svn
> Apache 2.2.8
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: everything works except apache seeing django app

2008-10-16 Thread felix
is your app like this

testSite
__init__.py
   models.py
   settings.py
   etc. ?


ie. its not one folder deeper

testSite
actualSite
 __init__.py
models.py
settings.py

and did you restart apache ?

flix





>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: delete tables

2008-10-17 Thread felix
here's what I'm using:

from django.core import management
from django.db import connection
cursor = connection.cursor()
# don't delete these tables
# note that I'm also keeping auth_user
tables =
['comments','objekt_objekt','tag','tags','user_objekt_tag','auth_user','auth_session']

current_tables = connection.introspection.table_names()

for table in current_tables:
if table not in tables:
try:
cursor.execute("drop table %s" % table)
except Exception,e:
raise e
#pass

management.call_command('syncdb')







On Fri, Oct 17, 2008 at 3:41 PM, Mirto Silvio Busico <[EMAIL PROTECTED]>wrote:

>
> Sorry  I was not clear.
>
> I have some utilities in view.py which have to reload tables content
> (migration from the legacy database; clearing a table and reloading with
> base content; ...)
>
> I know from the shell it is enough an "python manage py flush", but I
> have two problems:
>
>* the action have to be triggered by a user action on a form
>* the id have to be resetted because for me the id=0 and id=1 rows
>  have a fixed special meaning
>
> I have not found anything about deleting tables in
> http://docs.djangoproject.com/en/dev/topics/db/queries/ (it seems that
> "database api" has gone in 1.0)
> The only thing that seems I can use is "Executing custom SQL" in
> http://docs.djangoproject.com/en/dev/topics/db/models/
>
> There is a better/recommended method?
>
> Thanks
>Mirto
>
>
> Erik Allik ha scritto:
> > $ manage.py dbshell
> >  > DROP TABLE table_name;
> >
> > Django does not currently have a database schema management tool (with
> > the exception of syncdb and sql* commands).
> >
> > Erik
> >
> >
> > On 17.10.2008, at 15:30, Mirto Silvio Busico wrote:
> >
> >
> >> Hi all,
> >>
> >> what is the django way o deleting all table content and resetting the
> >> primary key counter?
> >>
> >> Thanks
> >>Mirto
> >>
> >> --
> >>
> >>
> _
> >> Busico Mirto Silvio
> >> Consulente ICT
> >> cell. 333 4562651
> >> email [EMAIL PROTECTED]
> >>
> >>
> >>
> >
> >
> > >
> >
> >
>
>
> --
>
> _
> Busico Mirto Silvio
> Consulente ICT
> cell. 333 4562651
> email [EMAIL PROTECTED]
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: [solved] Re: delete tables

2008-10-17 Thread felix
I just pulled it directly from django's source code.

I would only recommend doing syncdb in a development environment.  I just
use it as part of an import / convert from an old website's schema.

probably for what you are doing (a user doing something on a form) this is
too dangerous to do.

syncdb generates sql
checks for an admin user
and installs any initial_data fixtures

by looking at how it does that you should be to isolate just the commands
you want for just the application and db tables that you want.  look at
manage.py and keep following the code.

if you know which db you will be running on then maybe its better just to
delete the models and then reset the auto increment sequence using raw sql
as steve holden suggested.

maybe better is to delete all the models except for the 0 and 1
so they will still be there.

-f;lix




On Fri, Oct 17, 2008 at 4:34 PM, Mirto Silvio Busico <[EMAIL PROTECTED]>wrote:

>  Wanderful!
> This was exactly what I needed!
>
> There is any documentation about "call_command" and the other commnds you
> used?
>
>
> Thanks alot.
> Mirto
>
> felix ha scritto:
>
>
> here's what I'm using:
>
> from django.core import management
> from django.db import connection
> cursor = connection.cursor()
> # don't delete these tables
> # note that I'm also keeping auth_user
> tables =
> ['comments','objekt_objekt','tag','tags','user_objekt_tag','auth_user','auth_session']
>
> current_tables = connection.introspection.table_names()
>
> for table in current_tables:
> if table not in tables:
> try:
> cursor.execute("drop table %s" % table)
> except Exception,e:
> raise e
> #pass
>
> management.call_command('syncdb')
>
>
>
>
>
>
>
> On Fri, Oct 17, 2008 at 3:41 PM, Mirto Silvio Busico <[EMAIL PROTECTED]>wrote:
>
>>
>> Sorry  I was not clear.
>>
>> I have some utilities in view.py which have to reload tables content
>> (migration from the legacy database; clearing a table and reloading with
>> base content; ...)
>>
>> I know from the shell it is enough an "python manage py flush", but I
>> have two problems:
>>
>>* the action have to be triggered by a user action on a form
>>* the id have to be resetted because for me the id=0 and id=1 rows
>>  have a fixed special meaning
>>
>> I have not found anything about deleting tables in
>> http://docs.djangoproject.com/en/dev/topics/db/queries/ (it seems that
>> "database api" has gone in 1.0)
>> The only thing that seems I can use is "Executing custom SQL" in
>> http://docs.djangoproject.com/en/dev/topics/db/models/
>>
>> There is a better/recommended method?
>>
>> Thanks
>>Mirto
>>
>>
>> Erik Allik ha scritto:
>>  > $ manage.py dbshell
>> >  > DROP TABLE table_name;
>> >
>> > Django does not currently have a database schema management tool (with
>> > the exception of syncdb and sql* commands).
>> >
>> > Erik
>> >
>> >
>> > On 17.10.2008, at 15:30, Mirto Silvio Busico wrote:
>> >
>> >
>> >> Hi all,
>> >>
>> >> what is the django way o deleting all table content and resetting the
>> >> primary key counter?
>> >>
>> >> Thanks
>> >>Mirto
>> >>
>> >> --
>> >>
>> >>
>> _
>> >> Busico Mirto Silvio
>> >> Consulente ICT
>> >> cell. 333 4562651
>> >> email [EMAIL PROTECTED]
>> >>
>> >>
>> >>
>> >
>> >
>> > >
>> >
>> >
>>
>>
>> --
>>
>> _
>> Busico Mirto Silvio
>> Consulente ICT
>> cell. 333 4562651
>> email [EMAIL PROTECTED]
>>
>>
>>
>>
>
>
>
>
> --
>
> _
> Busico Mirto Silvio
> Consulente ICT
> cell. 333 4562651
> email [EMAIL PROTECTED]
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Blueprint css versus YUI grids versus ?

2009-01-19 Thread felix
I've also enjoyed blueprint for its clarity and speed.

ideally I would love to assign more semantic .classes and #ids and then use
a style sheet that assigns to styles to styles (yo dawg ... )

.detail {
 {% blueprint 'span-8' %}
 {% blueprint 'box' %}
  border: 1px solid {{ui.bordercolor}};
}

and then something like django-compress would render this final css by
parsing the blueprint CSS, copying the style defs over and into the actual
style sheet.

note also inserting vars from a ui object

this would be something like django-compress could do.


On Mon, Jan 19, 2009 at 3:02 PM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

>
>
>
> On 17 jan, 22:03, ydjango  wrote:
> > has anyone used Blue Print css?
>
> Yes. Tried it for a personal project, found it nice at first - and to
> be true, it really helped me prototyping. But now the design is ok to
> me, I'm in the process of rewriting all my markup and css to get rid
> of the "grid.css" part. There was too much markup that was just here
> to make blueprint work, and I don't like the kind of "reinventing
> table layout with css" feeling it had.
>
>
> >
>

--~--~-~--~~~---~--~~
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: Access production database via development environment

2009-01-20 Thread felix
it didn't work ?  you got the (remote) server correctly specified etc. ?
I haven't tried that myself.

I used to do this all the time with my old dev environment (a php
framework),
its very nice to run the dev code using the remote production db just to
check.




http://crucial-systems.com



On Tue, Jan 20, 2009 at 9:19 PM, jeffhg58  wrote:

>
> I was wondering if anyone has been able to access their production
> environment via the development environment. Because of the amount of
> data on the production environment, it would be advantageous to be
> able to just connect to the production database for query purposes.
>
> P.S. I tried modifying the settings file but that did not seem to
> work.
>
> Thanks,
> Jeff
> >
>

--~--~-~--~~~---~--~~
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: Problem with contenttype/renaming of an app

2009-01-24 Thread felix
look in auth_permission

I would just rename them by hand or by sql


http://crucial-systems.com



On Sat, Jan 24, 2009 at 8:19 PM, Benjamin Buch  wrote:

>
> Hi,
>
> during development, I messed around with an app name.
> First it was called 'body copies' (no native speaker!), then I renamed
> it to 'stanza', which I liked better.
> No problem there: As there was no data in the db, I deleted the tables
> and created them again, with other names.
>
> Then I deployed the project.
> I transfered the data via manage.py dumpdata/loaddata.
> Still no problems when I'm logged in as admin.
>
> But:
> When I create a new user group and want to give permissions, there's
> still 'body copy' instead of 'stanza'.
> ('bodyopies | body copy | Can add static content' and so on...)
>
> If I give the bodycopy permissions and log in as a user with those
> permissions, I'm not able to edit 'stanza'.
> The 'stanza'-area won't even show up in the admin panel, neither does
> 'bodycopies'.
>
> I took a look at the database, and in the table 'django_content_type'
> I found some entries refering to 'bodycopies':
>
> id |name   |  app_label | model
> ---+---++---
> 09 | body copy | bodycopies | bodycopy
>
> I renamed them to the according 'stanza' labels.
> After that, in the group permissions on the group page 'stanza' showed
> up instead of 'bodycopies',
> but I still was not able to edit 'stanza' as non-admin-user.
>
> Any ideas?
>
> Benjamin
>
>
>
> >
>

--~--~-~--~~~---~--~~
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: munge words and numbers into a URL, then reverse it ?

2009-01-27 Thread felix
there is some hashing function or combination of URL encoding that can do
this :


given some parameters :

'music' 'artist' 32L 2L 100 100
( artist id 32, 2nd picture, dimensions 100 x 100 )

I wish to generate a fake filename eg:

tartan_ba6e5e06e794f1368ed3ec20b4594eec.png

and then be able to reverse that filename back into the original parameters
when needed.

so its either hashing, or compressing the string (to use the most of the
allowable chars a-zA-Z0-9_ ) or something

hints or pointers anyone ?
thanks



http://crucial-systems.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 imagefield at development server

2009-01-27 Thread felix
no problem uploading using the dev server

no idea.  you didn't leave a pdb in your code, did you ?

what is the output if any in the shell ?



On Tue, Jan 27, 2009 at 2:58 PM, Akhmat Safrudin
wrote:

>
> dear list,
> i am a noob,
> i just starting a project, then create app and add some models,
> in the model there is an ImageField,
> at the admin area i can't insert record, the browser status is "waiting for
> localhost"
> is django development server can upload file/image ?
> i have completely read model documentation and django managing file but
> didn't get it solved.
>
> my models and settings look like this :
>
> class person(models.Model):
>name = models.CharField(max_length=30)
>address = models.CharField(max_length=50)
>photo = models.ImageField(upload_to='photo')
>
> settings.py :
> MEDIA_ROOT = '/home/somat/project/media/'
>
> MEDIA_URL = '/media/'
>
> thank's
>
> somat.
>
> --
> Stay Hungry Stay Foolish
> http://somat.wordpress.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: munge words and numbers into a URL, then reverse it ?

2009-01-27 Thread felix
ah, danke dir !

that's exactly what I was looking for

full encodings here:
http://docs.python.org/library/codecs.html#standard-encodings

actually I guess in this case I would have a series of numbers;

[ content_type_id, object_id, index, width, height ]

rather than a string. I can figure that out, or it would be simple enough to
join them and do the pack.
it won't be so long as the example I posted.


FYI
this would be for thumbnails :  if the thumbnail exists the static server
will serve it, else django will be triggered to build it.

but I wouldn't want to open up the URL so that anybody could request say

for i in range(0,1):
  get image urls until my server gives up ...


but I will design the paths so that it exposes the object ID like so:

%(content_type_id)s_%(object_id)s_%(encoded)s.jpg

so that I can easily delete all thumbs when the object is deleted

currently I create thumbs on demand via template tags.
this also leaves dead thumbs laying around.





On Tue, Jan 27, 2009 at 5:43 PM, Puneet Madaan wrote:

> I am assuming that you already have an idea of how your datastring will
> look like, and what data it is containing... I am considering *"music
> artist 32L 2L 100 100"* as input data
> so here is a example...
>
> L1 = "music artist 32L 2L 100 100".encode("hex")
>> L2 = zlib.compress(L1)
>> L3 = L2.encode("hex")
>> print L3
>>
>
> L3 can now be taken as URI referencing string.. which in this special case
> is
>
>
> '789c35c5c10d00200c02c095102aa4f3e8fe336862fcdc7967466e8bf00853ee28454862adfb7308c2ff00401d0b64'
>
> and reverse algo for this is also as easy
>
>
>> D1=789c35c5c10d00200c02c095102aa4f3e8fe336862fcdc7967466e8bf00853ee28454862adfb7308c2ff00401d0b64'.decode("hex")
>> D2 = zlib.decompress(D1)
>> D3 = D2.decode("hex")
>>
>
> you will get your "music artist 32L 2L 100 100" back
>
> And your URL will not send further a psuedo encoded number which is ugly
> enough for non-developers :D
> you are free to choose encoding, and can nest them in multiple algos to
> make the thing more complex
>
> greetings,
> Puneet
>
>
> On Tue, Jan 27, 2009 at 4:48 PM, felix  wrote:
>
>>
>> there is some hashing function or combination of URL encoding that can do
>> this :
>>
>>
>> given some parameters :
>>
>> 'music' 'artist' 32L 2L 100 100
>> ( artist id 32, 2nd picture, dimensions 100 x 100 )
>>
>> I wish to generate a fake filename eg:
>>
>> tartan_ba6e5e06e794f1368ed3ec20b4594eec.png
>>
>> and then be able to reverse that filename back into the original
>> parameters when needed.
>>
>> so its either hashing, or compressing the string (to use the most of the
>> allowable chars a-zA-Z0-9_ ) or something
>>
>> hints or pointers anyone ?
>> thanks
>>
>>
>>
>> http://crucial-systems.com
>>
>>
>>
>>
>
>
> --
> If you spin an oriental man, does he become disoriented?
> (-: ¿ʇɥǝɹpɹǝʌ ɟdoʞ uǝp ɹıp ɥɔı ,qɐɥ 'ɐɐu
>
> is der net süß » ε(●̮̮̃•̃)з
> -PM
>
> >
>

--~--~-~--~~~---~--~~
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 imagefield at development server

2009-01-27 Thread felix
on my dev server (laptop) I serve the MEDIA_ROOT through the normal apache
localhost.
I do not get django to serve them.

ie I do not do this at all:

   urlpatterns += patterns('',
   (r'^site-media/(?P.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
   )


pdb is very important to know.

just type

import pdb; pdb.set_trace()

anywhere in your code and you will be thrown into the debugger.
the browser will hang while you are in the debugger (in terminal/shell),
which is why I suggested maybe that was why you were hanging.

or do you mean : how do you do that when the code is the admin ?
only if you have edited anything in django code base itself .


On Tue, Jan 27, 2009 at 9:35 PM, Akhmat Safrudin
wrote:

>
> felix wrote:
> > no problem uploading using the dev server
> >
> > no idea.  you didn't leave a pdb in your code, did you ?
> >
> > what is the output if any in the shell ?
> i point the url in the browser to http://localhost:8000/admin/
> how to debug with pdb in admin area ?
>
> somat.
>
> --
> Stay Hungry Stay Foolish
>
>
> >
>

--~--~-~--~~~---~--~~
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: ContentTypes and fixtures

2009-01-29 Thread felix
this has bitten me too recently.

in general I'm moving away from fixtures.  they are breakable, they suffer
when the codebase is refactored.
particularily for tests I no longer use fixtures.

I would suggest trying the dump-to–python-code method




ideally there should be a away to dump a group (or all) objects into some
data structure where all foreign keys are referenced only internally through
some lookup table (that is saved with the objects).

then when loading the structure the objects would be given homes in the
database and the foreign keys would all get resolved into real-world db ids.

there would have to then be a part of the structure that resolved foreign
key ids by a lookup in the host environment where the structure is being
installed (eg looking up the content ids)

the other use for this system would be federating data from site to site.



 felix :crucial-systems.com



On Thu, Jan 29, 2009 at 12:15 AM, Russell Keith-Magee <
freakboy3...@gmail.com> wrote:

>
> On Thu, Jan 29, 2009 at 7:36 AM, Oliver Beattie 
> wrote:
> >
> > How can I be sure that the ContentType IDs are always constant, and
> > therefore my data in fixtures is guaranteed to always point to the
> > right object?
>
> Oliver, meet ticket #7052. Ticket #7052, meet Oliver :-)
>
> This is an annoying bug that I have wanted to address for a while. The
> ticket describes an approach that I believe will work, but doesn't
> contain a patch. On IRC a few days back, Eric Holscher mentioned that
> he had a nasty hack that implemented a fix for this. I don't know how
> far that hack has gone, or if he will be willing to share code.
>
> The best workaround that I can suggest is to include your ContentTypes
> in your fixtures. They are dumpable objects, just like everything else
> in Django. If your fixture contains the content types, it doesn't
> matter what primary key values are automatically created, because they
> will be overwritten by the fixture. You shouldn't get any duplicate
> primary key errors because the fixtures framework overwrites existing
> objects with the same primary key. The only time you need to be
> careful is when you start adding new models, and new content types are
> created - if you don't update your fixtures, you could get some
> interesting side effects.
>
> 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: free django hosting

2009-01-30 Thread felix
http://code.google.com/p/google-app-engine-django/
of course

some restrictions apply
your mileage may vary

 felix :crucial-systems.com



On Sat, Jan 31, 2009 at 1:12 AM, xankya  wrote:

>
> hi,
> anybody know free django hosting ?
> >
>

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



remember me on this computer vs SESSION_EXPIRE_AT_BROWSER_CLOSE

2009-01-31 Thread felix
I'm trying to implement the standard option "remember me on this computer"

which in practice means expire the session or not at the end of the session

it looks like django's auth uses a sitewide setting
SESSION_EXPIRE_AT_BROWSER_CLOSE

does anybody know the best way to approach this ?   is it the
SessionMiddleware that should be replaced ?


 felix :crucial-systems.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: Autogenerate a Model on Save

2009-02-02 Thread felix
generally you should keep this type of business logic out of the model

the place to put it is either in the Form
or the view


class OrderModelForm(forms.ModelForm):

class Meta:
model = Order

def save_model(self, request, obj, form, change):
"""
Given a model instance save it to the database.
"""

if not change: # only when adding
obj.created_by = request.user
if(not obj.from_email):
obj.from_email = request.user.email
#create your invoice now

obj.save()


# and if you are using that in the admin then add it to the admin too:

class OrderAdmin(admin.ModelAdmin):

form = OrderModelForm


and register it





 felix :crucial-systems.com



On Mon, Feb 2, 2009 at 8:50 PM, Alfonso  wrote:

>
> I'm full of queries today!...This one seems a simple notion that I
> can't get my head around...How would I get django to auto-generate a
> new Invoice record and populate with some values when a user saves a
> new Order record?  A custom def save(self) method?
>
> 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: Autogenerate a Model on Save

2009-02-02 Thread felix
the view is the first, and most easily understandable place to put it.

the form logic may make your head hurt more at first, but eventually you'll
feel more comfortable putting it there.

nothing wrong with coding it in the view

but OTOH you will get the same functionality if you use the form in your own
view or in the admin.
and if you create more views for different purposes, they can all use that
form.



On Mon, Feb 2, 2009 at 9:09 PM, Will Matos  wrote:

> Agreed. Your class is being saved in a view method. Upon successful saves
> create a new one.
>
> --
>  *From*: django-users@googlegroups.com
> *To*: django-users@googlegroups.com
> *Sent*: Mon Feb 02 15:07:48 2009
> *Subject*: Re: Autogenerate a Model on Save
> generally you should keep this type of business logic out of the model
>
> the place to put it is either in the Form
> or the view
>
>
> class OrderModelForm(forms.ModelForm):
>
> class Meta:
> model = Order
>
> def save_model(self, request, obj, form, change):
> """
> Given a model instance save it to the database.
> """
>
> if not change: # only when adding
> obj.created_by = request.user
> if(not obj.from_email):
> obj.from_email = request.user.email
> #create your invoice now
>
> obj.save()
>
>
> # and if you are using that in the admin then add it to the admin too:
>
> class OrderAdmin(admin.ModelAdmin):
>
> form = OrderModelForm
>
>
> and register it
>
>
>
>
>
>  felix :crucial-systems.com
>
>
>
> On Mon, Feb 2, 2009 at 8:50 PM, Alfonso  wrote:
>
>>
>> I'm full of queries today!...This one seems a simple notion that I
>> can't get my head around...How would I get django to auto-generate a
>> new Invoice record and populate with some values when a user saves a
>> new Order record?  A custom def save(self) method?
>>
>> 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: FileField and moving or updating files

2009-02-02 Thread felix
I was just learning/dealing with this now.

example:

class Mix(models.Model):
   mp3 = models.FileField(upload_to="mixes",blank=True)

# let's say the mix object already exists
mix = Mix.objects.get(  etc )


# however you get a file

file = request.FILES[u'Filedata']

# swfupload is awesome btw.

or by opening it from your post processed folder somewhere
or by creating a file directly in memory using content, or PIL etc.

then the correct way is this:

if mix.mp3.name: # if there is a previous file and we wish to delete it
   mix.mp3.storage.delete( mix.mp3.name )

get the field's defined storage to delete it

#name will be eg. "mixes/oldfile.mp3"

ideal_path = "mixes/newfile.mp3"

# save the new file into storage
saved_to = mix.mp3.storage.save( ideal_path, file )


the path may have _ added to it for non-clobber purposes and is returned
with the real path

# assign the string directly to the file field input
mix.mp3 = saved_to

# and save the new path into the object
mix.save()


this is nice in that you can switch the storage later or use multiple
storage systems across your site,
not just

from django.core.files.storage import default_storage
default_storage.save( path, file)


you can upload to "tempUploads/file.xxx" and then search for files whose
names are still in tempUploads and thus not yet processed

 felix :crucial-systems.com



On Mon, Feb 2, 2009 at 11:26 PM, timc3  wrote:

>
> So I take it that there is no way of doing 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
-~--~~~~--~~--~--~---



increasing upload speed

2009-02-03 Thread felix
hi-

I'm using swfupload (flash upload widget) with the speed plugin.
It looks like I'm getting 600k/s average upload speed to my slicehost
server.

it took me 28 mins for 140M

but down (served through apache) is way way faster.

part of that must be the asymmetrical DSL connection, and part must be using
django to chunk it to disk.

I could upload via apache and on completion fire an ajax command from the
page (the form page does not submit)
this ajax command could then cause django to go check out the file (read the
tags etc.) and put it where it ought to be.

does anybody have any experience with large uploads ?
any wisdom to share ?

 felix :crucial-systems.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: FileField and moving or updating files

2009-02-03 Thread felix
oh if its already where you want it (as long as its in the MEDIA ROOT)
then just set the file field with the string:

obj.filefield = "path/to/file.mov"
obj.save()


I might be wrong on this, but :
if you are working with a File that has a path, then you aren't really
moving it.
say its in /tmp/87fac12
and you
obj.filefield.storage.save( newpath,file )

it moves the file on the filesystem (gives it a new path reference), but it
doesn't have to actually move anything really.
its actually "rename"

the filesystem itself is a kind of database and you are just assigning a new
path

look at django.core.files.move


 felix :crucial-systems.com



On Tue, Feb 3, 2009 at 8:24 PM, azimix79  wrote:

>
> Hi,
> I have the same problem as above.
> I'm sure your solution works Felix, but it is important for me to
> avoid resaving the files (as they can be well over 500Mb-1Gb in size).
>
> The ideal solution would be to just change the path in the model
> without having to resave the file.
>
> Any help is appreciated.
> Thanks
>
> On Feb 3, 12:08 am, felix  wrote:
> > I was just learning/dealing with this now.
> >
> > example:
> >
> > class Mix(models.Model):
> >mp3 = models.FileField(upload_to="mixes",blank=True)
> >
> > # let's say the mix object already exists
> > mix = Mix.objects.get(  etc )
> >
> > # however you get a file
> >
> > file = request.FILES[u'Filedata']
> >
> > # swfupload is awesome btw.
> >
> > or by opening it from your post processed folder somewhere
> > or by creating a file directly in memory using content, or PIL etc.
> >
> > then the correct way is this:
> >
> > if mix.mp3.name: # if there is a previous file and we wish to delete it
> >mix.mp3.storage.delete( mix.mp3.name )
> >
> > get the field's defined storage to delete it
> >
> > #name will be eg. "mixes/oldfile.mp3"
> >
> > ideal_path = "mixes/newfile.mp3"
> >
> > # save the new file into storage
> > saved_to = mix.mp3.storage.save( ideal_path, file )
> >
> > the path may have _ added to it for non-clobber purposes and is returned
> > with the real path
> >
> > # assign the string directly to the file field input
> > mix.mp3 = saved_to
> >
> > # and save the new path into the object
> > mix.save()
> >
> > this is nice in that you can switch the storage later or use multiple
> > storage systems across your site,
> > not just
> >
> > from django.core.files.storage import default_storage
> > default_storage.save( path, file)
> >
> > you can upload to "tempUploads/file.xxx" and then search for files whose
> > names are still in tempUploads and thus not yet processed
> >
> >  felix :crucial-systems.com
> >
> > On Mon, Feb 2, 2009 at 11:26 PM, timc3  wrote:
> >
> > > So I take it that there is no way of doing 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
-~--~~~~--~~--~--~---



dynamically assigning settings on startup with wsgi

2009-02-03 Thread felix
adict = {
  'DATABASE_PASSWORD' : "something"
}

in settings.py :

locs = vars()
for key,value in adict:
locs[key] = value

I'm dynamically assigning variables in settings

this works in the development server (a wsgi), but NOT on the production
server using mod_wsgi

is there a known difference or reason why this should not work ?

thanks

 felix :crucial-systems.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: dynamically assigning settings on startup with wsgi

2009-02-03 Thread felix
nevermind

moral: if it seems illogical it probably is something else


On Wed, Feb 4, 2009 at 12:38 AM, felix  wrote:

>
> adict = {
>   'DATABASE_PASSWORD' : "something"
> }
>
> in settings.py :
>
> locs = vars()
> for key,value in adict:
> locs[key] = value
>
> I'm dynamically assigning variables in settings
>
> this works in the development server (a wsgi), but NOT on the production
> server using mod_wsgi
>
> is there a known difference or reason why this should not work ?
>
> thanks
>
>  felix :crucial-systems.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: FileField and moving or updating files

2009-02-03 Thread felix
and btw. if you have any wisdom regarding uploading really large files then
please share !
I posted another thread on that.


On Tue, Feb 3, 2009 at 8:50 PM, felix  wrote:

>
> oh if its already where you want it (as long as its in the MEDIA ROOT)
> then just set the file field with the string:
>
> obj.filefield = "path/to/file.mov"
> obj.save()
>
>
> I might be wrong on this, but :
> if you are working with a File that has a path, then you aren't really
> moving it.
> say its in /tmp/87fac12
> and you
> obj.filefield.storage.save( newpath,file )
>
> it moves the file on the filesystem (gives it a new path reference), but it
> doesn't have to actually move anything really.
> its actually "rename"
>
> the filesystem itself is a kind of database and you are just assigning a
> new path
>
> look at django.core.files.move
>
>
>  felix :crucial-systems.com
>
>
>
> On Tue, Feb 3, 2009 at 8:24 PM, azimix79  wrote:
>
>>
>> Hi,
>> I have the same problem as above.
>> I'm sure your solution works Felix, but it is important for me to
>> avoid resaving the files (as they can be well over 500Mb-1Gb in size).
>>
>> The ideal solution would be to just change the path in the model
>> without having to resave the file.
>>
>> Any help is appreciated.
>> Thanks
>>
>> On Feb 3, 12:08 am, felix  wrote:
>> > I was just learning/dealing with this now.
>> >
>> > example:
>> >
>> > class Mix(models.Model):
>> >mp3 = models.FileField(upload_to="mixes",blank=True)
>> >
>> > # let's say the mix object already exists
>> > mix = Mix.objects.get(  etc )
>> >
>> > # however you get a file
>> >
>> > file = request.FILES[u'Filedata']
>> >
>> > # swfupload is awesome btw.
>> >
>> > or by opening it from your post processed folder somewhere
>> > or by creating a file directly in memory using content, or PIL etc.
>> >
>> > then the correct way is this:
>> >
>> > if mix.mp3.name: # if there is a previous file and we wish to delete it
>> >mix.mp3.storage.delete( mix.mp3.name )
>> >
>> > get the field's defined storage to delete it
>> >
>> > #name will be eg. "mixes/oldfile.mp3"
>> >
>> > ideal_path = "mixes/newfile.mp3"
>> >
>> > # save the new file into storage
>> > saved_to = mix.mp3.storage.save( ideal_path, file )
>> >
>> > the path may have _ added to it for non-clobber purposes and is returned
>> > with the real path
>> >
>> > # assign the string directly to the file field input
>> > mix.mp3 = saved_to
>> >
>> > # and save the new path into the object
>> > mix.save()
>> >
>> > this is nice in that you can switch the storage later or use multiple
>> > storage systems across your site,
>> > not just
>> >
>> > from django.core.files.storage import default_storage
>> > default_storage.save( path, file)
>> >
>> > you can upload to "tempUploads/file.xxx" and then search for files whose
>> > names are still in tempUploads and thus not yet processed
>> >
>> >  felix :crucial-systems.com
>> >
>> > On Mon, Feb 2, 2009 at 11:26 PM, timc3  wrote:
>> >
>> > > So I take it that there is no way of doing this?
>>
>> >>
>>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: increasing upload speed

2009-02-04 Thread felix
On Wed, Feb 4, 2009 at 2:48 AM, Malcolm Tredinnick  wrote:

> So if you're thinking that
> those are the bottlenecks, rather than the network,


actually I assumed the network *was* the primary bottleneck.

I was just inquiring if anybody had experiences to share with uploading
large files,
and if there was any significant bottleneck on the django side.

since uploading through the local dev server on my own machine (no network
at all really)
is lightening fast, I'd have to say that there is no win to trying to cut
django out of the loop here.




> you need to try
> very, very hard to disprove your guess as it's entirely against what
> normal experience suggests in this arena. Your guesses may be correct,
> but I don't think you're able to say that yet.


indeed, that's why I was asking :)  normal experience is exactly what I'm
after.

thanks!



>
>
> 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: Admin widget for geotagging

2009-02-05 Thread felix
its also on my to do list

right now I have an ajax auto-complete for filling out the addresses, but I
would prefer the one line google-geo-code version

I like the way they did it here:

http://djangopeople.net/



On Thu, Feb 5, 2009 at 10:19 AM, Ales Zoulek  wrote:

>
> I need the same.
> Please, let us know, if you solve the issue. Other way I'll start to
> working on it in a few days.
>
>
> A.
>
>
>
> On Wed, Feb 4, 2009 at 10:04 PM, Cesar Mojarro  wrote:
> > are u paying someone for this
> >
> > On Wed, Feb 4, 2009 at 2:55 PM, Anders <
> anders.grimsrud.erik...@gmail.com>
> > wrote:
> >>
> >> Hi. I am in desperat need for a admin widget that let's my users
> >> search for an address (via google geocode) and select one of the
> >> results google provide or click in a google map to specify a position.
> >> This position should then be saved in two separate fields (latitude
> >> and longitude).
> >>
> >> I've been across a few snippets, but none that combines this - and
> >> none that works with latest django
> >>
> >> And no, I am not using GeoDjango. Just need the simple lat/long-
> >> fields.
> >>
> >> Thanks,
> >>
> >> Anders >>
> >
>
>
>
> --
> --
> Ales Zoulek
> +420 604 332 515
> Jabber: a...@jabber.cz
> ICQ: 82647256
> --
>
> >
>

--~--~-~--~~~---~--~~
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 do a three table join with django models

2009-02-05 Thread felix
Results.objects.all().select_related('profile','testcase')

that was easy

that's A join B,C

if it was   A join B join C

(my example)

class Release
fk Artist

class Artist
fk Label

class Label

Release.objects.all().select_related('artist','artist_label')

note selecting the C class via the B class   'B_C'




On Thu, Feb 5, 2009 at 5:28 PM, Daniel Roseman <
roseman.dan...@googlemail.com> wrote:

>
> On Feb 5, 3:50 pm, rc  wrote:
> > I am newbie to Django and I am struggling to get my arms around DJango
> > and it's data access api (models).
> >
> > I have these models:
> >
> > class Profile(models.Model):
> > profile_id = models.AutoField(primary_key=True)
> > profile_name = models.CharField(max_length=75)
> > def __unicode__(self):
> > return self.profile_id
> > def __unicode__(self):
> > return self.profile_name
> > class Meta:
> > db_table = 'profile'
> >
> > class Testcase(models.Model):
> > test_id = models.AutoField(primary_key=True)
> > test_name = models.CharField(max_length=300)
> > src = models.ForeignKey(Source, null=True, blank=True)
> > bitrate = models.IntegerField(null=True, blank=True)
> > test_type = models.CharField(max_length=300)
> > output_resolution = models.CharField(max_length=15, blank=True)
> > def __unicode__(self):
> > return self.test_name
> > class Meta:
> > db_table = 'testcase'
> >
> > class Results(models.Model):
> > result_id = models.AutoField(primary_key=True)
> > date = models.DateTimeField()
> > test = models.ForeignKey(Testcase)
> > profile = models.ForeignKey(Profile)
> > status = models.CharField(max_length=30)
> > graph = models.BlobField(null=True, blank=True)
> > y_psnr = models.DecimalField(null=True, max_digits=5,
> > decimal_places=2, blank=True)
> > u_psnr = models.DecimalField(null=True, max_digits=5,
> > decimal_places=2, blank=True)
> > v_psnr = models.DecimalField(null=True, max_digits=5,
> > decimal_places=2, blank=True)
> > yuv_psnr = models.DecimalField(null=True, max_digits=5,
> > decimal_places=2, blank=True)
> > def __unicode__(self):
> > return self.result_id
> > class Meta:
> > db_table = 'results'
> >
> > and I want to be able to display this data:
> >
> > select result_id, date, profile_name, test_name, status, y_psnr,
> > u_psnr, v_psnr, yuv_psnr
> > from profile, testcase, results
> > where profile.profile_id = results.profile_id
> > and testcase.test_id = results.test_id
> >
> >  Which is very easy to do with raw sql, but struggling to do it the
> > "django' way.
> >
> > Any ideas?
> > I have also tried to use raw sql, but struggled to get it to work in
> > my views and templates.
>
> The Django ORM is there to help you. If you don't find it easy, don't
> use it. However, the simple way of doing it would be something like
> this:
>
> for testcase in Testcase.objects.all():
>print testcase.status
>for result in testcase.result_set.all():
>print result.result_id, result.date,
> result.profile.profile_name, \
>result.status, result.y_psnr, \
>result.u_psnr, result.v_psnr, result.yuv_psnr
>
> You can make that much more efficient via proper use of
> select_related, but that's the general idea.
>
> Not related to your problem, but you've got an issue with your inner
> Meta classes - each time they are indented under the __unicode__
> method. They should be one indent level back.
>
>
> >
>

--~--~-~--~~~---~--~~
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: Changing the structure of an already running site

2009-02-05 Thread felix
try deseb

http://code.google.com/p/deseb/

Its ... magic  (good and bad.  mostly good in this case)

I simply run:

./manage.py evolvedb

and the SQL to be run is shown to me with the option to run it


and then the option to save it as a schema evolution.

the idea is that you would run it on your dev, save it to the schema
evolution, deploy that to production

and then run the pre-approved SQL on the live server

there are a few bugs and issues, but they have not affected me at all.

./manage.py evolvedb
deseb: music.schema_evolution module found (13 fingerprints, 7 evolutions)
deseb: fingerprint for 'music' is 'fv1:142275253' (recognized)
music: the following schema upgrade is available:
ALTER TABLE `music_releaseimage` ADD COLUMN `just_an_example` varchar(100);
do you want to run the preceeding commands?
type 'yes' to continue, or 'no' to cancel: no
schema not saved




On Wed, Feb 4, 2009 at 4:46 PM, phyl.jack...@gmail.com <
phyl.jack...@gmail.com> wrote:

>
>
> Im fairly new to django and new to databases in general and Im just
> trying to work out how Im going to make changes to my website once its
> up and running.
> Im using mySQL, any time i add a field to one of my models I run
> syncdb but any calling already created users or comments causes an
> error. The method Ive been using during development is to just delete
> my database file and recreate it, Im obviously not going to be able to
> continue to do this.
>
> Say you wanted to add a field to an existing model on a running
> website, what is the correct and safest way to go about doing this?
>
> Thanks,
> Phil
> >
>

--~--~-~--~~~---~--~~
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: Best practice question: subclassing external app components

2009-02-09 Thread felix
in my own setup I have a few apps where it might go:

globalapp
  - a collection of misc snippets, classes and utilities that I use on every
project I work on
{website}
  - the specific website if this code will not be reused
accountz
  - views, forms related to my own styles of login utils, registration etc.
 things from here are used on every site I work on

3 would be the best choice I think.


for capitalizing the labels on fields you should try just doing css

 felix :crucial-systems.com



On Mon, Feb 9, 2009 at 12:35 AM, zinckiwi  wrote:

>
> Hi folks,
>
> I'm just starting to play with django-registration and I want to
> subclass the RegistrationForm for a couple of cosmetic tweaks
> (capitalising the labels on the fields -- there may be a simpler way
> to do this, but indulge me for the purposes of this question). I
> understand that subclassing RegistrationForm and reassigning the label
> strings is the way to do this -- no problem.
>
> My question is where to *put* that subclass. I can think of a few
> places:
>
> - the project itself
> - an "overrides" app dedicated to holding overrides for external apps
> - a "registration_overrides" app dedicated to holding overrides for
> just that one external app
>
> Perhaps there are other ways. Of these, I'm favouring #2. While #3 has
> the virtue of being more portable, it seems like a lot of (logical)
> overhead to perform a simple modification to another app.
>
> So I guess I'd like to hear if there's an accepted way to do this, or
> failing that, what anyone has found to work well (or what to avoid).
>
> Thanks all,
> Scott
>
> >
>

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



WeakForeignKey - on delete set null rather than delete me

2009-02-09 Thread felix
that old "django deleted my object!" thing
plus solution (at bottom)

class Venue(models.Model):
pass

class Event(models.Model):
venue =
models.ForeignKey(Venue,related_name='venue',blank=True,null=True)

v = Venue.objects.create()
e = Event.objects.create(venue=v)
v.delete()

the Event e is now deleted from the db
any model with a ForeignKey will be deleted with the model it points to is
deleted.
which is exactly what ForeignKeys are supposed to do

but my desired behavior here is to set:  e.venue = None
aka ON DELETE SET NULL

its a weak relationship

btw. this is not the solution, to flip it around:

class Venue(models.Model):
events = models.ManyToManyField(Event,blank=True)

because in actual practice there are many ForeignKeys pointing to models in
different apps
and it would be horribly polluting to put ManyToManyFields in all of those.
in these cases these are more like attributes or extra information.
(tho in most cases ForeignKey is correct behavior)


but the best solution I think is to write a :

class WeakForeignKey(ForeignKey):
"""which can only be blank=True/null=True """"
...

class WeakManyToOneRel(ManyToOneRel):
pass


django.db.models.base

def _collect_sub_objects(self, seen_objs, parent=None, nullable=False):
...
if isinstance(related.field.rel, OneToOneRel):
...
elif isinstance(related.field.rel,WeakManyToOneRel):
for sub_obj in getattr(self, rel_opts_name).all():
setattr(sub_obj,related.field.name,None)
sub_obj.save()
else:
...


class Event(models.Model):
venue = models.WeakForeignKey(Venue)


which I did, it works, test written etc.

comments ?  prior art that I didn't find ?
easier solutions ?
naming advice ?

I'll happily write up a ticket and patch




 felix :crucial-systems.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
-~--~~~~--~~--~--~---



ModelForm not saving fields that are not in the form

2009-02-11 Thread felix
I have fields in the model that do not appear in the form.
Those fields are filled in by a geocode result.

but the data is not getting saved

class EditContactForm(forms.ModelForm):
""" this is the parent form class for all contact editing """
class Meta:
model = Contact
exclude = ('city','state','country','postcode','street')

def clean(self):
super(EditContactForm, self).clean()

address = self.cleaned_data['address']
json = self.data['address_json']
if json: # only gets a json input if something was changed and
javascript is on
geo = simplejson.loads(json)
geodict = gparse_create_csc(geo)

self.cleaned_data['street'] = geodict['street_address']
self.cleaned_data['city'] = geodict['city']
self.cleaned_data['state'] = geodict['state']
self.cleaned_data['country'] = geodict['country']
self.cleaned_data['postcode'] = geodict['postal_code']
# cleaned_data is all correctly filled in here
return self.cleaned_data

def save(self,commit=True):
# self.changed_data = ['address']
# adding the other fieldnames did not work

self.instance.street = self.cleaned_data['street']
self.instance.city = self.cleaned_data['city']
self.instance.state = self.cleaned_data['state']
self.instance.country = self.cleaned_data['country']
self.instance.postal_code = self.cleaned_data['postcode']

return super(EditContactForm, self).save(commit)


what do I have to do to get these fields to be saved ?

thanks

 felix :crucial-systems.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: Really slow functional tests

2009-02-11 Thread felix
do you have large initial_data fixtures ?

tables get flushed and initial_data is added each time.

 felix :crucial-systems.com



On Wed, Feb 11, 2009 at 1:50 PM, Andrea Reginato
wrote:

>
> Hei guys, I've a question related to some tests I've make.
>
> When I run them they need lot of time to be executed. I'm talking
> about 10 seconds for single test. They are functional test such as the
> one you can see above (normal functional tests).
>
>def setUp(self):
>self.c = Client()
>
># Basics
>def testLogin(self):
>response = self.c.post('/accounts/login/', {'username':
> TEST_USER, 'password': TEST_PASSWORD})
>self.assertEquals(response.status_code, 302)
>
> They are too slow, and in this way, I can't really test what I want
> because I loose a lot of time. This is my first experience, and I come
> from Rails development, where tests are executed really fast if
> compared to my first Django project.
>
> The only thing that make me think is that in the pages that I render
> the images are not locals, but are into S3, but I don't know if this
> can be the trouble. If somebody has any idea, or any way to check the
> steps I'm following I would be really grateful.
>
> Thnaks
>
> >
>

--~--~-~--~~~---~--~~
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: ModelForm not saving fields that are not in the form

2009-02-11 Thread felix
nevermind

the admin class wasn't calling super() in save_model

once again an hour of being stuck, then solved the problem minutes after
posting


On Wed, Feb 11, 2009 at 1:57 PM, felix  wrote:

>
> I have fields in the model that do not appear in the form.
> Those fields are filled in by a geocode result.
>
> but the data is not getting saved
>
>

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

2009-02-13 Thread felix
use Firefox with Firebug installed if you aren't already.

you can then see if you get any 404s and if any of the included files failed
with syntax errors
or if something happened during javascript runtime to kill it

also, I like django-compress quite a bit for css and js

 felix :crucial-systems.com



On Fri, Feb 13, 2009 at 6:11 PM, arbi  wrote:

>
> Thx, but I did this already. In fact i have no problem for a css doc,
> but problems for a js doc. I don't know why!
> My css is in "/media/css/css_file.css" and my js is in "/media/js/
> test.js". A simple "alert" in my test.js file doesn't work. I don't
> understand.
> Any help?
> Thx!
> Arbi
>
> On 12 fév, 23:29, Alex Gaynor  wrote:
> > On Thu, Feb 12, 2009 at 5:28 PM, arbi  wrote:
> >
> > > Hi all,
> >
> > > I am trying to execute a javascript doc to display a google map. The
> > > javascript doc to refer to is "google-map.js". How do I write it in
> > > here ? :
> > > TEMPLATE :
> > > 
> > > .
> >
> > > I tryed many things and it did not work! I read many things, but I
> > > can't figure out how to solve this pb.
> > > Is there an easy solution?
> >
> > > Thx a lot for your help
> > > Arbi (newb)
> >
> > Take a look here:
> http://docs.djangoproject.com/en/dev/howto/static-files/?from=olddocs
> >
> > Alex
> >
> > --
> > "I disapprove of what you say, but I will defend to the death your right
> to
> > say it." --Voltaire
> > "The people's good is the highest law."--Cicero
> >
>

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

2009-02-13 Thread felix
actually if you've got firebug on it won't cache at all.
it will check if for "not modified" headers and reuse if the server says its
not modified.

the worst thing is that firefox is very slow with all the gadgets turned on.
I use safari + firefox at the same time.  just safari for speed.

so arbi -

its a 404, you're path is wrong on the script tag.

you can always copy the js URL out of the html source and try to load the js
directly and try different paths till you find it.







On Fri, Feb 13, 2009 at 11:10 PM, Briel  wrote:

>
> Firefox is known to cashe things a lot, this might be the reason why
> it doesn't load all the stuff. Also you should look at the page source
> to see if the missing js file is listet.
>
> On 13 Feb., 21:14, arbi  wrote:
> > Ok I tryed it, and they say : "test.js is not loaded" in firebug.
> > I don't see what to do next. What is strange also is that my
> > background-body images are loaded on safari (no pb) and not on
> > firefox...
> > Any solution?
> > thx
> >
> > On 13 fév, 18:19, felix  wrote:
> >
> > > use Firefox with Firebug installed if you aren't already.
> >
> > > you can then see if you get any 404s and if any of the included files
> failed
> > > with syntax errors
> > > or if something happened during javascript runtime to kill it
> >
> > > also, I like django-compress quite a bit for css and js
> >
> > >  felix :crucial-systems.com
> >
> > > On Fri, Feb 13, 2009 at 6:11 PM, arbi  wrote:
> >
> > > > Thx, but I did this already. In fact i have no problem for a css doc,
> > > > but problems for a js doc. I don't know why!
> > > > My css is in "/media/css/css_file.css" and my js is in "/media/js/
> > > > test.js". A simple "alert" in my test.js file doesn't work. I don't
> > > > understand.
> > > > Any help?
> > > > Thx!
> > > > Arbi
> >
> > > > On 12 fév, 23:29, Alex Gaynor  wrote:
> > > > > On Thu, Feb 12, 2009 at 5:28 PM, arbi  wrote:
> >
> > > > > > Hi all,
> >
> > > > > > I am trying to execute a javascript doc to display a google map.
> The
> > > > > > javascript doc to refer to is "google-map.js". How do I write it
> in
> > > > > > here ? :
> > > > > > TEMPLATE :
> > > > > >  type="text/javascript">
> > > > > > .
> >
> > > > > > I tryed many things and it did not work! I read many things, but
> I
> > > > > > can't figure out how to solve this pb.
> > > > > > Is there an easy solution?
> >
> > > > > > Thx a lot for your help
> > > > > > Arbi (newb)
> >
> > > > > Take a look here:
> > > >http://docs.djangoproject.com/en/dev/howto/static-files/?from=olddocs
> >
> > > > > Alex
> >
> > > > > --
> > > > > "I disapprove of what you say, but I will defend to the death your
> right
> > > > to
> > > > > say it." --Voltaire
> > > > > "The people's good is the highest law."--Cicero
> >
>

--~--~-~--~~~---~--~~
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: Disabling middleware for tests

2009-02-16 Thread felix
ah ha.

yes, I've wasted several hours over this issue.  it took me a while to
figure out that it was the CSRF middleware that was breaking the tests.
both auth tests and actually every single one that tests the posting of
forms.

I didn't see it mention of this issue in either the CSRF docs or the unit
test docs, but those are both places that we would first look to diagnose.
a docs request ticket should be filed.  I couldn't find one existing.

I thought it was something to do with self.client.login failing (because I
would get 403)



I couldn't figure this out: is there a way to tell that we are running as a
test ?



 felix :crucial-systems.com




On Mon, Feb 16, 2009 at 9:33 PM, stryderjzw  wrote:

>
>
> > from settings import *
> >
> > #CSRFMiddleware breaks authtests
> > MIDDLEWARE_CLASSES = list(MIDDLEWARE_CLASSES)
> > MIDDLEWARE_CLASSES.remove
> > ('django.contrib.csrf.middleware.CsrfMiddleware')
> >
> > # Turn this off to allowteststhat look at http status to pass
> > PREPEND_WWW = False
>

sorry, I don't get this.  what fails ?  response.status_code == 200 ?





>
> >
> > I then run the test suite using this command:
> > python manage.py test --settings=mysite.settings-test.py
> >
> > Best,
> > Dave
> >
>
>

--~--~-~--~~~---~--~~
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 and php can they mix?

2009-02-17 Thread felix
if you don't have extensive pre-existing php (legacy) code I would say do it
all in django.

even if you wrote some already in php you will save more time by throwing it
away and reimplementing in django then you will trying to make them co-exist
or by trying to use a legacy db schema.

if you have to write the facebook part in php, then just do that part.  let
django build and manage the database schema.

I have one client with a large site developed in php and running since
2001.  its drudgery having to go back and do new stuff on it now. :(even
though it was a pretty clever framework at the time and I ported some django
and rails stuff to it over the years.




On Tue, Feb 17, 2009 at 4:14 PM, garagefan  wrote:

>
> The easiest solution i can consider is having php request a url from
> the django project that would return a dynamically created xml file
> that you could then parse via php, set variables from, display, etc.



php, even php5 has pretty poor xml support.  json would work better






>
> You could theoretically run the site in django, and the admin and all
> that goodness, but control display via php.
>
> I'm not really sure that its worth it though. I'm not a php developer,
> but there's got to be a php framework that is as simple to use as
> django as far as database work and an auto admin section is
> concerned... if not, i suppose it would be worth the hassle.
>
>
> On Feb 16, 8:13 am, TimSSP  wrote:
> > HI,
> >
> > I'm looking into using Django to redevelop a website to handle dynamic
> > content and some social app functions. I am interested in knowing
> > whether django can work alongside php, we built a modest database to
> > work on news articles in php and are considering using facebook's api
> > for an application in the near future.
> >
> > I'm wondering whether the facebook would be able to use django on its
> > frontend or whether it would have to be php coded into that part of
> > the site. Any help / advice would be a great help, thanks
> >
> > Best wishes
> >
> > Tim
> >
> > email: tim.clar...@gmail.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
-~--~~~~--~~--~--~---



markdown fails, can't figure out how or why

2009-02-18 Thread felix
I'm getting a failure on my deployed server and I can't figure out what
might cause it.
I've gotten it a few times.

something to do with markdown

going to the URL myself (its fetching the RSS feed) doesn't trigger the
error !

from the stack trace I have no way of knowing what went in

can anybody think of what might cause it ?


postz/models.py", line 252, in make_body
   body = markdown.markdown(force_unicode(smart_str(body)))

 File "build/bdist.linux-x86_64/egg/markdown.py", line 1822, in markdown
   return md.convert(text)

 File "build/bdist.linux-x86_64/egg/markdown.py", line 1745, in convert
   xml = pp.run(xml)

 File "build/bdist.linux-x86_64/egg/markdown.py", line 966, in run
   html, safe  = self.stash.rawHtmlBlocks[i]

IndexError: list index out of range






--~--~-~--~~~---~--~~
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: Modifying pythonpath in settings.py

2009-02-19 Thread felix
possible side effect:

I wrote some class that runs during settings.py and customizes settings
(dev/live/beta)


it logs when doing that, and so I've noticed that settings gets parsed 4
times !

loading ENVIRONMENT: local_settings.py
SITE_URL is: http://127.0.0.1:8000
loading ENVIRONMENT: local_settings.py
SITE_URL is: http://127.0.0.1:8000
loading ENVIRONMENT: local_settings.py
SITE_URL is: http://127.0.0.1:8000
loading ENVIRONMENT: local_settings.py
SITE_URL is: http://127.0.0.1:8000
Validating models...
0 errors found

Django version 1.0-final-SVN-9014, using settings 'sustain.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.


so you might just have appended 4 times.  worth investigating.
check the path before appending.


anyway, I would do it in the .wsgi



On Thu, Feb 19, 2009 at 6:10 AM, David Zhou  wrote:

>
> I've been doing the following for a while, but I'm not sure if it has
> unintended side effects:
>
> #settings.py
> import os, sys
> sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),
> 'apps'))
>
> I keep pluggable apps in an svn repo, and do checkouts of the ones I
> need in the apps folder that's specific to whatever site I'm working
> on.  And since I do this for most of my projects, I figured it'd be
> easier to make sure it was in the pythonpath rather than relying on
> the environment to properly define pythonpath.
>
> Is it considered bad practice to dynamically modify the pythonpath in
> something like settings.py?
>
> -- dz
>
> >
>

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



sporadic mysterious errors

2009-02-28 Thread felix
Mysteriously my site is occasionally throwing errors.  When I go check the
URL (not logged in) there is no such error.

Last night the suddenly site went down for many hours, throwing the errors
below on every response.
Actually I'm not sure if its every response or perhaps one misguided
process.

WSGIDaemonProcess crucial-systems.com processes=2 threads=15
maximum-requests=1000 inactivity-timeout=1


Restarted and everything works fine again.

 File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py", line
77, in get_response
   request.path_info)

 File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line
178, in resolve
   for pattern in self.urlconf_module.urlpatterns:

 File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line
197, in _get_urlconf_module
   self._urlconf_module = __import__(self.urlconf_name, {}, {}, [''])

 File "/home/crucial/crucial-stack/crucial/urls.py", line 39, in 
   admin.autodiscover()

 File "/usr/lib/python2.5/site-packages/django/contrib/admin/__init__.py",
line 40, in autodiscover
   __import__("%s.admin" % app)

 File "/home/crucial/crucial-stack/crucial/website/admin.py", line 3, in

   from crucial.website.models import *

 File "/home/crucial/crucial-stack/crucial/../crucial/website/models.py",
line 113, in 
   permissions.register()

AttributeError: 'module' object has no attribute 'register'


It looks like this is the first time urls.py is being loaded, right ?  Is
this a process starting up ?


I get the following once every few days.

NoReverseMatch: Reverse for 'crucial.default_rss' with arguments '()' and
keyword arguments '{}' not found.

I always use named urls {% url default_rss %}

That its searching for 'crucial.default_rss' is some kind of clue.



Any help or direction of where to investigate much appreciated.





 felix :crucial-systems.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
-~--~~~~--~~--~--~---



http://code.google.com/p/django-ajax-selects/

2009-03-02 Thread felix
I've posted a working first draft for many-to-many and foreign-key lookups
using jQuery.

Works for any form including in the admin


-f

--~--~-~--~~~---~--~~
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: Q search with foreign key

2009-03-03 Thread felix
use two underscores to address the other table/model

institution_institution

vs

institution__institution



django querysets rock !




On Tue, Mar 3, 2009 at 10:19 PM, Jesse  wrote:

>
> I tried that option and received this error:
>
> Cannot resolve keyword 'institution_institution' into field
>
> However, I think I may have it.  I used this statement:
>
>   qset2 = (
>   Q(institution__icontains=queryr)
>)
>resultsi = Institution.objects.filter(qset2).distinct()
> for id in resultsi:
>resultsii=Researchproject.objects.filter(institution=id)
>
> And am able to get the results in the template.  It just makes for
> more coding, however, in the view.  It would be easier to have all the
> code in the qset and not have to add another qset2.
>
> On Mar 3, 1:01 pm, Tim  wrote:
> > If you want to look up an Institution using the Project model, you
> > should be able to use "institution__institution__icontains"
> >
>

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



bizarre: Tabular Inline not showing in form when Debug is off

2009-09-01 Thread felix
I have some objects that have garbage UTF-8 in their titles
!俾爀最愀渀稀愀 ⠀吀爀愀渀猀瀀愀爀攀渀琀 䐀甀戀⤀ (for the amusement of our Chinese friends)

The admin for these objects has a TabularInline which would also repeat that
title, and I think this the clue to the problem.

When debug is off the TabularInline does not show, so the form is broken due
to  missing parts.
When debug is on the TabularInline is there and the form can be edited and
saved.

Does anybody have any insight as to why ?


-- 
felix

--~--~-~--~~~---~--~~
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 form in admin debugging confusion

2009-03-29 Thread felix
class ContactAdmin(Admin):

form = EditContactForm


EditContactForm has a save method that is never called by the Admin

but its clean() function does get called

 60 def clean(self):
 61 import pdb; pdb.set_trace()

 my confusion is that due to the snakey admin code the form class is created
using a different name and is created in the scope of a different module.
 even though the class is explicitly specified in my Admin, that name is
replaced with class_name = model.__name__ + 'Form'

 self.__class__
(Pdb) 
self
(Pdb) 
self.save
(Pdb) >

dir(self)
(Pdb) ['Meta', '__class__', '__delattr__', '__dict__', '__doc__',
'__getattribute__', '__getitem__', '__hash__', '__init__', '__iter__',
'__metaclass__', '__module__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__setattr__', '__str__', '__unicode__', '__weakref__',
'_changed_data', '_errors', '_get_changed_data', '_get_errors',
'_get_media', '_html_output', '_meta', 'add_initial_prefix', 'add_prefix',
'as_p', 'as_table', 'as_ul', 'auto_id', 'base_fields', 'changed_data',
'check_for_account', 'clean', 'clean_email', 'data', 'declared_fields',
'empty_permitted', 'error_class', 'errors', 'fields', 'files', 'full_clean',
'has_changed', 'initial', 'instance', 'is_bound', 'is_multipart',
'is_valid', 'label_suffix', 'media', 'non_field_errors', 'prefix', 'save',
'save_from_request', 'validate_unique', 'will_save']

I can see my clean_email method and other methods that I defined.  it
*is*my class, but its name and module have been changed which makes
debugging
quite difficult.

this leads me on a wild goose-chase trying to figure out why the wrong form
was instantiated.

is there any reason that normal classes aren't used ?  there doesn't seem to
be any use of passing in multiple bases

and I still don't know why save() isn't called by the admin

thankx for any insight

--~--~-~--~~~---~--~~
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 use email instead of username for user authentication?

2009-04-07 Thread felix
I use an EmailBackend for auth, found on django snippets
http://www.djangosnippets.org/snippets/74/
(though the one pkenjora posted looks the same but slightly better.)

and a generate_username to create a clean unique username when creating
accounts,
also found on django snippets

http://www.djangosnippets.org/snippets/723/


I sure wish djangosnippets had a google search box attached.


On Tue, Apr 7, 2009 at 10:38 AM, johan.uhIe <
johan.u...@student.hpi.uni-potsdam.de> wrote:

>
> The slugify function may also provide you with valid usernames, if you
> feed it with first and last name for example. But always be certain,
> that the username is unique, just as malcolm described.
> >
>

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



Help with some models inheritance and the use of default

2009-05-06 Thread Felix

I have the next models:

class Place(models.Model):
currency = models.CharField(_('currency'), max_length=128,
blank=True, null=True)
language = models.CharField(_('official language'),
max_length=128, blank=True, null=True)
class Meta:
abstract = True

class Country(Place):
country = models.CharField(_('country'), max_length = 100)
continent = models.CharField(_('continent'),
choices=CONTINENT_CHOICES, max_length = 2, blank = True, null=True)
president = models.CharField(_('president'), max_length = 100,
blank = True, null=True)

class City(Place):
city = models.CharField(_('city'), max_length=100)
country = models.ForeignKey(Country)
language = ??

How can I set language of the to the language of its country's
language by default?
Thanks for reading
--~--~-~--~~~---~--~~
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   3   >