Re: Model and Model Manager override-able methods

2009-12-07 Thread Daniel Roseman
On Dec 8, 4:11 am, Waqqas Jabbar wrote: > Hi, > > Where can i get the list of ALL the methods that a derive class can override > for Model and Model Manager classes > > goto >From the source code. It's just Python. You can override what you like. -- DR. -- You

Re: Has form.errors been deprecated?

2009-12-07 Thread Daniel Roseman
On Dec 8, 4:23 am, Continuation wrote: > I want a way to tell if the form submitted contains errors or not. > > There're django snippets that use the field form.errors to test for > errors (like this one:http://www.djangosnippets.org/snippets/1094/) > > And when I looked

Has form.errors been deprecated?

2009-12-07 Thread Continuation
I want a way to tell if the form submitted contains errors or not. There're django snippets that use the field form.errors to test for errors (like this one: http://www.djangosnippets.org/snippets/1094/ ) And when I looked at my own form.errors, it indeed contains the error messages. However,

Signals request finished from certain view

2009-12-07 Thread Joshua Partogi
Hi all, Is it possible to detect a django.core.signals.request_finished but only from a certain view? It seems that I can only get the signal from every request. I tried to read the documentation but can not find any reference about this. Kind regards, -- http://jobs.scrum8.com |

Model and Model Manager override-able methods

2009-12-07 Thread Waqqas Jabbar
Hi, Where can i get the list of ALL the methods that a derive class can override for Model and Model Manager classes goto -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To

Re: Green hosting suggestions for Django?

2009-12-07 Thread Nick Lo
I'm working with 2 clients hosting on and am part leasing servers from Servint that I've setup to serve Django applications. Their green initiative is outlined here: http://www.servint.net/servintgreeninitiative.php Nick > I'm working on a project for an environmentally-concious client that

Queryset filter on foreign key

2009-12-07 Thread GoSantoni
Guys, i'm struggling with this problem for more than a week now. My goal is to use a queryset filter with a foreign key. Issues are 1) column generates a list, what is the right way to get the blog id for a post? So whether the post belongs to blog 1 question or blog 2 answer? Tried

Re: How to validate a form field whose value can only increase?

2009-12-07 Thread Continuation
You're absolutely right. I don't know what I was thinking. Thanks! On Dec 7, 8:42 pm, Shawn Milochik wrote: > On Dec 7, 2009, at 7:16 PM, Continuation wrote: > > > > > I thought if form.is_valid() returns False, Django would send a list > > of the errors to browser. But

Green hosting suggestions for Django?

2009-12-07 Thread Daniel Quinn
I'm working on a project for an environmentally-concious client that would like a planet-friendly host, preferably Canadian, though that's not required. If that were it, I'd just google "green hosting" and be done with it, but since this is a Django project, I'd really appreciate some

Re: How to validate a form field whose value can only increase?

2009-12-07 Thread Shawn Milochik
On Dec 7, 2009, at 7:16 PM, Continuation wrote: > > I thought if form.is_valid() returns False, Django would send a list > of the errors to browser. But that's not what happened here. Do you have anything like these in your template? {{ my_form.errors }} {{ my_form.field_name.errors }} Shawn

CharField cannot have a "max_length" greater than 255 when using "unique=True"

2009-12-07 Thread germ
my platform: django 1.1.1, mysql 5.0.67, python 2.6.2 why does syncdb complain CharField cannot have a "max_length" greater than 255 when using "unique=True" when mysql 5.0.67 does allow greater tan 255? is there a way to override or ignore this error? this works in mysql mysql> create table

admin app doesn't find template

2009-12-07 Thread Xbiton
Hi, I'm new to django and I'm learning it trow a tutorial. Now I was trying to access the admin interface after adding the django.contib.flatpages to the installed app. I did run the python manage.py syncdb and I've seen that the tables for the admin an flatpages apps were created, unfortunately

Re: How to change this function to use generic view

2009-12-07 Thread 邓超
Anyone? Please... 2009/12/7 一千瓦的刀狼 > Hello? Anyone can help me? > > On Dec 6, 9:18 am, 邓超 wrote: > > Hi all, > > I want to change below function to use the generic view function > > update_object: > > > > @login_required > > def

