Re: Generic foreignKey model: Category

2009-02-11 Thread Jake Elliott

if i follow your question - you'd want a ForeignKey in CategoryItem to
your Category model, so you can add both your News object and Product
object to the same category through CategoryItem.  then you'll be able
to iterate through all of the items in a categoroy with something like
`mycategory.categoryitem_set.all` just as with any other foreign key.

On Wed, Feb 11, 2009 at 11:56 AM, danfreak  wrote:
>
> Cheers Jake,
>
> given the code:
> --
> from django.db import models
> from django.contrib.contenttypes.models import ContentType
> from django.contrib.contenttypes import generic
>
> class CategoryItem(models.Model):
>name = models.CharField(max_length=200)
>content_type = models.ForeignKey(ContentType)
>object_id = models.PositiveIntegerField()
>content_object = generic.GenericForeignKey('content_type',
> 'object_id')
>
>   def __unicode__(self):
>   return self.name
> --
>
> How do I link it to my Product model o News Model for example?!?!
>
> Should I overriding the default News.save() method or should I use a
> post-save signal
> like here 
> http://ryanberg.net/blog/2008/jun/24/basics-creating-tumblelog-django/
> ?
> Or the relation gets saved "automagically"?
>
> Cheers in advance!
>
> Dan
>
> >
>

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



Re: Generic foreignKey model: Category

2009-02-11 Thread Jake Elliott

hi dan -

a little further down on the contenttypes doc page you link to there
is documentation on the generic foreign key mechanism bundled with the
contenttypes app:
http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#id1

pretty similar to what you describe ;)

On Wed, Feb 11, 2009 at 11:05 AM, danfreak  wrote:
>
> Hey guys,
>
> I was wondering how to create a let's call it "GenericCategory" model.
>
> Given that News, Products, etc, often belongs to a Category, why have
> tons of tables (news_categories, products_categories) etc
>
> The "GenericCategory" model table structure should be like:
>
> - id
> - foreign_model_name
> - foreign_key
> - field_1 (category_name for example)
> - field_2 (category_description for example)
>
> Ho can I make this working with the The contenttypes framework (http://
> docs.djangoproject.com/en/dev/ref/contrib/contenttypes/)?
>
> Or is there a better way to achieve this result in Django?
> >
>

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



Re: signals in 1.0 problem: nesh django utils & django 1.0

2009-02-09 Thread Jake Elliott

hi robocop -

is it enough to add the '**kwargs' syntax to your receiver function?
or is that already present?

like:

def _save(self, **kwargs):
...

and

def delete(**kwargs):
...

-jake

