Re: FileUploadHandler not called in realtime

2009-04-16 Thread legutierr

I am experiencing exactly the same problem with Apache running against
FastCGI on a Mac.  It would seem that the problem is on the Django
side, not on the webserver side if this is the case.

Thomasz- Have you figured out a solution to this problem?  Did you log
a bug in the defect tracker?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: newbie: syncdb doesnt update schema after model change?

2009-04-16 Thread zayatzz

If the tables of this app hold no info, then you can do python
manage.py reset appname. This clears all tables of this app but the
changes will hit database :)

Alan

On Apr 16, 7:11 pm, Aneesh  wrote:
> This is by design.  syncdb only checks to see if it needs to create
> any new DB tables for any models; it does NOT alter existing model
> tables.  Seehttp://docs.djangoproject.com/en/dev/ref/django-admin/#syncdb
> for more info.
>
> If you don't have any valuable data in the table (ie, you're just
> developing or playing around), the best thing to do is drop the whole
> table from the DB entirely, and then syncdb will recreate it from
> scratch with the new column included.  You can also just issue an
> ALTER TABLE to add the column manually with the proper name, and
> Django will recognize it.
>
> Good luck,
> Aneesh
>
> On Apr 16, 9:00 am, gry  wrote:
>
> > [django: 1.1 beta 1 SVN-10407, python 2.5.2, ubuntu]
> > My first django toy app.  I've been working through the 
> > tutorialhttp://docs.djangoproject.com/en/dev/intro/tutorial02/.
> > I've already done a few cycles of  (change-model, ./manage.py syncdb)
> > with success.
> > I just added email and birthday fields to my Person model:
>
> > class Person(models.Model):
> >     name = models.CharField(max_length=200)
> >     def formalname(self):
> >         return 'Mr(Ms) ' + self.name
> >     phone = models.CharField(max_length=13)
> >     address = models.ForeignKey(Address)
> >     email = models.EmailField()
> >     birthday = models.DateField()
> >     def __unicode__(self):
> >         return self.name
>
> > I killed the server process(maybe not necessary).  I did ./manage.py
> > syncdb .
> > Now "./manage.py sql phones" reports:
> > CREATE TABLE "phones_person" (
> >     "id" integer NOT NULL PRIMARY KEY,
> >     "name" varchar(200) NOT NULL,
> >     "phone" varchar(13) NOT NULL,
> >     "address_id" integer NOT NULL REFERENCES "phones_address" ("id"),
> >     "email" varchar(75) NOT NULL,
> >     "birthday" date NOT NULL
> > )
> >  but dbshell  shows:
> > CREATE TABLE "phones_person" (
> >     "id" integer NOT NULL PRIMARY KEY,
> >     "name" varchar(200) NOT NULL,
> >     "phone" varchar(13) NOT NULL,
> >     "address_id" integer NOT NULL REFERENCES "phones_address" ("id")
> > );
>
> > I restart the server andhttp://127.0.0.1:8000/admin/phones/person/
> > gets me "Exception Value:
> > no such column: phones_person.email".
>
> > Why is my change not making it into the DB?  I even did "./manage.py
> > flush" and it still fails on the email field.
>
> > -- George
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django doesn't validates CharFields before gitting the DB?

2009-04-16 Thread Horacio de Oro

Hi! I've a problem with Django not validating my 'CharField's. Maybe
I'm misunderstanding the docs, and Django doesn't do this kind of
validations?

I've made a simple example. This is the model:

class SimpleModelC(models.Model):
name=models.CharField(max_length=256)
image_content_type=models.CharField(max_length=32, null=False,
blank=False)

and a simple view that get a parameter from request.GET:

def view_c3(request):
model_c=SimpleModelC()
model_c.name=request.GET['name']
model_c.save()
return HttpResponseRedirect("/ok/from/c3/")

Doing a request to: http://localhost:8000/view_c3/?name=Peter
I get a redirect to '/ok/from/c3/', and in the database:

SELECT * from myprojects_simplemodelc;
 id | name  | image_content_type
+---+
  7 | Peter |
(1 row)

Since 'SimpleModelC.image_content_type' is required to be not-null and
not-empty, shouldn't Django check for this before doing the INSERT?
In the database, in 'image_content_type'I get a blank string.

This is happening me with Django 1.0.2 and the development version of
Django 1.1.

Thanks in advance!
Horacio

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



how to organize favorites in template?

2009-04-16 Thread James

Hi,

I'm writing a video site on app engine where the user can tag videos
as favorites.

What I've done is store the keys of a users favorite videos in a dict,
and I try to determine if I should be allowing them to add or remove
this video from their favorites like this (truncated):

{% for video in video_list %}
{% if favorites[video.key] %}
  ... offer to remove
{% endif %}
{% endfor %}

... but this of course blows up because the template system can't
understand favorites[video.key]. I wonder how I should organize this
data and write the tags so that it works... should I be adding a
property to each video to mark it as a favorite? I've tried this:

for video in videos:
  video.favorite = True