Re: How to validate a form field whose value can only increase?

2009-12-07 Thread Continuation
Hi, Thank you very much for your help. I used your form validation method. The results is weird. I tested it with a value lower than the previous value. But didn't see any error message in my browser. I stepped through the code using pdb. I could see that forms.ValidationError("The amount in

Re: how can i find out that Development server is running or not?

2009-12-07 Thread Graham Dumpleton
On Dec 8, 9:45 am, Sameer Rahmani wrote: > i want to know just about development server . i mean i just want to know > when my code run under development server: The body of you post asked about both. :-) > if development_server: >       some code If this is for debugging

Re: how can i find out that Development server is running or not?

2009-12-07 Thread Sameer Rahmani
i want to know just about development server . i mean i just want to know when my code run under development server: if development_server: some code -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: how can i find out that Development server is running or not?

2009-12-07 Thread Graham Dumpleton
On Dec 7, 8:22 pm, Sameer Rahmani wrote: > hi > how can i find out that my project ran under apache or development server ? How are you running under Apache. Are you using mod_python, mod_wsgi, fastcgi, something else? One could try and look for the fingerprint of the

How to change default template name for django.views.defaults.page_not_found ?

2009-12-07 Thread mateusz.szulc
>From Django Part 3 tutorial: "The 404 view is also called if Django doesn't find a match after checking every regular expression in the URLconf." The 404 default view in django is defined as: def page_not_found(request, template_name='404.html'): How can I change the value of the template_name

Re: How to get the last item of array in a built-in template tag?

2009-12-07 Thread Gaffar Overcomes
hey pete this does not work :S negative index does not support error occured.. On Mon, Dec 7, 2009 at 12:38 AM, pjrhar...@gmail.com wrote: > Try: > > {{ my_array|slice:"-1:" }} > > Pete > > -- > > You received this message because you are subscribed to the Google Groups >

Re: How to create a form to edit an existing object without knowing the object's id?

2009-12-07 Thread Gaffar Overcomes
form = MyForm(instance=z) if (request.method == 'POST'): form = MyForm(request.POST, instance = z) if (form.is_valid()): z = form.save() z.save() return HttpResponseRedirect('redirect to success page') return

Re: Pydev + Django + Ubuntu 9.10

2009-12-07 Thread Brian McKeever
I'm using django from the repositories. Installed this way: http://docs.djangoproject.com/en/dev/topics/install/#installing-development-version I configured my interpretor in eclipse by doing this: "Now, on to re-configure the pydev interpreter to add those new paths... I'm kind of lazy, so,

Re: ManyToOne to auth.models.User

2009-12-07 Thread Carl Zmola
TiNo wrote: > On Sun, Nov 15, 2009 at 09:31, Dennis Kaarsemaker > wrote: > > >> On za, 2009-11-14 at 15:53 -0800, TiNo wrote: >> >> >>> In my apps, Users of the app participate in a certain Year. I would >>> like a Year to continue a ManyToOne relationship with a

Re: insert into data field of model based on other data field values

2009-12-07 Thread Shawn Milochik
Easy to do: Just override the save() function of the model. class MyModel(models.Model): def save(self, **kwargs): #add your logic here super(MyModel, self).save(**kwargs) -- You received this message because you are subscribed to the Google Groups

insert into data field of model based on other data field values

2009-12-07 Thread rc
I am trying to figure out the best way to go about this. Here is the scenario: I have five fields in my model that the user will set from the admin. When they save the model I want to insert a value into another field of the model based on these values. Where/How is the best place to handle

filter foreign key field in inline formset

2009-12-07 Thread cerberos
One of the fields in an inline formset has a foreign key to another model, how can I filter it? I'm building a library system, the models are loans, loan items and book instances. I don't want books that are currently out on loan to be available on the loan items dropdown list. -- You received

Re: Custom get/set from model

2009-12-07 Thread Waqqas Jabbar
I want that I could override get/set on a field of my model. I want to redirect get/set to another field of some other model. On Mon, Dec 7, 2009 at 8:47 PM, Daniel Hirsch wrote: > I'm not clear what you're asking. Do you want a custom get/set on a > particular database