On Mon, Feb 9, 2009 at 12:15 PM, Robocop  wrote:
>
> Hello,
> I've recently been porting many projects to 1.0, but have hit a snag
> with the current one.  I'm looking at an old project that uses nesh's
> django utils (mainly just the thumbnail image field model), and have
> been slowly porting the project (and by extension nesh's code) to
> 1.0.  Now i have read the documentation on signals, as well as the
> porting to 1.0 guide's signals section, but because i have not really
> used signals in my projects, i'm a little unsure what exactly is being
> called for by this error, and thought someone here may be of some
> help.
>
> The original code looked like:
>
>def contribute_to_class(self, cls, name):
>super(ImageWithThumbnailField, self).contribute_to_class(cls,
> name)
>dispatcher.connect(_delete, signals.post_delete, sender=cls)
>dispatcher.connect(self._save, signals.pre_save, sender=cls)
>
> My poor attempt at porting:
>
>  def contribute_to_class(self, cls, name):
>super(ImageWithThumbnailField, self).contribute_to_class(cls,
> name)
>signals.post_delete.connect(_delete, sender=cls)
>signals.pre_save.connect(self._save, sender=cls)
>
> and the resultant error:
>
> line 45, in contribute_to_class
>signals.post_delete.connect(_delete, sender=cls)
>  File "/usr/lib/python2.4/site-packages/django/dispatch/
> dispatcher.py", line 84, in connect
>assert argspec[2] is not None, \
> AssertionError: Signal receivers must accept keyword arguments
> (**kwargs).
>
>
> now my understanding of the syntax is that _delete and self._save
> would be keyword arguments, but apparently i am incorrect.  Any help
> or suggestions would be greatly appreciated.
>
> >
>

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



Re: simple record output

2009-02-02 Thread Jake Elliott

hi john -

you can use the 'spaceless' tag in your template:
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#spaceless

to filter out spaces & carriage returns.

-jake

On Mon, Feb 2, 2009 at 3:41 PM, John M  wrote:
>
> Grrr, I answered my own quesiton, if I remove all the CR's from the
> template, then it's OK.
>
> So changing the template to
>
> {% if object_list %}{% for obj in object_list %}{{ obj.name }}{%
> endfor %}{% endif %}
>
> Works like I want.  But now, how can I not have the CR's in the
> template effect my output?
>
> Thanks
>
>
> On Feb 2, 12:57 pm, John M  wrote:
>> I'm trying to use the generic views and templates to get a very simple
>> text output of records.
>>
>> I don't want HTML, but need them available from a command line (via
>> curl).
>>
>> Here's my URL setup.
>> newhosts_dict = {
>> 'queryset' : unixhost.objects.all().filter(hostsetting__userlist =
>> False)
>> }
>>
>> urlspatterns...
>>
>> (r'^likewise/newhosts/$',
>> 'django.views.generic.list_detail.object_list', newhosts_dict),
>>
>> here's the template:
>>
>> {% if object_list %}
>> {% for obj in object_list %}
>> {{ obj.name }}
>> {% endfor %}
>> {% endif %}
>>
>> If the queryset only has 1 record in it, why do I have three lines in
>> my output?  1 blank, 1 record output, and one 1 blank.
>>
>> thoughts?
>>
>> Thanks
> >
>

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



Re: Dreamhost now supports Django

2008-07-17 Thread jake elliott



On Jul 17, 3:15 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> Can anybody who is in a position to check this out please look at one
> thing in particular: assuming the default database is still MySQL, which
> version of the python MySQLdb wrapper are they using? If
>
>         >>> import MySQLdb
>         >>> MySQLdb.version_info
>
> doesn't say something like (1, 2, 1, 'final', 2) or (1, 2, 2, 'final',
> 0), then it's going to be problematic for them. Previously, Dreamhost
> had been running a much older version of MySQLdb and I'd be very
> interested in knowing for certain that they've upgraded at some point in
> the past 12 months.

i get:
(1, 2, 1, 'final', 2)

-jake
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Oh boy, I've gone and done it now.

2007-11-05 Thread jake elliott

hi baxter -

On Mon, 2007-11-05 at 10:35 -0800, [EMAIL PROTECTED] wrote:
> OK, I attempted to install patch 2070, and failed miserably, messing
> up /core/handlers/modpython.py among other things. When I realized I
> had done so, I tried updating and then reinstalling django to get back
> to a clean install. Now everything is broken. Most of the broken seems
> to relate to template tags and filters.

these issues sound like unicode and templatetag addressing changes
documented here
http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges

(see 5609 and 6289).

> And then there's thumbnails, which insists TypeError: make_thumbnail()
> keywords must be strings, but I'm passing it as a string, exactly as I
> always have.

the version of this library you have may not be compatible with new
unicode stuff in django.  this might help:
http://groups.google.com/group/nesh-django-utils/browse_thread/thread/42d4db5985e5b8f

best
jake


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: generic views

2007-10-22 Thread jake elliott


On Mon, 2007-10-22 at 14:12 -0500, jake elliott wrote:
> this is probably another really simple view.  you can use
> HttpResponseRedirect - or if you really want to end up using a generic
> view remember that you can call them within your own views also.
> 
> # views.py
> from django.views.generic.simple import redirect_to
> def myview(request):
> # something
> return redirect_to(url=mycalculatedurl)

by the way here's a great txt by james bennett about doing this kind of
wrapping:

http://www.b-list.org/weblog/2006/nov/16/django-tips-get-most-out-generic-views/

