Re: modelformset_factory, initial, and queryset

2010-10-14 Thread Daniel Roseman
On Oct 14, 10:32 am, Tim Valenta wrote: > This is driving me mad, so I must ask the community, in hopes of a > workaround: > > I've got a simple formset of models on a page, generated by > modelformset_factory.  This particular page will never create forms-- > it only modifies existing ones.  Ther

Re: UserProfile

2010-10-13 Thread Daniel Roseman
On Oct 13, 1:19 pm, reduxdj wrote: > I have a simple use-case. I want the user's profile to be available to > the context instance. For instance, the user's avatar image, i want > them to be able to see it all the time. Is there way to make the user > profile available to the context instance? > >

Re: Questions about Django's authentication system

2010-10-13 Thread Daniel Roseman
On Oct 13, 4:22 am, Andy wrote: > A few questions about Django's authentication system: > > - Once a user is logged in, how long does he remain logged in? Is > there any way to configure this - e.g. "users will remain logged in > for 24 hours"? It's determined by the value of SESSION_COOKIE_AGE.

Re: Legacy URLs redirect

2010-10-11 Thread Daniel Roseman
On Oct 11, 5:08 pm, "bax...@gretschpages.com" wrote: > I'm sure this is simple and I'm just not constructing the URL > properly. Basically, it used to be a drupal site, with the cruddy old > Drupal every url is a querystring setup. What I want is pretty > simple... all of those old URLs resolve to

Re: Serve static file from cdn

2010-10-08 Thread Daniel Roseman
On Oct 8, 9:37 am, Hudar wrote: > Hi, > > Just wondering how we could server static file if we have our files > hosted in cdn. > > I been trying several way, but nothings work. > > I have the files in let say ;   > http://commondatastorage.googleapis.com/static/media/node.js > > As far as I know,

Re: dictionary doesn't get properly updated

2010-10-07 Thread Daniel Roseman
On Oct 7, 3:20 pm, jimgardener wrote: > hi > In my django view ,I am creating a Thread subclass and adding it to a > ThreadManager TM to keep in a dictionary with name of thread as key > and instance as value.I have implemented TM as a singleton and > verified that only one instance of TM exists .

Re: Strange 404s

2010-10-06 Thread Daniel Roseman
On Oct 6, 10:32 pm, Scot Hacker wrote: > We have enabled the option to have 404 requests automatically emailed   > to admins. It works well, but sometimes we get strange reports like   > this: > > > Referrer:http://ourdomain.edu/forums/software/ > > Requested URL: /forums/software/ > > User agent:

Re: Django admin in app installed in directory below root.

2010-10-06 Thread Daniel Roseman
On Oct 6, 5:35 pm, Joe Murphy wrote: > Okay, so I've got my django project "bar" installed in, say,www.foo.com/bar/ > . I'm going to install another project inwww.foo.com, so I have nginx > using /bar/ as the root for the bar. This works fine for everything > except... the django admin, which is a

Re: adding process_exception() to middleware; newbie needs help

2010-10-06 Thread Daniel Roseman
On Oct 6, 3:42 pm, Fred wrote: > My django app is working great with Debug=True.  But now I'm in > production and I want to email exceptions to me and print them to my > logfile.  I've been googling and searching the docs for the last 2 > hours and what I really need is a snippet that shows how to

Re: inner join and only method

2010-10-06 Thread Daniel Roseman
On Oct 6, 2:44 am, refreegrata wrote: > Hello list. I'm have a questio. if I have an "inner join" query an use > an "only" restriction, how can i put a field of the second table in > the "only" tuple? > > Example: > > Model > - > class Abc(models.Model): >     fk_user = models.ForeignKey(U

Re: unit test :how to call a single test method alone

2010-10-06 Thread Daniel Roseman
On Oct 6, 4:07 am, jimgardener wrote: > hi > In my application,I have the following structure for tests > > myapp---__init__.py > | > | > tests- __init__.py #contains from functional import * from utility > import * >        | >        | >        functional - __init__.py >        | >  

Re: [ Error infinite loop ]

2010-10-06 Thread Daniel Roseman
On Oct 6, 10:17 am, Tsolmon Narantsogt wrote: > Hello everybody > > I got a this error when i call a page. > > *Exception RuntimeError: 'maximum recursion depth exceeded while calling a > Python object' in ignored* > * > * > Thank you > Tsolmon Oh good. Well, that's interesting. Of course, if y

Re: newbie error