Re: Show additional user information in admin

2009-12-07 Thread Carl Zmola
bax...@gretschpages.com wrote: >> You can do that by creating an >> InlineModelAdmin:http://docs.djangoproject.com/en/dev/ref/contrib/admin/#inlinemodelad... >> > > How, exactly? I tried this, with no luck: > > from user_profiles.models import Profile > from django.contrib.auth.admin import

Re: model design problem

2009-12-07 Thread Bill Freeman
Or there's overriding the metaclass... On Mon, Dec 7, 2009 at 12:39 PM, Bill Freeman wrote: > Hmmm.  Probably just as ugly, and untested, but: > > class A(basemodel): >    for o in range(MAXNUMREDPORTS): >         for i in (1,2): >             locals()["Port%d_redfield%d" %

Re: model design problem

2009-12-07 Thread Bill Freeman
Hmmm. Probably just as ugly, and untested, but: class A(basemodel): for o in range(MAXNUMREDPORTS): for i in (1,2): locals()["Port%d_redfield%d" % (o+1, i)] = models.FloatField() ... On Mon, Dec 7, 2009 at 12:10 PM, Daniel Goertzen wrote: >

Re: model design problem

2009-12-07 Thread Bill Freeman
Unless I'm very confused, django will happily delete your related objects (since they don't have anything to relate to anymore). Many to many would be more problematic. As far as creating a set of ports, you were stuck with that anyway, if I understand your original approach correctly. Even if

Re: model design problem

2009-12-07 Thread Preston Holmes
On Dec 7, 8:56 am, Daniel Goertzen wrote: > Thanks for the reply Bill.  The problem I had with that approach is that > after creating the product I have to worry about creating red and green > ports.  Likewise, upon deletion, I have to mop up the ports.  Looking >

Re: model design problem

2009-12-07 Thread Daniel Goertzen
Okay, I explored model generation a bit and found an approach that wasn't too offensive. For those that are trying to solve the same problem that I am, here is what I came up with: def red_port(prefix): return """ %(prefix)sredfield1 = models.FloatField() %(prefix)sredfield2 =

Re: browser input and strings

2009-12-07 Thread rvandam
>         browse_lijst = Nl.objects.filter(lijst__slug=browse) > > Does that solve your problem? > -- > DR. Yes Thanks a lot :-) Rob -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: model design problem

2009-12-07 Thread Daniel Goertzen
Thanks for the reply Bill. The problem I had with that approach is that after creating the product I have to worry about creating red and green ports. Likewise, upon deletion, I have to mop up the ports. Looking through the documentation, I did not find a way to bury this behavior in the Model.

Re: browser input and strings

2009-12-07 Thread Daniel Roseman
On Dec 7, 4:35 pm, rvandam wrote: > Sorry for the confusion. Here are both complete models: > > class Nl(models.Model): >         lijst = models.ForeignKey('Menu_nl') >         type = models.ForeignKey('Type_nl') >         perceel = models.ForeignKey('Perceel_nl') >    

Re: browser input and strings

2009-12-07 Thread rvandam
Sorry for the confusion. Here are both complete models: class Nl(models.Model): publiceren = models.BooleanField() titel = models.CharField(max_length=60) tekst = models.TextField() prijs = models.CharField(max_length=12) #tekst_html =

Re: model design problem

