Re: return related objects from a queryset

2009-09-17 Thread Milan Andric



On Sep 17, 4:02 am, mrts <mrts.py...@gmail.com> wrote:
> On Sep 17, 8:21 am, Milan Andric <mand...@gmail.com> wrote:
>
> > So is there a way I can query on Alumni.objects.filter(**query_params)
> > but then return the Profile objects related to the Alumni objects
> > rather than the Alumni objects?
> >>> query_params = {'grad_year': 2008, 'third_year': True}
> >>> profile_qp = dict(('alumni__' + key, val) for key, val in 
> >>> query_params.items())
> >>> profile_qp
>
> {'alumni__grad_year': 2008, 'alumni__third_year': True}
>
>
>
> >>> Profile.objects.filter(**profile_qp)

Beautiful.  I should have tried that duh!  Thanks.

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



return related objects from a queryset

2009-09-16 Thread Milan Andric

Hello, I'm not sure if the subject makes sense but i have two models:

class Profile(models.Model):
user = models.OneToOneField(User, primary_key=True)
middle_name = models.CharField(max_length=50, blank=True)
title = models.CharField(blank=True, max_length=128)
about = models.TextField(blank=True,help_text="A few sentences
about yourself - capsule biography. No HTML allowed.")
...

class Alumni(models.Model):
profile = models.OneToOneField(Profile, primary_key=True)
grad_year = models.IntegerField('Graduation
year',max_length=4,choices=constants.YEARS, null=True)
third_year = models.BooleanField('Is this student on the 3-year
plan?',default=False)
...

Now I'm working on a search page for people and it's easy enough to do
a query on each model to get results.  But each queryset would be on a
different model so the template would have to deal with a queryset on
Profile, Alumni, or any other extended class that I have.  That seems
kind of messy in the template.

So is there a way I can query on Alumni.objects.filter(**query_params)
but then return the Profile objects related to the Alumni objects
rather than the Alumni objects?  This would allow me to always treat
the results the same in the template regardless of what Profile
extension I am querying.

Thanks for you help,

Milan

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



Re: apps that relate to each other

2009-08-07 Thread Milan Andric



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

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

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



Re: apps that relate to each other

2009-08-07 Thread Milan Andric



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

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

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



Re: apps that relate to each other

2009-08-07 Thread Milan Andric



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

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

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



apps that relate to each other

2009-08-07 Thread Milan Andric

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

people.models:

  class Profile(Model):
 secondary_email = CharField()

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


resources.models:

  class Room(Model):
 name = CharField()

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

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

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

Thanks,

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



Re: how to deploy Django on the web server?

2009-08-07 Thread Milan Andric


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

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

--
Milan

On Aug 7, 1:56 pm, justin jools  wrote:
> thanks for the reply but I have access to a server for free so I wanted to
> set it up myself, how can it be so difficult? Django is renowned as an easy
> rapid development framework so why is it so difficult to deploy?
>
>
>
> On Fri, Aug 7, 2009 at 8:34 PM, lzantal  wrote:
>
> > On Aug 7, 12:06 pm, justin jools  wrote:
> > > This has been driving me nuts for a month.
>
> > > I wanted to use a free web server to do development testing and have
> > > found : 000webhost.com and heliohost.com which apparently support
> > > Python, but what about Django? Do I install that myself?
>
> > > I have read the django book on deployment chapter but find it doesnt
> > > tell me what I want.
>
> > > Could someone please just tell me simply how I can get my scripts
> > > running on the webserver.
>
> > Tryhttp://webfaction.com.
> > They have super easy install for django through their control panel
>
> > hope that helps
>
> > lzantal
> >http://twitter.com/lzantal
>
> > > justinjo...@googlemail.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



multiple sites using one CMS

2009-05-16 Thread Milan Andric

So we are building a CMS that should allow multiple sites to be
supported based on the sites framework or a sites key on various
models we want to be multisite.  This is how I imagine it working:

Each publication site will be a separate django project using the same
database as the CMS.  And each project/publication will have its own
set of templates and media.

Some problems though.  Since we're using the same database we cannot
have any site specific apps that use a database?   So that means users
have to be shared for authentication because the user's contrib app is
not site aware?

Any thoughts on the right way to handle this?

Thanks,

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



mystery with my form being saved

2009-04-29 Thread Milan Andric

Hello,

I've been banging my head on this for several hours ... for some
reason on my reservation edit view, the start_when field will not save
but summary does.  The assertEquals always fails on line 198 in the
paste below.  Do you see anything fishy here?

http://dpaste.com/39489/

Is it because my form does not have that field defined so the save
ignores it?  Or am I just going about this wrong by not setting the
value explicitly in the view.  The next thing I am going to try is to
add hidden fields for the fields that I want saved by the form.

Your thoughts are appreciated,

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



Re: Does anyone know how to prepopulate a form with model data

2009-04-28 Thread Milan Andric



On Apr 9, 1:02 am, Daniel Roseman 
wrote:
> On Apr 9, 2:55 am, codecowboy  wrote:
>
>
>
> > I want to create aformthat allows a user to edit his/her profile.  I
> > don't want to bind myformto a model because theformwill involve
> > two different models.  Does anyone have any ideas.  I've read chapter
> > 7 in the Django Book but it only to a simple example that does not
> > help me.
>
> > Here is what I have tried.
>
> > s = get_object_or_404(Scientist, pk=7)
> >form= ScientistProfileForm(initial=s)
>
> > I've also tried.
>
> >form= ScientistProfileForm(s)
>
> > I always get the following error message.
>
> > Caught an exception while rendering: 'Scientist' object has no
> > attribute 'get'
>
> > Thanks in advance for any help.  If I figure this out then I will post
> > my solution in here in great detail for anyone else that needs it.
>
> If it's not a ModelForm, you can't just pass in an instance. You'll
> need a dictionary.
>
> initial_dict = {
>     'name': s.name,
>     ... etc ...}
>
> form= ScientistProfileForm(initial=initial_dict)
>

Anything wrong with doing this?  form = ScientistProfileForm( initial
= s.__dict__ )

--
Milan

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



Re: dynamic search forms

2009-03-05 Thread Milan Andric

On Thu, Mar 5, 2009 at 6:56 AM, Christoph Pingel
 wrote:
>
> Hello,
>
> this is my first post to the list. Great to work with such a well-
> designed framework!
>
> My question - is there an 'official' way to build dynamic search
> forms where users can add/remove search criteria?
> And if not: How would I best deal with search param names that are
> not initially known server side? I could come up with some
> handcrafted solution, but I'm looking for best practices here to
> avoid unnecessary trouble.
>

Well you could have some kind of mapping between GET args and model
attributes. I have one view like that where I process GET key values
and stick them directly into a .filter() after a bit of processing,
i.e. Model.objects.filter(**kwargs).

Not sure if that answers your question, but hope it helps.  I think
what you are after is GET string processing, not sure of a way around
the grunt work.

--
Milan

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



Re: how reverse works

2009-03-05 Thread Milan Andric



On Mar 5, 12:56 pm, adrian  wrote:
> I've had some problems with reverse and have some questions and
> thoughts:
>
> 1. When I add a view and a corresponding entry in urls,py, sometimes I
> get a reverse error until I stop the dev server and restart it, even
> though nothing is wrong with either file.   Is there an order in which
> those changes should be made that guarantees this won't happen?
>
> 2. The doc says templates are intended to be editable by designers/non-
> programmers.   But any {% url view arg %} tag that is not 100% correct
> (both view and arg) will bring down that page, not just cause a broken
> link.
> The error message usually points to the first {% url %} tag, which may
> be in a base template not in the template that actually contains the
> error.

This is true and many people have commented on this.  The alternative
I have seen is to use the old style, obj.get_absolute_url() and just
put a reverse() inside there. I think that is the best offer django
currently has.

>
> 3. The details given in the error messages for reverse are very
> misleading.   The error is almost always elsewhere and the arguments
> are usually irrelevant.   It is not good policy to imply a specific
> error location when the error system has no idea where the problem
> is.

I've also noticed that errors originating in templates are difficult
to decipher.  I think {% url %} is a case where this problem becomes
very evident since all your urls should use it.  I'm not sure what
django 1.1 has in store, but I know many people have complained about
this.

>
> 4.  One improvement would be something (in the dev server?) that does
> some basic comparison of urls.py and views.   Django  has access to
> all the URL patterns and all the views modules, so couldn't it compare
> the views in one to the views in the other and warn you if there is a
> mismatch?   This would not require reversing the Regexes, just making
> sure the view functions referenced in urls.py are all present in
> views.    That would localize one source of reverse errors.

Not sure what this would achieve.  If you have a urls.py pattern that
points to a non existent view the error is pretty clear when you try
to browse to that page.  I think the real solution for this is to
write tests for every view you expect to exist.  So I think it is a
testing framework solution rather than a default "dry-run" django
should do all the time.  There is a django app that exists to
facilitate this type of automatic test "scaffolding" you might call
it.  But it is a separate app, which I think is good.

http://ericholscher.com/projects/django-test-utils/

>
> 5.  If the checking specified in #4 finds no errors, wouldn't that
> mean the error must be in the template?   At that point, would it be
> possible to localize {% url %} tag errors to show the context of the
> error?   If the template loader combines base templates with sub-
> templates, then the line number is of limited use so the context would
> be more useful.

This would be ideal, I imagine folks are working on this.  If not then
you might want to print this up on django-dev.

>
> I understand this is a difficult problem, but I've found this
> frustrating and believe
> it could be improved.
>
> I'm running 1.0.2 and if this have been improved already, then great.

I second this ...

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



Re: Django docs and automation tests

2009-01-25 Thread Milan Andric



On Jan 25, 9:32 am, Oleg Oltar  wrote:
> Hi!
> Can you please explain me idea of testing django applications with Client()
>
> There many examples in doc, where test cases just checked the
> response.status_code == 200,
>
> But I am often getting 302 instead of 200. Is there any workaround in this
> case?
>

If you are doing a POST and a Redirect then you will get 302 or if you
test a URL with the trailing slash you will get a 302 to redirect to
the complete URL with the trailing slash.

So either you should be checking for a 302 or you should use the
complete URL would be my guess.  More information is required for
further debugging.

--
Milan


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



Re: installing django and pythan

2009-01-16 Thread Milan Andric



On Jan 16, 6:13 am, jazz  wrote:
> iam installing django and activepython on my vista machine but its not
> working. can anyone help me with the installation please. I am bit
> confused how to create the environment variable. nothing is working
> for me...

Sorry jazz I don't have much advice for you, I'm not familiar with
activepython on vista.  If you have normal python working with
activepython then you can install django in the site-packages folder
as a library just like any other libary/module.  Download the django
release and run python setup.py install like stated in the install
docs.

http://docs.djangoproject.com/en/dev/topics/install/#installing-an-official-release

Then you should be able to run python and import django.  Then django
is installed.

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



Re: reusable apps and dependencies

2009-01-10 Thread Milan Andric

On Sat, Jan 10, 2009 at 1:15 PM, uber.ubiwanken...@gmail.com
 wrote:
>
> Sorry, I'm afraid I was not too clear.
> For example:
>
> I've got 2 projects 'myproject1' and 'myproject2' that use django-cms
> (and django-tinymce and so on...).
> 'myproject1' use an old version of django-cms, 'myproject2' a new one.
>
> In settings.py of my projects I have:
>
> INSTALLED_APPS = (
>...
>'cms',
>'tinymce',
>'filebrowser',
>...
> )
>
> In my .profile I have something like this:
>
>  export PYTHONPATH=/Users/giorgio/workspaces/django/apps:$PYTHONPATH
>
> and in /Users/giorgio/workspaces/django/apps I have the old version of
> diango-cms that I don't want to update.
>
> What I have to do? How I have to put the new version?
> How can I have both versions of django-cms?
>

Thinking could create a separate apps directory for each project?  Or
put the old django-cms in a apps-old directory and then set your
python path for that specific project to be

export 
PYTHONPATH=/Users/giorgio/workspaces/django/apps-old:/Users/giorgio/workspaces/django/apps

That's one idea ..

If you were deploying with mod_wsgi then you could do a similar thing
in your dispatch.wsgi file with sys.path.insert() to specify your
python path for each project.

--
Milan

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



Re: working with shp files and geodjango

2008-12-24 Thread Milan Andric

I kind of figured this one out...  the source spatial relation was in  
SRID 3084 format "North_American_Datum_1983".  So if i set that in the  
model as an attribute then I can use the transform method to tranform  
to WGS84 or srid 4326, the default.

poly = models.GeometryField(srid=3084) # 3084 is NAD83 spatial relation

--
Milan

On Wed, Dec 24, 2008 at 10:31 PM, Milan Andric <mand...@gmail.com>  
wrote:
> Hello, I'm playing around with geodjango and this is a GIS question
> but I'm starting my quest for an answer by asking here.
>
> So have a shp file I'm using from the city of chicago:
>
> http://egov.cityofchicago.org/webportal/COCWebPortal/COC_ATTACH/CitywideWardsMap2008.zip
>
> There is a wards.shp file bundled in there that you can successfully
> import into a django model.  Using ogrinfo, for example, I can see the
> polygon information looks like:
>
> ogrinfo -ro -al wards.shp
>
> POLYGON ((1160473.00538277426
> 1921203.86462765656,1160474.21998807907 ...
>
> And the layer description is:
>
> ogrinfo -ro -so apps/wards/data/wards.shp wards
> INFO: Open of `apps/wards/data/wards.shp'
> using driver `ESRI Shapefile' successful.
>
> Layer name: wards
> Geometry: Polygon
> Feature Count: 53
> Extent: (1091130.772400, 1813891.890100) - (1205199.881775, 1951669.020100 
> )
> Layer SRS WKT:
> PROJCS["NAD_1983_StatePlane_Illinois_East_FIPS_1201_Feet",
>   GEOGCS["GCS_North_American_1983",
>   DATUM["North_American_Datum_1983",
>   SPHEROID["GRS_1980",6378137.0,298.257222101]],
>   PRIMEM["Greenwich",0.0],
>   UNIT["Degree",0.0174532925199433]],
>   PROJECTION["Transverse_Mercator"],
>   PARAMETER["False_Easting",984250.0],
>   PARAMETER["False_Northing",0.0],
>   PARAMETER["Central_Meridian",-88.33],
>   PARAMETER["Scale_Factor",0.75],
>   PARAMETER["Latitude_Of_Origin",36.66],
>   UNIT["Foot_US",0.3048006096012192]]
> OBJECTID: Integer (10.0)
> DATA_ADMIN: Real (19.8)
> PERIMETER: Real (19.8)
> WARD: String (4.0)
> ALDERMAN: String (60.0)
> CLASS: String (2.0)
> WARD_PHONE: String (12.0)
> HALL_PHONE: String (12.0)
> HALL_OFFIC: String (45.0)
> ADDRESS: String (39.0)
> EDIT_DATE1: String (10.0)
> SHAPE_AREA: Real (19.11)
> SHAPE_LEN: Real (19.11)
>
> But when I use an example from the geodjango tutorial (
> http://geodjango.org/docs/tutorial.html#id4 ) the numbers are in a
> different format and resemble latitude/longitude.
>
> ogrinfo -ro -so apps/world/data/TM_WORLD_BORDERS-0.3.shp  
> TM_WORLD_BORDERS-0.3
> INFO: Open of `apps/world/data/TM_WORLD_BORDERS-0.3.shp'
> using driver `ESRI Shapefile' successful.
>
> Layer name: TM_WORLD_BORDERS-0.3
> Geometry: Polygon
> Feature Count: 246
> Extent: (-180.00, -90.00) - (180.00, 83.623596)
> Layer SRS WKT:
> GEOGCS["GCS_WGS_1984",
>   DATUM["WGS_1984",
>   SPHEROID["WGS_1984",6378137.0,298.257223563]],
>   PRIMEM["Greenwich",0.0],
>   UNIT["Degree",0.0174532925199433]]
> FIPS: String (2.0)
> ISO2: String (2.0)
> ISO3: String (3.0)
> UN: Integer (3.0)
> NAME: String (50.0)
> AREA: Integer (7.0)
> POP2005: Integer (10.0)
> REGION: Integer (3.0)
> SUBREGION: Integer (3.0)
> LON: Real (8.3)
> LAT: Real (7.3)
>
> So I think what I need to use is the Transverse_Mercator projection
> but I don't know how.Given a lat/long I would like to calculate
> what ward it is in.  Any ideas on how to accomplish this calculate a
> lat/long against this specific projection or vise versa?
>
> Thanks,
>
> Milan
>


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



working with shp files and geodjango

2008-12-24 Thread Milan Andric

Hello, I'm playing around with geodjango and this is a GIS question
but I'm starting my quest for an answer by asking here.

So have a shp file I'm using from the city of chicago:

http://egov.cityofchicago.org/webportal/COCWebPortal/COC_ATTACH/CitywideWardsMap2008.zip

There is a wards.shp file bundled in there that you can successfully
import into a django model.  Using ogrinfo, for example, I can see the
polygon information looks like:

ogrinfo -ro -al wards.shp

POLYGON ((1160473.00538277426
1921203.86462765656,1160474.21998807907 ...

And the layer description is:

ogrinfo -ro -so apps/wards/data/wards.shp wards
INFO: Open of `apps/wards/data/wards.shp'
  using driver `ESRI Shapefile' successful.

Layer name: wards
Geometry: Polygon
Feature Count: 53
Extent: (1091130.772400, 1813891.890100) - (1205199.881775, 1951669.020100)
Layer SRS WKT:
PROJCS["NAD_1983_StatePlane_Illinois_East_FIPS_1201_Feet",
GEOGCS["GCS_North_American_1983",
DATUM["North_American_Datum_1983",
SPHEROID["GRS_1980",6378137.0,298.257222101]],
PRIMEM["Greenwich",0.0],
UNIT["Degree",0.0174532925199433]],
PROJECTION["Transverse_Mercator"],
PARAMETER["False_Easting",984250.0],
PARAMETER["False_Northing",0.0],
PARAMETER["Central_Meridian",-88.33],
PARAMETER["Scale_Factor",0.75],
PARAMETER["Latitude_Of_Origin",36.66],
UNIT["Foot_US",0.3048006096012192]]
OBJECTID: Integer (10.0)
DATA_ADMIN: Real (19.8)
PERIMETER: Real (19.8)
WARD: String (4.0)
ALDERMAN: String (60.0)
CLASS: String (2.0)
WARD_PHONE: String (12.0)
HALL_PHONE: String (12.0)
HALL_OFFIC: String (45.0)
ADDRESS: String (39.0)
EDIT_DATE1: String (10.0)
SHAPE_AREA: Real (19.11)
SHAPE_LEN: Real (19.11)

But when I use an example from the geodjango tutorial (
http://geodjango.org/docs/tutorial.html#id4 ) the numbers are in a
different format and resemble latitude/longitude.

ogrinfo -ro -so apps/world/data/TM_WORLD_BORDERS-0.3.shp TM_WORLD_BORDERS-0.3
INFO: Open of `apps/world/data/TM_WORLD_BORDERS-0.3.shp'
  using driver `ESRI Shapefile' successful.

Layer name: TM_WORLD_BORDERS-0.3
Geometry: Polygon
Feature Count: 246
Extent: (-180.00, -90.00) - (180.00, 83.623596)
Layer SRS WKT:
GEOGCS["GCS_WGS_1984",
DATUM["WGS_1984",
SPHEROID["WGS_1984",6378137.0,298.257223563]],
PRIMEM["Greenwich",0.0],
UNIT["Degree",0.0174532925199433]]
FIPS: String (2.0)
ISO2: String (2.0)
ISO3: String (3.0)
UN: Integer (3.0)
NAME: String (50.0)
AREA: Integer (7.0)
POP2005: Integer (10.0)
REGION: Integer (3.0)
SUBREGION: Integer (3.0)
LON: Real (8.3)
LAT: Real (7.3)

So I think what I need to use is the Transverse_Mercator projection
but I don't know how.Given a lat/long I would like to calculate
what ward it is in.  Any ideas on how to accomplish this calculate a
lat/long against this specific projection or vise versa?

Thanks,

Milan

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



template inheritance miff

2008-12-20 Thread Milan Andric

Hello,

I have two templates in this example, page_base.html
http://dpaste.com/101058/ and intro.html  http://dpaste.com/101059/ .
intro.html inherits from page_base.html,  but the content_head block
does not get inherited.  what am i doing wrong or mis-understanding?

Thanks for your help,

Milan

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



Re: auth: get_profile(): create if it does not exist.

2008-12-17 Thread Milan Andric

On Wed, Dec 17, 2008 at 4:00 AM, Thomas Guettler  wrote:
>
> Hi,
>
> The method user.get_profile() fails, if the user has no profile. During
> my custom login I
> check if the user has a profile and create it if needed.
>
> But sometimes this fails: A new user gets created, but before his first
> login someone else
> tries to access the not yet created profile.
>
> Since all fields of my profile model have default values, it could be
> created it on the fly.
>
> Since I don't want to run a modified django, I will use my own
> get_profile method.
>
> Does some know this problem? How do you solve this?
>
>  Thomas
>

How about setting up a signal on user creation that also creates a profile?

--
Milan

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



Re: TemplateSyntaxError No module name utils

2008-12-10 Thread Milan Andric



On Dec 10, 8:52 pm, Milan Andric <[EMAIL PROTECTED]> wrote:
> I'm getting one of those bubbly exceptions coming through the template
> that are tricky to debug.
>
> TemplateSyntaxError at /
> Caught an exception while rendering: Could not import
> journalism_mm.workshops.views. Error was: No module named utils
>
> http://dpaste.com/97981/
>
> I was reorganizing my code, moving directories around and upgrading
> all my third party apps I reference.
> I also upgraded to django 1.0.x from svn.  I have grepped my code base
> for a dangling utils, but no luck.  I was thinking to use pdb.set_trace
> () but don't know where to begin besides googling.  Also tried
> removing all .pyc files but didn't help.
>
> Any help is greatly appreciated.

Got help on IRC.  All I needed to do was try to import
journalism_mm.workshops.views in the shell and was pointed to the bad
import in journalism_mm.workshops.forms.

> 8 from django.forms.utils import ValidationError

Old cruft.  Thanks rozwell.  I should have tried the shell first
before pdb. hah.

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



TemplateSyntaxError No module name utils

2008-12-10 Thread Milan Andric

I'm getting one of those bubbly exceptions coming through the template
that are tricky to debug.

TemplateSyntaxError at /
Caught an exception while rendering: Could not import
journalism_mm.workshops.views. Error was: No module named utils

http://dpaste.com/97981/

I was reorganizing my code, moving directories around and upgrading
all my third party apps I reference.
I also upgraded to django 1.0.x from svn.  I have grepped my code base
for a dangling utils, but no luck.  I was thinking to use pdb.set_trace
() but don't know where to begin besides googling.  Also tried
removing all .pyc files but didn't help.

Any help is greatly appreciated.

--
Milan



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



Re: Django Training

2008-12-08 Thread Milan Andric

On Mon, Dec 8, 2008 at 10:39 AM, Roland van Laar <[EMAIL PROTECTED]> wrote:
>
> Steve Holden wrote:
>> I am looking at expanding our training offerings for the coming year,
>> and a short course in Django looks like it might be popular. There
>> don't seem to be many Django classes at the moment, and several of the
>> students from our introductory Python classes expressed interest in
>> Django.
>>
>> Without wanting anyone on the list to do my work for me, it would be
>> useful to see some opinions about what to include. The tutorial gives
>> people a good start: should we assume that anyone who wants to take
>> the class has already run through that, or would it be better to start
>> from scratch?

I have successfully taught a one day workshop based on the Django
tutorial/from scratch. I wouldn't want people agonizing on their own
if they are going to take a class.  That's one main reason people take
classes, to save time and energy by having an expert guide them.

Even as I was teaching the tutorial  I found I needed to chop it up
because it was too long for total newbies.  I like teaching from the
tutorial because when people want to go back and learn they know
exactly where to go and can continue where they left off or dive in
deeper on specific areas they are interested in.

I've been wanting to do a screencast based on the tutorial or mainly
the part without the admin customizations.  Just the MVC (err, MTV)
concepts well done and completed using the poll app as the example,
similar to the tutorial.  And then a second screencast on the admin
contrib app.  This is enough to fill a one or two day workshop for
people completely new to Django.

The screencasts and official Django tutorial would be the learning
companions for the workshop/class. The class would allow people the
freedom to ask questions/share knowledge and stay focused while
getting loaded up with  condensed/organized information.

--
Milan

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



Re: filtering in a template based on foreign key or query params

2008-11-08 Thread Milan Andric
Oh, the answer here was to use the regroup template tag.  Thanks Magus.

--
Milan

On Fri, Nov 7, 2008 at 4:37 PM, Milan Andric <[EMAIL PROTECTED]> wrote:

>
> Any thoughts on this one?  Just checking.
>
> Thanks.
>
> On Nov 6, 9:06 pm, "Milan Andric" <[EMAIL PROTECTED]> wrote:
> > Hello,
> >
> > I have a view that displays hundreds of applications based on some filter
> > params.  But I want to render the actual template based on user (an fkey)
> > and list their applications as sub objects. but only the applications
> that
> > were filtered on. bleh.
> >
> > So in the view I do something like:
> >
> > # define queryset params from query string.
> > query_params = {
> > 'status'   : request.GET.get('status', None),
> > 'complete' : request.GET.get('complete', None),
> > 'workshop__in' : request.GET.getlist('workshop__in'),
> > 'user__is_active':True,
> > }
> > # form params need to be integers
> > query_params['workshop__in'] = [int(i) for i in
> > query_params['workshop__
> > in']]
> >
> > # None or '' means don't filter on it.  Remove it so
> > # Foo.objects.filter() will give the correct results.
> > for key in query_params.keys():
> > if query_params[key] == None or query_params[key] == '':
> > del query_params[key]
> >
> > # Pass query dict we just built as keyword args to filter().
> > queryset = Application.objects.filter(**query_params)
> >
> > This gives me applications based on the query params that I iterate over
> in
> > my template.  The problem is I want to change the template now to display
> > based on the person/user foreign key and have the applications listed
> > underneath the person.  If I send a queryset of Users to the template
> then I
> > can get a list of users but I lose the applications filters.  Or is this
> a
> > good solution for some kind of querying filter/template tag?  If I send a
> > list of applications then  I can't list by user.
> >
> > Any suggestions?
> >
> > Thank you,
> >
> > --
> > Milan
> >
>

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



Re: filtering in a template based on foreign key or query params

2008-11-07 Thread Milan Andric

Any thoughts on this one?  Just checking.

Thanks.

On Nov 6, 9:06 pm, "Milan Andric" <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I have a view that displays hundreds of applications based on some filter
> params.  But I want to render the actual template based on user (an fkey)
> and list their applications as sub objects. but only the applications that
> were filtered on. bleh.
>
> So in the view I do something like:
>
>         # define queryset params from query string.
>         query_params = {
>             'status'   : request.GET.get('status', None),
>             'complete' : request.GET.get('complete', None),
>             'workshop__in' : request.GET.getlist('workshop__in'),
>             'user__is_active':True,
>         }
>         # form params need to be integers
>         query_params['workshop__in'] = [int(i) for i in
> query_params['workshop__
> in']]
>
>         # None or '' means don't filter on it.  Remove it so
>         # Foo.objects.filter() will give the correct results.
>         for key in query_params.keys():
>             if query_params[key] == None or query_params[key] == '':
>                 del query_params[key]
>
>         # Pass query dict we just built as keyword args to filter().
>         queryset = Application.objects.filter(**query_params)
>
> This gives me applications based on the query params that I iterate over in
> my template.  The problem is I want to change the template now to display
> based on the person/user foreign key and have the applications listed
> underneath the person.  If I send a queryset of Users to the template then I
> can get a list of users but I lose the applications filters.  Or is this a
> good solution for some kind of querying filter/template tag?  If I send a
> list of applications then  I can't list by user.
>
> Any suggestions?
>
> Thank you,
>
> --
> Milan
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



filtering in a template based on foreign key or query params

2008-11-06 Thread Milan Andric
Hello,

I have a view that displays hundreds of applications based on some filter
params.  But I want to render the actual template based on user (an fkey)
and list their applications as sub objects. but only the applications that
were filtered on. bleh.

So in the view I do something like:

# define queryset params from query string.
query_params = {
'status'   : request.GET.get('status', None),
'complete' : request.GET.get('complete', None),
'workshop__in' : request.GET.getlist('workshop__in'),
'user__is_active':True,
}
# form params need to be integers
query_params['workshop__in'] = [int(i) for i in
query_params['workshop__
in']]

# None or '' means don't filter on it.  Remove it so
# Foo.objects.filter() will give the correct results.
for key in query_params.keys():
if query_params[key] == None or query_params[key] == '':
del query_params[key]

# Pass query dict we just built as keyword args to filter().
queryset = Application.objects.filter(**query_params)

This gives me applications based on the query params that I iterate over in
my template.  The problem is I want to change the template now to display
based on the person/user foreign key and have the applications listed
underneath the person.  If I send a queryset of Users to the template then I
can get a list of users but I lose the applications filters.  Or is this a
good solution for some kind of querying filter/template tag?  If I send a
list of applications then  I can't list by user.

Any suggestions?

Thank you,

--
Milan

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



Re: dispatch.fcgi as text

2008-09-02 Thread Milan Andric

On Mon, Sep 1, 2008 at 7:19 PM, Ronaldo Z. Afonso
<[EMAIL PROTECTED]> wrote:
>
> Hi everybody,
>
> I'm running Django on a shared-hosting provider with Apache and I walked
> through the documentation about FastCGI of the Django website but when I
> try to access some page of my web site, instead of seen the html
> rendered I just see the dispatch.fcgi as text. Does anyone can help me?
>
> ps) My dispatch.fcgi is executable.
>

Ronaldo,

You probably don't have the fastcgi module activated.  In your apache
or .htaccess config make sure you have something like AddHandler
fastcgi-script .fcgi .  If you have the AddHandler in your .htaccess
then maybe Apache is overriding that or it's not in your vhost config.
 AllowOverride All is another important Apache directive that allows
you to use AddHandler in your .htaccess, you can check that also.

Are you running your own apache or just using a service?  If you are
using a service then they may have better instructions about setting
it up.  If you still can't get it to work then post some configuration
information, like your .htaccess and vhost config.

--
Milan

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



Re: dreaded FieldError (used to be KeyError) can only replicate on production, ugh!

2008-07-10 Thread Milan Andric

On Tue, Jul 8, 2008 at 4:30 PM, Milan Andric <[EMAIL PROTECTED]> wrote:
>
>
>
> On Jun 30, 3:01 pm, Milan Andric <[EMAIL PROTECTED]> wrote:
>> I've been wresting with this one for a couple hours now trying to
>> track it down, but no luck.  I'm recently updated to django trunk and
>> getting very odd reponses.  I could take the same page and refresh it
>> several times in succession and eventually get the page, but usually
>> get 500 errors.  What would cause that?
>>
>> http://multimedia.journalism.berkeley.edu/training/projects/
>>
>> I also restarted/stop/started and removed all .pyc files from my
>> project, installed apps and django just for good measure.
>>
>>  I managed to get the traceback while in debug mode that raises a
>> FieldError:http://dpaste.com/5/
>>
>> Here's the wrapped generic view that is being called:http://dpaste.com/60002/
>>
>> Here's the model:http://dpaste.com/60005/
>>

Removing the limit_choices_to param from the Project model's (see
dpaste link above) members attr seems to fix the FieldError.

---snip
members = models.ManyToManyField(
User,
   # limit_choices_to= {'pk__in': get_member_pks()},
help_text="This list is limited to people accepted in
a workshop or staff. ",
filter_interface=models.HORIZONTAL,
)
snip---

--
Milan

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



Re: AutoImageField From Custom upload and filters

2008-07-09 Thread Milan Andric

On Tue, Jul 8, 2008 at 10:23 AM, Milan Andric <[EMAIL PROTECTED]> wrote:
> On Tue, Jul 8, 2008 at 10:02 AM, moos3 <[EMAIL PROTECTED]> wrote:
>>
>> does any know why the auto_rename loses the file name but not the
>> extension?
>
> Not familiar with auto_rename but maybe if you show a little code and
> explain what you are trying to do then someone can help.
>

> http://dpaste.com/61358/ here is the code. here is also the wiki page
> http://code.djangoproject.com/wiki/CustomUploadAndFilters some reason
> instance isn't getting set for some reason.

Still not sure what you mean, auto_rename is supposed to replace or
lose the filename and keep the extension ...

" Renames a file, keeping the extension."

--
Milan

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



Re: Django, Apache, and CSS

2008-07-08 Thread Milan Andric

On Tue, Jul 8, 2008 at 9:47 PM, foo <[EMAIL PROTECTED]> wrote:
>
> First, I want to thank you for your reply Milan!  I just recently
> joined the group and I'm impressed at how active the group is and how
> helpful all of the advice I've found here has been.
>
> I've made the changes that you suggested and unfortunately, I'm still
> seeing the same behavior.  What I did was:
>

What happens when you try to access http://yourserver/media/style.css ?
If you get a 404 then something is not setup right, it could be some
other directive is overriding your media settings.  If you get the
style sheet as expected then we're looking at template glitch, sounds
like a combo. ;)  Just wondering exactly what "seeing same behavior"
means and tackling one thing at a time ...

--
Milan

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



Re: does django cache models.py?

2008-07-08 Thread Milan Andric

On Tue, Jul 8, 2008 at 6:12 PM, Daehee <[EMAIL PROTECTED]> wrote:
>
> i'm trying it figure out why django is not recognizing a new models.py
> file for my app. even when i completely butcher the code in models.py
> or change the filename and run "manage.py sqlreset" or "manage.py
> syndb," it still generates the old model. any thoughts??

Are you sure that app is in INSTALLED_APPS in settings.py?  Otherwise
django and hence runserver ignore it.  Not sure if I'm following
exactly.  If you can post a bit more information like your
directory/file structure and your settings.py that would help
diagnosis.

--
Milan

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



Re: Django, Apache, and CSS

2008-07-08 Thread Milan Andric

On Tue, Jul 8, 2008 at 7:58 PM, foo <[EMAIL PROTECTED]> wrote:
>
> OK, I know this has been posted in the forums before, but for some
> reason, I'm still struggling to get my CSS stylesheet applied to my
> django templates.  I'm hoping that if I post my configuration, someone
> can point out what I'm missing.
>
> I have my django project at:  /opt/python/django-apps/foo/
> In my settings.py file, I have MEDIA_ROOT set to /opt/python/django-
> apps/foo/templates/media/ and MEDIA_URL set to http://localhost/media
>
> In my apache2.conf file, I have the following:
>
> # Django configuration
> LoadModule python_module modules/mod_python.so
>
> 
>SetHandler python-program
>PythonHandler django.core.handlers.modpython
>SetEnv DJANGO_SETTINGS_MODULE foo.settings
>PythonDebug On
>PythonPath "['/opt/python/django-apps/'] + sys.path"
> 
> 
>SetHandler python-program
>PythonHandler django.core.handlers.modpython
>SetEnv DJANGO_SETTINGS_MODULE foo.settings
>PythonDebug On
>PythonPath "['/opt/python/django-apps/'] + sys.path"
> 
>
> 
>SetHandler None
> 
>

An alias directive to tell apache where to find your media is probably
all you need. Assuming your apache's DocumentRoot is something other
than your templates dir.


   SetHandler None

Alias /media/ /opt/python/django-apps/foo/templates/media/

Also putting your media dir in your templates dir is kind of odd.
Usually it's at the top of the project directory.

Then set MEDIA_URL='/media/' you don't need 'http://localhost'.

> In my base.html file, I reference the stylesheet as  rel="stylesheet" type="text/css" href="media/style.css"
> media="screen" />

Finally in your templates use '/media/foo' not 'media/foo', that way
it doesn't matter what location you are serving from, /media/ will
work.

> When I point my browser at http://localhost/contact, all I get is a
> blank page... no style and no text.  The contact.html template is
> below:
>
> {% extends "base.html" %}
>
> {% block title %}
>- Contact Us
> {% endblock %}
>
> {% block content %}
>some content...please show up
> {% endblock %}
>
> I'm not sure if there not being any text is related to the CSS problem
> or not.  I haven't spent any time troubleshooting that just yet, but I
> thought I'd throw it in for good measure.
>
> Any help that anyone can give is greatly appreciated!
>

Also don't forget to set DEBUG=True in your settings.py and check your
error log for more info.

--
Milan

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



Re: Trying to understand project structure w/apps

2008-07-08 Thread Milan Andric

On Tue, Jul 8, 2008 at 3:53 PM, eddie <[EMAIL PROTECTED]> wrote:
>
> Hi guys+gals,
>
> I'm new to django, and I'm trying to wrap my head around a project
> structure.  I have a simple case that I'm thinking about, but can't
> put together a reasonable mental model for it.
>
> I've got a site that has a schedule component (events), and a news
> component (news items).  So I can easily create two apps, one for
> events, and the other for news, and I can create varying ways to
> display these components.  My problem is that when I start thinking
> about the homepage... where I'd like to display both some events, and
> some news items.  I can't figure out how I would use templates to do
> such a thing... place both on the same page.  Ideally, I would like to
> have a template that displays an event, and one that displays a news
> item.  But I'm not sure how that would work, with both of them
> extending the same base template.
>
> I could, of course, create one app which has all of these models
> internal, which would let me easily pull them into a single template,
> but I would really rather not couple the two distinct models together
> in both the view and the templates.
>

Another option is to skip writing a view and just use a generic view
which you can do with a urls.py file and a template.  We just had a
couple people asking similar question:

http://groups.google.com/group/django-users/browse_thread/thread/d2524403e13fcd22/4fe607f6d9487ee9#4fe607f6d9487ee9

But there is nothing wrong and it's quite easy to just create a
frontpage app with just a view that returns the correct objects to a
template.

--
Milan

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



Re: dreaded FieldError (used to be KeyError) can only replicate on production, ugh!

2008-07-08 Thread Milan Andric



On Jun 30, 3:01 pm, Milan Andric <[EMAIL PROTECTED]> wrote:
> I've been wresting with this one for a couple hours now trying to
> track it down, but no luck.  I'm recently updated to django trunk and
> getting very odd reponses.  I could take the same page and refresh it
> several times in succession and eventually get the page, but usually
> get 500 errors.  What would cause that?
>
> http://multimedia.journalism.berkeley.edu/training/projects/
>
> I also restarted/stop/started and removed all .pyc files from my
> project, installed apps and django just for good measure.
>
>  I managed to get the traceback while in debug mode that raises a
> FieldError:http://dpaste.com/5/
>
> Here's the wrapped generic view that is being called:http://dpaste.com/60002/
>
> Here's the model:http://dpaste.com/60005/
>

Does anyone have comments on the above model?  I'm wresting with a
FieldError during a loop in the template and having a hell of a time
tracking down the problem.

The relevant part of the template is:

{% for m in p.members.all %}
{{m.get_profile.get_display_name}}{% if not forloop.last %},
{% endif %}
{% endfor %}


When I do the same loop in the shell I don't get any exceptions.  Any
help is greatly appreciated, this is on trunk.
The code seems to choke on specifically one project (id 51) but I've
traced all the relations in the db that I could think of and don't see
any inconsistencies.  But the template error is not consistent meaning
sometimes i get the exception and sometimes I don't so just trying to
clean things up where I can, starting with the model.

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



Re: AutoImageField From Custom upload and filters

2008-07-08 Thread Milan Andric

On Tue, Jul 8, 2008 at 10:02 AM, moos3 <[EMAIL PROTECTED]> wrote:
>
> does any know why the auto_rename loses the file name but not the
> extension?

Not familiar with auto_rename but maybe if you show a little code and
explain what you are trying to do then someone can help.

--
Milan

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



Re: newforms-admin, forms.ModelForm, formtools.preview

2008-07-08 Thread Milan Andric

On Tue, Jul 8, 2008 at 10:00 AM, Milan Andric <[EMAIL PROTECTED]> wrote:
> On Mon, Jul 7, 2008 at 6:22 AM, d-rave <[EMAIL PROTECTED]> wrote:
>>
>> Has anyone successfully got formtools.preview working with
>> forms.ModelForm so that the form fields are populated from the model.
>>
>> If so, do you have an example??
>
> Dave, I'm not familiar with formtools but if all you want to do is
> prepopulate a form then you can use the initial={} keyword arg.  This
> probably doesn't help but ... you could do this in your view if you
> want:
>
> form = Form(initial={'user':u, ...})
>
> http://www.djangoproject.com/documentation/newforms/#dynamic-initial-values
>

Another trick is to use model_to_dict to pass in initial values :

from django.newforms.models import model_to_dict
...
 f = Form( initial=model_to_dict(obj) )

--
Milan

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



Re: newforms-admin, forms.ModelForm, formtools.preview

2008-07-08 Thread Milan Andric

On Mon, Jul 7, 2008 at 6:22 AM, d-rave <[EMAIL PROTECTED]> wrote:
>
> Has anyone successfully got formtools.preview working with
> forms.ModelForm so that the form fields are populated from the model.
>
> If so, do you have an example??

Dave, I'm not familiar with formtools but if all you want to do is
prepopulate a form then you can use the initial={} keyword arg.  This
probably doesn't help but ... you could do this in your view if you
want:

form = Form(initial={'user':u, ...})

http://www.djangoproject.com/documentation/newforms/#dynamic-initial-values

--
Milan

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



Re: ImageField error

2008-07-06 Thread Milan Andric

On Sun, Jul 6, 2008 at 3:12 PM, Molly <[EMAIL PROTECTED]> wrote:
>
> Millan,
>
> I'm doing this in dev environment with the built in webserver. No it's
> not a mod_python error.
>
> I'm using the static setup and I can get to it fine when I upload my
> photo.
> The problem is when I click the photo it seems to be pointing to
> somewhere else.
>
> In my models:
> ==
> photo = models.ImageField("Photograph", upload_to='images/uploaded',
> blank=True,null=True)
> ==
>
> if i manually go to /images/uploaded my photo is there, but the link
> in the admin site seems to be wrong.
>
> this is the link, it's adding all of the extra information:
> ==
> http://127.0.0.1:8000/admin/base/incident/1/media/images/uploaded/DCP_0326.JPG
> ==

What do you have for MEDIA_URL in your settings.py file?  Should be
something like MEDIA_URL='/media/', my guess is you are missing a
leading slash.  If you can paste your settings.py and model that would
help, http://dpaste.com .

--
Milan

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



Re: Using a Custom Manager for date based generic views??

2008-07-06 Thread Milan Andric

On Sun, Jul 6, 2008 at 5:53 PM, Christopher Clarke <[EMAIL PROTECTED]> wrote:
> Hi Guys
> I'm  building a django based system for a company that monitors the mutuals
> funds industry
> We have Mutual Funds Companies (Issuer) who have one or more funds (Fund)
> and every month the funds submit a volume report
> Here is a simplified version
> 
> class Issuer(models.Model):
>name=models.CharField(max_length=100,unique=True)
>--
>--
>--
> class Fund(models.Model):
> issuer = models.ForeignKey(Issuer)
> symbol = models.CharField(max_length=15,unique=True)
> --
> --
> class FundVolumeReport(models.Model):
>
> fund= models.ForeignKey(Fund)
> period_ending=models.DateField()
>
>  
> units_purchased_individuals=models.FloatField(verbose_name="Individuals",blank=True,null=True)
>
>  
> units_purchased_institutions=models.FloatField(verbose_name="Instutions",blank=True,null=True)
> --
> --
> Now we need to produce totals for each Issuer by month   i implemented a
> date based generic view using a model (IssuerVolumeAggregates) which wrapped
> a database view which did the aggregation i.e
> CREATE OR REPLACE VIEW core_issuervolumeaggregates AS
>   select
>   
> trim(to_char(i.id,'999'))||trim(to_char(vd.period_ending_id::int,''))::int
> as id,
>   i.id as issuer_id,
>   max(i.name)as name,
>   m.dateix as period_ending,
>   count(*) as no_funds
>   --
> --
>  from core_fundvolumedata vd,
>   core_fund f, core_issuer i, freqdates_monthly m
>   where f.id=vd.fund_id and f.issuer_id=i.id
>   and m.id=vd.period_ending_id
>   group by i.id,vd.period_ending_id,m.dateix
>   order by i.id,m.dateix;
> This works pretty well but its kind a clunky so i was wondering if i could
> do the same thing with a custom manager
> ==
> class IssuerManaager(models.Manager):
>
> def with_aggs(self):
> from django.db import connection
> cursor=connection.cursor()
> cursor.execute("""
> select i.id,max(i.name), m.dateix AS period_ending,
> count(*) AS no_funds,
> sum(vd.total_units_issued_outstanding) as
> total_units_issued_outstanding,
> sum(vd.total_unit_holders) as no_unit_holders,
> sum(vd.tt_total_net_assets_under_management) AS
> net_assets_under_management,
> sum(vd.tt_value_redemptions) AS total_redemptions,
> sum(vd.tt_value_sales) AS total_sales
> FROM core_fundvolumedata vd, core_fund f, core_issuer i,
> freqdates_monthly m
> WHERE f.id = vd.fund_id AND f.issuer_id = i.id AND m.id =
> vd.period_ending_id
> GROUP BY i.id, m.dateix, vd.period_ending_id
> ORDER BY i.id, m.dateix;
> """)
> results_list= []
> for each in cursor.fetchall():
> p= self.model(id=each[0],name=each[1])
> p.period_ending=each[2]
> p.no_funds = each[3]
> p.units_issued_outstanding=each[4]
> p.no_unit_holders=each[5]
> p.net_assets_under_management=each[6]
> p.redemptions=each[7]
> p.sales=each[8]
> results_list.append(p)
> return results_list
>
> class Issuer(models.Model):
> name = models.CharField(max_length=100)
>   --
>   --
>   --
> objects = IssuerManaager()
>   The manager works but when i try to use it in the generic view
>  return archive_month(
>  request,
>  year=year,
>  month=month,
>  queryset = Issuer.objects.with_aggs(),
>  date_field = 'period_ending',
> I get
> list' object has no attribute 'model'
> Am i on the right track and how do i get this to work??
> Thanks for any help

Hrm, can you include a complete traceback?  Looks like you are on the
right track, just looking at
http://www.djangoproject.com/documentation/model-api/#custom-managers
.

--
Milan

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



Re: home page

2008-07-06 Thread Milan Andric

On Sun, Jul 6, 2008 at 10:52 PM, keegan3d <[EMAIL PROTECTED]> wrote:
>
> Hey everyone,
>
> I am a little foggy on how I would go about making a home page, by
> that I mean the page that people see when they go to the main address:
> www.mysite.com.
>
> Should I make a "home page" app? or does django have a way of dealing
> with this?
>

If your frontpage doesn't change much you can also just use a template
and generic view url config to manage it.

# or also include some forum entries on the homepage as well
object_list = Forum.objects.all()
...
  url(
   r'^$',
   'django.views.generic.simple.direct_to_template',
   {'template': 'home.html', 'extra_context': {
'object_list':object_list } }
   ),
...

http://www.djangoproject.com/documentation/generic_views/#django-views-generic-simple-direct-to-template

--
Milan

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



Re: html templates - 'for' cycle without a variable

2008-07-06 Thread Milan Andric

On Thu, Jul 3, 2008 at 10:21 AM, antony_h <[EMAIL PROTECTED]> wrote:
>
> How could I repeat my  20 times?
> I've found how I can repeat it 5 times:
> {% for a in 12345|make_list %}
> 
> {% endfor %}
> But it's not so great for e.g. a hundred
> Usage: my designer wants to test his layout and I don't want to create
> a custom tag for such a simple task
>

You could probably use a generic view for this pretty easily, just
pass in a list with 20 elements in it.  Something like :

list = range(0,20)

   url(
r'^test/$',
'django.views.generic.simple.direct_to_template',
{'template': 'test.html', 'extra_context': { 'list':list } }
),

See generic views documentation:
http://www.djangoproject.com/documentation/generic_views/#django-views-generic-simple-direct-to-template

The django templating language is purposely dumbed down so the work is
done in the view according to the model-view-template pattern.

--
Milan

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



Re: pluggable django ticketing app?

2008-07-06 Thread Milan Andric

On Sun, Jul 6, 2008 at 12:05 AM, chefsmart <[EMAIL PROTECTED]> wrote:
>
> Does anyone know of a pluggable django ticketing app? Something like
> the apps used by webhosts for online support?

I have yet to see something available for Django that does
ticketing/issue tracking.  But I may have missed it, hopefully someone
on this list can enlighten the both of us.  But in the Python world
setting up Trac to integrate Django authentication was not too ugly.
Here's the Trac module I used with the 0.12 (i think) version of Trac.

http://trac-hacks.swapoff.org/attachment/wiki/DjangoAuthIntegration/djangoauth_1.py
http://trac-hacks.org/wiki/DjangoAuthIntegration

But I have heard at least a handful of people interested in developing
this kind of app, me included, but my queue is backlogged as usual.

--
Milan

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



Re: Django based CMS

2008-07-05 Thread Milan Andric

On Sat, Jul 5, 2008 at 6:09 AM, Fernando Rodríguez <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> Is there any open source django based cms you would recommend?  Th
> eonlyone I've seen so far is PyLucid. What else is there?
>
> Thanks!

There's a couple of them available on code.google.com and elsewhere on
the net. But most of the time you use the framework to build a custom
CMS so instead of finding CMSs you will find applications.  That is
the general pattern, people release apps and a CMS is just a django
project using a specific set of installed apps, some custom and some
maintained elsewhere.

One interesting "CMS" I ran into lately is Pinax,
http://pinax.hotcluboffrance.com/ .

--
Milan

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



Re: Free Comments problem...

2008-07-02 Thread Milan Andric

Can you paste your template at http://dpaste.com so we can have a look?

On Wed, Jul 2, 2008 at 11:10 AM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> : ) absolutely! It's in an entry template. I've tried the same thing
> in other templates as well (a gallery page, a photo page...) and the
> same.
>
> I don't get any error messages at all. The page loads fine. If I
> change the syntax of the {% free_comment_form ... %}, for example by
> introducing a spelling error or something, then I get an error page,
> but otherwise, Django doesn't complain.
>
> On Jul 2, 11:27 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>> On Wed, Jul 2, 2008 at 11:14 AM, [EMAIL PROTECTED] <
>>
>> [EMAIL PROTECTED]> wrote:
>>
>> > Yeah, so in the parent template (base.html) I've specified the usual
>> > {% block content %} and in the child template, the call to the form is
>> > well within the corresponding block tags. I've checked syntax about a
>> > million times too, to make sure there's no syntax error - it's a
>> > pretty simple project, so not much to check.
>>
>> > thanks for the answer though - any other ideas?
>>
>> Are you absolutely sure the template being rendered is the one where you
>> have put the {% free_comment_form ... %}?  If you deliberately introduce an
>> error (like omitting the {% load comments %} or mistyping a variable name in
>> the comment form arguments, do you get the expected "Invalid block tag" and
>> "VariableDoesNotExist" errors?
>>
>> Karen
> >
>

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



Re: Using WingIDE's shell instead of manage.py shell

2008-07-02 Thread Milan Andric

On Wed, Jul 2, 2008 at 11:30 AM, Fernando Rodríguez <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I'd like to use WingIDE's own python shell with django, instead of the
> terminal you get with manage.py shell.
>
> However, if I try to eval a file form within Wing, I get this error:
>
> Traceback (most recent call last):
>  File "/home/fernando/", line 1, in 
>  File "/var/lib/python-support/python2.5/django/db/__init__.py", line
> 7, in 
>if not settings.DATABASE_ENGINE:
>  File "/var/lib/python-support/python2.5/django/conf/__init__.py", line
> 28, in __getattr__
>self._import_settings()
>  File "/var/lib/python-support/python2.5/django/conf/__init__.py", line
> 53, in _import_settings
>raise EnvironmentError, "Environment variable %s is undefined." %
> ENVIRONMENT_VARIABLE
> EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is
> undefined.
>
> How can I fix this?

You need to set the environment variable in wingIDE somehow .  Not
sure how that's done but i'm sure google knows. In bash it would be :

export DJANGO_SETTINGS_MODULE='myproject.settings'

--
Milan

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



Re: ImageField error

2008-07-02 Thread Milan Andric

On Wed, Jul 2, 2008 at 12:21 PM, Molly <[EMAIL PROTECTED]> wrote:
>
> I added ImageField to my models like this:
>
> 
> photo = models.ImageField("Photograph", upload_to='media/images',
> blank=True,null=True)
> 
>
> I "import Image" in my imports, and in my models I:
>
> 
> from django.db.models import ImageField
> 
>
> Everything works.. it shows up on my site, I upload it and it is
> there. When I open the picture, i get this error:
>
> 
> error: (10061, 'Connection refused')
> 
>
> I would appreciate any help!
>
> Thank you!!

Molly,

Are you doing this in your dev. environment with the built in
webserver or on a production setup?  Just wondering about the
connection error, never heard of it.  Is that a mod_python error?
Maybe you can post the entire stack trace if you have it at
http://dpaste.com/ ?

If you are serving static media, you should be able to copy an image
in your media dir and manually type in the URL to get it.

Also  have a look here, many people use this type of setup in their
dev environment to serve static media using django.views.static.serve.

http://www.djangoproject.com/documentation/static_files/#limiting-use-to-debug-true

--
Milan

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



Re: Adding groups to groups

2008-07-02 Thread Milan Andric

On Wed, Jul 2, 2008 at 2:23 PM, Dan Lazewatsky <[EMAIL PROTECTED]> wrote:
>
> Is there any way to add a group to another group, similarly to how you
> would add a user to a group. For example, let's say I have four groups:
> Undergraduates, Grad Students, Faculty and Staff, and there are a bunch
> of permissions that will always be the same for Undergraduates and Grad
> Students - so it would be nice to be able to add Undergraduates and Grad
> Students to a sort of meta-group called Students where I can manage all
> of the permissions they have in common.
>

Just wondering why you wouldn't just create the "meta" group called
Students and assign a user to more than one group?  So a grad student
would be in Student and Grad Student.  Just one extra click for an
admin and would probably save you a bunch of work.

Not an answer to your question but it would provide the functionality.
 I know nothing about adding a group to a group unfortunately.

--
Milan

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



Re: dreaded FieldError (used to be KeyError) can only replicate on production, ugh!

2008-07-01 Thread Milan Andric



On Jul 1, 5:03 am, "Scott Moonen" <[EMAIL PROTECTED]> wrote:
> Milan, I took another look at the error and your template.  Judging from the
> error (it seems to be complaining about some access to the member object,
> rather than the project list), I think the reference to line 9 is a red
> herring.  In other words, the outermost tag that Django is rendering at the
> time is your outer for loop, but the real problem is occurring in the
> rendering of an inner loop.
>
> So I'd ignore the reference to line 9 and look further at the inner contents
> of that for loop.  I don't think the entire for loop is included in the
> dpaste traceback snippet, as I don't see its endfor.
>

The problem is with the {% for m in p.members.all %} line, where the
manytomanyfield members gets resolved.  When I comment out that for
loop things are fine.  I have no problem doing this in the django
shell:

>>> for p in Project.objects.all():
>>>   p.members.all()

But it causes a FieldError in the template only on production (apache/
mod_python) which is running MySQL4 while my dev has MySQL5.  I will
try a recent copy of the db to see if it's something in the db.  Also,
I made a UserProfile model change since I upgraded to queryset-
refactor/trunk which consisted of doing OneToOneField(User,
primary_key=True) ...

--
Milan


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



Re: dreaded FieldError (used to be KeyError) can only replicate on production, ugh!

2008-06-30 Thread Milan Andric



On Jun 30, 3:32 pm, Milan Andric <[EMAIL PROTECTED]> wrote:
> On Jun 30, 3:08 pm, "Scott Moonen" <[EMAIL PROTECTED]> wrote:
>
> > Hi Milan, would you mind posting the source for the object_list function as
> > well?
>
> I just imported object_list from django.views.generic.list_detail.
>

One oddity I think I picked out of the html traceback was in
/foobar/django/db/models/query.py in filter
return self._filter_or_exclude(False, *args, **kwargs)

self is a list of ALL the User objects.  Not sure what is causing all
that stuff to be pulled through a seemingly simple view.

Attached screenshot:
http://flickr.com/photos/mandric/2626560500/sizes/o/

Figured maybe this has something to do with the traceback since it
seems like django is looking for a .project attribute on a User
object.  Any clues are greatly appreciated!

--
Milan

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



Re: dreaded FieldError (used to be KeyError) can only replicate on production, ugh!

2008-06-30 Thread Milan Andric


On Jun 30, 3:08 pm, "Scott Moonen" <[EMAIL PROTECTED]> wrote:
> Hi Milan, would you mind posting the source for the object_list function as
> well?
>

I just imported object_list from django.views.generic.list_detail.

--
Milan

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



dreaded FieldError (used to be KeyError) can only replicate on production, ugh!

2008-06-30 Thread Milan Andric

I've been wresting with this one for a couple hours now trying to
track it down, but no luck.  I'm recently updated to django trunk and
getting very odd reponses.  I could take the same page and refresh it
several times in succession and eventually get the page, but usually
get 500 errors.  What would cause that?

http://multimedia.journalism.berkeley.edu/training/projects/

I also restarted/stop/started and removed all .pyc files from my
project, installed apps and django just for good measure.

 I managed to get the traceback while in debug mode that raises a
FieldError:
http://dpaste.com/5/

Here's the wrapped generic view that is being called:
http://dpaste.com/60002/

Here's the model:
http://dpaste.com/60005/

I also have copied the production database into a dev environment
using the built-in webserver and verified  code versions are the same
(django and my project). I cannot replicate the problem in dev
environment so it's kind of a pain to debug.  Not sure what other
software components to look at that would squelch or avoid the error
in my dev environment.  The only main difference is I'm using the
built-in webserver and MySQL5 instead of MySQL4.

Any help is greatly appreciated,

--
Milan


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



Re: get admin url patch on db/models/base.py

2008-06-30 Thread Milan Andric



On Jun 29, 7:46 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2008-06-29 at 17:27 -0700, Milan Andric wrote:
> > I was just curious if anything like this get_admin_url patch was
> > already available in django trunk somewhere and I can eliminate the
> > patch from my patched version of django.  Or is there a more
> > appropriate way to do this so it doesn't cause a conflict?
>
> > Link:http://dpaste.com/59850/
>
> Code like that doesn't really have any place in the Models class, so
> it's not likely to be in core. It would promote the admin application to
> some kind of special treatment by hardcoding it in and we try very hard
> to avoid doing that. Remember that we are in the process of moving admin
> dependencies *out* of the Model class not putting them in.
>
> Adding a method like that to a class sounds more like something that
> would be done by the admin class (I'm thinking about newforms-admin
> here, since existing admin is on life-support only) as part of
> initialiasing that. However, it doesn't make sense to do it by default,
> since each model won't necessarily have a unique admin URL. But it's
> certainly something you could do as a custom addition to the admin class
> for particular models with newforms-admin.
>

Ok, I will revisit this when newforms-admin gets merged in trunk.
Thanks for the feedback Malcolm.

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



get admin url patch on db/models/base.py

2008-06-29 Thread Milan Andric

I was just curious if anything like this get_admin_url patch was
already available in django trunk somewhere and I can eliminate the
patch from my patched version of django.  Or is there a more
appropriate way to do this so it doesn't cause a conflict?

Link: http://dpaste.com/59850/

Pasted:
svn diff /opt/local/lib/python2.5/site-packages/django/db/models/
base.py
Index: /opt/local/lib/python2.5/site-packages/django/db/models/base.py
===
--- /opt/local/lib/python2.5/site-packages/django/db/models/base.py
(revision 7787)
+++ /opt/local/lib/python2.5/site-packages/django/db/models/base.py
(working copy)
@@ -8,6 +8,7 @@
 import django.db.models.manager # Ditto.
 from django.core import validators
 from django.core.exceptions import ObjectDoesNotExist,
MultipleObjectsReturned, FieldError
+from django.core.urlresolvers import reverse
 from django.db.models.fields import AutoField, ImageField,
FieldDoesNotExist
 from django.db.models.fields.related import OneToOneRel,
ManyToOneRel, OneToOneField
 from django.db.models.query import delete_objects, Q,
CollectedObjects
@@ -524,6 +525,8 @@
 setattr(self, cachename, get_image_dimensions(filename))
 return getattr(self, cachename)

+def get_admin_url(self):
+return
reverse('django.contrib.admin.views.main.change_stage',
args=(self._meta.app_label, self._meta.module_name, self.pk,))
 
 # HELPER FUNCTIONS (CURRIED MODEL METHODS) #
 


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



ugh, TypeError: Cannot resolve keyword err ...

2008-06-20 Thread Milan Andric

This TypeError message always baffles me and is hard to debug.  I'm
using SVN 6962 which means I should probably upgrade, but I tried that
a month or so ago around query-set-refactor merge and things were
unhappy so decided to wait.

TypeError: Cannot resolve keyword 'presentation' into field. Choices
are: groups, user_permissions, tutorial, forum_post_set, subscription,
logentry, application, ...

Here's two stack traces that cause the problem:

http://dpaste.com/57816/
http://dpaste.com/57701/

Here's the patch that causes both of them, very odd:

Index: /workshops/models.py
===
--- /workshops/models.py (revision 967)
+++ /workshops/models.py (revision 1015)
@@ -1217,11 +1217,20 @@
 return dir_choices

+def get_member_pks():
+"""
+Return unique list of user id's that are staff or have been
accepted.
+"""
+dict={}
+for u in User.objects.filter(is_staff=True):
+dict[u.pk]=True
+for u in
User.objects.filter(application__status=Application.ACCEPTED_STATUS):
+dict[u.pk]=True
+return dict.keys()
+
 workshop = models.ForeignKey(Workshop)
 members = models.ManyToManyField(
 User,
-limit_choices_to={
-'application__status' :
Application.ACCEPTED_STATUS,
-},
-help_text="This list is limited to people accepted in
a workshop. ",
+limit_choices_to= {'pk__in': get_member_pks()},
+help_text="This list is limited to people accepted in
a workshop or staff. ",
 filter_interface=models.HORIZONTAL,
 )

Here's the model the patch applies to:

class Project(models.Model):

def get_dir_choices():
"""
returns a tuple of tuples of directories for use with choices
in a
selectfield.
"""
import os
import re
dir_choices = []
# only go 4 dirs deep from project_static_root
match1 = re.compile('^[^/]+/[^/]+/[^/]+/[^/]+$')
match2 = re.compile('^[^/]+/[^/]+/[^/]+$')
for root, dirs, files in
os.walk(settings.PROJECT_STATIC_ROOT):
for d in dirs:
d = os.path.join(root, d)
d = d.replace(settings.PROJECT_STATIC_ROOT, "", 1)
# relative path is stored in DB
if re.search(match1, d) or re.search(match2, d):
# check for index.html
if os.path.isfile(settings.PROJECT_STATIC_ROOT+d
+os.path.sep+'index.html'):
dir_choices.append((d, d))
return dir_choices

def get_member_pks():
"""
Return unique list of user id's that are staff or have been
accepted.
"""
dict={}
for u in User.objects.filter(is_staff=True):
dict[u.pk]=True
for u in
User.objects.filter(application__status=Application.ACCEPTED_STATUS):
dict[u.pk]=True
return dict.keys()

workshop = models.ForeignKey(Workshop)
members = models.ManyToManyField(
User,
limit_choices_to= {'pk__in': get_member_pks()},
help_text="This list is limited to people accepted in
a workshop or staff. ",
filter_interface=models.HORIZONTAL,
)
pub_date = models.DateField('Published Date')
title = models.CharField(blank=False, max_length=255)
directory = models.TextField(
'Directory',
help_text="The directory where the project files live, not
including the base.  This maps directly to the filesystem.  Currentl
the base is "
+ settings.PROJECT_STATIC_ROOT + '.',
blank=True,
choices=get_dir_choices(),
#prepopulate_from=('title','pub_date'),
)
url = models.URLField(
help_text="Useful if the project is hosted on another
server.",
verify_exists=False,
blank=True
)
pullquote = models.CharField(max_length=150, blank=True)
desc = models.TextField(blank=False)
public = models.BooleanField(default=False)
enable_comments = models.BooleanField(default=True)
image = models.ImageField(
help_text='A small screenshot or thumbnail that represents
this project. Typically less than 250px wide.',
upload_to='upload/projects/',
blank=True)


class Admin:
list_display = ( '__unicode__',
'workshop','pub_date','public',)
list_filter = ['workshop']
js = (
 '/admin/media/js/getElementsBySelector.js',
 '/admin/media/filebrowser/js/AddFileBrowser.js',
 '/media/js/tiny_mce/tiny_mce.js',
 '/media/js/TinyMCEAdmin.js',
 '/media/js/admin.js',
)

def __unicode__(self):
return self.title


def get_show_url(self):
if self.url:
return self.url
else:
return 

local import or not for django apps?

2008-05-29 Thread Milan Andric

http://code.google.com/p/django-survey/issues/detail?id=9=1

Anyone happen to have a strong opinion on this?  Should django
applications use local imports or package based imports?  Sorry if
this has been mulled over a million times.

pasting conversation here:

Comment 2 by doug.napoleone, Today (90 minutes ago)

NOTE: The convention is moving to local imports over package named
imports for
reusable apps. For instance one client of django-survey has all their
3rd party apps
under 'externals' and imports those apps as externals.survey.models

This means that they have to edit our imports to use the prefix
'externals.'
In general when doing package development in python, local imports are
preferred over
absolute as you do not have control over what 'absolute' actually is.

Comment 3 by mandric, Today (76 minutes ago)

no shit ... news to me.  When I went to the python conference in
Chicago this year,
all I heard was that local imports are evil.  But I guess it all
depends.

I also thought one of the basic tenants of app development is that the
app should
always sit on the python path.  I wonder what ubernostrum's take is on
this because
releases (django-registration, django-profiles) use package based
imports.  And those
apps have been around for a long time, he is also a core maintainer
and gets paid to
work on Django from the what I know.

--~--~-~--~~~---~--~~
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: Ning-like applications for Django?

2008-05-28 Thread Milan Andric

Wow. Django distributions ... this should be on the djangoproject
website.  I'm amazed anyway ... the one that makes me happiest though
is openid support.

--
Milan

On May 28, 6:26 am, "Justin Lilly" <[EMAIL PROTECTED]> wrote:
> Funny you should mention this. Check 
> outhttp://pinax.hotcluboffrance.comwhisis basically exactly what you're
> looking for.
>  -justin
>
>
>
> On Wed, May 28, 2008 at 7:05 AM, ZebZiggle <[EMAIL PROTECTED]> wrote:
>
> > Hi, for a new project I'm working on I had planned on using Ning as
> > the community holder and then using Django to make widgets to fit
> > inside. But I find that Ning is painfully slow to the point that it's
> > unusable (anyone else found this)?
>
> > That said, I think I need to go another route.
>
> > Can anyone suggest a good social networking application/framework that
> > is Django-based?
>
> > Core features:
> > + Friend management
> > + Messages
> > + Photos
> > + Videos
> > + Extensible with custom content
>
> > Thanks in advance,
> > Zeb
>
> --
> Justin Lilly
> Web Developer/Designerhttp://justinlilly.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: hanging os.system() when doing pdf generation

2008-05-27 Thread Milan Andric



On May 27, 11:05 am, Milan Andric <[EMAIL PROTECTED]> wrote:
> On May 27, 1:10 am, Jeff Anderson <[EMAIL PROTECTED]> wrote:
>
> > Milan Andric wrote:
> > > Hello,
>
> > > I have a helper-like django method that does a little pdf generation.
> > > For some reason when I run this view on the dev server the os.system()
> > > call just hangs.  When I run the cmd by hand it works fine.  I'm using
> > > python 2.5 and pretty recent trunk of Django.  It's a bit rough around
> > > the edges...
>
> > This is what I'd do to help diagnose/solve the problem:
>
> > 1) make sure that the environment is suitable to running the command
> > (PATH set correctly, correct working directory, perms, etc...)
> > 2) run the command using os.system() in a python interpretor
>
> Worked just fine from the interpreter but I noticed some stuff being
> returned on stdout (same as on cmd line).  So I added the --quiet
> option to htmldoc and now it seems fine and returns 0 in the
> interpreter.  Maybe the os.system() call within the view didn't make
> django very happy since it was returning junk.
>


Furthermore I just did

import sys
sys.stderr.write(os.system(cmd))
sys.stderr.flush()

to see what the error message from the command is in the production
server log.

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



Re: Genealogy apps

2008-04-28 Thread Milan Andric



On Apr 28, 12:32 pm, ecrosstexas <[EMAIL PROTECTED]> wrote:
> Does anyone know of any existing apps writtrn in Django for
> genealogy?  I thought there was one in Google Code awhile back, but I
> can't seem to find it now.

I've heard of one called begat but it may have disappeared from google
code.

http://begat.google.com/

Here's the project from a while ago, maybe you can contact the
original author.

http://andric.us/media/begat.zip

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



Great article about web2py

2008-04-28 Thread Milan Andric

This is not Django specific but it is framework relevant.  I thought
this was a great writeup of features for any framework.  At least I am
one person who likes the features of this web2py framework.

http://mdp.cti.depaul.edu/examples/static/web2py_vs_others.pdf

Web2py makes development happen faster because people can get up and
running quickly.  I have only played with it enough to be amazed.  It
allows the less technical disciplines like designers, journalists and
web producers to start building or collaborating with web based
database driven apps.

The difficulty for my organization (News21) is the biggest technical
problem which is integrating different technologies like flash and
javascript.  It is difficult to do when each discipline has their own
tools and technologies that don't integrate well. I think this is one
step closer to making these different disciplines work better.

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



Re: setting up apache on OSX

2008-02-09 Thread Milan Andric

Newbie, I use macports with osx, but that's on my production
environment.   Macports makes handling all the software packages much
easier.  You just need the latest version of Xcode (gcc and friends)
to start building with macports.   If you're just doing development
you don't have to go through all that, but usually development leads
to something. ;)

On Feb 9, 1:20 am, js <[EMAIL PROTECTED]> wrote:
> Hi,
>
> If you're not planning on setting up productioin environment,
> but just for testing/developing, you don't have to use apache.
> Django development server is good enough your porpose.
>
> If you want to learn how to set up secure apache,
> you might want to checkhttp://httpd.apache.org/userslist.html
>
> On Feb 9, 2008 3:43 PM, newbiedoobiedoo <[EMAIL PROTECTED]> wrote:
>
>
>
> > I started working to install apache on OSX, so I can use django, and I
> > realized I'm in over my head.  I don't want to make stupid errors in
> > file sharing
> > and firewall settings, leaving my computer open to attack.
>
> > Is it safe to do this?
> > Is there anyone out there who would be willing to help me go through
> > the mundane
> > but treacherous part of setting up the system preferences and etc.  I
> > am a programmer, but a sys admin, I'm not.
>
> > I'm not sure what I can offer in return...   If you live in Berkeley,
> > I can offer
> > to trade coffee/dinner/housework?   I could offer some of the DVDs I
> > made on
> > do-it-yourself healthcare...
>
> > 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
-~--~~~~--~~--~--~---



needs some template logic or model logic

2008-02-08 Thread Milan Andric

Hi I'm working on extending a forum app to allow for email
subscriptions.
http://code.google.com/p/django-forum/issues/list

I'm running into one fairly simple issue and thought someone might be
able to enlighten me.

Here's part of my model: http://dpaste.com/34401/

And here's the template logic: http://dpaste.com/34400/

{% for t in threads %}

{{ t.forum.title }}
{% if t.sticky %}Sticky {% endif %}{{ t.title }}{% if t.closed %}
(Closed){% endif %}


{% endfor %}

user.subscription_set.all isn't specific enough because I actually
need to query on user AND thread.  So does is there no easy way around
a template tag?

Thanks for you suggestions,

Milan

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



Re: Shared hosting with FastCGI, problems

2008-01-05 Thread Milan Andric

On Jan 5, 7:46 pm, Michael Hipp <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I'm hoping to rework my website into Django, but am having trouble at my
> shared hosting provider (HostMonster).
>
> They don't support mod_python, so Hostmonster said to add this to .htaccess
> for FastCGI:
>
>AddHandler fcgid-script .fcgi
>
> I did that and my html sites still work, but when I add the recommendations
> from Django my html sites don't work and neither does my fledgling Django 
> site.
>
>AddHandler fastcgi-script .fcgi
>RewriteEngine On
>RewriteCond %{REQUEST_FILENAME} !-f
>RewriteRule ^(.*)$ mysite.fcgi/$1 [QSA,L]
>
> I also did the mysite.fcgi file. My Django site just returns blank pages. The
> html sites get an 'Internal Server Error'.
>

If your code is working fine with the development server ( manage.py
runserver) then you can pretty much rule out a problem with your
code.

To get some help with this problem you'll need to post something from
your apache error log since it sounds like that's where the stacktrace
is going.  And you should also post your mysite.fcgi script.  You
probably just need to double check your pythonpath, which you usually
need to set in your .fcgi.

I set mine like this:

import sys
sys.path.insert(0, "/home/me/sites/example.com/apps" )
sys.path.insert(0, "/home/me/lib/python" )

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



creating a profile when a user is created

2008-01-03 Thread Milan Andric

Is it possible to set the destination of a redirect after a create in
the admin?

My scenario is such that when users are created it's also necessary to
create a profile object.  I'm trying to figure out a quick (possibly
hack) that would make creating a user and profile easier.  (I know,
it's just one more step, but it's a hassle.) One possibility is to
just redirect people to the create profile page after a user is
created.

I thought about subclassing or patching the the User model's save()
method to also create a profile on create.  But I'd like to avoid
adding my own patches into django if possible.

Thanks for your advice,

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



Re: readable object

2007-12-12 Thread Milan Andric



On Dec 12, 1:13 pm, Milan Andric <[EMAIL PROTECTED]> wrote:
> Is there an easy way to print an object in html?  Basically with
> display names and manytomany relationships resolved.  (just for
> viewing)
>
> I was thinking to write something like model_to_dict(obj)  that
> resolves a bunch of stuff and makes it more readable.  But returns a
> big html string similar to printing a form but without input fields.
>
> Anything like that exist already?
>

In case you've never seen model_to_dict() I recently found out about
it from Magus the great on IRC.
http://code.djangoproject.com/browser/django/trunk/django/newforms/models.py#L148

Always asking for more!

TIA --

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



multiplehiddeninput assigning to list

2007-12-12 Thread Milan Andric

Hello,

I ran into a problem recently (after updating to latest svn) where I'm
assigning a list to a widgets.MultipleHiddenInput field  but the list
is rendered as a string in the html form.

How do I assign a list to a multipleinput form field so it's rendered
appropriately?

The problem is exhibited when I do (in the view)
new_data['foo'] = [u'6', u'8']  or [6,8]
form = Form(new_data)

... then in the html the hidden input value="[u6,
u8]" instead of
name="foo_0" value="6"  and name="foo_1" value="8"

What am I doing wrong?  It's probably a recent patch I missed.

Thanks,

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



Re: validating fields with newforms

2007-11-19 Thread Milan Andric

On Nov 19, 12:30 pm, Milan Andric <[EMAIL PROTECTED]> wrote:
> On Nov 19, 12:16 pm, Milan Andric <[EMAIL PROTECTED]> wrote:
>
> > On Nov 19, 12:13 pm, RajeshD <[EMAIL PROTECTED]> wrote:
>
> > > > I would like to validate a field if another field is defined.  So i
> > > > have two fields (state and state (international) ) -- one of them
> > > > needs to be defined.  How would i do this with newforms?
>
> > > By adding a clean() method to your form class. See the 3rd cleaning
> > > method described here:
>
> > >http://www.djangoproject.com/documentation/newforms/#custom-form-and-...
>
> > Ah, override the Form's clean method as opposed to the field's.  That
> > makes sense.
>
> Found a good thread on it, thank you.
>
> http://groups.google.com/group/django-users/browse_thread/thread/2ab9...
>

Here's what I came up with ...

def clean(self):
"""
Do some special validation on biz_state and biz_zip fields so
either it
or international fields are defined.
"""
try:
if self.cleaned_data['biz_state']:
# just make sure it's not empty string
pass
else:
try:
if self.cleaned_data['biz_state_intl']:
# just make sure it's not empty string
pass
else:
# if we got this far that means the two fields
#validated (are clean) but empty. set the
errors.
self._errors['biz_state'] = [
u'Please define a US State or
International State.'
]
self._errors['biz_state_intl'] = [
   u'Please define a US State or International
State.'
]
except KeyError:
# biz_state_intl wasn't clean. let the parent
class do its
# thing.
pass
except KeyError:
# biz_state wasn't clean. let the parent class do its
thing.
pass

try:
if self.cleaned_data['biz_zip']:
# just make sure it's not empty string
pass
else:
try:
if self.cleaned_data['biz_zip_intl']:
# just make sure it's not empty string
pass
else:
# if we got this far that means the two fields
#validated (are clean) but empty. set the
errors.
self._errors['biz_zip'] = [
u'Please define a US State or
International Zipcode.'
]
self._errors['biz_zip_intl'] = [
u'Please define a US State or
International Zipcode.'
]
except KeyError:
# biz_zip_intl wasn't clean. let the parent class
do its
# thing at the bottom.
pass
except KeyError:
# biz_zip wasn't clean. let the parent class do its thing.
pass

return super(AppFormPart1, self).clean()

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



Re: validating fields with newforms

2007-11-19 Thread Milan Andric

On Nov 19, 12:16 pm, Milan Andric <[EMAIL PROTECTED]> wrote:
> On Nov 19, 12:13 pm, RajeshD <[EMAIL PROTECTED]> wrote:
>
> > > I would like to validate a field if another field is defined.  So i
> > > have two fields (state and state (international) ) -- one of them
> > > needs to be defined.  How would i do this with newforms?
>
> > By adding a clean() method to your form class. See the 3rd cleaning
> > method described here:
>
> >http://www.djangoproject.com/documentation/newforms/#custom-form-and-...
>
> Ah, override the Form's clean method as opposed to the field's.  That
> makes sense.

Found a good thread on it, thank you.

http://groups.google.com/group/django-users/browse_thread/thread/2ab9463bae7d8320/37fe68ea76416872

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



Re: validating fields with newforms

2007-11-19 Thread Milan Andric

On Nov 19, 12:13 pm, RajeshD <[EMAIL PROTECTED]> wrote:
> > I would like to validate a field if another field is defined.  So i
> > have two fields (state and state (international) ) -- one of them
> > needs to be defined.  How would i do this with newforms?
>
> By adding a clean() method to your form class. See the 3rd cleaning
> method described here:
>
> http://www.djangoproject.com/documentation/newforms/#custom-form-and-...

Ah, override the Form's clean method as opposed to the field's.  That
makes sense.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



validating fields with newforms

2007-11-19 Thread Milan Andric

Hello,

I would like to validate a field if another field is defined.  So i
have two fields (state and state (international) ) -- one of them
needs to be defined.  How would i do this with newforms?

Thanks and sorry if this is something obvious and I missed it.

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



Re: booleanfield and required = true

2007-11-15 Thread Milan Andric



On Nov 9, 12:34 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2007-11-09 at 06:26 +0000, Milan Andric wrote:
>
> > On Nov 9, 12:02 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
> > wrote:
> > > > Shouldn't the form give errors and not validate?
>
> > > Nope. It's a bit tricky, though. The problem is that HTML forms do not
> > > send *anything* for a checkbox that you don't check. So missing data for
> > > a checkbox field means it wasn't checked and is, therefore, False.
>
> > Seems if I have (pseudocode)
>
> > Form:
> >f = someField(required=True)
>
> > When I pass no data into that form it should not validate?  Just
> > doesn't seem right?
>
> In general, that will be true. However checkboxes are special: no data
> just means the value wasn't checked in the form, it doesn't mean that
> form field wasn't processed. It's an HTML oddity that Django has to
> accomodate.
>
> However, now that I'm thinking about this, there might be a bug here.
> Having required=True should mean you're required to check the box. There
> was a huge debate about this in a ticket, but the general acceptance
> amongst the maintainers and frequent contributors who commented was that
> that was the correct behaviour.
>
> I was responsible for checking in the change that makes no data = False
> for checkboxes (only), but I think I might have broken something in the
> process. I'll have to look a bit deeper into this at some point.
>
> Malcolm

Ok, so I have a  forms.BooleanField(required=True) ... that is pretty
much meaningless because when an html form is submitted the checkbox
is only present in the POST if it is checked.

So I handle it manually in the view by setting the dict value to
False.  This still doesn't do anything because now a value has been
submitted so required=True conditional passes.

None of this makes sense to me at least:

In [35]: class testForm(forms.Form):
   : checkme=forms.BooleanField(required=True)
   :
   :

In [36]: f=testForm({})

In [37]: f.is_valid()
Out[37]: True

In [38]: f=testForm({'checkme':False})

In [39]: f.is_valid()
Out[39]: True

In [40]: f=testForm({'checkme':''})

In [41]: f.is_valid()
Out[41]: False

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



Re: booleanfield and required = true

2007-11-08 Thread Milan Andric



On Nov 9, 12:02 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> > Shouldn't the form give errors and not validate?
>
> Nope. It's a bit tricky, though. The problem is that HTML forms do not
> send *anything* for a checkbox that you don't check. So missing data for
> a checkbox field means it wasn't checked and is, therefore, False.
>

Seems if I have (pseudocode)

Form:
   f = someField(required=True)

When I pass no data into that form it should not validate?  Just
doesn't seem right?

Just so no again if you don't feel like explaining.  ;) I appreciate
the answer nonetheless.

--
Milan


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



booleanfield and required = true

2007-11-08 Thread Milan Andric

I might be misunderstanding  the documentation about BooleanField.
http://www.djangoproject.com/documentation/newforms/#booleanfield

but it seems if i have :

>>> class Foo(forms.Form):
bool = forms.BooleanField(required=True)
>>> f=Foo({})
>>> f.is_valid()
True
>>>f.cleaned_data
{'b': False}

Doesn't that conflict with what the docs say?

Shouldn't the form give errors and not validate?

This is with lastest svn.

Thanks!

--
Milan


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



uncommon newforms usage

2007-11-01 Thread Milan Andric

Hi,

I'm working on an a little newforms problem and can surely use some
advice.

I have an application process that is broken up into several forms.
So I have one Application model class and several AppFormParts 1-8.
Since the application process is so painfully long we decided to break
it up into parts (smaller forms).  We also allow people to create an
application and continue it/update it later.

The only common field among all the AppFormParts is the workshops
field. It is hidden field on all the AppForms except the first, where
it gets set for the rest of the process.

Here are the components rough sketch:

"""
Forms
"""
class AppForm(forms.Form):

workshops = forms.MultipleChoiceField(
widget = widgets.CheckboxSelectMultiple(),
choices = [ (w.id,w) for w in
Workshop.objects.get_not_past_deadline() ],
help_text = 'Apply for any or all of the workshops by checking
the boxes. We encourage people to check all workshops to increase
their chances of being accepted into one of them.',
)

def save(self):
# save an application for each workshop
workshops = self.cleaned_data['workshops']
# remove these so we can loop through all fields
del(self.cleaned_data['workshops'])
del(self.cleaned_data['workshop'])
for w in workshops:
try:
# look for existing app
app = Application.objects.get(
  #needs a workshop object
  workshop=Workshop.objects.get(pk=w),
  #needs a user object
  user=self.cleaned_data['user'],
  )
except Application.DoesNotExist, Workshop.DoesNotExist:
# start new app
app = Application(
workshop=Workshop.objects.get(pk=w),
user=self.cleaned_data['user']
  )
# loop through all keys from the form and map to object
for key,val in self.cleaned_data:
if hasattr(app,key):
setattr(app,key,val)
obj.save()

class AppFormPart1(AppForm):

"""
Personal information section of the application.
This is the minimum requirement for an application to exist.
Field names correspond to Application model.
"""

title = forms.CharField(
)
organization = forms.CharField(
)
email_2 = forms.CharField(
)
phone = forms.CharField(
max_length=12,
)
[snip]

class AppFormPart2(AppForm):

def __init__(self):
self.workshops.widget = widgets.MultipleHiddenInput()

   . more fields

"""
view
"""

@login_required
def app_create_update(request, part=1):
from myproject.workshops import forms as myforms

next_part= part+ 1

if request.method == 'POST':

new_data = request.POST.copy()

# get form dynamically according to part param
Form = getattr(myforms,'AppFormPart%s' % part)
form = Form(new_data)

if form.is_valid():
form.cleaned_data['user'] = request.user
form.save()
# form validates, set the response message
request.user.message_set.create(
message=Application.USER_MSGS['saved'],
)
# redirect to next part
return HttpResponseRedirect( '/training/apply/%s/' %
next_part)
 else :
   [snip]

Please let me know if there's a better way to go about this.  Or where
the major problems lie.

Thanks,

--
Milan


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



Re: using newforms, an uncommon case.

2007-10-30 Thread Milan Andric



On Oct 30, 12:27 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote:



> Basically, you'd write pend() to take care of storing an in-progress
> form, and save() for processing a completed form. Then you have a
> couple options on deciding when to call which one. Also, I'll leave
> pulling up a pended form as an exercise for you. It shouldn't be that
> hard once you get the storage worked out.

That sounds like a great idea.  Now I just need to figure out how to
add a save() and pend() method to my form class.  I didn't see any
examples of this in the newforms doc, but I figure it's very similar
to adding a save() method to a model class.

Will get back with the results soon,

--
Milan


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



sharing django on production and dev

2007-09-28 Thread Milan Andric

Is there some standard practice on a machine that has production code
running in mod_python but also has developers running their django-
python web server?  Is that discouraged?  I figure a regular user
would not share the same django with mod_python because of .pyc files
and permissions?  So developers would maintain separate django
installs.  This makes it difficult because then they can't develop
using the same python or need to override the library path?

Seems like the appropriate configuration is for production to have a
django and developers to each have their own django.  Then the
developers would just modify their python include path to include
their copy of django?  Is there a simple way to do this or do most
developers just choose to have their own dev environment running
locally?  Does this discourage sharing of a dev server and hence more
admin work for everyone instead of one stable dev environment.

Looking for answers since I'm still pretty new to Django and python.

Your thoughts are appreciated,

--
Milan


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



subclassing flatpages model

2007-09-12 Thread Milan Andric

Hi,

I would like to add tinymce to my flatpages in the admin.  But the
only way I can figure out how to do this is modifying django/contrib/
flatpages/models.py.

Is there a way I can subclass the flatpages model and reference it
from the django flatpage app?  I'm   confused.

Thanks for your help,

Milan


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



Re: rendering files in markdown

2007-05-21 Thread Milan Andric

Last one, promise.

On May 21, 5:53 pm, Milan Andric <[EMAIL PROTECTED]> wrote:
> > On May 17, 5:34 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> > > [snip]
> > >http://code.google.com/p/django-template-utils/wiki/GenericMarkup
>
> Ok, I've got to be pretty close here.  I went ahead and  created an
> empty app with just a template tags directory mmtags/templatetags/
> mm_markup.py ... I'm still getting a ValueError when trying to render
> the template though.
>
> ValueError at /tutorials/audio/audioflash/
> 'mm_markdown' is not a registered markup filter. Registered filters
> are: textile, restructuredtext, markdown.
>
> http://dpaste.com/10791/
>
> What am I doing wrong?

doing:
from template_utils.markup import formatter

rather than:
from template_utils.markup import MarkupFormatter

then formatter.register(...) did the trick.

All is well.  Thanks for listening.


--~--~-~--~~~---~--~~
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: rendering files in markdown

2007-05-21 Thread Milan Andric

> On May 17, 5:34 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> > [snip]
> >http://code.google.com/p/django-template-utils/wiki/GenericMarkup

Ok, I've got to be pretty close here.  I went ahead and  created an
empty app with just a template tags directory mmtags/templatetags/
mm_markup.py ... I'm still getting a ValueError when trying to render
the template though.

ValueError at /tutorials/audio/audioflash/
'mm_markdown' is not a registered markup filter. Registered filters
are: textile, restructuredtext, markdown.

http://dpaste.com/10791/

What am I doing wrong?





--~--~-~--~~~---~--~~
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: rendering files in markdown

2007-05-21 Thread Milan Andric

On May 18, 1:59 am, Milan Andric <[EMAIL PROTECTED]> wrote:
> On May 17, 5:34 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> > [snip]
> >http://code.google.com/p/django-template-utils/wiki/GenericMarkup
>
> Thanks alot for writing this, it was a sinch to get going.
>
> Now I have a  def my_markdown in template_utils/markup.py where I can
> do everything I need to do some tricks with ![File:123].

Ok, one last followup here.  Sorry I'm so ignorant, but I'd like to
extend this module/template tag without modifying the original app/
source.

So GenericMarkup creates a generic_markup template tag and in turn
allows you to extend some of the markup filters.

Thus I have a django template referencing the global {% load
generic_markup %} which does a from template_utils.markup import
formatter.  template_utils.markup is where I want to add my
function(s) or new markup filters.

I'm just not seeing a straightforward solution to this besides
modifying template_utils/markup.py ... what are some other
alternatives?

Thanks for your patience,

Milan


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



TypeError: Cannot resolve keyword 'user' into field.

2007-05-18 Thread Milan Andric

I'm up against a problem and I don't really have a clue on how to
approach it.

When I try to edit a User in the Django admin I get this error:

  TypeError at /admin/auth/user/12/
  Cannot resolve keyword 'user' into field. Choices are: permissions,
id, name

I've tried tracing the problem and I think it might be here:
  http://dpaste.com/10605/

/opt/local/lib/python2.4/site-packages/django/db/models/query.py in
_get_sql_clause
 483.  # Convert self._filters into SQL.

 484. joins2, where2, params2 = self._filters.get_sql(opts)

f 
joins {}
opts 
params []
select  ['`auth_group`.`id`', '`auth_group`.`name`']
selfError in formatting:Cannot resolve keyword 'user' into field.
Choices are: permissions, id, name
tables  []
where   []

Any ideas what might cause this?  Here's the full stack trace:
http://dpaste.com/10604/

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: rendering files in markdown

2007-05-18 Thread Milan Andric



On May 17, 5:34 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
>
> http://code.google.com/p/django-template-utils/wiki/GenericMarkup
>

Thanks alot for writing this, it was a sinch to get going.

Now I have a  def my_markdown in template_utils/markup.py where I can
do everything I need to do some tricks with ![File:123].




--~--~-~--~~~---~--~~
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: rendering files in markdown

2007-05-17 Thread Milan Andric

So these will definitely take care of the backend and rendering.

But on the admin frontend all I'm using is the normal builtin stuff.
So the child File objects appear below the Pages they're part of when
you edit a Page.  And you just grab the link from the file object and
drag it into the text area of the Page to get the full path, works in
FF2 at least.  Then markdown is added by hand.  Ideally that would
appear as a standard ![title here][123] or custom ![title here][File:
123 option] markdown element.

Any ideas how I could achieve this little tweak on the frontend?

Thanks in advance,

Milan


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



Re: rendering files in markdown

2007-05-17 Thread Milan Andric


On May 17, 5:34 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 5/17/07, Milan Andric <[EMAIL PROTECTED]> wrote:
>
> > So how would i extend the markdown filter?
>
> > Would this be better handled in another place, better way or different
> > module?
>
> Shameless self-promotion: I wrote a little app a while back which is
> designed to make this sort of thing much easier; check out the
> documentation here and see if it fits with what you want:
>
> http://code.google.com/p/django-template-utils/wiki/GenericMarkup
>

Also great -- wow now I've got at least three options!

I think this might be the most Django friendly way to go, but I was
thinking it would be cool to write a general markdown extension for
all the markdown people.  But then again it would probably only apply
to Django and my models in the end anyway.  Gosh, seems like the kind
of thing every site needs so it would be cool to make something
useful.

Will keep you posted, more to think about!  If anyone else is
interested in collaborating with me on this  please send me a mail.

On the road,
--
Milan


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



Re: rendering files in markdown

2007-05-17 Thread Milan Andric

Thanks!

Someone in IRC also recommended writing another template filter and
passing it through there before going to markdown.  So between all
these solutions, I'll come up with something.

--
Milan


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



rendering files in markdown

2007-05-17 Thread Milan Andric

Hello,

I'm using markdown as an output filter in my templates.

I'd like to extend it somehow so that it can parse a ![][123] image
reference but the reference number will be a file object id or a
inline reference, etc.  So then the object would get rendered
appropriately and dynamically from the db.

So how would i extend the markdown filter?

Would this be better handled in another place, better way or different
module?

Thanks,

Milan


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



Re: ManyToManyField and TypeError using lists

2007-05-14 Thread Milan Andric



On May 14, 11:20 am, Milan Andric <[EMAIL PROTECTED]> wrote:
> Hello,
>
> My Tutorial model has an author field, which can contain many authors:
>
> class Tutorial(models.Model):
> ...
> author = models.ManyToManyField(User,limit_choices_to =
> {'is_staff' :1})
>
> When i try to save :
>
> users=[]
> users.append(User.objects.get(username='joe'))
> users.append(User.objects.get(username='bob'))
> t = Tutorial(author=users, ...)
> t.save()
>
> I get an error:
>
> TypeError: 'author' is an invalid keyword argument for this function
>

A friend on IRC informed me ..

since the object has no ID yet
and an m2m is a link between IDs
t = Tutorial(...everything but author...)
t.save()
t.author.add(user1)

Makes sense, trying ...

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



ManyToManyField and TypeError using lists

2007-05-14 Thread Milan Andric

Hello,

My Tutorial model has an author field, which can contain many authors:

class Tutorial(models.Model):
...
author = models.ManyToManyField(User,limit_choices_to =
{'is_staff' :1})


When i try to save :

users=[]
users.append(User.objects.get(username='joe'))
users.append(User.objects.get(username='bob'))
t = Tutorial(author=users, ...)
t.save()

I get an error:

TypeError: 'author' is an invalid keyword argument for this function

How do I save this field type using the python console? Does it want a
dict rather than list, how would   I structure the dict? I tried a
quick search but couldn't find the answer.

Thanks!

Milan


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



Re: migrating 400 images

2007-05-07 Thread Milan Andric



On May 5, 7:17 am, Nate Straz <[EMAIL PROTECTED]> wrote:
>
> >>> from blog.migrate import loadCOREBlog
>
> In loadCOREBlog I loaded all of the Zope libraries and started iterating
> through whatever needed to be migrated.  When I detected a problem I
> would use Python's code.interact function to get a shell at that point
> in my script to help deal with any unexpected migration issues.
>
> http://refried.org/viewvc/viewvc.py/refriedorg/blog/migrate.py?view=m...
>

Wow, interact() is very cool.  Now I just need to find write one that
does a similar thing with html body and the local img srcs recursively
on files within a directory.  Is there a library that parses html
pages, I'm sure there is, but one that you recommend?

--
Milan


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



migrating 400 images

2007-05-04 Thread Milan Andric

Hi,

I'm migrating a tutorials site to Django and have created a file model
that is associated with tutorial pages, etc.  Now I need to go through
and migrate all the old content.  Rather than upload 400 images I was
hoping to write a script to call the File.save() method appropriately
and just copy the images into the new location.

Any thoughts on how to approach this?  Do you think this will likely
take more time than just doing it by hand?

Thanks,

Milan


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



Re: a very slow view, > 30secs to load

2007-03-30 Thread Milan Andric


On Mar 30, 1:08 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
>
> I'm confused. First you said it took 0.2 seconds, then you say it took
> 47  seconds and then 3 seconds. Both of those numbers are bigger than
> 0.2. I know this because I took advanced maths courses at university.
>

Yea, I tried to clear that up in the previous post.  .2 seconds was on
the dev server, not apache2/mod_python, little data and without the
optimization.

47 and 3 was before and after the optimization on the production env:
apache2/mod_python and production data (19 presentations).

> Even so, around three seconds for 19 iterations of that loop without the
> form seems a bit slow. That's only just over five per second (since it's
> really 3.8 seconds). We may need to look at newforms performance when
> things have settled down a bit. Not worth being too premature in the
> optimisation, but this is an interesting data point.

Also as a side note, this is Django 4455.  I'll be happy to try to
write up some tests or something.  I should get familiar with tests
sooner than later anyway.



--~--~-~--~~~---~--~~
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: a very slow view, > 30secs to load

2007-03-30 Thread Milan Andric



On Mar 29, 8:31 pm, "Gary Wilson" <[EMAIL PROTECTED]> wrote:
> On Mar 29, 2:26 pm, "Milan Andric" <[EMAIL PROTECTED]> wrote:
>
> > But in the dev environment I can see pretty well that the view is
> > functioning very quickly.  So your hunch about the problem lying in
> > the templates is probably right.
>
> If you aren't seeing the slowdown on your dev server, then you
> shouldn't be seeing a slowdown on your production server either.  Is
> your dev database loaded with the same amount of data as production?

Yes

> When you say that the view is functioning very quickly, do you mean
> the time from request to page render?  If so, the template is already
> getting run and is probably not your problem.

My conclusion that the view was functioning quickly was from a print
time.time() test I did.  According to that it took .2 secs from start
to the point right before the view called render_to_response().
Again, this was on my dev site which doesn't have as much data.

>
> > Let me know what you think.
>
> In your view, I think you can take this code:
>
> f = newforms.form_for_model(PresentationEval)
> f.base_fields['presentation'].widget = widgets.HiddenInput()
> f.base_fields['application'].widget = widgets.HiddenInput()
> f.base_fields['topic_rating'].widget =
> widgets.Select( choices=PresentationEval.RATINGS)
> f.base_fields['substance_rating'].widget =
> widgets.Select( choices=PresentationEval.RATINGS)
> f.base_fields['expertise_rating'].widget =
> widgets.Select( choices=PresentationEval.RATINGS)
> f.base_fields['relevance_rating'].widget =
> widgets.Select( choices=PresentationEval.RATINGS)
> f.base_fields['overall_rating'].widget =
> widgets.Select( choices=PresentationEval.RATINGS)
>
> out of the loop, as it is just constructing the form class that will
> be used to instantiate your pForms instances.

I took that out of the loop and it made a big difference.  Makes total
sense too, I was doing a lot of extra work there but didn't realize
it.  The time difference was dramatic.  I timed it using basic
sys.stderr.write() and .flush() with apache2/mod_python.

creating classes inside the loop, calling newforms.form_for_model() 19
times:
for p in ... 1175239555.13
done with for p in ... 1175239601.91
47 Seconds?!

only creating the class once:
for p in ... 1175239882.93
done with for p in ... 1175239886.7
3 Seconds!

So I think that was it.

This is on django-svn 4455, a bit outdated. I tried updating a few
days ago but some non-backwards compat code bit me and had to back off
for a bit.

Thanks Gary and Everyone!


--~--~-~--~~~---~--~~
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: a very slow view, > 30secs to load

2007-03-29 Thread Milan Andric

Great pointers, thanks!  I will look at that.  In the meantime I
thought i would post my debug info.   I used this snippet in my
template to see what queries are happening.

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

Looks like I'm making quite a few queries there, 71, but they still
don't seem to add up to 30+ seconds.

http://dpaste.com/7617/

Hrm, any thoughts so far?

--
Milan


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



Re: a very slow view, > 30secs to load

2007-03-29 Thread Milan Andric

On Mar 28, 6:26 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Wed, 2007-03-28 at 19:59 +0000, Milan Andric wrote:
> > Hellow,
>
> > Any advice you can offer on optimizing this view would be greatly
> > appreciated.
>
> >http://dpaste.com/7543/
>
> > I was planning on trying to reduce the amount of data in pForms, the
> > list that is passed to the template.  Since i'm saving 19
> > presentations into this list along with the forms, i'm assuming this
> > is the bottleneck.  Any ideas how to work around this?
>
> Don't assume... test! You can put calls to time.time() in various places
> in the view and then print out the differences between them to a file or
> to stderr (or even stdout if you are using the development server). That
> will show you which portions are taking the longest. With a few
> iterations, moving the time.time() calls around, you should be able to
> work out the exact lines that are taking the most time.
>
> Then come back and we can talk.
>
> You might discover, for example, that it's not the view that is taking
> all the time, but the template rendering for some reason (such as making
> a lot of database calls by constructing querysets whilst rendering the
> template).
>

Hi Malcolm,

Thanks for your response.  I'm failing at getting any debug
information out of the production (apache2/mod_python) environment.  I
tried using print and  sys.stderr.write but the logs show no signs of
it.  So there might be something broken there.  Will get to that
later.

But in the dev environment I can see pretty well that the view is
functioning very quickly.  So your hunch about the problem lying in
the templates is probably right.

So I posted the template: http://dpaste.com/7603/ .
I'm not sure how to optimize the querysets.  Don't make the queries in
the template?   What are some ways to optimize this template.  In the
meantime I'll try to scan the ML archives and looking at caching.

Let me know what you think.

The problem with caching is that this view is unique for each user.
That's how it is now at least, but maybe I need to take a new
approach.  My current one takes little thought.  Pre-optimization is
the root of all evil. ;)

Milan


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



a very slow view, > 30secs to load

2007-03-28 Thread Milan Andric

Hellow,

Any advice you can offer on optimizing this view would be greatly
appreciated.

http://dpaste.com/7543/

I was planning on trying to reduce the amount of data in pForms, the
list that is passed to the template.  Since i'm saving 19
presentations into this list along with the forms, i'm assuming this
is the bottleneck.  Any ideas how to work around this?

I was going to start by only saving the data that I need, rather than
the entire object.

Also, since most of this data does not change very often, I should
probably cache it.  Do you have a recommendation on how to cache the
objects in this view?

Thanks,

Milan


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



Re: changing maxlength html attribute

2007-02-09 Thread Milan Andric

In the database it is 75, same here.  But the html widget was getting
rendered with maxlength=30.

I just realized I created a forms.py for it to define the html form.
It was in there, sorry for the dumb post.

Should move to newforms!

On Feb 9, 3:11 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> If you're having user registration, I think you're quickly going to
> want more than the builtin auth/user will give you.
> I'd take a look at extending the user 
> model:http://www.b-list.org/weblog/2006/06/06/django-tips-extending-user-model
>
> Also, I'm not sure why it's giving you a maxlength of 30. In my
> database, email is 75 characters, and I don't recall changing that.
>
> On Feb 9, 4:56 pm, "Milan Andric" <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > I'm using contrib/auth User for my registration process like alot of
> > folks but the maxlength attr on the html form for the email is 30 and
> > that's too short.
>
> > I tried modifying contrib/auth/models.py and adding maxlength to
> > User.email but that doesn't seem to affect the form.
>
> > So I need to subclass the email form?  Where is that located?  Any
> > hints on a good way to do this?
>
> > --
> > Milan


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



changing maxlength html attribute

2007-02-09 Thread Milan Andric

Hello,

I'm using contrib/auth User for my registration process like alot of
folks but the maxlength attr on the html form for the email is 30 and
that's too short.

I tried modifying contrib/auth/models.py and adding maxlength to
User.email but that doesn't seem to affect the form.

So I need to subclass the email form?  Where is that located?  Any
hints on a good way to do this?

--
Milan


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



horrendous view, need advice on cleaning up

2007-02-05 Thread Milan Andric

Hello,

I have a poorly written view that is 1) hard to understand and 2)
performs slowly.  Can you offer any incite into what is slowing this
view down so much?  Besides the app being over 60 fields long, what
other things can I adjust to make this view perform better?

http://dpaste.com/5362/

The reason I looped through app._meta.fields was because I did not
want to write the html for each field.  I figure this is what is
causing the slowness and is better handled by the rendering/templating
engine.  Looking for advice before embarking on the wrong path.

Much appreciated,

Milan


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



Re: messages, filters and templates o my!

2007-02-03 Thread Milan Andric

Cool, so you write a view that returns what, json, html?  Do you
recommend any specific library or possibly have an example?  Since
I've never done it, I'm wondering where all the pieces fit in the
django layout.  I'll search the ML for tips.

Thanks.

On Feb 3, 6:11 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> When I'm doing something like that, I use ajax to do the server side
> stuff and return the message without ever leaving the page.
>
> On Feb 2, 7:39 pm, "Milan Andric" <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > I have a small problem, I'm submitting a review form (form x) on a
> > page that has many of these forms in a list, so  you can view other
> > reviews, add new ones or edit your own.   When a review is edited a
> > view processes it and redirects the person back to the review using an
> > anchor like /urlstring/12/#id_review_8.
>
> > Works fine, now I just need to print some kind of notice to the user
> > that the data was saved.
>
> > Messages won't work because i don't have enough control to only print
> > a message for the form that was updated. Or so i think.  In my
> > template I just have a for loop,
> >  e.g. {% for review in reviews %}  > id="id_review_{{review.id}}"> ...
>
> > Do you have any suggestions or examples to lead me towards a solution?
>
> > I guess it's time for this newbie to write a template tag?
>
> > Thank for your help,
>
> > Milan


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



messages, filters and templates o my!

2007-02-02 Thread Milan Andric

Hello,

I have a small problem, I'm submitting a review form (form x) on a
page that has many of these forms in a list, so  you can view other
reviews, add new ones or edit your own.   When a review is edited a
view processes it and redirects the person back to the review using an
anchor like /urlstring/12/#id_review_8.

Works fine, now I just need to print some kind of notice to the user
that the data was saved.

Messages won't work because i don't have enough control to only print
a message for the form that was updated. Or so i think.  In my
template I just have a for loop,
 e.g. {% for review in reviews %}  ...

Do you have any suggestions or examples to lead me towards a solution?

I guess it's time for this newbie to write a template tag?

Thank for your help,

Milan


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



Re: restricting comments to registration/login using django.contrib.comments

2006-12-19 Thread Milan Andric



On Dec 16, 11:30 am, "James Bennett" <[EMAIL PROTECTED]> wrote:
>
> The forms mostly work the same, and you're already including the full
> URLConf for the comments app, so you should be able to just change
> your templates to pull in the registered comments forms and it'll work
> (e.g, instead of using the free_comment_form tag, use the comment_form
> tag).
>

Thanks for you help, that was quite smooth.  Just removed all instances
of "free_" or "free" in the templates.


--~--~-~--~~~---~--~~
 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: extracting field information from models

2006-12-17 Thread Milan Andric



On Dec 16, 1:01 pm, "Phil Davis" <[EMAIL PROTECTED]> wrote:
>Try:
>
> app_fields = []
> for f in app._meta.fields:
>app_fields.append(
>  {
> 'label' : f.verbose_name,
>'value': getattr(app, f.name),
> }
>
> Works for me on Boolean fields.
> 

Thanks, getattr() did the trick and worked on all fields.


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



  1   2   >