2010-10-05 Thread Daniel Roseman
On Oct 5, 12:52 pm, chocolatero wrote: > Hi Friends! I'm working with django and i have this error: > > Request Method:         GET > Request URL:    http://127.0.0.1:8000/myapp/New_page/ > Django Version:         1.2.3 > Exception Type:         ValueError > Exception Value: > > invalid literal fo

Re: Get simple data from form

2010-10-04 Thread Daniel Roseman
On Oct 3, 11:15 am, petarda wrote: > Sorry, that I was so brief. > It is a modeform: > form = modelform(instance=object) > instantiated after click on detail of brand for update this brand. > But, First I need only get and view raw data from form.. like title, > description etc.. > then I need to

Re: Get simple data from form

2010-10-03 Thread Daniel Roseman
On Oct 2, 9:33 pm, petarda wrote: > Hello, > I have simple question. How Can I get raw data from form object in my > template? > I don't need html tags only data. > I am trying {{ form.myfield.data }} , but always get None.. What sort of form is it? What data are you trying to get? How are you in

Re: Why can't I use this model architecture?

2010-10-03 Thread Daniel Roseman
On Oct 3, 2:37 am, mathphreak wrote: > I've got three different classes in models.py and register all three > in admin.py within my app.  Viewing the admin page that I have, > however, gives mehttp://dpaste.com/252244/which doesn't look good. > Is this a Django bug, or do I need to rewrite my app?

Re: Change auth User display name in admin interface

2010-09-30 Thread Daniel Roseman
On Sep 30, 6:34 pm, Nathan wrote: > I'm using the django User authentication. > > I have a model that has a ManyToManyField which allows you to select > several users to associate with that model. In the django admin site, > it's set to use the filter_horizontal option. > > When adding a new insta

Re: Calling method of a proxy-model in a template

2010-09-30 Thread Daniel Roseman
On Sep 30, 3:31 pm, mettwoch wrote: > Hi, > > Let's say that I have a proxy model of the User model that adds some > methods. What would be an elegant way to access these methods from > within a template in the same easy way I access the User attributes > through {{ request.session.user.some_attri

Re: TemplateSyntaxError at /accounts/register/ Invalid filter: 'apnumber'

2010-09-30 Thread Daniel Roseman
On Sep 30, 1:14 pm, prakashadm wrote: > Hello friends, > > I have getting below error > > TemplateSyntaxError at /accounts/register/ > > Invalid filter: 'apnumber' > > i am working on simple user registration of page.any budy have idea > abt it? > > http://www.stonemind.net/blog/2007/04/13/django-

Re: User.get_profile() not working

2010-09-29 Thread Daniel Roseman
On Sep 29, 4:34 am, Skylar Saveland wrote: > Using *args and **kwargs might work > > then maybe > > self.website = kwargs.get('website', 'default.com') But the point is, there's no need to do that. That is built-in functionality: both the setting of 'website' via keyword, and the default, which c

Re: What is the correct way to copy an object from one model to a similar model?

2010-09-29 Thread Daniel Roseman
On Sep 29, 6:06 am, Yo-Yo Ma wrote: > I have two models that are identical in structure except one has 2 > extra fields. The second one is used for record keeping and is never > edited by users. The system takes the first model and copies it to the > second model, adding some extra meta informatio

Re: User.get_profile() not working

2010-09-28 Thread Daniel Roseman
On Sep 28, 6:45 pm, adj7388 wrote: > Django newbie issue. Just trying to understand. I'm setting up a > simple UserProfile class to link to User (as described in several > places in documentation). Here's what I have --- a simple example of > storing the user's website in a profile > > #In myapp/m

Re: using both SQL and NonSql (MondoDB) in same project?

2010-09-27 Thread Daniel Roseman
On Sep 27, 9:43 pm, Bill Seitz wrote: > I know Django will support multiple SQL databases by just having a > tuple of DATABASES entries in settings.py. > > But can I put a single item in DATABASES for a SQL part, and a 'from > mongoengine import connect' section in as well? > > I'd like to have us

Re: JavaScript with Dango

2010-09-26 Thread Daniel Roseman
On Sep 26, 12:48 pm, aug dawg wrote: > Does Django work with JavaScript? If so, how can I use JavaScript in my > Django projects? What a strange question. Django creates web pages, and you can use JavaScript in the pages it produces just as you would with any other website pages. -- DR. --

Re: reverse ForeignKey

2010-09-25 Thread Daniel Roseman
On Sep 25, 9:51 am, ionut cristian cucu wrote: > I've tried to do something like that: > class Pacienti_manager(models.Manager): >   def get_visible(self): >     return(super(Pacienti_manager, > self).get_query_set().filter(pacient_id__exact=pacient_id) > but still no go, I tried > def queryset(

Re: How to avoid nested references