but that property (or attribute or whatever it's called) doesn't show
up in my template as true ... ??

Many Thanks,

James


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



Creating menu from self-nested list

2009-04-16 Thread skydark

I have an app in which the objects can relate to themselves and I
wrote a view function that returns a nested list in a similar
structure as the one accepted by the unordered_list built-in template
tag.
[['cat1', ['sub1',sub2]], ['cat2', ['sub3', ['sub4,[sub5]]] ]]

I want more than just a simple unordered_list as a menu since it can
have many levels and would occupy to much space.

As far as I know, other than the unordered_list tag, there is no
simple way of translating the information on the list to a decent
menu, so I think I have to create a function to help unpack. And this
is where I'm having trouble:
-->In a function how can I iterate over this self-nested list, if I
don't know if I'm getting a string or another list. Is there a way to
know if the value represents a string?Or a list?

-->should I create a custom filter tag to do this or should I have my
view output the information on a different structure that would be
easier to read using the control flow tags of 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: setting a model field to null

2009-04-16 Thread rvr

Obviously I misread something. None works perfectly. Thanks very much.

On Apr 16, 3:05 pm, Margie  wrote:
> blah.foo = None should do the trick
>
> On Apr 15, 8:01 pm, rvr  wrote:
>
>
>
> > How can I set a model field to null after it has had a non-null value?
>
> > --
> > class Blah(models.Model):
> >     foo = models.IntegerField(null=True)
>
> > blah = Blah()
> > blah.foo = 5
>
> > # now set it to null
> > blah.foo = ???
> > --
>
> > None doesn't seem to work and I don't seem to be able to figure this
> > out from the documentation. Thanks for your help.
>
> > ~rvr
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Help! PNG file upload error...

2009-04-16 Thread higer

Can anyone tell me why does this problem occur?

On Apr 12, 2:13 pm, higer  wrote:
> Thanks for your suggestion. But Python 2.5 already has zlib moudle.
> To png file,I wrote lines of code to save it first on disk and then
> handled the saved copy,then that works.
> I do not why there is some differencies between png file and file of
> other formats.The following is my code:
>
>                 parser = ImageFile.Parser()
>                 for chunk in f.chunks():
>                     parser.feed(chunk)
>                 img = parser.close()
>
>                 if format == 'png':
>                     des_origin_f = open("tmp.png","ab")
>                     for chunk in f.chunks():
>                         des_origin_f.write(chunk)
>                     des_origin_f.close()
>                     img = Image.open("tmp.png")
>
>                 ##other operations to handle the image
>                 img.save("test"+"."+fileExt) #save this image
>
> I can not make sure whether the problem is caused by Django. Because
> what my code tells is thatPILcan handle the png file from a disk,but
> can not handle a png file from a Django response(you can see my code
> in the first message and compare with the code above).
>
> On Apr 10, 9:46 pm, Brian Neal  wrote:
>
> > On Apr 9, 12:45 am, higer  wrote:
>
> > > When I upload a PNG file and usePILto handle it,there will be an
> > > error occured:
> > > 'NoneType' object is unsubscriptable
>
> > > I do not know why and other formats(BMP GIF JPG JPEG) are all ok.
>
> > I don't know if this is your problem, but in order to use certain file
> > formats inPILyou have to have some prequisites installed. Here is
> > thePILdoc page for PNG support:
>
> >http://www.pythonware.com/library/pil/handbook/format-png.htm
>
> > In particular, note:
>
> > "PILidentifies, reads, and writes PNG files containing "1", "L", "P",
> > "RGB", or "RGBA" data. Interlaced files are currently not supported."
>
> > And also:
>
> > "Note: To enable PNG support, you need to build and install the ZLIB
> > compression library before building the Python Imaging Library. See
> > the distribution README for details."
>
> > BN
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Query exclude in and selective sort questions

2009-04-16 Thread Thierry

Let's say I have a list of words in my database:

['bbb', 'aaa', 'zzz', 'ddd']

How can I retrieve a list of the above excluding the following words
['aaa', 'zzz'] by using __in?  I can do the above with:

   words_list = Words.objects.exclude(
Q(word_name = 'aaa') | Q(word_name = 'zzz')
)

The following type of syntax doesn't seem to work with exclude but
works with filter:

exclude_list = ['aaa', 'zzz']
country _list = Countries.objects.exclude(word_name__in =
exclude_list)

The other operation I want to do is to construct a list where I hand
pick two items and place it at the beginning of a list while the rest
is sorted.  For example, if I want 'zzz' and 'ddd' to be at the
beginning of the list while the rest is sorted, my desired output will
look like:

   ['zzz', 'ddd', 'aaa', 'bbb']

I could do the above in 2 steps but I end up with two QuerySet objects
which I cannot join together.  Any help on the above?


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

2009-04-16 Thread Dave Benjamin

On Apr 16, 3:30 pm, andybak  wrote:
> Is there any other approach to this that could be thread safe?

Well, one way would be to cut and paste the entire body of
changelist_view from django/contrib/admin/options.py and add some
logic around the call to the ChangeList constructor. However, this
would mean cutting and pasting 34 lines in order to only change 1,
which I was trying to avoid. Another (ugly) option would be
monkeypatching the ChangeList constructor.

I think it would be nice to be able to define class attributes like
popup_list_display, popup_list_display_links, etc. that would override
the non-popup attributes for popups if specified.

Dave

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



Re: Queries, how to get what i want?

2009-04-16 Thread google torp

Hi.
I think the problem is that get is being run before the exclude when
you still have two results and fails as it can only handle a single
result.
In this case you can't use get but should use filter().exclude()[0] to
get
the result.

On Apr 16, 10:01 pm, zayatzz  wrote:
> I need help with making queries. I keep 
> readinghttp://docs.djangoproject.com/en/dev/ref/models/querysets/http://docs.djangoproject.com/en/dev/topics/db/queries/
>
> but neither of those pages has exactly what i want nor explains why i
> cant get what i want with existing queries.
>
> Ill first post existing models here:
>
> class Trans(models.Model):
>         keel = models.ForeignKey(lang)
>         content_type = models.ForeignKey(ContentType)
>         object_id = models.PositiveIntegerField()
>         content_object = generic.GenericForeignKey("content_type",
> "object_id")
>         name= models.CharField(max_length=500)
>         def __unicode__(self):
>                 return unicode(self.name)
>
> class Poll(models.Model):
>         name = generic.GenericRelation(Trans)
>         pub_date = models.DateTimeField('date published')
>         active = models.BooleanField()
>         def __unicode__(self):
>                 return unicode(self.name)
>
> What im trying to achieve with query is to retrieve the actual
> translation (from trans model) instead of poll name.
>
> I wrote model manager for it -
>
>         def tname(self):
>                 q = ContentType.objects.get_for_model(self)
>                 z = Trans.objects.get(content_type__pk=q.id,
> object_id=self.id).exclude(keel=2)
>                 t = z.name
>                 return t
>
> What i fail to understand is how this query can retrieve 2 objects not
> one, because i keep getting this error:
>
> Caught an exception while rendering: get() returned more than one
> Trans -- it returned 2! Lookup parameters were {'object_id': 1,
> 'content_type__pk': 11}
>
> Doesnt the exclude work?
>
> There is 2 translations for each poll. one with language 1 and one
> with language 2.
>
> This also gives me 2 results
> z = Trans.objects.filter(poll = self)
> q = z.get(keel = 1)
> t = q.name
>
> Error was :  Caught an exception while rendering: get() returned more
> than one Trans -- it returned 2! Lookup parameters were {'keel': 1}
>
> What i fail to understand is, that when i use enough filters to filter
> results down to 1 - then i cant get .name value from the result, but
> when i use get instead of filter i get too many results even though i
> use exclude or additional parameters like keel = 1.
>
> Please help me understand how queries are supposed to work and how can
> i get what i want.
>
> Alan.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Two projects, one admin, filebrowser

2009-04-16 Thread shacker

On Apr 15, 12:37 am, patrickk  wrote:

> ### if your intranet-site and your public-site are on the same server
> you could maybe use a symlink as well.
> ### you could also "hack" the upload-function. define a second upload-

Ah, right - by just symlinking the upload dir from one site to the
other, each site can have its own general media dir, but a shared
upload dir. Yep, works perfectly. Thanks for the tip!

./s

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

2009-04-16 Thread andybak

Is there any other approach to this that could be thread safe?

On Apr 16, 10:46 pm, Dave Benjamin  wrote:
> On Apr 16, 2:20 pm, Alex Gaynor  wrote:
>
> > This code isn't threadsafe.  If you use your application in a multithreaded
> > application they will "cross the streams" so to speak and you will see
> > things rendred with the wrong list display.
>
> Ahh, that's what I was afraid of. Thanks for the confirmation.
>
> Dave
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Generic relations and unit tests.

2009-04-16 Thread Stavros

Is there some way I can empty the contenttypes table before the
fixtures are loaded and have django load them normally? That would
take care of this problem, as it would mean that the proper
contenttypes would get loaded from the fixture. Unfortunately, I have
not been able to find a way to run code between creating the tables
and loading the fixture, in which I assume I need to do something like
ContentType.objects.delete().

Thanks for your help,
Poromenos

On Apr 11, 3:47 am, Russell Keith-Magee 
wrote:
> On Sat, Apr 11, 2009 at 5:53 AM,Poromenos wrote:
>
> > Hello,
> > I created a model that has a ForeignKey to ContentType, but now I
> > can't use my test fixtures, since the IDs they point to are random
> > every time the test database is created. I can't dump the contenttypes
> > data because then I get many duplicate inserts, since Django rebuilds
> > them every time it sets up the test DB. Is there any way for me to use
> > both ContentType and unit tests?
>
> The IDs won't be completely random, but they certainly will be fragile
> and subject to change.
>
> You have discovered ticket #7052; unfortunately, there isn't any easy
> fix at the moment.
>
> 1) Don't use fixtures - create your test objects in the setUp() method
> of your test using normal Python code.
>
> 2) Use the fixture to define the basic data in your objects, and then
> use the setUp() method to modify the contenttypes at runtime, based on
> the current values in the database. This means you don't serialize the
> contenttype objects themselves in your fixture, and you use and
> foreignkey reference to a contenttype as a temporary placeholder for
> the real value that will be inserted at runtime.
>
> Obviously, neither of these are ideal solutions. This bug is something
> I want to look at for Django v1.2.
>
> Yours
> Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Fewer columns in admin popups

2009-04-16 Thread Dave Benjamin

On Apr 16, 2:20 pm, Alex Gaynor  wrote:
> This code isn't threadsafe.  If you use your application in a multithreaded
> application they will "cross the streams" so to speak and you will see
> things rendred with the wrong list display.

Ahh, that's what I was afraid of. Thanks for the confirmation.

Dave

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



csv download link or views that the modify more than one template...

2009-04-16 Thread Nick

I'm interested in returning both an html view (as a template) and a
link to a csv file (either as a template or using the CSV module) in
response to a query (GET or POST).  Is there a way to both of these
actions simultaneously without hitting a database twice and without
writing a file to disk?  Seems like it should be possible, but all the
view examples I can find only return one modified template at a time.

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



Re: is it possible to have more than one search result in a view

2009-04-16 Thread greatlemer

Whoops, I think I hit the wrong reply option when I tried to post to
this just now as it doesn't seem to have gone to the group.

If what you're looking to do is to combine the results of both queries
into one then what you probably want to use are the django Q objects
to give something like this:

from django.db.models import Q
search_results = Activity.objects.filter(Q(firm__firms__icontains=q)|Q
(clients__client__icontains=q))

I hope this helps

-- G

P.S. If you want more info on Q objects, check out:
http://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects

On Apr 16, 5:54 pm, nixon66  wrote:
> I have the view below and wonder if its possible to add other search
> results into the view or would I need to write seperate ones. Ideally,
> I'd like to have
>
> firm_search = Activity.objects.filter(firm__firms__icontains=q)
> client_search= Activity.objects.filter(clients__client__icontains=q)
>
> Would I just add these to the existing view? Confused? Any suggestion
> would be appreciated.
>
> def search_detail(request):
>     if 'q' in request.GET:
>         q = request.GET['q']
>         search_results = Activity.objects.filter
> (country__country__icontains=q)
>     else:
>         q = None
>         search_results = None
>     return render_to_response('country/search_detail.html',
>                 {'search_results': search_results, 'query': q})

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

2009-04-16 Thread Alex Gaynor
On Thu, Apr 16, 2009 at 5:13 PM, Dave Benjamin wrote:

>
> On Apr 11, 9:29 am, Dave Benjamin  wrote:
> > Is it possible to exclude columns from the popup list view?
>
> I may have answered my own question. It looks like the popup is
> generated from the changelist_view method of ModelAdmin, and this
> method gets the request as a parameter. I was able to modify the
> list_display attribute (which seems to be used as an instance
> attribute even though it normally starts out as a class attribute)
> before the change list gets generated. However, it seems like the
> ModelAdmin instance is saved and reused, so I have to code for both
> the popup and non-popup states, and I wonder if mutating the instance
> is a thread-safe operation. Anyway, here's what I came up with:
>
> class CustomUserAdmin(UserAdmin):
># ...
>
>def changelist_view(self, request, *args, **kwargs):
>is_popup = admin.views.main.IS_POPUP_VAR in request.GET
>if is_popup:
>self.list_display = [
>u'username',
>u'last_name',
>u'first_name',
>u'is_active',
>u'last_login',
>]
>self.list_display_links = [u'username']
>else:
>self.list_display = [
>u'username',
>u'last_name',
>u'first_name',
>u'is_active',
>u'is_staff',
>u'date_joined',
>u'last_login',
>]
>self.list_display_links = [u'username']
>return super(CustomUserAdmin, self).changelist_view(request,
> *args, **kwargs)
>
> admin.site.unregister(User)
> admin.site.register(User, CustomUserAdmin)
>
> >
>
This code isn't threadsafe.  If you use your application in a multithreaded
application they will "cross the streams" so to speak and you will see
things rendred with the wrong list display.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: Fewer columns in admin popups

2009-04-16 Thread Dave Benjamin

On Apr 11, 9:29 am, Dave Benjamin  wrote:
> Is it possible to exclude columns from the popup list view?

I may have answered my own question. It looks like the popup is
generated from the changelist_view method of ModelAdmin, and this
method gets the request as a parameter. I was able to modify the
list_display attribute (which seems to be used as an instance
attribute even though it normally starts out as a class attribute)
before the change list gets generated. However, it seems like the
ModelAdmin instance is saved and reused, so I have to code for both
the popup and non-popup states, and I wonder if mutating the instance
is a thread-safe operation. Anyway, here's what I came up with:

class CustomUserAdmin(UserAdmin):
# ...

def changelist_view(self, request, *args, **kwargs):
is_popup = admin.views.main.IS_POPUP_VAR in request.GET
if is_popup:
self.list_display = [
u'username',
u'last_name',
u'first_name',
u'is_active',
u'last_login',
]
self.list_display_links = [u'username']
else:
self.list_display = [
u'username',
u'last_name',
u'first_name',
u'is_active',
u'is_staff',
u'date_joined',
u'last_login',
]
self.list_display_links = [u'username']
return super(CustomUserAdmin, self).changelist_view(request,
*args, **kwargs)

admin.site.unregister(User)
admin.site.register(User, CustomUserAdmin)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Getting the Model type of an unknown object?

2009-04-16 Thread BradMcGonigle

Bah!  As usual...I figure this out right after posting something.

This works:

{% for object in stream_list %}
  {% ifequal object._meta.object_name 'Entry' %}

On Apr 16, 4:33 pm, BradMcGonigle 
wrote:
> Oddly enough I am trying to do the exact same thing Matt is trying to
> do.
>
> I tried this:
>
> {% for object in stream_list %}
>       {% if object._meta.Entry %}
>
> but underscores are not allowed to start variables and attributes.
>
> Is there another way to do this at the template level or is my syntax
> just wrong.
>
> Brad
>
> On Apr 16, 2:00 pm, Daniel Roseman 
> wrote:
>
> > On Apr 16, 6:02 pm, Matthew  wrote:
>
> > > Is it possible to do this?
>
> > > I'm using a custom MultiQuerySet snippet to merge a bunch of querysets
> > > from different models, and then I want to iterate over the resultant
> > >list, but I want to be able to pull out from eachobjectin thelist
> > > its ownModeltype so I can perform a few comparisons/functions. Short
> > > of writing a method into eachmodel, I can't think of anyway it could
> > > be done, and that won't work because I want to throw Comments into
> > > that merged queryset too.
>
> > > Help would be much appreciated,
> > > Thanks
> > > Matt
>
> > There's a couple of ways.
>
> > You could use the built-in Python attribute __class__ that exists on
> > everyobject. This returns a classobject.
>
> > Or, you could use some of the data in the _meta subclass of each
> > Djangomodel. For instance, x._meta.object_name gives the name of 
> > x'smodeltype. Do dir(x._meta) to get alist.
> > --
> > DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django-grappelli setup problem

2009-04-16 Thread patrickk

I´m working with the request-context-processor. I´ll change that for
the user (because the auth-processor is required for the admin
anyway). nevertheless, without the request-processor, bookmarks
probably doesn´t work.

simple fix:
just add "django.core.context_processors.request", to your template
context processors.

however, I´ll take another look at that in order to simplify.

thanks,
patrick


On 16 Apr., 21:44, Lars Stavholm  wrote:
> patrickk wrote:
> > it´s really easy to debug here:
> > line 60 of index.html is {% get_navigation request.user %}.
> > check the templatetag (navigation.py) and see if the user is there and
> > if the navigation is loaded (e.g. using "print object_list" when the
> > dev-server is started). if there are problems, use the shell (python
> > manage.py shell) to do some testing.
>
> > shouldn´t be hard to find the "error" ...
>
> Well, error or not, I've managed to get the Bookmarks and
> Navigation to show nicely. However, this happened only after
> replacing request.user with user in {% get_navigation request.user %}
> on line 60 in index.html (and then the same kind of hoopla in
> base.html with didn't work out for request.path). Then I remembered
> that django forced me to add the django.core.context_processors.auth
> to the TEMPLATE_CONTEXT_PROCESSORS in my settings.py. This apparently
> makes "request.user" useless, but allows you to use "user" instead.
>
> However, I get the feeling that there's something fishy going on here,
> since you don't seem to use the django context processor for auth.
> How do you get away with that? Or maybe there's a mismatch of versions
> here. I use django-1.0.2 and I was led to believe that django-grappelli
> was developed towards the latest release of django, i.e. 1.0.2.
> /L
>
> > On 16 Apr., 18:44, Lars Stavholm  wrote:
> >> So that all went well. Now all I need now is the bookmarks
> >> and the sidebar navigation box. They're not visible as of
> >> right now and I'm not sure what to do about it. The recommended
> >> fixtures are loaded.
>
> >> Any ideas anyone?
> >> /L
>
> >> Lars Stavholm wrote:
> >>> patrickk wrote:
>  line 53 of base.html is {% get_help request.path %}.
>  I´m not exactly sure what´s happening here and I´m not able to
>  reproduce this error.
>  you might wanna try to debug ... request.user seems to work (because
>  that´s a couple of lines before), so request.path should also work.
>  but I´ve never tested this locally, so I´m not sure if that can cause
>  the error (we´re having test/development-servers to do this).
>  if you dig a little depper and you think you´ve found a bug - then
>  please report it using the google-code issue tracker.
> >>> No bug (as far as I can see), just newbie-ness. Turns out that
> >>> there's some sort of conflict with other apps, namely the batchadmin
> >>> app, possibly more (I removed them all). In addition, being a newbie,
> >>> I neglected to tell you that I'm running the development server. I
> >>> followed the instructions by Chris Scott, and after a bit of fiddling,
> >>> presto, I can see the light:)
> >>> It looks brilliant!
> >>> /L
>  On 15 Apr., 20:14, Lars Stavholm  wrote:
> > patrickk wrote:
> >> in order to use the admin, just use /admin/ (grappelli doesn´t change
> >> the admin-urls).
> > Thanks, but that got me in to some other problem:
> > TemplateSyntaxError at /admin/
> > Caught an exception while rendering: Failed lookup for key [request] in
> > u"[{'root_path': u'/admin/', 'app_list': [{'app_url': 'asset/',
> > [snip]
> > Request Method:         GET
> > Request URL:    http://localhost:8000/admin/
> > Exception Type:         TemplateSyntaxError
> > Exception Value:        
> > Caught an exception while rendering: Failed lookup for key [request] in
> > [snip]
> > Exception Location:
> > /usr/lib/python2.6/site-packages/django/template/debug.py in
> > render_node, line 81
> > Python Executable:      /usr/bin/python
> > Python Version:         2.6.0
> > Python Path:    ['/home/stava/proj/bfact',
> > '/home/stava/lib/Trac-0.11.1-py2.5.egg', '/home/stava/lib',
> > '/home/stava/proj', '/usr/lib/python26.zip', '/usr/lib/python2.6',
> > '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk',
> > '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload',
> > '/usr/lib/python2.6/site-packages',
> > '/usr/lib/python2.6/site-packages/Numeric',
> > '/usr/lib/python2.6/site-packages/PIL',
> > '/usr/local/lib/python2.6/site-packages',
> > '/usr/lib/python2.6/site-packages/gtk-2.0',
> > '/usr/lib/python2.6/site-packages/wx-2.8-gtk2-unicode']
> > Server time:    Wed, 15 Apr 2009 20:07:53 +0200
> > Template error
> > In template /home/stava/proj/bfact/templates/admin/base.html, error at
> > line 53
> > My ursl.py looks like this:

Re: is it possible to have more than one search result in a view

2009-04-16 Thread nixon66

That's what I was thinking, so my question is can I do this?

def search_detail(request):
if 'q' in request.GET:
q = request.GET['q']
search_results = Activity.objects.filter
(country__country__icontains=q)
firm_search =  Activity.objects.filter
(firm__firm__icontains=q)
client_search = Activity.objects.filter
(client__client__icontains=q)
else:
q = None
search_results = None
return render_to_response('country/search_detail.html',
{'search_results': search_results, 'query': q})




On Apr 16, 1:30 pm, commander_coder 
wrote:
> Perhaps I don't understand the question, but why cannot your context
> include a number of different pieces of data?
>   return render_to_response('country/search_detail.html',
>                 {'search_results': search_results,
>                  'firm_search':firm_search,
>                  'client_search':client_search,
>                  'query': q})
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Authenication for django.views.generic Views

2009-04-16 Thread Col Wilson

Thanks all. I have some reading to do, but I have also noticed in the
meantime that generic views docs (http://docs.djangoproject.com/en/dev/
ref/generic-views/#ref-generic-views) have a hook into the auth
system. Look for 'login_required'.

Having said that, I still have a bit of reading to do.


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



Queries, how to get what i want?

2009-04-16 Thread zayatzz

I need help with making queries. I keep reading
http://docs.djangoproject.com/en/dev/ref/models/querysets/
http://docs.djangoproject.com/en/dev/topics/db/queries/

but neither of those pages has exactly what i want nor explains why i
cant get what i want with existing queries.

Ill first post existing models here:

class Trans(models.Model):
keel = models.ForeignKey(lang)
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey("content_type",
"object_id")
name= models.CharField(max_length=500)
def __unicode__(self):
return unicode(self.name)

class Poll(models.Model):
name = generic.GenericRelation(Trans)
pub_date = models.DateTimeField('date published')
active = models.BooleanField()
def __unicode__(self):
return unicode(self.name)

What im trying to achieve with query is to retrieve the actual
translation (from trans model) instead of poll name.

I wrote model manager for it -

def tname(self):
q = ContentType.objects.get_for_model(self)
z = Trans.objects.get(content_type__pk=q.id,
object_id=self.id).exclude(keel=2)
t = z.name
return t

What i fail to understand is how this query can retrieve 2 objects not
one, because i keep getting this error:

Caught an exception while rendering: get() returned more than one
Trans -- it returned 2! Lookup parameters were {'object_id': 1,
'content_type__pk': 11}

Doesnt the exclude work?

There is 2 translations for each poll. one with language 1 and one
with language 2.

This also gives me 2 results
z = Trans.objects.filter(poll = self)
q = z.get(keel = 1)
t = q.name

Error was :  Caught an exception while rendering: get() returned more
than one Trans -- it returned 2! Lookup parameters were {'keel': 1}

What i fail to understand is, that when i use enough filters to filter
results down to 1 - then i cant get .name value from the result, but
when i use get instead of filter i get too many results even though i
use exclude or additional parameters like keel = 1.

Please help me understand how queries are supposed to work and how can
i get what i want.

Alan.

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

2009-04-16 Thread Lars Stavholm

patrickk wrote:
> it´s really easy to debug here:
> line 60 of index.html is {% get_navigation request.user %}.
> check the templatetag (navigation.py) and see if the user is there and
> if the navigation is loaded (e.g. using "print object_list" when the
> dev-server is started). if there are problems, use the shell (python
> manage.py shell) to do some testing.
> 
> shouldn´t be hard to find the "error" ...


Well, error or not, I've managed to get the Bookmarks and
Navigation to show nicely. However, this happened only after
replacing request.user with user in {% get_navigation request.user %}
on line 60 in index.html (and then the same kind of hoopla in
base.html with didn't work out for request.path). Then I remembered
that django forced me to add the django.core.context_processors.auth
to the TEMPLATE_CONTEXT_PROCESSORS in my settings.py. This apparently
makes "request.user" useless, but allows you to use "user" instead.

However, I get the feeling that there's something fishy going on here,
since you don't seem to use the django context processor for auth.
How do you get away with that? Or maybe there's a mismatch of versions
here. I use django-1.0.2 and I was led to believe that django-grappelli
was developed towards the latest release of django, i.e. 1.0.2.
/L

> On 16 Apr., 18:44, Lars Stavholm  wrote:
>> So that all went well. Now all I need now is the bookmarks
>> and the sidebar navigation box. They're not visible as of
>> right now and I'm not sure what to do about it. The recommended
>> fixtures are loaded.
>>
>> Any ideas anyone?
>> /L
>>
>> Lars Stavholm wrote:
>>> patrickk wrote:
 line 53 of base.html is {% get_help request.path %}.
 I´m not exactly sure what´s happening here and I´m not able to
 reproduce this error.
 you might wanna try to debug ... request.user seems to work (because
 that´s a couple of lines before), so request.path should also work.
 but I´ve never tested this locally, so I´m not sure if that can cause
 the error (we´re having test/development-servers to do this).
 if you dig a little depper and you think you´ve found a bug - then
 please report it using the google-code issue tracker.
>>> No bug (as far as I can see), just newbie-ness. Turns out that
>>> there's some sort of conflict with other apps, namely the batchadmin
>>> app, possibly more (I removed them all). In addition, being a newbie,
>>> I neglected to tell you that I'm running the development server. I
>>> followed the instructions by Chris Scott, and after a bit of fiddling,
>>> presto, I can see the light:)
>>> It looks brilliant!
>>> /L
 On 15 Apr., 20:14, Lars Stavholm  wrote:
> patrickk wrote:
>> in order to use the admin, just use /admin/ (grappelli doesn´t change
>> the admin-urls).
> Thanks, but that got me in to some other problem:
> TemplateSyntaxError at /admin/
> Caught an exception while rendering: Failed lookup for key [request] in
> u"[{'root_path': u'/admin/', 'app_list': [{'app_url': 'asset/',
> [snip]
> Request Method: GET
> Request URL:http://localhost:8000/admin/
> Exception Type: TemplateSyntaxError
> Exception Value:
> Caught an exception while rendering: Failed lookup for key [request] in
> [snip]
> Exception Location:
> /usr/lib/python2.6/site-packages/django/template/debug.py in
> render_node, line 81
> Python Executable:  /usr/bin/python
> Python Version: 2.6.0
> Python Path:['/home/stava/proj/bfact',
> '/home/stava/lib/Trac-0.11.1-py2.5.egg', '/home/stava/lib',
> '/home/stava/proj', '/usr/lib/python26.zip', '/usr/lib/python2.6',
> '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk',
> '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload',
> '/usr/lib/python2.6/site-packages',
> '/usr/lib/python2.6/site-packages/Numeric',
> '/usr/lib/python2.6/site-packages/PIL',
> '/usr/local/lib/python2.6/site-packages',
> '/usr/lib/python2.6/site-packages/gtk-2.0',
> '/usr/lib/python2.6/site-packages/wx-2.8-gtk2-unicode']
> Server time:Wed, 15 Apr 2009 20:07:53 +0200
> Template error
> In template /home/stava/proj/bfact/templates/admin/base.html, error at
> line 53
> My ursl.py looks like this:
> from django.conf.urls.defaults import *
> from django.contrib import admin
> admin.autodiscover()
> urlpatterns = patterns('',
>   (r'^grappelli/', include('grappelli.urls')),
>   (r'^admin/(.*)', admin.site.root),
> )
> /L
>> On 15 Apr., 10:06, Lars Stavholm  wrote:
>>> patrickk wrote:
 which URL causes that error?
>>> http://localhost:8000/grappelli/admin/
 please note that in order to use grappelli you have to setup the admin-
 site before, 
 seehttp://docs.djangoproject.com/en/dev/ref/contrib/admin/#ref-contrib-a

Re: TemplateSyntaxError: Settings issue?

2009-04-16 Thread Aneesh

Thanks BN, your intuition was spot on.  It was a python path problem.
Adding the following line to my dispatch.fcgi file did the trick.

sys.path += ['/path/to/my/project']

It seems that "manage.py runserver" took care of this in my dev
environment, so the issue didn't come up.

On Apr 16, 10:43 am, Brian Neal  wrote:
> On Apr 16, 11:33 am, Aneesh K  wrote:
>
>
>
> > Why is the TemplateSyntaxError raised, and why don't I see this
> > problem on my development server?
>
> > Thanks!
> > Aneesh
>
> Could be a python path problem? Put the directory that has your
> application in it on the python path. I think when you do the
> manage.py command it puts the parent directory on the python path for
> you (as an aid to new users).
>
> BN
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Authenication for django.views.generic Views

2009-04-16 Thread Dan Harris

http://docs.djangoproject.com/en/dev/topics/auth/#limiting-access-to-generic-views

hope this helps. Basically you write your own view which calls the
generic view after you have done your authentication.

On Apr 16, 11:25 am, Col Wilson 
wrote:
> I'm using generic views to render my pages
> (django.views.generic.date_based, django.views.generic.list_detail
> etc) and they're very handy.
>
> However, the app I'm trying to build would like a security and on
> reading the "User Authentication in Django" document, it just talks
> about adding authentication to the views.
>
> Generic views of course are buried in the django installation
> directories and you don't want to go messing about in there, so it's
> not obvious to me how I can do that.
>
> Can someone give me a hand please?

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

2009-04-16 Thread Marco Maier
On Thu, Apr 16, 2009 at 5:25 PM, koranthala  wrote:

>
> On Apr 16, 6:41 pm, Alex Gaynor  wrote:
> > On Thu, Apr 16, 2009 at 6:39 AM, koranthala 
> wrote:
> >
> > > Hi,
> > >I was comparing between signal and save() and came across this
> > > following mail chain -
> >
> > >http://groups.google.com/group/django-users/browse_thread/thread/d0ff.
> ..
> >
> > >In this it is mentioned that -
> > > ---
> > > If you want to implement some
> > > functionality that operates across multiple types of models, you need
> > > to
> > > use the signal infrastructure, since the same signal is raised no
> > > matter
> > > what the type of model (you can differentiate the model type in the
> > > signal handler, though).
> > > 
> >
> > >   I was unable to understand why we should go for signals in case we
> > > have to work across models?
> > >   Say, for example - I have ModelA and ModelB. Everytime, I save an
> > > element in ModelA, I need to update 15 fields in ModelB.
> > >   In this case, shouldn't I do everything in ModelA.save itself?
> > > ModelA.save():
> > >   super.save()
> > >   Update 15 fields in ModelB
> >
> > >   I do not understand why we should go for signals in this case too?
> > >   Sorry if I am dense :-)
> >
> > One of the simplest reasons to use signals in that situation is because
> you
> > can't change the code in that application.  Say you want to trigger
> > something on the User object being saved, you don't want to monkey patch
> > django.contrib.auth so use just use the signal for code clarity.
> >
> > Alex
> >
> > --
> > "I disapprove of what you say, but I will defend to the death your right
> to
> > say it." --Voltaire
> > "The people's good is the highest law."--Cicero
>
> Thank you Alex.
> But considering the scenario mentioned above - wherein I need to make
> modifications to a separate table - both of which I have full access
> to - should I go ahead with signals or should I go with save?
> Malcolms mail  - the link mentioned earlier - seems to suggest that I
> should be using signals - but I am unable to understand the
> justification for it.
>
> If ModelA and ModelB belong (logically) together, I'd go for save(). Say
ModelA is "Article" and ModelB is "Category" and when you insert an article,
you want to update some field in the corresponding category, I'd put that
into the article's save() method.
If the two models are not really related to each other, I'd use the signal.
E.g. ModelA is "Article" and ModelB is "LogEntry". The logs are a different
set of functionality, so this should not be mixed up. Furthermore, you
probably want to use the log functionality with other models, too. So you
could just listen for the signal(s) to apply it to all of them. I think, the
latter is what Malcolm meant with "implement some functionality that
operates across multiple types of models".

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

2009-04-16 Thread Daniel Roseman

On Apr 16, 4:25 pm, Col Wilson 
wrote:
> I'm using generic views to render my pages
> (django.views.generic.date_based, django.views.generic.list_detail
> etc) and they're very handy.
>
> However, the app I'm trying to build would like a security and on
> reading the "User Authentication in Django" document, it just talks
> about adding authentication to the views.
>
> Generic views of course are buried in the django installation
> directories and you don't want to go messing about in there, so it's
> not obvious to me how I can do that.
>
> Can someone give me a hand please?

The basic way to do this is to write a simple view which is just a
short wrapper around a generic view, but which takes authentication.
James Bennett has a good post on this:
http://www.b-list.org/weblog/2006/nov/16/django-tips-get-most-out-generic-views/
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Authenication for django.views.generic Views

2009-04-16 Thread Colin Bean

On Thu, Apr 16, 2009 at 8:25 AM, Col Wilson
 wrote:
>
> I'm using generic views to render my pages
> (django.views.generic.date_based, django.views.generic.list_detail
> etc) and they're very handy.
>
> However, the app I'm trying to build would like a security and on
> reading the "User Authentication in Django" document, it just talks
> about adding authentication to the views.
>
> Generic views of course are buried in the django installation
> directories and you don't want to go messing about in there, so it's
> not obvious to me how I can do that.
>
> Can someone give me a hand please?
> >
>

Middleware would be one option.  You could write a process_view
function that checks request.user and redirects requests with no
authentication.  This will all happen before the view gets called.
More here:

http://docs.djangoproject.com/en/dev/topics/http/middleware/#process-view

Colin

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Getting the Model type of an unknown object?

2009-04-16 Thread Daniel Roseman

On Apr 16, 6:02 pm, Matthew  wrote:
> Is it possible to do this?
>
> I'm using a custom MultiQuerySet snippet to merge a bunch of querysets
> from different models, and then I want to iterate over the resultant
> list, but I want to be able to pull out from each object in the list
> its own Model type so I can perform a few comparisons/functions. Short
> of writing a method into each model, I can't think of anyway it could
> be done, and that won't work because I want to throw Comments into
> that merged queryset too.
>
> Help would be much appreciated,
> Thanks
> Matt

There's a couple of ways.

You could use the built-in Python attribute __class__ that exists on
every object. This returns a class object.

Or, you could use some of the data in the _meta subclass of each
Django model. For instance, x._meta.object_name gives the name of x's
model type. Do dir(x._meta) to get a list.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: possible filter bug with manytomany fields and slice?

2009-04-16 Thread Margie

First let me mention I am on sqlite3!  Perhaps it doesn't support
this? I do not know much about the various sql db interfaces, so I
have no idea what supports what ..

I've actually sort of lost track at this point of what I was
originally trying to do.  But here's some more information on the
general issue, with the output from as_sql() for the case that seems
to not work.  Let me know if you still think it is a bug and I will
post it.

>>> Tile.objects.all()
[, , , ]

# When I filter based on Tile.objects.all()[0] I get an error - it's
not interable.  This seems reasonable
>>> PdTask.objects.filter(tiles__in=Tile.objects.all()[0])
TypeError: 'Tile' object is not iterable

# So instead I'll put the rhs of tiles_in into a list to find all
PdTask objects that have tile 'll_1' in their tiles m2m field
# This returns two tasks (the first named 'foo', the second happens to
have no name)
>>> PdTask.objects.filter(tiles__in=[Tile.objects.all()[0]])
[, ]

# Now do the same thing using the slice Tile.objects.all()[0:1]. I
think this should return the same two pdtasks, but it returns empty
list
[, ]
>>> PdTask.objects.filter(tiles__in=Tile.objects.all()[0:1])
[]

# Here's the sql query generated for the above example:
>>> PdTask.objects.filter(tiles__in=Tile.objects.all()[0:1]).query.as_sql()
('SELECT "pdtaskmanager_pdtask"."id",
"pdtaskmanager_pdtask"."created", "pdtaskmanager_pdtask"."modified",
"pdtaskmanager_pdtask"."name", "pdtaskmanager_pdtask"."deadline",
"pdtaskmanager_pdtask"."priority",
"pdtaskmanager_pdtask"."description",
"pdtaskmanager_pdtask"."owner_id", "pdtaskmanager_pdtask"."status",
"pdtaskmanager_pdtask"."result", "pdtaskmanager_pdtask"."forum_id",
"pdtaskmanager_pdtask"."parentTask_id",
"pdtaskmanager_pdtask"."chip_id", "pdtaskmanager_pdtask"."stage_id"
FROM "pdtaskmanager_pdtask" INNER JOIN "pdtaskmanager_pdtask_tiles" ON
("pdtaskmanager_pdtask"."id" =
"pdtaskmanager_pdtask_tiles"."pdtask_id") WHERE
"pdtaskmanager_pdtask_tiles"."tile_id" IN (SELECT U0."id" FROM
"chipmanager_tile" U0 LIMIT 1) ORDER BY
"pdtaskmanager_pdtask"."deadline" DESC', ())


Margie


On Apr 16, 12:15 am, Malcolm Tredinnick 
wrote:
> On Thu, 2009-04-16 at 00:01 -0700, Margie wrote:
> > Ah - ok, cool, good to know.  I am on 1.1 pre-alpha SVN-9814.
>
> Hmm .. then maybe there's an actual problem there. The ability to use
> nested querysets was added in r9701 (with a few bug fixes in subsequent
> patches). I only said 1.1-beta as a rough reference point, as opposed to
> 1.0.X.
>
> Might be worth having a look at the SQL that is being generated to see
> what's going on there. Maybe I've screwed up limits or something (I
> can't really stop to test this myself right now, as I'm still at work).
>
> Have a look at the output of
>
> PdTask.objects.filter(tiles__in=pdTask.objects.all()[0]).query.as_sql()
>
> and see if it looks broken in any obvious fashion. If so, feel free to
> open a ticket (assign it to "mtredinnick" so I'll remember to look at it
> on the weekend). You shoudl still try a slightly later version
> (something around beta-1) just to check it wasn't fixed by some of the
> later tweaks in that area, but I'm now a bit suspicious that something
> is going wrong.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Serving Static Files - Pics work, but CSS doesn't

2009-04-16 Thread Wayne Koorts

>> Also just another tip: it is a good idea to not use named colour
>> values ("green" / "red" etc.) as each CSS rendering engine might
>> interpret it differently.  For green you could use: "color: rgb(0,
>> 255, 0);" and for red you could use: "color: rgb(255, 0, 0);".
>
> That is incorrect, the named colors are all specified in 24bit RGB
> values as part of the CSS spec. No renderer deviates from those values.
>
> http://www.w3.org/TR/CSS21/syndata.html#color-units

I see, I was clearly misinformed.  Thanks for the link.

Regards,
Wayne

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

2009-04-16 Thread Brian Neal

On Apr 16, 11:33 am, Aneesh K  wrote:
>
> Why is the TemplateSyntaxError raised, and why don't I see this
> problem on my development server?
>
> Thanks!
> Aneesh

Could be a python path problem? Put the directory that has your
application in it on the python path. I think when you do the
manage.py command it puts the parent directory on the python path for
you (as an aid to new users).

BN
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: is it possible to have more than one search result in a view

2009-04-16 Thread commander_coder

Perhaps I don't understand the question, but why cannot your context
include a number of different pieces of data?
  return render_to_response('country/search_detail.html',
{'search_results': search_results,
 'firm_search':firm_search,
 'client_search':client_search,
 'query': q})
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Running django test suite

2009-04-16 Thread jeffhg58

I recently installed django 1.1 beta and I needed to run the django
test suite. So, under the tests directory I executed runtests.py. I
received some errors when trying to execute all the tests. I was
expected that all the tests would have passed. I am thinking it might
be with my setup. Here are the errors I encountered.

http://dpaste.com/34433/

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



Re: django-grappelli setup problem

2009-04-16 Thread patrickk

it´s really easy to debug here:
line 60 of index.html is {% get_navigation request.user %}.
check the templatetag (navigation.py) and see if the user is there and
if the navigation is loaded (e.g. using "print object_list" when the
dev-server is started). if there are problems, use the shell (python
manage.py shell) to do some testing.

shouldn´t be hard to find the "error" ...

patrick.


On 16 Apr., 18:44, Lars Stavholm  wrote:
> So that all went well. Now all I need now is the bookmarks
> and the sidebar navigation box. They're not visible as of
> right now and I'm not sure what to do about it. The recommended
> fixtures are loaded.
>
> Any ideas anyone?
> /L
>
> Lars Stavholm wrote:
> > patrickk wrote:
> >> line 53 of base.html is {% get_help request.path %}.
>
> >> I´m not exactly sure what´s happening here and I´m not able to
> >> reproduce this error.
> >> you might wanna try to debug ... request.user seems to work (because
> >> that´s a couple of lines before), so request.path should also work.
>
> >> but I´ve never tested this locally, so I´m not sure if that can cause
> >> the error (we´re having test/development-servers to do this).
>
> >> if you dig a little depper and you think you´ve found a bug - then
> >> please report it using the google-code issue tracker.
>
> > No bug (as far as I can see), just newbie-ness. Turns out that
> > there's some sort of conflict with other apps, namely the batchadmin
> > app, possibly more (I removed them all). In addition, being a newbie,
> > I neglected to tell you that I'm running the development server. I
> > followed the instructions by Chris Scott, and after a bit of fiddling,
> > presto, I can see the light:)
>
> > It looks brilliant!
>
> > /L
>
> >> On 15 Apr., 20:14, Lars Stavholm  wrote:
> >>> patrickk wrote:
>  in order to use the admin, just use /admin/ (grappelli doesn´t change
>  the admin-urls).
> >>> Thanks, but that got me in to some other problem:
>
> >>> TemplateSyntaxError at /admin/
> >>> Caught an exception while rendering: Failed lookup for key [request] in
> >>> u"[{'root_path': u'/admin/', 'app_list': [{'app_url': 'asset/',
>
> >>> [snip]
>
> >>> Request Method:         GET
> >>> Request URL:    http://localhost:8000/admin/
> >>> Exception Type:         TemplateSyntaxError
> >>> Exception Value:        
>
> >>> Caught an exception while rendering: Failed lookup for key [request] in
>
> >>> [snip]
>
> >>> Exception Location:
> >>> /usr/lib/python2.6/site-packages/django/template/debug.py in
> >>> render_node, line 81
> >>> Python Executable:      /usr/bin/python
> >>> Python Version:         2.6.0
> >>> Python Path:    ['/home/stava/proj/bfact',
> >>> '/home/stava/lib/Trac-0.11.1-py2.5.egg', '/home/stava/lib',
> >>> '/home/stava/proj', '/usr/lib/python26.zip', '/usr/lib/python2.6',
> >>> '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk',
> >>> '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload',
> >>> '/usr/lib/python2.6/site-packages',
> >>> '/usr/lib/python2.6/site-packages/Numeric',
> >>> '/usr/lib/python2.6/site-packages/PIL',
> >>> '/usr/local/lib/python2.6/site-packages',
> >>> '/usr/lib/python2.6/site-packages/gtk-2.0',
> >>> '/usr/lib/python2.6/site-packages/wx-2.8-gtk2-unicode']
> >>> Server time:    Wed, 15 Apr 2009 20:07:53 +0200
> >>> Template error
>
> >>> In template /home/stava/proj/bfact/templates/admin/base.html, error at
> >>> line 53
>
> >>> My ursl.py looks like this:
>
> >>> from django.conf.urls.defaults import *
> >>> from django.contrib import admin
> >>> admin.autodiscover()
>
> >>> urlpatterns = patterns('',
> >>>   (r'^grappelli/', include('grappelli.urls')),
> >>>   (r'^admin/(.*)', admin.site.root),
> >>> )
>
> >>> /L
>
>  On 15 Apr., 10:06, Lars Stavholm  wrote:
> > patrickk wrote:
> >> which URL causes that error?
> >http://localhost:8000/grappelli/admin/
> >> please note that in order to use grappelli you have to setup the admin-
> >> site before, 
> >> seehttp://docs.djangoproject.com/en/dev/ref/contrib/admin/#ref-contrib-a
> >> maybe this should be mentioned in the docs, but I guess it´s pretty
> >> obvious.
> > I guess it is, admin up and running nicely without grappelli.
> > /L
> >> On Apr 14, 8:36 pm, Lars Stavholm  wrote:
> >>> Hi All,
> >>> I'm trying to get django-grappelli running, but after following
> >>> the installation instructions, I end up with a 404 and the following:
> >>> Using the URLconf defined in bfact.urls, Django tried these URL
> >>> patterns, in this order:
> >>>    1. ^admin/(.*)
> >>>    2. ^grappelli/ ^bookmark/add/$
> >>>    3. ^grappelli/ ^bookmark/remove/$
> >>>    4. ^grappelli/ ^help/(?P\d+)/$
> >>>    5. ^grappelli/ ^help
> >>>    6. ^grappelli/ ^obj_lookup/$
> >>>    7. ^grappelli/ ^related_lookup/$
> >>>    8. ^grappelli/ ^m2m_lookup/$
> >>>    9. 

Re: Need help first user of django..

2009-04-16 Thread Aaron

I got a new question.   I notice in the admin panel  I can see
flatpages. In each page in the admin it offers content.

Do I put html code in their? Or is  it just a fast way to change text?

I was given a zip folder that is named flatpages. Inside is each html
page of what the website has or supposed to.

It has very little html in the docuement showing that it's only html
code when the url calls for this page.



On Apr 16, 11:52 am, Aaron  wrote:
> I took a look at that site. It's informative. I just don't see
> anything about flagpages.  I saw how to map a url to a view meaning
> server-sided code.
>
> currently I need 3 things to show up. 2 forms and  content from
> flagpages to display.  I also need to use if statements to display
> those 2 forms on the right pages/url etc.
>
> I already played around with the IF statements I need to use ifequal
> statement for 2 pages So something like  If title="home" or
> title="sales"  then display the request form.
>
> The problem is that I tried it and I get errors saying that I have 2
> or more arguments.
>
> Do you think I can do a  if equal statement with a elseifequal
> statement?
>
> The documentation and the site you gave I can't find the if statements
> well I can on the django site documentation but in the examples it
> shows ifequal only using one argument.
>
> I want a if statement that has one condition but can show the form
> only if one of the 2 is true. So  if the client is at the home page
> then display the form.
>
> If the client is on the sales page then display the form Otherwise
> don't display the form.
>
> I do think I have the if statements right.  I used a if statement on
> loading a image only on one page and It works.
>
> It's just the forms.
>
> Does the forms need any special way to be dealt with?
>
> I need to know how to load in the flatpages .html files  which I was
> told are extensions to the website. We have a base.html  and a
> root.html
>
> those are the guts of the page layout. We have those flagpages  that
> only has text.  We had to form html code in the base.html  file.
>
> so currently the text that is supposed to be loaded in from those
> flagpages are not loading at all. I see none.
>
> We do have  admin area where the pervious programmer I guess made a
> flagpages area. Where we add the url, title, content.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Getting the Model type of an unknown object?

2009-04-16 Thread Matthew

Is it possible to do this?

I'm using a custom MultiQuerySet snippet to merge a bunch of querysets
from different models, and then I want to iterate over the resultant
list, but I want to be able to pull out from each object in the list
its own Model type so I can perform a few comparisons/functions. Short
of writing a method into each model, I can't think of anyway it could
be done, and that won't work because I want to throw Comments into
that merged queryset too.

Help would be much appreciated,
Thanks
Matt
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: is it possible to have more than one search result in a view

2009-04-16 Thread nixon66

Oop, should be can you have more than one search results in a view for
a search form.

On Apr 16, 12:54 pm, nixon66  wrote:
> I have the view below and wonder if its possible to add other search
> results into the view or would I need to write seperate ones. Ideally,
> I'd like to have
>
> firm_search = Activity.objects.filter(firm__firms__icontains=q)
> client_search= Activity.objects.filter(clients__client__icontains=q)
>
> Would I just add these to the existing view? Confused? Any suggestion
> would be appreciated.
>
> def search_detail(request):
>     if 'q' in request.GET:
>         q = request.GET['q']
>         search_results = Activity.objects.filter
> (country__country__icontains=q)
>     else:
>         q = None
>         search_results = None
>     return render_to_response('country/search_detail.html',
>                 {'search_results': search_results, 'query': q})
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



is it possible to have more than one search result in a view

2009-04-16 Thread nixon66

I have the view below and wonder if its possible to add other search
results into the view or would I need to write seperate ones. Ideally,
I'd like to have

firm_search = Activity.objects.filter(firm__firms__icontains=q)
client_search= Activity.objects.filter(clients__client__icontains=q)

Would I just add these to the existing view? Confused? Any suggestion
would be appreciated.

def search_detail(request):
if 'q' in request.GET:
q = request.GET['q']
search_results = Activity.objects.filter
(country__country__icontains=q)
else:
q = None
search_results = None
return render_to_response('country/search_detail.html',
{'search_results': search_results, 'query': q})
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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-grappelli setup problem

2009-04-16 Thread Lars Stavholm

So that all went well. Now all I need now is the bookmarks
and the sidebar navigation box. They're not visible as of
right now and I'm not sure what to do about it. The recommended
fixtures are loaded.

Any ideas anyone?
/L


Lars Stavholm wrote:
> patrickk wrote:
>> line 53 of base.html is {% get_help request.path %}.
>>
>> I´m not exactly sure what´s happening here and I´m not able to
>> reproduce this error.
>> you might wanna try to debug ... request.user seems to work (because
>> that´s a couple of lines before), so request.path should also work.
>>
>> but I´ve never tested this locally, so I´m not sure if that can cause
>> the error (we´re having test/development-servers to do this).
>>
>> if you dig a little depper and you think you´ve found a bug - then
>> please report it using the google-code issue tracker.
> 
> No bug (as far as I can see), just newbie-ness. Turns out that
> there's some sort of conflict with other apps, namely the batchadmin
> app, possibly more (I removed them all). In addition, being a newbie,
> I neglected to tell you that I'm running the development server. I
> followed the instructions by Chris Scott, and after a bit of fiddling,
> presto, I can see the light:)
> 
> It looks brilliant!
> 
> /L
> 
>> On 15 Apr., 20:14, Lars Stavholm  wrote:
>>> patrickk wrote:
 in order to use the admin, just use /admin/ (grappelli doesn´t change
 the admin-urls).