2009-12-07 Thread Bill Freeman
I'm not clear on what you need to store, so I'll assume that you have individual data to store for each port of each type, and it is unrelated to data stored for another instance of the same or a different product. What comes to mind is that there is a "Product" model and a "Port" model (or if

Re: browser input and strings

2009-12-07 Thread Daniel Roseman
On Dec 7, 3:11 pm, rvandam wrote: > Hi Shawn thanks for your reply. > > I have some categories, with multiple items per category. If a user > entershttp://mysite.com/items-from-100-to-1000I want a short > description of all items in that category listed. > > I have done this

Re: How to create a form to edit an existing object without knowing the object's id?

2009-12-07 Thread Daniel Roseman
On Dec 7, 12:22 am, Continuation wrote: > I have: > > class MyModel(models.Model): >     fk                    = models.ForeignKey(AnotherModel) >     field               = models.PositiveIntegerField() > > class MyForm((forms.ModelForm): >     class Meta: >         model

Re: How to create a form to edit an existing object without knowing the object's id?

2009-12-07 Thread Bill Freeman
Off the top of my head, you have three choices. 1. Create a hidden field to carry the id (yes, you do know it once you've done that query - it's z.id or z.pk). 2. (My favorite) encode the id as part of the url or as a query parameter in the action attribute of your form. Then access it in the

Re: Custom get/set from model

2009-12-07 Thread Daniel Hirsch
I'm not clear what you're asking. Do you want a custom get/set on a particular database field in one of your models (tables)? On Dec 7, 1:18 am, Waqqas Jabbar wrote: > Peace to all, > > I want to do a custom implementation of "get" and "set" functions of a > database

Re: model design problem

2009-12-07 Thread Daniel Goertzen
Each port would have about a half-dozen fields, and different port types are totally different from one another. I won't be querying port fields. I've thought about your JSON field trick before, but not with the nice wrapper methods. Good idea, thanks! The solution does have flaws, but if

Re: model design problem

2009-12-07 Thread Shawn Milochik
What kind of information will the database have to store about the ports themselves? How will you need to be able to filter querysets by information in the port fields, if at all? I'm going to throw this one solution out there, but depending on your needs it may not fit: Create a red_ports

Re: Pydev + Django + Ubuntu 9.10

2009-12-07 Thread turkan
Hello Brian. Strange, I am also using Eclipse downloaded from eclipse.org. Did you add any special folders to the PYTHONPATH? Are you using django from the Ubuntu repositories? On Dec 7, 6:06 am, Brian McKeever wrote: > I was having the same trouble you are when I installed

Re: browser input and strings

2009-12-07 Thread rvandam
I cut the model down too much this one is missing: lijst = models.ForeignKey('Menu_nl') this is the Menu_nl model: class Menu_nl(models.Model): categorie = models.CharField(max_length=50) order = models.IntegerField() slug = models.SlugField() def

model design problem

2009-12-07 Thread Dan
I am relatively new to django and relational databases, and need some Model advice. I have a family of network products each with a different combination of ports.. I will call them red ports and green ports. For example, product A will have its own Model and could have 2 red ports and 1 green

Re: browser input and strings

2009-12-07 Thread rvandam
Hi Shawn thanks for your reply. I have some categories, with multiple items per category. If a user enters http://mysite.com/items-from-100-to-1000 I want a short description of all items in that category listed. I have done this so far with: {% for x in browse_lijst %} {% ifequal

Re: Django Flatpage Internationalization BUG

2009-12-07 Thread Carlos Ricardo Santos
So just put your http://localhost:PORT if you're in development, or the real link if you are in production :D 2009/12/7 Cyberbiagio > Thanks for your suggestion but in site there is mysite.com and the > sites_id is correctly linked to flat page id > > :( > > On 7 Dic,

Re: Django Flatpage Internationalization BUG

2009-12-07 Thread Cyberbiagio
Thanks for your suggestion but in site there is mysite.com and the sites_id is correctly linked to flat page id :( On 7 Dic, 14:42, Carlos Ricardo Santos wrote: > Check in the admin panel if you have linked it to a site, then check > settings.Py if the site_id

how to allow RSS aggregators to use feeds available only for logged-in users?

2009-12-07 Thread Miernik
I want to have RSS feeds in my Django application, which should be viewable only by a logged-in user. I want to allow users to add these RSS feeds to all aggregators, so I would need something which would work like this: supply the feed URL with a token, for example:

Re: browser input and strings

2009-12-07 Thread Shawn Milochik
What exactly are you trying to do? Can you give a little of the data in your model, and then exactly how you want it to look on the rendered page? I'm having some trouble understanding what your template and view are intended to do. Shawn -- You received this message because you are

Re: Model instances used for class attributes

2009-12-07 Thread Thomas Guettler
bruno desthuilliers wrote: > On 7 déc, 11:45, Thomas Guettler wrote: >> Hi, >> >> I have this code: >> >> from django.contrib.auth.models import Group >> >> class MyModel(models.Model): >> default_group=Group.objects.get(name='MyGroup') >> >> This worked, since I added

Re: how can i find out that Development server is running or not?

2009-12-07 Thread Tim Chase
> how can i find out that my project ran under apache or development server ? Though not 100% foolproof, I usually use from sys import argv if 'runserver' in argv: do_development_server_stuff() else: do_non_development_server_stuff() -tim -- You received this message

Re: Django Flatpage Internationalization BUG

2009-12-07 Thread Carlos Ricardo Santos
Check in the admin panel if you have linked it to a site, then check settings.Py if the site_id matches the id of the site you associated in the admin. On Dec 7, 2009 12:08 PM, "Cyberbiagio" wrote: Hi, i'm a new django developer, i need help for a strange bug: I have a

browser input and strings

2009-12-07 Thread rvandam
I have an application that generates a list of items in a category. Therefore i have this in my urls.py: (r'^categorie/(.*)/$', browse_page), This is my view..py: def browse_page(request, browse): browse_lijst = Nl.objects.all() menu =

Re: Unique model field and case sensitivity (postgres)

2009-12-07 Thread David De La Harpe Golden
chefsmart wrote: > By the way, right now I'm using a State.objects.get(name__iexact=name) > in clean_name() method in a form subclass to prevent creation of case- > insensitive duplicates. Just wondering if there is a built-in or > better way. > Well, in postgresql itself one can make a case

Re: Model instances used for class attributes

2009-12-07 Thread bruno desthuilliers
On 7 déc, 11:45, Thomas Guettler wrote: > Hi, > > I have this code: > > from django.contrib.auth.models import Group > > class MyModel(models.Model): >     default_group=Group.objects.get(name='MyGroup') > > This worked, since I added the Model after the group MyGroup > was

Re: What apps do besides provide views?

2009-12-07 Thread bruno desthuilliers
On 5 déc, 16:34, Preston Holmes wrote: > On Dec 3, 12:02 pm, Wayne Koorts wrote: (snip) > > Can anyone point out a section in the docs (or anywhere else actually) > > the Django "app" concept?  I've had a look through the docs but > > haven't been able to

Re: Extending result count at bottom of admin pages

2009-12-07 Thread Count László de Almásy
On Dec 6, 9:33 am, Kaze wrote: > You can override "changelist_view" function in admin.py for that > model. ok, thanks, that helped me figure out a solution. here's what i added to admin.py within my Sales class. i can then access 'cl.amount_sum' from my pagination.html

Re: admin templates issue

2009-12-07 Thread gentlestone
Sorry, my stupid mystake. I've copied bat templates from old Django 1.0 version. On 7. Dec., 08:50 h., gentlestone wrote: > I did not make any changes, just copied the original template to > template/admin > > I tried to copy the tepmplate to root (templates/admin) for

Model instances used for class attributes

2009-12-07 Thread Thomas Guettler
Hi, I have this code: from django.contrib.auth.models import Group class MyModel(models.Model): default_group=Group.objects.get(name='MyGroup') This worked, since I added the Model after the group MyGroup was created. But it breaks syncdb. I need this on the class, using a property does

how can i find out that Development server is running or not?

2009-12-07 Thread Sameer Rahmani
hi how can i find out that my project ran under apache or development server ? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to

Re: Hello

2009-12-07 Thread Waqqas Jabbar
you can go in admin site and add/modify/remove user and user permissions On Mon, Dec 7, 2009 at 11:13 AM, Tsolmon Narantsogt wrote: > How to use a permission. > ./manage.py syncdb > then how to create a users permissions > > -- > > You received this message because you are

Custom get/set from model

2009-12-07 Thread Waqqas Jabbar
Peace to all, I want to do a custom implementation of "get" and "set" functions of a database model. Do I ve to write a custom model manager or derive a class from models.Model ? Is it possible to write custom "get" and "set" functions for a model field ? goto -- You received this message

Re: Pydev + Django + Ubuntu 9.10

2009-12-07 Thread Info Cascade
Hi, Turkan, Sorry -- the link is: here. Hope that helps. I had to use Postgres 8.3 instead of 8.4, but