best
jake



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: generic views

2007-10-22 Thread jake elliott

hi bernd,

On Mon, 2007-10-22 at 18:40 +0200, Bernd wrote:
> I want to use a generic view with an url that had a parameter. This
> parameter should filter my queryset.
> How does this work? I don't now what to write in the filter-option? 
> -
> e = {
> 'template': 'foo.html',
> 'extra_context': {'list': Event.objects.filter(date__year=)}
> }
> 
> urlpatterns = patterns('django.views.generic.simple ',
>  url(r'^events/(?P\d{4})/$', 'direct_to_template', e),
> )
> -

you may run into some trouble here constructing that query in urls.py.
but really the view that you're composing here is pretty simple without
generic views:

# views.py
def myview(request, year):
return render_to_response('foo.html',
{ 'list': Event.objects.filter(date__year=year) })


> The url "example.com/app/events/" should be redirect to
> "example.com/app/events/2007/". 
> But 2007 shouldn't be hard-coded. 2007 should be the result from a
> object-filtering. Is this possible 
> with a generic view:
> -
> urlpatterns = patterns('django.views.generic.simple',
>  url(r'^events/$', 'redirect_to', {'url':  }),
> )
> - 

this is probably another really simple view.  you can use
HttpResponseRedirect - or if you really want to end up using a generic
view remember that you can call them within your own views also.

# views.py
from django.views.generic.simple import redirect_to
def myview(request):
# something
return redirect_to(url=mycalculatedurl)

best
jake


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: template and array like template variable access

2007-10-17 Thread jake elliott

hi johnny,

you can use dot syntax for indices also, ie:

{{ a_tup.0 }}
{{ a_tup.1 }}

-jake