>>> Thanks, but that got me in to some other problem:
>>>
>>> TemplateSyntaxError at /admin/
>>> Caught an exception while rendering: Failed lookup for key [request] in
>>> u"[{'root_path': u'/admin/', 'app_list': [{'app_url': 'asset/',
>>>
>>> [snip]
>>>
>>> Request Method: GET
>>> Request URL:http://localhost:8000/admin/
>>> Exception Type: TemplateSyntaxError
>>> Exception Value:
>>>
>>> Caught an exception while rendering: Failed lookup for key [request] in
>>>
>>> [snip]
>>>
>>> Exception Location:
>>> /usr/lib/python2.6/site-packages/django/template/debug.py in
>>> render_node, line 81
>>> Python Executable:  /usr/bin/python
>>> Python Version: 2.6.0
>>> Python Path:['/home/stava/proj/bfact',
>>> '/home/stava/lib/Trac-0.11.1-py2.5.egg', '/home/stava/lib',
>>> '/home/stava/proj', '/usr/lib/python26.zip', '/usr/lib/python2.6',
>>> '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk',
>>> '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload',
>>> '/usr/lib/python2.6/site-packages',
>>> '/usr/lib/python2.6/site-packages/Numeric',
>>> '/usr/lib/python2.6/site-packages/PIL',
>>> '/usr/local/lib/python2.6/site-packages',
>>> '/usr/lib/python2.6/site-packages/gtk-2.0',
>>> '/usr/lib/python2.6/site-packages/wx-2.8-gtk2-unicode']
>>> Server time:Wed, 15 Apr 2009 20:07:53 +0200
>>> Template error
>>>
>>> In template /home/stava/proj/bfact/templates/admin/base.html, error at
>>> line 53
>>>
>>> My ursl.py looks like this:
>>>
>>> from django.conf.urls.defaults import *
>>> from django.contrib import admin
>>> admin.autodiscover()
>>>
>>> urlpatterns = patterns('',
>>>   (r'^grappelli/', include('grappelli.urls')),
>>>   (r'^admin/(.*)', admin.site.root),
>>> )
>>>
>>> /L
>>>
 On 15 Apr., 10:06, Lars Stavholm  wrote:
> patrickk wrote:
>> which URL causes that error?
> http://localhost:8000/grappelli/admin/
>> please note that in order to use grappelli you have to setup the admin-
>> site before, 
>> seehttp://docs.djangoproject.com/en/dev/ref/contrib/admin/#ref-contrib-a
>> maybe this should be mentioned in the docs, but I guess it´s pretty
>> obvious.
> I guess it is, admin up and running nicely without grappelli.
> /L
>> On Apr 14, 8:36 pm, Lars Stavholm  wrote:
>>> Hi All,
>>> I'm trying to get django-grappelli running, but after following
>>> the installation instructions, I end up with a 404 and the following:
>>> Using the URLconf defined in bfact.urls, Django tried these URL
>>> patterns, in this order:
>>>1. ^admin/(.*)
>>>2. ^grappelli/ ^bookmark/add/$
>>>3. ^grappelli/ ^bookmark/remove/$
>>>4. ^grappelli/ ^help/(?P\d+)/$
>>>5. ^grappelli/ ^help
>>>6. ^grappelli/ ^obj_lookup/$
>>>7. ^grappelli/ ^related_lookup/$
>>>8. ^grappelli/ ^m2m_lookup/$
>>>9. ^accounts/login/$
>>>   10. ^accounts/logout/$
>>> Notice the space after "grappelli/".
>>> Anyone else out there using django-grappelli?
>>> Any ideas as to what causes this?
>>> I'm using django-1.0.2 on Linux with latest grappelli from trunk.
>>> Any ideas appreciated
>>> /Lars
>>>
> 
> 
> > 
> 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 