2010-09-23 Thread Daniel Roseman
On Sep 23, 6:26 pm, Marc Aymerich wrote: > Hi > I'm trying to define two clases, one of them is a relational class between > services and users, so it has two foreign keys, one to services and another > to the user. On the other hand every service must have at least a default > tariff, so it has a

Re: 'ifequal' takes two arguments

2010-09-22 Thread Daniel Roseman
On Sep 22, 4:48 pm, Bradley Hintze wrote: > I am getting an ''ifequal' takes two arguments' error for this line: > > {% ifequal {{ param2_trunc_new.3.0 }} {{ param2.4.1 }} %} > > I believer those are indeed two arguments. What going on here? > > -- > Bradley J. Hintze Don't put arguments within v

Re: How to use custom classes in django

2010-09-22 Thread Daniel Roseman
On Sep 22, 9:10 am, jake2891 wrote: > Hey guys, i am using extjs in django and am wondering the correct way > to build custom classes like file upload classes and classes of > functions. I am a bit confused does everything have to go into > views.py by defining a function for each ajax request or

Re: overriding the admin's template sucks

2010-09-20 Thread Daniel Roseman
On Sep 20, 11:54 am, Julian wrote: > Hi, > > I want to display a customized table for a model in the admin. I've > just written a customized filter, which works very well. > > The problem: My model has a field 'timestamp' which is a > datetimefield. It may be null, so in the admin it's displayed a

Re: Admin not using verbose_name on required fields

2010-09-16 Thread Daniel Roseman
On Sep 16, 7:26 pm, geraldcor wrote: > Hello all, > > I am using the admin and fieldsets to display a change form as usual. > Some fields' labels, even with blank=True are being given the class > required and are not using the verbose_name argument either given via > keyword or positional usage.

Re: How do I get rid of the "Something object" text in inlines?

2010-09-16 Thread Daniel Roseman
On Sep 16, 3:06 pm, hejsan wrote: > When adding an inline object, there is always the text "Something > object" displayed above the first column. > (Replace "Something" with the classname of the inline object) > > How do I get rid of that? Please don't tell me I have to override the > template.. >

Re: getting force_update to work

2010-09-15 Thread Daniel Roseman
On Sep 14, 8:44 pm, Anomal wrote: > According to the Django docs,  a new row is created with the new value > primary key when  when I change the value of a primary key and save > the object. > > In this case, I am looking to change the value. So, I use > force_update=True. Instead of changing the

Re: Not calling clean() properly

2010-09-14 Thread Daniel Roseman
On Sep 13, 10:50 pm, Christos Jonathan Hayward wrote: > Other attempts to write a clean that would run a print statement and then > call to_python(), validate(), and run_validators() did not result in that > print statement being called. > > Am I missing something about data being cleaned? The hoo

Re: Form not taking my input...

2010-09-13 Thread Daniel Roseman
On Sep 13, 9:32 pm, keynesiandreamer wrote: > Hi Daniel, thanks for looking at this! > > Here is my views.py code related to this: > > @login_required > def wine_add_page(request): >   if request.method == 'POST': >     form = WineAddForm(request.POST) >     if form.is_valid(): >       #create or

Re: Form not taking my input...

2010-09-13 Thread Daniel Roseman
On Sep 13, 5:48 pm, keynesiandreamer wrote: > Howdy, > > I am still new to Django and have been working with forms. > > Currently I a getting an error that says a field can't be NULL, even > though I have entered data into it. Weird! > > Error: > IntegrityError at /save/ > > winerater_wine.alcohol

Re: django join queries

2010-09-13 Thread Daniel Roseman
On Sep 13, 12:26 pm, ashy wrote: > Ok, > > but I want to retrieve rows from both the tables based on the foreign > key. > User.objects.all() > or > Userdata.objects.all() > will give me data from either table. How can retrieve data from both > the tables using the foreign key? > > thanks >    ashy

Re: django join queries

2010-09-13 Thread Daniel Roseman
On Sep 13, 12:18 pm, ashy wrote: > Hi All, > > I have the following model class > > from django.db import models > from django.contrib.auth.models import User > > # Create your models here. > class Userdata(models.Model): >   user = models.ForeignKey(User) >   location = models.CharField(max_lengt

Re: query with "join"

2010-09-08 Thread Daniel Roseman
On Sep 8, 3:25 pm, refreegrata wrote: > Hello list, I have question. With this model: > - > 1) class EE(Persona): >     . > 2) class DD(models.Model): >     ee_id = models.ForeignKey(EE) > > 3) The User table > > 4) class PPDD

Re: How do you avoid this race condition in Django?