On Wed, 2007-10-17 at 08:20 -0700, johnny wrote:
> 
> {% for a_tup in rs %}
> 
> {{ a_tup[0] }}/
>{{ a_tup[1]
> 
> {% endfor %}
> 
> Exception Type:   TemplateSyntaxError
> Exception Value:  Could not parse the remainder: '[0]' from 'a_tup[0]'
> 
> Only way to do this is to have nested for loop inside template?
> 
> 
> > 


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



Re: generic views

2007-10-11 Thread jake elliott

Marty Alchin wrote:
> You'd replace "what goes here" with what you put in
> "template_object_name": "author" (only without the quotes). Of course,
> it'd be a little more readable if you use the plural "authors", since
> you're getting a list of more than one author.

actually you'll use "author_list" here - list_detail.object_list appends
"_list" to the value set for "template_object_name"

best
jake

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



Re: Problem with nesh.thumbnail

2007-10-04 Thread jake elliott

hi divan,

Divan Roulant wrote:
> "'myproject.thumbnail' is not a valid tag library: Could not load
> template library from django.templatetags.apparto.thumbnail, No module
> named myproject.thumbnail"

here's the change that's tripping you up:
http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Templatetagloadingrespectsdottednotation

that page is an invaluable reference when living on the trunk!

best
jake

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



Re: How to keep track of iterations through a for loop in my template?

2007-10-01 Thread jake elliott

hi greg

Greg wrote:
> Hello,
> I have a table in my template that will contain an x number of rows
> depanding on what I get back from the view.  I want my table row
> background color to rotate between red and white.  As of now, I don't
> know how to keep track of each iteration through my for loop to set
> the appropriate bgcolor.
> 
> Any suggestions?

i think you want {% cycle %}:

http://www.djangoproject.com/documentation/templates/#cycle

best,
jake

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: change list in admin

2007-09-27 Thread jake elliott

hi jose

Lic. José M. Rodriguez Bacallao wrote:
> how can I limit items in "change list" of the admin interface?

the admin will use your model's default manager (the first specified
manager) to filter results.

more information here:
http://www.djangoproject.com/documentation/model-api/#modifying-initial-manager-querysets

best,
jake

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Sorting product

2007-09-26 Thread jake elliott

hi francis -

Francis Lavoie wrote:
> I have a page that list products. These products are in different
> categories, some belongs to other products (like addons). But I need to
> sort them as the most important product is at the top. The problem is
> that I can't come up with a good solution. I though to add an sorting
> (int) field. But it seem to be too complicated to manage. How to switch
> the sorting number in the admin interface, etc..
> 
> Is there something in django that can automatically manage that kind of
> stuff (maybe I miss it in the doc)? Or any hint for a better solution
> will be helpful.

you're not missing anything; this functionality isn't packaged with
django.  if i'm not mistaken it *is* built into the newforms-admin
branch (can anyone correct me?).

for the time being, i have a hacked together little app for my own
projects that provides a couple of generic views for sorting, which i
just now packaged together and wrote some light documentation for:
http://dai5ychain.net/jake/2007/09/27/a-simple-django-sorting-app/

hope it's useful!

best,
jake

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Union/join of two queryset?

2007-09-24 Thread jake elliott

hi francesco

cesco wrote:
> I have two QuerySets and I need to join them to pass them as first
> parameter to the ObjectPaginator class.
> How can I do that?
> The "+" operator doesn't work (like it does for lists) and there is no
> a method like the list one "extend()".


you can use the bitwise operators '&' and '|', '&' will give you
intersection and '|' will give you union

qs & otherqs = intersection
qs | otherqs = union

best
jake

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: elsif in templates?

2007-09-24 Thread jake elliott

hi a.

A. Reppel wrote:
> does the template language have a elsif clause for if and if{not}equal?

nope, you'll have to go with

{% if %}

{% else %}
  {% if %}
  {% endif %}
{% else %}

{% endif %}

best,
jake

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



Re: How to call a .htm page without going to the views.py file?

2007-09-21 Thread jake elliott

hi greg -

you're looking for this:
http://www.djangoproject.com/documentation/generic_views/#django-views-generic-simple-direct-to-template

best
jake

Greg wrote:
> Ok,
> Very easy question here.  Is there anyway that I can directly call
> my .htm file from within my urls.py file?
> 
> Now, I have the following:
> 
> (r'^customer_care/$', 'mysite.rugs.views.customer_care'),
> 
> def customer_care(request):
>   return render_to_response('customer_care.html', {})
> 
> /
> 
> As you can see my view does nothing except call a .html file.  Is
> there anyway I can do this is my urls.py file so that I can delete the
> customer_care function in views.py all together?
> 
> 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: General site organization

2007-09-20 Thread jake elliott

hi florian -

Florian Lindner wrote:
> I have the site xgm.de with a blog, an abbreviation database and some static 
> pages.
> How would a organize such a site with Django?
> Create an app for the blog, an app for the DB and the static pages as 
> templates of the project?

you really have a lot of flexibility & you can search this group for
prior discussions of a general django project layout, but here are my
thoughts ;).

you might consider contrib.flatpages for the static pages in your project.

http://www.djangoproject.com/documentation/flatpages/

also i find myself using direct_to_template a lot to as a shortcut to
build simple views:

# yourproject/urls.py
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
from myapp.models import News, Sidebar

urlpatterns = patterns('',
(r'^$', direct_to_template, {'template': 'frontpage.html',
'extra_context': {'news': News.objects.all, 'sidebars':
Sidebar.objects.all } }),

(r'blog/$', include('blog.urls')),
)

or something like that.  more about direct_to_template here:
http://www.djangoproject.com/documentation/generic_views/

best
jake

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



Re: Can't update my django source via svn

2007-09-19 Thread jake elliott

hi jeff -

django devs are in the process of moving servers so i think this is
probably just a temporary issue.  fwiw i am able to 'svn up' right now
with no problem :|

best,
jake

jeffself wrote:
> I've never run into this problem before but all of a sudden its not
> working.  My source is located in /opt/django_src.  I run 'sudo svn
> update' and I'm now getting errors.
> 
> svn: PROPFIND request failed on '/svn/django/trunk'
> svn: PROPFIND of '/svn/django/trunk': Could not read status line:
> Connection reset by peer.
> 
> Is the repository down right now?
> 
> 
> > 
> 


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