TemplateSyntaxError: Settings issue?

2009-04-16 Thread Aneesh K

I have two environments for my new Django site: dev and production.
Everything works great on my local dev machine with "manage.py
runserver".  When I try to view any page on the production site, I get
a "TemplateSyntaxError Caught an exception while rendering: No module
named tasks".  "tasks" is one of my models, and running ">>> import
tasks" from the command line in production works without any errors.

The only thing that's different on my production box is the
settings.py file (and the production site runs Apache with FastCGI,
instead of the Django development webserver).  That leads me to
believe it could be a settings issue.  I'm using the trunk version of
Django from svn, and my production server has Python 2.4.4.

Why is the TemplateSyntaxError raised, and why don't I see this
problem on my development server?

Thanks!
Aneesh
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: newbie: syncdb doesnt update schema after model change?

2009-04-16 Thread Brian Neal

On Apr 16, 11:00 am, gry  wrote:
> [django: 1.1 beta 1 SVN-10407, python 2.5.2, ubuntu]
> My first django toy app.  I've been working through the 
> tutorialhttp://docs.djangoproject.com/en/dev/intro/tutorial02/.
> I've already done a few cycles of  (change-model, ./manage.py syncdb)
> with success.
> I just added email and birthday fields to my Person model:
>
[snip]
>
> Why is my change not making it into the DB?  I even did "./manage.py
> flush" and it still fails on the email field.
>
> -- George

Because syncdb doesn't do that. See the note in the documentation as
to why:

http://docs.djangoproject.com/en/dev/ref/django-admin/#syncdb

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: newbie: syncdb doesnt update schema after model change?

2009-04-16 Thread Aneesh

This is by design.  syncdb only checks to see if it needs to create
any new DB tables for any models; it does NOT alter existing model
tables.  See http://docs.djangoproject.com/en/dev/ref/django-admin/#syncdb
for more info.

If you don't have any valuable data in the table (ie, you're just
developing or playing around), the best thing to do is drop the whole
table from the DB entirely, and then syncdb will recreate it from
scratch with the new column included.  You can also just issue an
ALTER TABLE to add the column manually with the proper name, and
Django will recognize it.

Good luck,
Aneesh

On Apr 16, 9:00 am, gry  wrote:
> [django: 1.1 beta 1 SVN-10407, python 2.5.2, ubuntu]
> My first django toy app.  I've been working through the 
> tutorialhttp://docs.djangoproject.com/en/dev/intro/tutorial02/.
> I've already done a few cycles of  (change-model, ./manage.py syncdb)
> with success.
> I just added email and birthday fields to my Person model:
>
> class Person(models.Model):
>     name = models.CharField(max_length=200)
>     def formalname(self):
>         return 'Mr(Ms) ' + self.name
>     phone = models.CharField(max_length=13)
>     address = models.ForeignKey(Address)
>     email = models.EmailField()
>     birthday = models.DateField()
>     def __unicode__(self):
>         return self.name
>
> I killed the server process(maybe not necessary).  I did ./manage.py
> syncdb .
> Now "./manage.py sql phones" reports:
> CREATE TABLE "phones_person" (
>     "id" integer NOT NULL PRIMARY KEY,
>     "name" varchar(200) NOT NULL,
>     "phone" varchar(13) NOT NULL,
>     "address_id" integer NOT NULL REFERENCES "phones_address" ("id"),
>     "email" varchar(75) NOT NULL,
>     "birthday" date NOT NULL
> )
>  but dbshell  shows:
> CREATE TABLE "phones_person" (
>     "id" integer NOT NULL PRIMARY KEY,
>     "name" varchar(200) NOT NULL,
>     "phone" varchar(13) NOT NULL,
>     "address_id" integer NOT NULL REFERENCES "phones_address" ("id")
> );
>
> I restart the server andhttp://127.0.0.1:8000/admin/phones/person/
> gets me "Exception Value:
> no such column: phones_person.email".
>
> Why is my change not making it into the DB?  I even did "./manage.py
> flush" and it still fails on the email field.
>
> -- George

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



Re: Need help first user of django..

2009-04-16 Thread Aaron

I took a look at that site. It's informative. I just don't see
anything about flagpages.  I saw how to map a url to a view meaning
server-sided code.

currently I need 3 things to show up. 2 forms and  content from
flagpages to display.  I also need to use if statements to display
those 2 forms on the right pages/url etc.

I already played around with the IF statements I need to use ifequal
statement for 2 pages So something like  If title="home" or
title="sales"  then display the request form.

The problem is that I tried it and I get errors saying that I have 2
or more arguments.

Do you think I can do a  if equal statement with a elseifequal
statement?

The documentation and the site you gave I can't find the if statements
well I can on the django site documentation but in the examples it
shows ifequal only using one argument.

I want a if statement that has one condition but can show the form
only if one of the 2 is true. So  if the client is at the home page
then display the form.

If the client is on the sales page then display the form Otherwise
don't display the form.

I do think I have the if statements right.  I used a if statement on
loading a image only on one page and It works.

It's just the forms.

Does the forms need any special way to be dealt with?


I need to know how to load in the flatpages .html files  which I was
told are extensions to the website. We have a base.html  and a
root.html

those are the guts of the page layout. We have those flagpages  that
only has text.  We had to form html code in the base.html  file.

so currently the text that is supposed to be loaded in from those
flagpages are not loading at all. I see none.

We do have  admin area where the pervious programmer I guess made a
flagpages area. Where we add the url, title, content.


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



newbie: syncdb doesnt update schema after model change?

2009-04-16 Thread gry

[django: 1.1 beta 1 SVN-10407, python 2.5.2, ubuntu]
My first django toy app.  I've been working through the tutorial
http://docs.djangoproject.com/en/dev/intro/tutorial02/.
I've already done a few cycles of  (change-model, ./manage.py syncdb)
with success.
I just added email and birthday fields to my Person model:

class Person(models.Model):
name = models.CharField(max_length=200)
def formalname(self):
return 'Mr(Ms) ' + self.name
phone = models.CharField(max_length=13)
address = models.ForeignKey(Address)
email = models.EmailField()
birthday = models.DateField()
def __unicode__(self):
return self.name

I killed the server process(maybe not necessary).  I did ./manage.py
syncdb .
Now "./manage.py sql phones" reports:
CREATE TABLE "phones_person" (
"id" integer NOT NULL PRIMARY KEY,
"name" varchar(200) NOT NULL,
"phone" varchar(13) NOT NULL,
"address_id" integer NOT NULL REFERENCES "phones_address" ("id"),
"email" varchar(75) NOT NULL,
"birthday" date NOT NULL
)
 but dbshell  shows:
CREATE TABLE "phones_person" (
"id" integer NOT NULL PRIMARY KEY,
"name" varchar(200) NOT NULL,
"phone" varchar(13) NOT NULL,
"address_id" integer NOT NULL REFERENCES "phones_address" ("id")
);

I restart the server and http://127.0.0.1:8000/admin/phones/person/
gets me "Exception Value:
no such column: phones_person.email".

Why is my change not making it into the DB?  I even did "./manage.py
flush" and it still fails on the email field.

-- George

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



Authenication for django.views.generic Views

2009-04-16 Thread Col Wilson

I'm using generic views to render my pages
(django.views.generic.date_based, django.views.generic.list_detail
etc) and they're very handy.

However, the app I'm trying to build would like a security and on
reading the "User Authentication in Django" document, it just talks
about adding authentication to the views.

Generic views of course are buried in the django installation
directories and you don't want to go messing about in there, so it's
not obvious to me how I can do that.

Can someone give me a hand please?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 vs. save()

2009-04-16 Thread koranthala



On Apr 16, 6:41 pm, Alex Gaynor  wrote:
> On Thu, Apr 16, 2009 at 6:39 AM, koranthala  wrote:
>
> > Hi,
> >    I was comparing between signal and save() and came across this
> > following mail chain -
>
> >http://groups.google.com/group/django-users/browse_thread/thread/d0ff...
>
> >    In this it is mentioned that -
> > ---
> > If you want to implement some
> > functionality that operates across multiple types of models, you need
> > to
> > use the signal infrastructure, since the same signal is raised no
> > matter
> > what the type of model (you can differentiate the model type in the
> > signal handler, though).
> > 
>
> >   I was unable to understand why we should go for signals in case we
> > have to work across models?
> >   Say, for example - I have ModelA and ModelB. Everytime, I save an
> > element in ModelA, I need to update 15 fields in ModelB.
> >   In this case, shouldn't I do everything in ModelA.save itself?
> > ModelA.save():
> >   super.save()
> >   Update 15 fields in ModelB
>
> >   I do not understand why we should go for signals in this case too?
> >   Sorry if I am dense :-)
>
> One of the simplest reasons to use signals in that situation is because you
> can't change the code in that application.  Say you want to trigger
> something on the User object being saved, you don't want to monkey patch
> django.contrib.auth so use just use the signal for code clarity.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero

Thank you Alex.
But considering the scenario mentioned above - wherein I need to make
modifications to a separate table - both of which I have full access
to - should I go ahead with signals or should I go with save?
Malcolms mail  - the link mentioned earlier - seems to suggest that I
should be using signals - but I am unable to understand the
justification for it.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Need help first user of django..

2009-04-16 Thread Aaron

well, I am currently employed in a company. I need to finish adding my
web design for their site.

when I took the job I assumed he used apache or some hosting service
provider.

I later on after designing the stuff and getting hired it. I asked him
what he uses for a server he said google. I never knew google had such
services.

So I started to learn google apps engine. Now I need to finish this as
soon as possible. He wants me to get the site up today.

I just need to have one form appear on 2 pages and another form to
appear on one page.

I need to just use the if statements.

Thanks for the other resource I will take a look at it.

On Apr 16, 7:31 am, commander_coder 
wrote:
> Those are both good, and the book _Practical Django Projects_ by
> Bennett is another good choice.
>
> Jim
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to use InlineModelAdmin for ManyToMany without an Intermediary model?

2009-04-16 Thread Christopher Dodd

I can almost see how forms.models.inlineformset_factory could be
tweaked to follow ManyToMany relationships to create inline formsets,
perhaps with a parameter telling it which ManyToMany field to use.

Am I barking up the wrong tree? Are these questions better off in the
developer's group?

On Apr 10, 2:06 pm, Christopher Dodd  wrote:
> I realized my question was just a bit off. What I really want is to
> create a TabularInline to edit the members relationship on the Group
> interface.  This is what you get when you use an intermediary model,
> as well as the ability to edit the other members of that model.
>
> I could, of course, create a bogus intermediary model and get what I
> want, but it would be really unfortunate if I had to change my (valid)
> Model to clean up my Admin interface.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Clean URL Design: List Views and Details Views

2009-04-16 Thread Aidas Bendoraitis [aka Archatas]

> /products/?action=add
> /products/?action=print
> /products/?action=rss
> /products/myproduct/?action=rss
> /products/myproduct/?action=print
>
Those are examples of ugly (not clean anymore) urls.

In such a case, you would need to have a wrapper view in Django, which
would return the results of specific views depending on the passed
"action" parameter. That's not a nice way as you can't use the default
urls.py for defining the views like "add_product", "export_pdf", etc.
there in the default Django way.

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

2009-04-16 Thread Dorian

Also, make sure that



is included in your template, otherwise it will not work.
{{form.media}} does not include it by default.

Dorian