2010-09-07 Thread Daniel Roseman
On Sep 7, 9:02 am, bruno desthuilliers wrote: > The SQL "update" statement is atomic (well, it's supposed to be at > least), so queryset.update should solve the problem (nb : not tested): > > YourModel.objects.filter( >     pk=object.pk, >     expiration_datetime < datetime.datetime.now() >     ).

Re: Reverse lookup - models

2010-09-06 Thread Daniel Roseman
On Sep 6, 6:27 pm, Shamail Tayyab wrote: > Hi, > >   I've a model something like this: > > class Article ( models.Model ): > >    text = models.TextField () >    lasteditedby = models.ForeignKey ( User ) >    whenedited = models.DateTimeField ( default = datetime.datetime.now() ) > > class Topic (

Re: how do forms select language to render?

2010-09-06 Thread Daniel Roseman
On Sep 5, 10:26 pm, Aljoša Mohorović wrote: > if django.utils.translation.get_language() and LANGUAGE_CODE returns > one language what does form.as_p use that it renders localized stuff > in another language? > > Aljosa Mohorovic Forms aren't special in any regard - they follow the usual rules f

Re: Generate a daily serial/batch/lot number

2010-09-06 Thread Daniel Roseman
On Sep 6, 8:38 am, kmpm wrote: > On Sep 6, 9:02 am, Mike Dewhirst wrote: > > > > > > > On 6/09/2010 4:19pm, kmpm wrote: > > > > I have a project running in a manufacturing industry that is actually > > > built upon django. > > > In this I need to generate a unique serial, batch or lot number > >

Re: ANN: PyMySQL 0.3

2010-09-05 Thread Daniel Roseman
On Sep 4, 9:58 pm, Pete Hunt wrote: > Hi Andy - > > Below is a patch that will let Django use pymysql if MySQLdb is not > available. Currently it is not in use in production anywhere but I am > hoping to change that soon. Currently its primary use is prototyping > applications that are being devel

Re: Problem with ModelForm

2010-09-04 Thread Daniel Roseman
On Sep 4, 5:19 pm, Jagdeep Singh Malhi wrote: > I try to Create forms from models > I am facing error message with 'is_valid()' > > error is  : > { > AttributeError at /add_db/ > > 'Input' object has no attribute 'is_valid' > > Request Method:         POST > Request URL:    http://localhost/django

Re: Template syntax

2010-09-03 Thread Daniel Roseman
On Sep 3, 5:14 pm, Javier Guerra Giraldez wrote: > On Fri, Sep 3, 2010 at 11:10 AM, Bradley Hintze > > wrote: > > -In my template I put {{ param1.0 }}, expecting to see the first list > > in the list of lists. > > Result: nothing was printed to the page. > > that zero becomes a string '0', not a

Re: customize url for GET form

2010-09-03 Thread Daniel Roseman
On Sep 3, 2:20 pm, jean polo wrote: > hello > while using GET form, I can select several objects with an URL like: > xx?id=1&id=2&id=3 etc.. > > How could I have instead an URL like that: > xx?id=1,2,3,4 etc... ?? > > Thanks, > _j Why would you want to? The first is the standard HTTP meth

Re: How to share Custom Template Tag in other APP?

2010-09-03 Thread Daniel Roseman
On Sep 3, 9:27 am, funcrush wrote: > Hi, all. > I wrote a custom template tag package in a app that named Blogs. > And I made other app named SMS. > But I don't know how to use the custom template tag that located Blogs > in SMS app. > If anybody know, please help me. > thank you :) You don't nee

Re: Alternative to passing request object to every object/function?

2010-09-02 Thread Daniel Roseman
On Sep 2, 3:30 pm, Daniel Klaffenbach wrote: > Hi, > > I am developing a Django app which relies on information from the > request object a lot, especially request.user. I need this object (or > let's say at least 'REMOTE_USER') in many models and I was wondering > if there is another way to get t

Re: I don't understand the difference between these two views

2010-09-02 Thread Daniel Roseman
On Sep 2, 2:45 pm, Karim Gorjux wrote: > Working on the Coltrane's Book :-) ... > > I create two views that do the same thing but the first one use the > generic view and the second a render to response. > I don't understand why because both works but the second besides don't > passe the category

Re: django,how to read data from database when db has large volume of data

2010-09-02 Thread Daniel Roseman
On Sep 2, 9:49 am, girish shabadimath wrote: > actually i wanted to access values from database and use those values in url > unittesting,,, > > like: > response = self.client.get('def/defect/', {'*ID*':*id*}) > self.failUnlessEqual(response.status_code, 200) > > how to get id from database..?,,,a

Re: Extracting json data for parsing from HTTP GET

2010-09-02 Thread Daniel Roseman
On Sep 2, 10:37 am, irum wrote: > Hi, > Thanks for your prompt reply. > I have tried both the things but I get the same error. > With, > x = json.loads(p.read()) >            print x > > I get following error:  'HttpResponse' object has no attribute > 'read' > Also I get same error with, json.dump

Re: Extracting json data for parsing from HTTP GET

2010-09-02 Thread Daniel Roseman
On Sep 2, 9:57 am, irum wrote: > Hi, > I am having problems with extracting json data  for parsing from HTTP > GET request. > > What I am doing is that I am receiving json data over HTTP via GET. > After debugging much, I have realized that the data also has HTTP > headers and other information th

Re: django,how to read data from database when db has large volume of data

2010-09-02 Thread Daniel Roseman
On Sep 2, 8:17 am, girishmss wrote: >          Hi folks,im working on django project,,is there a way to access db > without using fixtures,, as fixtures is not working in my project,,i > want to test urls of type: > >                    /abc/xyz/123 where '123' comes from database., > >          

Re: _unicode_ method not working?

2010-09-01 Thread Daniel Roseman
On Sep 1, 7:28 pm, Erskine wrote: > Hi, > > I've just started using Django and have been following the 'Writing > your first Django App' tutorial. So far so good, but I've run into a > little irritation - the use of the _unicode_ method doesn't work for > me. I'm using Django 1.2.1. I'm pretty sur

Re: url lookup not working?

2010-09-01 Thread Daniel Roseman
On Sep 1, 5:43 pm, eiriks wrote: > I'm reading Bennets Practical Django Projects and I'm stuck on chapter > 6, on templates. > > The error I get is: > "Caught an exception while rendering: Could not import > django.views.generic_list_detail. Error was: No module named > generic_list_detail" > with

Re: static files

2010-08-30 Thread Daniel Roseman
On Aug 30, 7:26 pm, Bradley Hintze wrote: > Hi all, > > I have my site on a production server (apache) and am trying to get > static files to be served but cannot get it to work (serving on the > same server). Following the django documentation did not work, I > edited the httpd.conf as described

Re: manage.py: syncdb/sql do not pick up models from custom directory structure

2010-08-30 Thread Daniel Roseman
On Aug 30, 7:46 am, Dan wrote: > On 30 Aug., 08:26, Kenneth Gonsalves wrote:> import > lib.models > > > from lib.models import * - you may get an error here > > Both commands work without giving any error messages. However they do > not actually import anything, since the models reside in sepera

Re: Unable to add two Numbers

2010-08-29 Thread Daniel Roseman
> I have written the code > model.py > from django.db import models > > class Math(models.Model): >    input1 = models.IntegerField() >    input2 = models.IntegerField() >    output = models.IntegerField() > > Views.py file > > from django.template import RequestContext > from django.shortcuts impo

Re: NoReverseMatch error when attempting to spawn an intermediate window from an admin action

2010-08-19 Thread Daniel Roseman
On Aug 19, 9:16 am, Guy wrote: > I am having trouble with learning to use httpresponseredirect and > reverse. > I am trying to generate an admin action on a selection of a list of > items. The purpose is to generate an intermediate window that can be > used to select a new > status for all the obj

Re: Context processor

2010-08-19 Thread Daniel Roseman
On Aug 19, 9:53 am, Pep wrote: > Sorry ! The matter was I believed that an object was in my > context_processor and it wasn't. > > So, I have a new problem which also concern context_processors. Is it > possible to give an argument in a context_processor. > > For example, I have a context_processo

Re: Context processor

2010-08-19 Thread Daniel Roseman
On Aug 19, 8:42 am, Pep wrote: > Hi everybody, > > I would like to use the context processor I wrote with my registration > views. But I don't see how to do it without changing the registration > views ? Somebody has an idea ? > > Thanks ! > > PEP Context processors are automatically applied to a

Re: How to execute some user defined codes (functions) when Django boot?

2010-08-18 Thread Daniel Roseman
On Aug 18, 7:05 am, Tang Daogang wrote: > hi, Emily, > > Let me introduce Scala/Lift as example. > > Every lift project has a file named 'Boot.scala', this file will only > be executed once when this project boots up. In this file, we can > write some initial codes to initial project and some user

Re: select statements with specific fields across multiple tables...

2010-08-17 Thread Daniel Roseman
On Aug 17, 1:57 pm, Cindy wrote: > But that filter will just give me a list of tuples with > RaidPhysicalDrive's values.  I want to understand how I can include > in the list I send to my template, the *additional* values for system > name, storage name, and array name, so I can display/dump > all

Re: Another question: how to apply custom variable into django template automatically?

2010-08-17 Thread Daniel Roseman
On Aug 17, 2:36 am, Tang Daogang wrote: > Dear all, > > I have developed a CMS, which containing a dynamic menu. Because menu > should be displayed on every page of my site, I need to write the menu > variable into every view function against every page template, this is > very boring... > > So is

Re: running a django app on ubuntu linux server

2010-08-15 Thread Daniel Roseman
On Aug 15, 3:58 pm, Himanshu Srivastava wrote: > Hi > I am a newbie > I want to run simple app in ubuntu linux server > when i do manage.py syncdb it works fine > but as i do manage.py runserver > the server starts reloading and nothing happens > How to make it run > Pls answer soon > Regards. Wh

Re: javascript

2010-08-13 Thread Daniel Roseman
On Aug 13, 3:50 pm, Imad Elharoussi wrote: > I mean can we make operations to the DjangoTemplateVariable in the > javascript function >  for example: > function myJavaScriptFunction( pValue ) { > >   {{pValue.getName}} > ... > > } > No. How would that be possible? The template is rendered on the

Re: reading pickled files

2010-08-13 Thread Daniel Roseman
On Aug 12, 4:53 pm, Tony wrote: > This is more of a python question but its in my Django project.  I am > reading a unicode object and an integer from a database into a > dictionnary and storing that in a pickled file.  Ive confirmed the > dictionary is done correctly because i print it out from t

Re: How long do objects live?

2010-08-12 Thread Daniel Roseman
On Aug 12, 2:24 am, Andy wrote: > When I create an object in Django, how long does it live? > > When Django finishes responding to a HTTP request, the Python process > lives on to serve the next request. Does that mean all those objects > that were created would continue to hang around? It depend

Re: do QuerySet joins still suck?

2010-08-10 Thread Daniel Roseman
On Aug 11, 2:28 am, Phlip wrote: > >  orders = Order.objects.filter( > >    pk=42, > >    order_items__product='whiteboards' > >    ) > > > Is this not what you want? > > We made a feeb attempt at that and gave up. Thanks! I will try it next. > > The next question, if it works, will be how to valu

Re: Django 1.1.1's Feed only display the latest item

2010-08-10 Thread Daniel Roseman
On Aug 10, 1:35 pm, Federico Maggi wrote: > On Tue, Aug 10, 2010 at 13:38, Daniel Roseman wrote: > > This was actually an issue with the OP's get_absolute_url method, > > which has been diagnosed on StackOverflow. > >     could you please be more specific (e

Re: Django 1.1.1's Feed only display the latest item

2010-08-10 Thread Daniel Roseman
On Aug 10, 9:04 am, Federico Maggi wrote: > On Tue, Aug 10, 2010 at 09:47, Tomi Pieviläinen wrote: > > As mentioned in the IRC channel, the feed did indeed display two > > items, but because it was invalid markup (based on W3) Safari didn't > > show them properly. > >     I noticed, but has this

Re: filtering related object in template

2010-08-10 Thread Daniel Roseman
On Aug 10, 1:34 am, Martin Tiršel wrote: > Hello, > > I can do: > > {% for image in gallery.image_set.all %} > ... > {% endfor %} > > but my image model has: > is_thumbnail = models.BooleanField() > > and I want to limit displaying only these images which have   > is_thumbnail=True. I can create a

Re: manually add objects to a QuerySet

2010-08-09 Thread Daniel Roseman
On Aug 9, 8:13 am, chefsmart wrote: > I already have the objects in an earlier chunk of the code. I don't > want to hit the database again to get something I already have in > another form. That is what I mean when I say that code like my_qs = > MyModel.objects.filter(pk=obj1.pk) is utterly silly.

Re: Querying in a loop - cached results?

2010-08-08 Thread Daniel Roseman
On Aug 8, 6:03 pm, Nick Arnett wrote: > I'm having a problem that I can't figure out from reading the docs.  I have > a loop that runs the same query every five minutes, to see if there is new > data to process.  However, it doesn't return the new data the second and > subsequent times it loops.  

Re: Filtering and the letter å

2010-08-08 Thread Daniel Roseman
On Aug 8, 1:45 pm, finn wrote: > I am developing a web application for maintaining spellcheck > dictionaries. I have noticed that when I filter database records like > this: > >     words = Word.objects.filter(lemma='male') > > I'll also get 'måle' among the hits. This is also the case for its > u

Re: how to query foreign keys down more than one level

2010-08-07 Thread Daniel Roseman
On Aug 7, 7:47 pm, rmschne wrote: > I have a model like that I would like query down more than one level > (using my nomenclature). > > class Library(models.Model) >   branch=models.CharField(max_length=100) > > class Book(models.Model) >   libraryid=models.ForeignKey(Library,related_name="books")

Re: CheckBoxInput widget: check_test

2010-08-06 Thread Daniel Roseman
On Aug 6, 7:13 pm, lingrlongr wrote: > Having difficulty getting the check_test to work.  Can't find any > examples out there that help.  I'll probably have to give a little > background.  I simplified where able to... > > class Cat: >   name = CharField > > class Category: >   name = ForeignKey(C

Re: queryset field order

2010-08-06 Thread Daniel Roseman
On Aug 6, 6:08 pm, owidjaya wrote: > I checked it and the field order still not the same. > Just to clarify. I want the to do this A.objects.all().values() > and still get the each list in the result to have the same "field > order" as the database table defined. `values()` returns a set of dicti

Re: For tag fails in template

2010-08-06 Thread Daniel Roseman
On Aug 6, 5:46 pm, kostia wrote: > What is wrong? > > My view function: > def project(request, project_id): > >     try: > >         project_id = int(project_id) > >     except ValueError: > >         raise Http404 > >     myProject = get_object_or_404(Project, id = project_id) >     events = Even

Re: HttpResponseRedirect

2010-08-06 Thread Daniel Roseman
On Aug 6, 1:33 pm, bagheera wrote: > I have two pages with two different forms. Each, if validated, redirects   > to "thanks" page. I want to customize this behavior, so "thanks" page   > should display different message, regarding witch form was invoked, or   > redirects to "/' if no redirection

Re: How to get the model name of an object in template?

2010-08-05 Thread Daniel Roseman
On Aug 4, 7:27 pm, "David.D" wrote: > I just wonder if there's some way requires writing nothing. Just like > an attribute. > > thanks. Yes, there is. Each model and model instance object has a _meta attribute, which contains information about the model - the .app_label, object_name and .verbose_

Re: Flexible relationships - tips/advice?

2010-08-05 Thread Daniel Roseman
On Aug 5, 12:32 am, v0idnull wrote: > I want to be able to link one model to another model, regardless of > what models they are. Articles can be related to Photos, Videos, other > Articles, etc etc etc. > > I have created a Relationship model to represent these relationships, > but I'm unsure if

Re: Forms and 'prefix' parameter

2010-08-05 Thread Daniel Roseman
On Aug 5, 7:16 am, Ed Schofield wrote: > On Aug 5, 2:23 pm, Karen Tracey wrote: > > > > > > > On Thu, Aug 5, 2010 at 12:10 AM, Ed Schofield wrote: > > > Hi everyone, > > > > I'm trying to use a view with multiple forms under Django 1.2.1. I'm > > > puzzled that the prefix parameter seems to scre

Re: View Decorator

2010-08-04 Thread Daniel Roseman
On Aug 4, 2:15 pm, Dan Gentry wrote: > I'm trying to move some code from a view to a decorator to use with > many views.  This is the view: > > views.py: > def list_type(request): > >     inst_id=request.session.get('inst_id',None) > >     ## move to decorator >     if not inst_id: >         path

Re: Must I put the rules logic on Python or Django code and why?

2010-08-04 Thread Daniel Roseman
On Aug 4, 2:38 pm, André A. Santos wrote: > Hello friends, > this is André AS from São Paulo-Brazil, total beginner to Python > technologies, I am working on a project that uses those we are > converting all those to Java, so I would like to know where I must put the > logic rules I am a little co

Re: problem : create form

2010-08-04 Thread Daniel Roseman
On Aug 4, 9:19 am, Jagdeep Singh Malhi wrote: > i follow these documentation for create form > > http://docs.djangoproject.com/en/dev/topics/forms/ > > i use command for create application > #python manage.py startapp form > > after this a use this code in model.py file > > from django import form

Re: Need help setting up dynamic options for select (drop down) box of form.

2010-08-03 Thread Daniel Roseman
On Aug 3, 5:04 am, Chris Seberino wrote: > I'm trying to make the options of a particular drop down box be > determined at runtime. > > I added a __init__ constructor to my django.forms.Form subclass as > follows... > >         def __init__(self, >                            data                =

Re: passing a keyword argument from form to a field in that form

2010-08-03 Thread Daniel Roseman
On Aug 2, 11:06 pm, Jim wrote: > Hello, > > I have a custom field whose behavior depends on a parameter show_all. > (It makes the field pull from the database for display only those > keywords where show=True.) > >     class KeywordsField(forms.ChoiceField): >         def __init__(self, choices=()

Re: return pk id on Form

2010-08-02 Thread Daniel Roseman
On Aug 2, 3:27 pm, alan-l wrote: > Hi, > i have the below that im thought would be the best approach to have a > add contact page on my app: > > class ContactForm(ModelForm): >     class Meta: >         model = Contacts >         fields = ('contact_type', 'firstname', 'surname', 'notes') > > def a

Re: RadioButton Form Validation

2010-08-02 Thread Daniel Roseman
On Aug 2, 2:46 pm, rupert wrote: > I have a form that validates all of the fields except for radio > buttons. If there is a radio button not selected, it will reset the > form. Any thoughts? Has anyone run into this before? Show some code... -- DR. -- You received this message because you are s

Re: JSON reponseText is undefined

2010-08-01 Thread Daniel Roseman
On Aug 1, 8:54 am, Himanshu Srivastava wrote: > Hi > I am sending  a Json data from django on an ajax call as A > HttpResponse but i get it as undefined when i try to access it in > javascript > The code is as follows\ > > Views.py > > data=simplejson.dump(dic) > return HttpResponse(data,mimetype=

Re: django-admin.py not working

2010-08-01 Thread Daniel Roseman
On Jul 31, 3:41 pm, ginost7 wrote: > Im using ubuntu > > I managed to get through the poll project working on the django tut. >  then tried another project > > At the prompt i get > > g...@gino-laptop:~/djangoDEV$ django-admin > The program 'django-admin' is currently not installed.  You can > ins

Re: How do I populate a multi-select field with a single column from a model?

2010-07-31 Thread Daniel Roseman
On Jul 31, 10:07 am, strayhand wrote: > I want to grab a single column in a model and use it to populate a > multi-select form field. Here's the code that I'm currently using: > > areas = forms.ModelMultipleChoiceField(queryset=Area.objects.all(), > label='Preferred Areas', help_text='Select the a

Re: UnicodeEncodeError

2010-07-31 Thread Daniel Roseman
On Jul 30, 11:17 pm, EricBrian wrote: > Daniel, if I don't do that, I get the unicode error in the list of > dashboards in the admin section. > You'd better post the traceback for that, then. Just to be clear, your method should look like this: def __unicode__(self): return self.nam

Re: Form Validation

2010-07-30 Thread Daniel Roseman
On Jul 30, 4:49 pm, rupert wrote: > Here's the view template: > > def respondant(request): > >         user = request.user > >         if set(RESPONDANT_FIELDS).issubset(set([key for key,value in > request.POST.items()])): >                 form = RespondantForm(request.POST) >                 if

Re: Form Validation

2010-07-30 Thread Daniel Roseman
On Jul 30, 4:42 pm, rupert wrote: > I'm trying to use this line of code in form validation, and it is not > working: > > {{ form.field_name.errors }} > > The following lines do output: > {{ form.filed_name}} > {{ form.field_name.help_text }} > > Any thoughts? Could it be something in the view? Ve

Re: Raw sql and admin site

2010-07-30 Thread Daniel Roseman
On Jul 29, 11:38 pm, Spoksss wrote: > Hi, > > I try to use raw sql in admin site, it is possible somehow? > > I use postresql and have some problem with ordering. > > I have in database something like: > Category(id=1, name='first', parent_category=None, > materialised_path='1') > Category(id=2, n

Re: test's client.post says post but request.method says GET

2010-07-30 Thread Daniel Roseman
On Jul 30, 1:18 am, Phlip wrote: > Django aficionados: > > Here's my test code: > >         from django.test.client import Client >         self.client = Client() >         from django.core.files.base import ContentFile >         file_content = ContentFile(sample_inventory_update_cvs()) >        

Re: UnicodeEncodeError

2010-07-30 Thread Daniel Roseman
On Jul 29, 11:27 pm, Eric wrote: > I am getting this error in the Django Administration section when I > add an entry for a Dashboard object. > > When I return to the item in the Admin section, the record has been > added and it displays correctly in the list of Dashboard objects. When > I click o

Re: When doing select_related, the sql query produced is an INNER JOIN can that be changed to LEFT JOIN

2010-07-29 Thread Daniel Roseman
On Jul 29, 8:49 pm, thusjanthan wrote: > Hi, > > I have the following relation: > > class Email(models.Model): >     id = models.CharField(max_length=15,primary_key=True) > > ... > > class Person(models.Model): >     id= models.CharField(max_length=15,primary_key=True) >     email = models.Foreign

<    5   6   7   8   9   10   11   12   13   14   >