Re: Add Support for Hex numbers is Admin

2007-09-19 Thread jake elliott

hi kevin,

you could convert to int in the model's save() method

class MyModel(models.Model):
def save(self):
self.hexval = int(str(self.hexval), 16)
super(MyModel, self).save()

or whatever hex->decimal method you need for how you have the hex val
stored.

but then how to get it back into a hex representation when someone goes
to edit the field?  the only thing that comes to my mind is javascript
but i'm sure there's a less hackish solution :)

best
jake

Kevin wrote:
> In the admin interface if someone enters a number in hex, then it
> fails the validation test. I've managed to make it pass the validation
> test, but now the number gets passed in hex to the back-end database
> (which does not support hex). Any ideas on how I might be able to
> convert the number to an integer before it hits the database?
> 
> Thanks,
> Kevin
> 
> 
> > 
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: ifequal function not working?

2007-09-13 Thread jake elliott

hi john -

John M wrote:
> {% ifequal selected_id recordset.id %}   never seems to work.
> 
> where selected_id = 1
> recordset has ID from 1 - 10

just a guess - are selected_id and recordset.id really the same type?
{% ifequal %} will not match for example '1' == 1

best,
jake

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: 404 Page Help

2007-09-11 Thread jake elliott

hi ryan,

how about a context processor?

http://www.djangoproject.com/documentation/templates_python/#writing-your-own-context-processors

-jake

Ryan K wrote:
> Hi. All URLs in my templates are preceded by variables I added to the
> settings file so I could easily deploy my site on many different URLs,
> this includes CSS file URLs. When the custom error 404 page comes up,
> there is obviously no style because I can't pass the setting to it. Is
> there a way to hook into the mechanism to allow the 404 page to the
> get the URL of the stylesheet? 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: Help me understand the error of my ways...

2007-09-07 Thread jake elliott

hi atendo -

i think you may have some misunderstandings about what template context
is and what it's doing here.

maybe another look at this page:
http://www.djangoproject.com/documentation/templates_python/#basics

will help clear this up for you.

best,
jake

Atendo wrote:
> I think I see what you are getting at.  In my views.py, I was able to
> define my context which is why it worked when I initially tried
> mapping the app to the URL.  But in the template tag, the context is
> not defined.  Thing is, how do you define the context in the template
> tag?
> 
> 
> > 
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Help me understand the error of my ways...

2007-09-07 Thread jake elliott

hi atendo,

Atendo wrote:
> If I do that, I get this error:
> 
> 
> KeyError at /
> 'link'
> Request Method:   GET
> Request URL:  http://localhost:8080/
> Exception Type:   KeyError
> Exception Value:  'link'
> 

this KeyError is coming from your line:


context['link']


when 'link' isn't actually part of the template's context (and therefore
not a valid key to the dictionary-like object 'context').  if you'd like
to more-or-less silently ignore this error for now you can use instead


context.get('link')


which will return None if link isn't part of the context.

best,
jake

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



Re: Form field deletion

2007-09-07 Thread jake elliott

Oleg Korsak wrote:
>> Sure - use the 'fields' option to specify the subset of model fields
>> you want to use on the form.
>>
>   form_for_instance() got an unexpected keyword argument 'fields'
> 

this argument to form_for_instance() and form_for_model() is only
available in the SVN version of django.

one quick way to get this behavior without that argument is to set the
'user' field 'editable=False'

user = models.ForeignKey(User, editable=False)

remember this will affect the change form in contrib.admin also, which
may or may not be desirable for your project.

-jake

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Help me understand the error of my ways...

2007-09-07 Thread jake elliott

hi atendo,

Atendo wrote:
> And then in the homepage index.html I've got this:
> 
> {% load industry_widget %}
> 

sorry if i miss the mark here but are you actually invoking the
templatetag you've loaded anywhere in your template?  ie:


{% load industry_widget %}

{% industry_widget %}


here you happen to have named your templatetag module and your inclusion
tag the same thing, but they are separate entities.

-jake

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---