On Feb 17, 4:31 pm, Alex Gaynor  wrote:
> On Tue, Feb 17, 2009 at 7:27 AM,  wrote:
>
> > I'm trying to reuse FilteredSelectMultiple from admin.widgets in my
> > forms (two select-widgets to choose from one to other like 'user
> > permisions' in admin interface), but didn't find how. The closest I've
> > done was with this code:
>
> > class PersonaForm(ModelForm):
> >    def __init__(self, *args, **kwargs):
> >        super(PersonaForm, self).__init__( *args, **kwargs)
> >        self.fields['fecha_actualizacion'].widget =
> > widgets.AdminDateWidget()
> >        self.fields['titulos'].widget = widgets.FilteredSelectMultiple
> > ("titulos",False)
> >        self.fields['titulos'].queryset = Titulo.objects.all()
> >        ...
>
> > AdminDateWidget works well, but FilteredSelectMultiple only shows a
> > multiple select widget and the 'SelectFileter is not defined'
> > javascript error.
>
> > Any idea?
>
> Are you including the form's media when you render the form?
>
> You can do this by putting {{ form.media }} somewhere in the HEAD of the
> document.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero

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



Re: Changing raw_id_field from 'id'

2009-04-16 Thread Christopher Dodd

I do something similar in 
http://groups.google.com/group/django-users/browse_thread/thread/14e580f3dd32e87d#

Do you want a comma delimited list of barcodes? Assuming the barcode
value is another field, you may be able to reuse some of my code but
override the RawIdField instead of Field.


On Apr 15, 9:19 am, Alfonso  wrote:
> Is there an easy way to change the raw_id_field in a foreign key
> relationship?  I'd like to change an inline formset to display not the
> item pk id alongside the raw_id_field 'magnifying glass' but a barcode
> field instead.
>
> 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: Emacs/yasnippet bundle for Django 1.0

2009-04-16 Thread Jon Atkinson

Hello,

> http://github.com/jonatkinson/yasnippet-djangotree/master

Somehow I managed to make a typo :-) The correct link to the github page is:

http://github.com/jonatkinson/yasnippet-django/tree/master

Cheers,

--Jon

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



Re: Admin widget for filter_vertical and filter_horizontal slow

2009-04-16 Thread Christopher Dodd

Yeah, this is a known issue. http://code.djangoproject.com/ticket/3202
I ran into it myself and have been trying all kinds of things to work
around it.
Once you get enough rows in a table the default controls are no longer
feasible.

Have you looked into the raw_id_fields option? It wasn't an option for
me but it might help you.
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-options


On Apr 16, 3:40 am, maco  wrote:
> My model has two Foreign Keys. Each FK has 4000 entries or more. In
> admin.py I use filter_horizontal for those FK.
>
> I noticed that JS widget is slow both on first render of admin page
> (add item) and on every selection of an FK item inside the widget. I
> takes 5 seconds AFTER admin page already loads for JS to render
> widget. In this time browser is unresponsive. Selection of an item
> takes even longer.
>
> I've tested this on various browsers and systems.
>
> I'm am fairly confident that the number of FK items is a major factor
> in slowing down the render of the widget because I tried deleting FK
> items and browser was starting to show improvements in speed. When the
> number of FK items dropped under 1000 admin site become much faster
> (and actually usable).
>
> I've also completely removed filter_horizontal just to be sure nothing
> is wrong with admin on a general and all seemed good and super fast.
>
> So, I recon, some revision of JS for filter in admin is needed or sth.
>
> Thanks for any thoughts on that.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



problem with iexact / icontains matches and TR locale

2009-04-16 Thread omat

Hi all,

In Turkish, the capital for 'i' (ascii char) is 'İ' (a non-ascii char)
and capital for 'ı' (non-ascii) is 'I' (ascii).

I want to match slugified version of a username, which comes from the
requested URL to a user.

If the username contains 'I', which is a legal ascii character for a
username, iexact does not match it with 'i', which is the slugified
version of the 'I', but matches with 'ı' (the non-ascii char), when
the locale is TR.

i.e. I need something like:

User.objects.get(username__slug=username)

but db backends does not support this.

Any suggestions?


Thanks,
oMat

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



Emacs/yasnippet bundle for Django 1.0

2009-04-16 Thread Jon Atkinson

Hello,

I've been wanting a better set of Django snippets to use with
yasnippet/Emacs for quite a while. I was at a bit of a loose end yesterday,
so I decided to do something about this :-) I've based this set of
snippets on Brian Kerr's excellent set of Django 1.0 snippets for
Textmate[1]. They've available on github at:

http://github.com/jonatkinson/yasnippet-djangotree/master

... and I've made the first release, a tarball is available here:

http://cloud.github.com/downloads/jonatkinson/yasnippet-django/yasnippet-django-1.0.zip

I hope someone finds this useful.

Cheers,

--Jon

[1] http://bitbucket.org/bkerr/django-textmate-bundles/wiki/Home

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



Admin - Hide fields on add, show on change?

2009-04-16 Thread Alfonso

Is it possible to hide some irrelevant fields when a user adds a
record via django admin, i.e. they are only relevant on the change
view?

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



Re: Django admin question

2009-04-16 Thread Daniel Roseman

On Apr 16, 2:47 pm, zayatzz  wrote:
> So this means, that i can return whichever other value with this
> unicode method... even value from other models?
>
> Alan.

If you want, and you've got a way of getting there from the current
model - eg via a foreign key. Bear in mind though that this value is
used in all sorts of places, so you should use something that makes
sense and identifies your instance.

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



Re: Clean URL Design: List Views and Details Views

2009-04-16 Thread Marcin Mierzejewski

Hi Archatas,

On Apr 16, 4:07 pm, "Aidas Bendoraitis [aka Archatas]"
 wrote:
> > 8. Using parameters
> >      /products/?sort=popularity
> >      /products/?filter=featured
> >      /products/?page=5
> >      /products/add/
> >      /products/myproduct/
> >      /products/myanotherproduct/
> In this case, you still need to have a black list of words like "add",
> "export", "print", "rss", "send-to-friend" or any other. So this is
> not the best way to go.

/products/?action=add
/products/?action=print
/products/?action=rss
/products/myproduct/?action=rss
/products/myproduct/?action=print

Best regards,
Macin

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Clean URL Design: List Views and Details Views

2009-04-16 Thread Aidas Bendoraitis [aka Archatas]

> 8. Using parameters
>      /products/?sort=popularity
>      /products/?filter=featured
>      /products/?page=5
>      /products/add/
>      /products/myproduct/
>      /products/myanotherproduct/

In this case, you still need to have a black list of words like "add",
"export", "print", "rss", "send-to-friend" or any other. So this is
not the best way to go.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: help! i'm new in django

2009-04-16 Thread 83nini

thanks a million for the tip, the first command worked :)

On 16 Apr, 15:52, Alfonso  wrote:
> Hi 83nini,
>
> It doesn't matter too much where you place the actual project folder
> for the django code, just ensure all your paths are setup correctly.
> For example I just have mine sitting in ~/Users/me/django/
> django_projects/ but could be anywhere.
>
> Good luck!
>
> A
>
> On 16 Apr, 14:41, 83nini <83n...@gmail.com> wrote:
>
>
>
> > Hi all,
>
> > I'm new to django and i'm trying to go through the first tutorial to
> > create a website. I am using the tutorial on the official website,
> > problem is i have no idea where i should put the folder where i am to
> > keep the project that i'm making!
>
> > thanks guys for help.
> > cheers- Dölj citerad text -
>
> - Visa citerad text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Fieldlookup: NOT

2009-04-16 Thread Christian Joergensen

Thomas Guettler wrote:
> Hi,
> 
> 
> For forms which display a list of results I use:
> form=QueryForm(request.GET)
> 
> queryset=MyModel.objects.filter(**form.cleaned_data)
> 
> But, now I need to use exclude() instead of filter().
 >
> 
> I looked at the queryset API, but it seems that there is no
> alternative to qs.exclude().

What's wrong with exclude() as it is now?

-- 
Christian Joergensen
http://www.technobabble.dk

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Clean URL Design: List Views and Details Views

2009-04-16 Thread Aidas Bendoraitis [aka Archatas]

Here are the advantages and disadvantages I see myself:

> 1. One of the approaches is to use special symbols for the controlling
> words, which are not allowed in slugs, like in last.fm or wikipedia
> does.
(+) url rules for the app might be defined in a separate file
(+) shortness
(-) unusual/unnatural

> 2. Another way is to use a special symbol like a dot together with the
> primary key as a part of the url for product-details page
(+) url rules for the app might be defined in a separate file
(-) IDs shouldn't be shown to people (technologies should serve real
live but not vice versa).

> 3. Using a prefix for product details
(+) url rules for the app might be defined in a separate file
(+) shortness
(-) unnecessary not humanized wording

> 4. Using a separate namespace for product details
(+) url rules for the app might be defined in a separate file
(+) clean naturally-looking separation
(-) URL is long
(-) where would /products/product/ lead?

> 5. Using upper case for controlling words
(+) url rules for the app might be defined in a separate file
(-) weird and shouting too much

> 6. Using plural for managing lists and using singular for managing
> details
(+) url rules for the app might be defined in a separate file
(+) naturally conceived
(+) shortness
(-) where would /product/ lead?
(-) requires two files for url rules if the urls are defined in each
app
mentioned in: http://www.xml.com/pub/a/2005/04/06/restful.html

> 7. Using the controlling words before the type of list:
(-) some urls look realy weird
(-) can't be used in the app level

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Running two django version from same python.

2009-04-16 Thread Ayaz Ahmed Khan

On 16-Apr-09, at 3:27 PM, Harish wrote:
> Hi Folks,
>
> Is it possble to install two seperate django versions (0.97  and
> 1.0.x) in one python site-package file.  If yes how  and if no
> why?
>

Describing how I have done it for my scenario, I wrote about it a
while back.



-- 
Ayaz Ahmed Khan

An evil mind is a great comfort.


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



Fieldlookup: NOT

2009-04-16 Thread Thomas Guettler

Hi,


For forms which display a list of results I use:
form=QueryForm(request.GET)

queryset=MyModel.objects.filter(**form.cleaned_data)

But, now I need to use exclude() instead of filter().

I looked at the queryset API, but it seems that there is no
alternative to qs.exclude().

Wouldn't it be nice to have a "not" field lookup? Example:

MyModel.objects.filter(field__not=...)
MyModel.objects.filter(field__not__in=...)

  Thomas


-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

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



Re: help! i'm new in django

2009-04-16 Thread Alfonso

Hi 83nini,

It doesn't matter too much where you place the actual project folder
for the django code, just ensure all your paths are setup correctly.
For example I just have mine sitting in ~/Users/me/django/
django_projects/ but could be anywhere.

Good luck!

A

On 16 Apr, 14:41, 83nini <83n...@gmail.com> wrote:
> Hi all,
>
> I'm new to django and i'm trying to go through the first tutorial to
> create a website. I am using the tutorial on the official website,
> problem is i have no idea where i should put the folder where i am to
> keep the project that i'm making!
>
> thanks guys for help.
> cheers
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Clean URL Design: List Views and Details Views

2009-04-16 Thread Andrew Ingram

Ok, best practices time.

Segments:
Only introduces a new segment if it indicates a page that is a logical
descendant of the previous, traversing a category hierarchy would be
the typical example

/books/thrillers/

Query Parameters:
Used to define the viewing parameters of the current level in the
hierarchy, you'd use this for sorting, pagination and arguably
filters.

/books/thrillers?page=2=a-z=discontinued

It might not look pretty, but this is the way URL syntax works, now
you could arguably have 'discontinued' as another url segment but once
you start down that line of thought you end up with some fairly deep
url structures that could logically be in any order (creating a huge
number of possible combinations)

I typically overload a single level in the hierarchy with multiple
functions by using different slug formats to differentiate between
different view functions. You end up with some limitations but you
keep fairly short and logical URLs.

Regards,
Andrew Ingram


2009/4/16 Marcin Mierzejewski :
>
> Hi Aidas,
>
>> 7. Using the controlling words before the type of list:
>>     /by-popularity/products/
>>     /featured/products/
>>     /page5/products/
>>     /add/products/
>>     /products/myproduct/
>>     /products/myanotherproduct/
>
> 8. Using parameters
>     /products/?sort=popularity
>     /products/?filter=featured
>     /products/?page=5
>     /products/add/
>     /products/myproduct/
>     /products/myanotherproduct/
>
> Best regards,
> Marcin
> >
>

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

2009-04-16 Thread zayatzz

So this means, that i can return whichever other value with this
unicode method... even value from other models?

Alan.

On Apr 16, 4:22 pm, Daniel Roseman 
wrote:
> On Apr 16, 2:18 pm, zayatzz  wrote:
>
> >http://docs.djangoproject.com/en/dev/intro/tutorial02/#adding-related...
>
> > On that page is small picture of adding choice to a poll. There is
> > selectbox and textfields.
>
> > My question is - how to choose which field of poll model will be shown
> > in this selectbox?
>
> > Alan.
>
> It's not a field, it's the result of calling unicode() on the poll
> instance. If you want to change it, change the __unicode__ method.
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



help! i'm new in django

2009-04-16 Thread 83nini

Hi all,

I'm new to django and i'm trying to go through the first tutorial to
create a website. I am using the tutorial on the official website,
problem is i have no idea where i should put the folder where i am to
keep the project that i'm making!

thanks guys for help.
cheers

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



Re: possible filter bug with manytomany fields and slice?

2009-04-16 Thread Alex Gaynor
On Thu, Apr 16, 2009 at 3:15 AM, Malcolm Tredinnick <
malc...@pointy-stick.com> wrote:

>
> On Thu, 2009-04-16 at 00:01 -0700, Margie wrote:
> > Ah - ok, cool, good to know.  I am on 1.1 pre-alpha SVN-9814.
>
> Hmm .. then maybe there's an actual problem there. The ability to use
> nested querysets was added in r9701 (with a few bug fixes in subsequent
> patches). I only said 1.1-beta as a rough reference point, as opposed to
> 1.0.X.
>
> Might be worth having a look at the SQL that is being generated to see
> what's going on there. Maybe I've screwed up limits or something (I
> can't really stop to test this myself right now, as I'm still at work).
>
> Have a look at the output of
>
> PdTask.objects.filter(tiles__in=pdTask.objects.all()[0]).query.as_sql()
>
> and see if it looks broken in any obvious fashion. If so, feel free to
> open a ticket (assign it to "mtredinnick" so I'll remember to look at it
> on the weekend). You shoudl still try a slightly later version
> (something around beta-1) just to check it wasn't fixed by some of the
> later tweaks in that area, but I'm now a bit suspicious that something
> is going wrong.
>
> Regards,
> Malcolm
>
>
>
> >
>
Are you using MySQL?  I know it doesn't support limits int nested querysets,
perhaps it's just not returning anything instead of throwing an exception.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



PDFs with Pisa

2009-04-16 Thread Alfonso

Hi,

I'm trying out Pisa to generate PDFs and am getting a weird error when
rendering the pdf:

Caught an exception while rendering: 'Context' object has no attribute
'push'

Here's the code I'm using (largely unchanged from pisa example)

http://dpaste.com/34323/

It seems to hit this error whenever it encounters a '{% block
something %}  If I remove the block tags and simply have plain html
it's not a problem.

Also having difficulty displaying images unless I specify an absolute
path.

Would love to make this work, any help 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: signals vs. save()

2009-04-16 Thread Alex Gaynor
On Thu, Apr 16, 2009 at 6:39 AM, koranthala  wrote:

>
> Hi,
>I was comparing between signal and save() and came across this
> following mail chain -
>
> http://groups.google.com/group/django-users/browse_thread/thread/d0ff6dd3432d25fa/99a92f9f4b343b1e
>
>In this it is mentioned that -
> ---
> If you want to implement some
> functionality that operates across multiple types of models, you need
> to
> use the signal infrastructure, since the same signal is raised no
> matter
> what the type of model (you can differentiate the model type in the
> signal handler, though).
> 
>
>   I was unable to understand why we should go for signals in case we
> have to work across models?
>   Say, for example - I have ModelA and ModelB. Everytime, I save an
> element in ModelA, I need to update 15 fields in ModelB.
>   In this case, shouldn't I do everything in ModelA.save itself?
> ModelA.save():
>   super.save()
>   Update 15 fields in ModelB
>
>   I do not understand why we should go for signals in this case too?
>   Sorry if I am dense :-)
>
>
> >
>
One of the simplest reasons to use signals in that situation is because you
can't change the code in that application.  Say you want to trigger
something on the User object being saved, you don't want to monkey patch
django.contrib.auth so use just use the signal for code clarity.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: Clean URL Design: List Views and Details Views

2009-04-16 Thread Marcin Mierzejewski

Hi Aidas,

> 7. Using the controlling words before the type of list:
>     /by-popularity/products/
>     /featured/products/
>     /page5/products/
>     /add/products/
>     /products/myproduct/
>     /products/myanotherproduct/

8. Using parameters
 /products/?sort=popularity
 /products/?filter=featured
 /products/?page=5
 /products/add/
 /products/myproduct/
 /products/myanotherproduct/

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



Clean URL Design: List Views and Details Views

2009-04-16 Thread Aidas Bendoraitis

Hello,

Recently, we are solving a conceptual question of designing clean urls
for list and detail views of objects with slugs.

Let's say we have products with their slugs. In the naive way, the
list view could be accessed by
/products/
and the detail views could be accessed by
/products/myproduct/
where "myproduct" is a slug of a product.

Problems appear when you want to filter or sort list of products by
different parameters, have a possibility to add another product, or
have pagination. In those cases
/products/by-popularity/
/products/featured/
/products/page5/
/products/add/
etc.
would clash with
/products//
and there should be either a black list of words for 
like del.ici.ous and flickr.com does, or there should be another way
to differentiate between slugs and controlling words. In my opinion,
the black-list approach is very limited and doesn't make your website
extensible. So let's see what other options are.

1. One of the approaches is to use special symbols for the controlling
words, which are not allowed in slugs, like in last.fm or wikipedia
does. So the list urls might look like this:
/products/sort-by:popularity/
/products/filter-by:featured/
/products/page:5/
/products/action:add/
/products/myproduct/
/products/myanotherproduct/
or
/products/+by-popularity/
/products/+featured/
/products/+page5/
/products/+add/
/products/myproduct/
/products/myanotherproduct/

2. Another way is to use a special symbol like a dot together with the
primary key as a part of the url for product-details page, i.e.:
/products/by-popularity/
/products/featured/
/products/page5/
/products/add/
/products/123.myproduct/
/products/456.myanotherproduct/
or
/products/by-popularity/
/products/featured/
/products/page5/
/products/add/
/products/myproduct.123/
/products/myanotherproduct.456/

3. Using a prefix for product details:
/products/by-popularity/
/products/featured/
/products/page5/
/products/add/
/products/prod_myproduct/
/products/prod_myanotherproduct/
/products/prod_featured/

4. Using a separate namespace for product details:
/products/by-popularity/
/products/featured/
/products/page5/
/products/add/
/products/product/myproduct/
/products/product/myanotherproduct/
or
/products/by-popularity/
/products/featured/
/products/page5/
/products/add/
/products/details/myproduct/
/products/details/myanotherproduct/
or
/products/by-popularity/
/products/featured/
/products/page5/
/products/add/
/products/unit/myproduct/
/products/unit/myanotherproduct/

5. Using upper case for controlling words:
/products/BY-POPULARITY/
/products/FEATURED/
/products/PAGE5/
/products/ADD/
/products/myproduct/
/products/myanotherproduct/

6. Using plural for managing lists and using singular for managing
details:
/products/by-popularity/
/products/featured/
/products/page5/
/products/add/
/product/myproduct/
/product/myanotherproduct/

7. Using the controlling words before the type of list:
/by-popularity/products/
/featured/products/
/page5/products/
/add/products/
/products/myproduct/
/products/myanotherproduct/

What approaches do/would you use and why? What would be best for a
future-proof website? Are there any valuable resources about URL
design?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Unittests

2009-04-16 Thread Daniel Joshua Worth
the method past_performance() simply checks if the date of the performance
is before today's date.

>>> Can you send your test.py file to the list?

import unittest
from booking.models import *

class PerformanceTest(unittest.TestCase):
def setUp(self):
self.performance = Performance.objects.create(title='test',
venue='test venue',
date='2009-01-01', street1='1234 test way', street2='unit #1',
city='testville',
state='CO', zip='0', price='$10', link='
http://example.com',
contact='exam...@example.com', phone='111-111-',
note='testing one two three',public=1)

def pastTest(self):
self.assertEquals(self.performance.past_performance(), False)

>>> You should rather not name it "test.py" because there is a standard
>>>Python module with that name.

The file is named tests.py, plural(I miss typed). I am just trying to follow
the docs on unittests.

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

2009-04-16 Thread Daniel Roseman

On Apr 16, 2:18 pm, zayatzz  wrote:
> http://docs.djangoproject.com/en/dev/intro/tutorial02/#adding-related...
>
> On that page is small picture of adding choice to a poll. There is
> selectbox and textfields.
>
> My question is - how to choose which field of poll model will be shown
> in this selectbox?
>
> Alan.

It's not a field, it's the result of calling unicode() on the poll
instance. If you want to change it, change the __unicode__ method.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django admin question

2009-04-16 Thread zayatzz

http://docs.djangoproject.com/en/dev/intro/tutorial02/#adding-related-objects

On that page is small picture of adding choice to a poll. There is
selectbox and textfields.

My question is - how to choose which field of poll model will be shown
in this selectbox?

Alan.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Running two django version from same python.

2009-04-16 Thread Marcin Mierzejewski

Hi Harish,

On Apr 16, 12:27 pm, Harish  wrote:
> Is it possble to install two seperate django versions (0.97  and
> 1.0.x) in one python site-package file.
> If yes how  and if no why?

You can put django into your project directory, e.g.

/myproject
  /__init__.py
  /manage.py
  /urls.py
  /settings.py
  /django   <

If you run manage.py runserver from /myproject directory, then django
from /myproject/django directory will be used.

If you will have any problem, please ask.

Best regards,
Marcin


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Newcastle, UK Django positions (was "Some django-based jobs available")

2009-04-16 Thread tonemcd

Thanks for the rewrite of the subject line Tim, I should have put more
location information into the post. I've also added it to django-gigs
to get a wider audience.

And thanks for being understanding regarding those 'abominably long
target URLs' - it's an outsourced operation over which we have no
control. They've obviously not heard of SEO!

Regarding the jobs: I don't think we can go for telecommuting at the
moment, but it's something we're willing to consider in the future.

thanks again for your help,
Tone


On Apr 16, 1:55 pm, Tim Chase  wrote:
> tonemcd wrote:
> > I hope I'm not breaching etiquette here.
>
> Not particularly...however you may also want to post 
> onhttp://djangogigs.comto reach the broadest audience.
>
> One other tip -- though your email CC's Newcastle, UK addresses
> and the below redirectors point to the Newcastle pages, it's
> helpful to include location information right up front (as well
> as any telecommuting option if available) in the body/subject of
> the email.  This helps folks filter out chaff or spot positions
> of interest.  I've changed the subject line to reflect it, but
> for others on the list that may be considering posting positions,
> it helps.
>
> > The URLs are;
>
> > Infrastructure Development Officer:http://is.gd/sJW9
> > and
> > Web Development Officer:http://is.gd/sJWu
>
> In some circles (more so on mailing lists & blogs, less so on
> twitter), this is more a breech of etiquette -- using shortened
> URLs that point randomly into the internet.  However, in the case
> of those abominably long target URLs, I think shortening is
> acceptable in this case :)
>
> -tim
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Serving Static Files - Pics work, but CSS doesn't

2009-04-16 Thread Les

You might post your settings.py as a help to other newbies

On Apr 15, 7:21 pm, Anthony  wrote:
> Thanks.
>
> I was just trying to get the stylesheet to show up.  I have a full CSS
> template I got from somewhere else that I'll be using now that it's
> being successfully pulled in.
>
> On Apr 15, 4:06 pm, Wayne Koorts  wrote:
>
> > >> > The picture shows up, but the text doesn't turn green like I think it
> > >> > should.
>
> > See if it helps changing your code and CSS as follows (basically
> > making it XHTML compliant - not sure what you're aiming at
> > specifically with what you've done):
>
> > 
> >     
> >     Test paragraph.
> > 
>
> > p.baseline {
> >     color: green;
> >     border: solid red;
>
> > }
>
> > Also just another tip: it is a good idea to not use named colour
> > values ("green" / "red" etc.) as each CSS rendering engine might
> > interpret it differently.  For green you could use: "color: rgb(0,
> > 255, 0);" and for red you could use: "color: rgb(255, 0, 0);".
>
> > Regards,
> > Wayne
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Problem to install psycopg

2009-04-16 Thread Sergio González - Paraguay

Hello everybody

I'm trying to install psycopg2 in my fedora.

this is the error in the command line:

[...@machine psycopg2-2.0.9]$ python setup.py build
running build
running build_py
running build_ext
error: No such file or directory
[...@machine psycopg2-2.0.9]$

Can someone help me please

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Newcastle, UK Django positions (was "Some django-based jobs available")

2009-04-16 Thread Tim Chase

tonemcd wrote:
> I hope I'm not breaching etiquette here.

Not particularly...however you may also want to post on 
http://djangogigs.com to reach the broadest audience.

One other tip -- though your email CC's Newcastle, UK addresses 
and the below redirectors point to the Newcastle pages, it's 
helpful to include location information right up front (as well 
as any telecommuting option if available) in the body/subject of 
the email.  This helps folks filter out chaff or spot positions 
of interest.  I've changed the subject line to reflect it, but 
for others on the list that may be considering posting positions, 
it helps.

> The URLs are;
> 
> Infrastructure Development Officer: http://is.gd/sJW9
> and
> Web Development Officer: http://is.gd/sJWu

In some circles (more so on mailing lists & blogs, less so on 
twitter), this is more a breech of etiquette -- using shortened 
URLs that point randomly into the internet.  However, in the case 
of those abominably long target URLs, I think shortening is 
acceptable in this case :)

-tim




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



Some django-based jobs available

2009-04-16 Thread tonemcd

I hope I'm not breaching etiquette here.

We have two jobs going at the moment, where a large proportion of the
work will be in Django.

To apply, you *must* go through our University online system. Sorry
about that.

The URLs are;

Infrastructure Development Officer: http://is.gd/sJW9
and
Web Development Officer: http://is.gd/sJWu

All further details (including contact details of people who can give
more information) are available at the URLs.


Thanks,
Tone

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



Re: Problem with self referencing Foreign key field and mysql InnoDB

2009-04-16 Thread Tom Evans

On Thu, 2009-04-16 at 00:33 -0700, limas wrote:
> I were using Mysql MyISAM. But I want to enable transaction.
> So i shifted to InnoDB.
> Actually I have one model as below (*designed somebody i can't
> change).
> 
> class Folder(models.Model):
>   folder_id=models.AutoField(primary_key=True)
>   user_name=models.ForeignKey(User)
>   folder_name=models.CharField(max_length=80)
>   parent_folder=models.ForeignKey('self')
> 
> At some point i want to insert in this table as below:
> Folder(user_name_id=1,folder_name="s",parent_folder_id=0)
> 
> But it raises one error like this.
> 
> IntegrityError: (1452, 'Cannot add or update a child row: a foreign
> key constraint fails (`myproject/folder_folder`, CONSTRAINT
> `parent_folder_id_refs_folder_id_12515019` FOREIGN KEY
> (`parent_folder_id`) REFERENCES `folder_folder` (`folder_id`))')
> 
> But with MyISAM there was no problem like this...
> 
> Anyways i need Transaction functionality for other tables in the
> database.
> Is there any solution for this problem. Please Help me.
> 
> Thanks
> Lima


Your model code says "I have a foreign key to myself, and it is always
required", which might make a tree structure hard to derive! Change the
'parent_folder' member definition to look like so:
parent_folder = models.ForeignKey('self', null=True, blank=True)

Also, instead of setting parent_folder_id to be 0 (which surely does not
refer to a valid Folder model instance?), you should either not set it
at all or set it to None.

The reason it worked before, is that MyISAM has no referential
integrity, where as InnoDB does, so when you try to insert that row, it
now refuses because there is no such row in the folder_folder table with
the id 0. MyISAM would never check that, so your code worked.

Cheers

Tom


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Serving Static Files - Pics work, but CSS doesn't

2009-04-16 Thread Tom Evans

On Thu, 2009-04-16 at 11:06 +1200, Wayne Koorts wrote:
> Also just another tip: it is a good idea to not use named colour
> values ("green" / "red" etc.) as each CSS rendering engine might
> interpret it differently.  For green you could use: "color: rgb(0,
> 255, 0);" and for red you could use: "color: rgb(255, 0, 0);".
> 
> Regards,
> Wayne

That is incorrect, the named colors are all specified in 24bit RGB
values as part of the CSS spec. No renderer deviates from those values.

http://www.w3.org/TR/CSS21/syndata.html#color-units

Cheers

Tom


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



Re: Need help first user of django..

2009-04-16 Thread commander_coder

Those are both good, and the book _Practical Django Projects_ by
Bennett is another good choice.

Jim
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Running two django version from same python.

2009-04-16 Thread Jarek Zgoda

Wiadomość napisana w dniu 2009-04-16, o godz. 12:27, przez Harish:

> Is it possble to install two seperate django versions (0.97  and
> 1.0.x) in one python site-package file.
> If yes how  and if no why?


Use separate virtual environments for each version with virtualenv.  
There's no way to run different versions of Django side-by-side.

-- 
We read Knuth so you don't have to. - Tim Peters

Jarek Zgoda, R, Redefine
jarek.zg...@redefine.pl


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



signals vs. save()

2009-04-16 Thread koranthala

Hi,
I was comparing between signal and save() and came across this
following mail chain -
http://groups.google.com/group/django-users/browse_thread/thread/d0ff6dd3432d25fa/99a92f9f4b343b1e

In this it is mentioned that -
---
If you want to implement some
functionality that operates across multiple types of models, you need
to
use the signal infrastructure, since the same signal is raised no
matter
what the type of model (you can differentiate the model type in the
signal handler, though).


   I was unable to understand why we should go for signals in case we
have to work across models?
   Say, for example - I have ModelA and ModelB. Everytime, I save an
element in ModelA, I need to update 15 fields in ModelB.
   In this case, shouldn't I do everything in ModelA.save itself?
ModelA.save():
   super.save()
   Update 15 fields in ModelB

   I do not understand why we should go for signals in this case too?
   Sorry if I am dense :-)


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



Running two django version from same python.

2009-04-16 Thread Harish

Hi Folks,

Is it possble to install two seperate django versions (0.97  and
1.0.x) in one python site-package file.
If yes how  and if no why?

Regards
Harish Bhat

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



Re: Need help first user of django..

2009-04-16 Thread johan.uhIe

You already know the Django Documentation. Another good ressource is
the Django Book. Have a look at this: http://djangobook.com/ Maybe you
should work through the entire book to get a good understanding how
forms and flatpages work.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with self referencing Foreign key field and mysql InnoDB

2009-04-16 Thread Daniel Roseman

On Apr 16, 8:33 am, limas  wrote:
> I were using Mysql MyISAM. But I want to enable transaction.
> So i shifted to InnoDB.
> Actually I have one model as below (*designed somebody i can't
> change).
>
> class Folder(models.Model):
>         folder_id=models.AutoField(primary_key=True)
>         user_name=models.ForeignKey(User)
>         folder_name=models.CharField(max_length=80)
>         parent_folder=models.ForeignKey('self')
>
> At some point i want to insert in this table as below:
> Folder(user_name_id=1,folder_name="s",parent_folder_id=0)
>
> But it raises one error like this.
>
> IntegrityError: (1452, 'Cannot add or update a child row: a foreign
> key constraint fails (`myproject/folder_folder`, CONSTRAINT
> `parent_folder_id_refs_folder_id_12515019` FOREIGN KEY
> (`parent_folder_id`) REFERENCES `folder_folder` (`folder_id`))')
>
> But with MyISAM there was no problem like this...
>
> Anyways i need Transaction functionality for other tables in the
> database.
> Is there any solution for this problem. Please Help me.
>
> Thanks
> Lima

The other difference between InnoDB and MyISAM is that InnoDB supports
- and enforces - foreign key constraints. '0' does not refer to an
existing folder_id, so the constraint fails. There isn't any way
around that with the way you've set up your models currently: you need
to change the parent_folder field so that null=True.

You say you can't change the db structure, but obviously you've
already made some changes to it to move to InnoDB. I recommend you add
null=True to the Django field definition, then run this SQL on the
database:
ALTER TABLE appname_folder MODIFY COLUMN parent_folder_id INTEGER
NULL;

Now you can define your folder without setting a parent_folder:
Folder(user_name_id=1,folder_name="s")

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



Admin widget for filter_vertical and filter_horizontal slow

2009-04-16 Thread maco

My model has two Foreign Keys. Each FK has 4000 entries or more. In
admin.py I use filter_horizontal for those FK.

I noticed that JS widget is slow both on first render of admin page
(add item) and on every selection of an FK item inside the widget. I
takes 5 seconds AFTER admin page already loads for JS to render
widget. In this time browser is unresponsive. Selection of an item
takes even longer.

I've tested this on various browsers and systems.

I'm am fairly confident that the number of FK items is a major factor
in slowing down the render of the widget because I tried deleting FK
items and browser was starting to show improvements in speed. When the
number of FK items dropped under 1000 admin site become much faster
(and actually usable).

I've also completely removed filter_horizontal just to be sure nothing
is wrong with admin on a general and all seemed good and super fast.

So, I recon, some revision of JS for filter in admin is needed or sth.

Thanks for any thoughts on that.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: manage.py loaddata fails to report error [was: Why does dumpdata, flush, loaddata cycle not result in same db content?]

2009-04-16 Thread Russell Keith-Magee

On Thu, Apr 16, 2009 at 11:30 AM, Phil Mocek
 wrote:
>
> On Thu, Apr 16, 2009 at 11:03:33AM +0800, Russell Keith-Magee wrote:
>> Loaddata doesn't take input from stdin - it loads files that are
>> specified on the command line.
>
> Thanks, Russell.
>
> I should have read the documentation for the loaddata command more
> closely, but this is quite counter-intuitive.  Can someone tell me
> what the rationale for this syntax is?

In my original response, I oversimplified a little. The rationale with
loaddata is that you're not actually specifying a filename. What
you're specifying is a label, and Django will discover multiple
fixtures using that label. By happy coincidence, a label can be a
filename, but filenames are a subset of all possible labels.

The classic example for loaddata is the initial data fixture. When you
run syncdb, Django loads the 'initial_data' fixture - that is, any
fixture, in any of the supported locations, in any supported format,
with the label "initial_data". This means every application in your
project can potentially provide an initial data fixture; some in XML,
some in JSON, some in YAML, and they will all be loaded automatically.

initial_data is a special case because of the relationship with
syncdb, but the same rules apply to any fixture - if you put a
collection of fixtures called 'bootstrap' around your project, you can
'loaddata bootstrap' and they will all be loaded.

The problem with loading a fixture from stdin is that you have no idea
what format that fixture is. Currently, fixture format is detected
from the filename extension; if fixture data comes from stdin, we
would need to either:
 1) Use file magic to work out what type of input was being provided
 2) Add a --format option so the input format could be explicitly specified.

Neither of these two options particularly appeals to me, but I am open
to be being convinced otherwise.

> The built-in usage help shows that the filename argument (called a
> fixture for reasons that I have not yet researched) is mandatory:
>
>    Usage: manage.py loaddata [options] fixture [fixture ...]
>
> However, manage.py does not report an error when a fixture is not
> specified:
>
>    $ ./manage.py loaddata
>    $ echo $?
>    0

The fact that no error message is raised for the 'you didn't provide
any arguments' case looks like a bug to me.This should be logged
as a new ticket so it isn't forgotten.

Yours,
Russ Magee %-)

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



Problem with self referencing Foreign key field and mysql InnoDB

2009-04-16 Thread limas

I were using Mysql MyISAM. But I want to enable transaction.
So i shifted to InnoDB.
Actually I have one model as below (*designed somebody i can't
change).

class Folder(models.Model):
folder_id=models.AutoField(primary_key=True)
user_name=models.ForeignKey(User)
folder_name=models.CharField(max_length=80)
parent_folder=models.ForeignKey('self')

At some point i want to insert in this table as below:
Folder(user_name_id=1,folder_name="s",parent_folder_id=0)

But it raises one error like this.

IntegrityError: (1452, 'Cannot add or update a child row: a foreign
key constraint fails (`myproject/folder_folder`, CONSTRAINT
`parent_folder_id_refs_folder_id_12515019` FOREIGN KEY
(`parent_folder_id`) REFERENCES `folder_folder` (`folder_id`))')

But with MyISAM there was no problem like this...

Anyways i need Transaction functionality for other tables in the
database.
Is there any solution for this problem. Please Help me.

Thanks
Lima
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: possible filter bug with manytomany fields and slice?

2009-04-16 Thread Malcolm Tredinnick

On Thu, 2009-04-16 at 00:01 -0700, Margie wrote:
> Ah - ok, cool, good to know.  I am on 1.1 pre-alpha SVN-9814. 

Hmm .. then maybe there's an actual problem there. The ability to use
nested querysets was added in r9701 (with a few bug fixes in subsequent
patches). I only said 1.1-beta as a rough reference point, as opposed to
1.0.X.

Might be worth having a look at the SQL that is being generated to see
what's going on there. Maybe I've screwed up limits or something (I
can't really stop to test this myself right now, as I'm still at work).

Have a look at the output of 

PdTask.objects.filter(tiles__in=pdTask.objects.all()[0]).query.as_sql()

and see if it looks broken in any obvious fashion. If so, feel free to
open a ticket (assign it to "mtredinnick" so I'll remember to look at it
on the weekend). You shoudl still try a slightly later version
(something around beta-1) just to check it wasn't fixed by some of the
later tweaks in that area, but I'm now a bit suspicious that something
is going wrong.

Regards,
Malcolm



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



Komodo and auto-complete

2009-04-16 Thread Mariano Sokal

Hello again...

I was using notepad++ and now Im trying to switch to komodo edit.

Has anyone been successful on getting 'auto-complete' working?

I get the following error:

"evaluating 'models' at models.py#21: could not resolve first part of
'models' (error determining completions)"

Thanks in advance,
Mariano

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: setting a model field to null

2009-04-16 Thread Margie

blah.foo = None should do the trick

On Apr 15, 8:01 pm, rvr  wrote:
> How can I set a model field to null after it has had a non-null value?
>
> --
> class Blah(models.Model):
>     foo = models.IntegerField(null=True)
>
> blah = Blah()
> blah.foo = 5
>
> # now set it to null
> blah.foo = ???
> --
>
> None doesn't seem to work and I don't seem to be able to figure this
> out from the documentation. Thanks for your help.
>
> ~rvr
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: possible filter bug with manytomany fields and slice?

2009-04-16 Thread Margie

Ah - ok, cool, good to know.  I am on 1.1 pre-alpha SVN-9814.  Am
moving soon to the 1.1. beta.  I originally encountered this on a case
that wasn't quite what I posted.  I had a situation where I was
guaranteed that my Task had only a single tile in the tiles field.  So
I was trying to filter like this:

PdTask.objects.filter(tiles__in=pdTask.objects.all()[0])

IE, I was trying to find all PdTasks that contained a tile that was
the same as the single tile in pdTask.  Then I started experimenting
and began to think that maybe I just didn't understand the manytomany
queries at all - thought maybe I was doing it wrong.

Anyway, your answer allayed my concerns - I have a workaround, no
problem there, just didn't want to find that I was using the queries
wrong in general.

Malcolm - monitoring this group must be a full time job for you.
Thank you so much for all of your responses.

Margie

On Apr 15, 11:39 pm, Malcolm Tredinnick 
wrote:
> On Wed, 2009-04-15 at 23:13 -0700, Margie wrote:
>
> [...]
>
> > # PROBLEM IS HERE
> > # Find all pdtasks that have an entry in tiles that is in slice 0:4 of
> > Tile.objects.all()
> > # I think this should return bar as well, but it returns an empty
> > list.  WHY???
> > (Pdb) PdTask.objects.filter(tiles__in=Tile.objects.all()[0:4])
> > []
>
> Are you using Django 1.0.X here? Because nested queryset support only
> exists in 1.1-beta and later. Tile.objects.all()[0:4] is a queryset in
> that expression and so won't make sense as an rvalue in 1.0.X.
>
> If you are using 1.0.X, you could write that as:
>
>         values = Tile.objects.values_list("id", flat=True)[0:4]
>         PdTask.objects.filter(tiles__in=values)
>
> or you could use the slightly ugly hack involving ".query" described in
> [1]
>
> [1]http://docs.djangoproject.com/en/dev/ref/models/querysets/#in
>
> Also, I hope your Tasks model has a Meta.ordering specification,
> otherwise you could well start seeing all sorts of unexpected (but
> completely correct) results when using slices. Database servers are not
> required to serve up results in any particular order (or even the same
> order on successive queries) unless you specify an ordering.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Basic RSS in Django

2009-04-16 Thread Oto Brglez

Thanx Jeff!

it works now ;)

Oto

On 15 apr., 15:25, Jeff FW  wrote:
> It looks like you're missing (or at least, didn't mention) the
> templates. In documentation:
>
> http://docs.djangoproject.com/en/dev/ref/contrib/syndication/#ref-con...
>
> make sure to read the paragraph starting with "One thing's left to do"
> under "A simple example".
>
> -Jeff
>
> On Apr 15, 8:30 am, Oto Brglez  wrote:
>
> > Hi all you Django users and developers!
>
> > I have a question aboutRSSframework in Django. I want basicRSS.
> > Nothing custom nothing advanced. JustRSSfrom my model for last 10
> > imports in model. This is what i got:
>
> > # Model:
>
> > class Koda(models.Model):
> >         naslov = models.CharField(max_length=50)
> >         slug = models.SlugField(max_length=255,blank=True,null=True)
> >         koda = models.TextField()
> >         dodano = models.DateTimeField(default=datetime.datetime.now ,
> > blank=True)
> >         avtor = models.ForeignKey(User)
>
> >         @permalink
> >         def get_absolute_url(self):
> >                 return ('koda_view', [self.slug])
>
> >         def __unicode__(self):
> >                 return self.jezik.ime + ' / '+ self.naslov
>
> > #  RSSModel:
>
> > class SvezaKoda(Feed):
> >         title = "Rsstitle..."
> >         link = "/rss/"
> >         description = "Description..."
>
> >         def items(self):
> >                 return Koda.objects.order_by('-dodano')[:10]
>
> >         def item_link(self,item):
> >                 return '/'+ item.jezik.slug + '/' + item.slug
>
> >         def item_author_name(self,item):
> >                 return item.avtor
>
> >         def item_pubdate(self,item):
> >                 return item.dodano
>
> > # URLs:
>
> > feeds = {
> >     'koda': SvezaKoda,
>
> > }
>
> > urlpatterns = patterns('',
> >         (r'^rss/(?P.*)/$', 'django.contrib.syndication.views.feed',
> > {'feed_dict': feeds}),
> > ...
>
> > ---
>
> > Now. This works. But in content field i don't get content that i want.
> > I want the field "koda" to be shown insideRSScontent field. Insted
> > of the content insiderssitem i get value of __unicode__
>
> > Can someone please help me.
>
> > Oto
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



  1   2   >