Import models from CSV files?

2009-01-05 Thread Victor Hooi
heya, This question might seem a bit simple, but what's the best way to instantiate models from .csv files? Essentially, I have two .csv files. One contains a list of people, and their access rights (one-to-many). The second .csv file contains a log of doorway access (just a bunch of sequential

Re: Import models from CSV files?

2009-01-06 Thread Victor Hooi
gt; > Best regards, > -- > Valts > > On Tue, Jan 6, 2009 at 07:02, Victor Hooi wrote: > > > heya, > > > This question might seem a bit simple, but what's the best way to > > instantiate models from .csv files? > > > Essentially, I have two .csv

Re: Import models from CSV files?

2009-01-06 Thread Victor Hooi
heya, Whoops...forgot. I'm also confused on the recommended way to deal with duplicates? (not duplicate .csv files, but duplicate entries, perhaps in two different ones.). Just do a plain search for each entry? Or is there a better way? On Jan 7, 11:55 am, Victor Hooi wrote: > heya, &

Re: Import models from CSV files?

2009-01-07 Thread Victor Hooi
e them > based on setting). You can also specify a subset of model fields to > use to determine whether a given row represents a duplicate. This > allows for "batch update" too. > > If you get into it and have any problems, drop me a note. > > Keyton > > On Jan 6, 12

http://jacobian.org/tags/ - Source?

2009-08-17 Thread Victor Hooi
heya, I was just wondering if anybody knew if the source to the tagging/ bookmarking part of Jacob's site has been made available? http://jacobian.org/tags/ Or if there's any other django projects that provide something similar? It seems fairly simple, but it's quite well done, and I was just h

Re: http://jacobian.org/tags/ - Source?

2009-08-22 Thread Victor Hooi
presented/organised on his site. Just thought there might be existing open source for it floating around somewhere, or something similar. Ah well, maybe it'll be fun to build. Anybody else have thoughts? Cheers, Victor On Aug 18, 11:44 am, Joshua Partogi wrote: > On Tue, Aug 18, 2009 a

Django ORM and Google Gears (or alternatives?)

2009-08-22 Thread Victor Hooi
heya, I've got a small project involving an ordering system web application. One of the requirements is offline functionality (i.e. it will function without a direct internet connection, at least on a limited scale - e.g. they can search their previous orders, and submit orders, with a cached pri

Re: NetBeans IDE for Python

2009-04-14 Thread Victor Hooi
heya, I'm still a bit confused as to how to setup Django to work with Netbeans. I'm using Netbeans 6.7 M3 from here: http://bits.netbeans.org/download/6.7/m3/ I've created a new Django project using django-admin, e.g.: django-admin.py startproject testproject and then I'm creating a new "Pyt

models.py - __unicode() - Access related object's attributes?

2009-10-27 Thread Victor Hooi
heya, In my models.py, I've got an "Address", as well as an abstract "Trip" object, and then a "ToTrip", and "ReturnTrip" object that derive from that. ToTrip and ReturnTrip both contain references to two Address objects (models.ForeignKey). class Address(models.Model): description = models.

Re: models.py - __unicode() - Access related object's attributes?

2009-10-27 Thread Victor Hooi
Cheers, Victor On Oct 28, 3:11 am, Daniel Roseman wrote: > On Oct 27, 2:49 pm, Victor Hooi wrote: > > > > > heya, > > > In my models.py, I've got an "Address", as well as an abstract "Trip" > > object, and then a "ToTrip", and &q

Using SOAP-API as Model?

2009-12-03 Thread Victor Hooi
heya, We need to make a web-frontend for listing and adding items to a YSM (Yahoo Search Marketing) account. These would include things like new sub-accounts, new campaigns, keywords etc. You can check/edit these items through a SOAP API. At the moment, I'm using the SUDS library to manage these (

UserProfile and Admin interface

2009-12-08 Thread Victor Hooi
heya, I'm having issues extending Django's user model via UserProfile, and then editing this through the admin interface. Essentially, what I want is to add some extra fields to the User model (I've called this model "Person"), and be able to edit these along with the normal User attributes inline

Re: UserProfile and Admin interface

2009-12-08 Thread Victor Hooi
guess profiles is the way to go, but I'm trying to find a more intuitive way to deal with it all. Cheers, Victor On Dec 9, 2:53 pm, Victor Hooi wrote: > heya, > > I'm having issues extending Django's user model via UserProfile, and > then editing this through the admin

Re: UserProfile and Admin interface

2009-12-08 Thread Victor Hooi
ictor On Dec 9, 3:24 pm, Victor Hooi wrote: > heya, > > Well, now that was a bit silly of me. > > I just noticed that I was importing with "from > django.contrib.auth.admin import UserAdmin", but then I was calling > "admin.UserAdmin" below, rather than "

FK to an Abstract class? Alternative?

2009-12-15 Thread Victor Hooi
heya, We have a small project where we need to store a series of exam results for students. Some exams receive a grade out of 100, others are simply a pass/fail, while others are given a one-word grade (e.g. pass, fail, credit, distinction). In a sense, they all do map to a 0 to 100 scale (e.g.

Generic Inlines in Admin - Causes Parent model to disappear in Admin

2009-12-22 Thread Victor Hooi
heya, I have an address object, which is setup as a generic relation. class Address(models.Model): street_address = models.CharField(max_length=50) ... (etc.) content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() conten

Re: Generic Inlines in Admin - Causes Parent model to disappear in Admin

2009-12-23 Thread Victor Hooi
Dec 23, 10:16 pm, Daniel Roseman wrote: > On Dec 23, 5:41 am, Victor Hooi wrote: > > >     class AddressInline(generic.GenericTabularInline): > >         models = Address > > Is that just a typo here, or do you actually have it as 'models' in > your code? It sho

Re: Inline and ForeignKeys - Weird ordering?

2010-04-15 Thread Victor Hooi
o popup a new window. Anyhow, I suppose when I create custom forms or extend the admin, I could do that, but otherwise it's not that big a deal. Cheers, Victor On Apr 15, 9:23 pm, Karen Tracey wrote: > On Thu, Apr 15, 2010 at 3:24 AM, Victor Hooi wrote: > > However, I still wanted some

Django Admin - m2m widget with blank=true, null=true - How to unselect all FKs?

2010-04-18 Thread Victor Hooi
Hi, I have a field in a model which is set to null/blank = True firm = models.ManyToManyField(Firm, null=True, blank=True) I tried using the default m2m filter, however, I wasn't sure how to unselect an entry. I also tried using filter_horizontal, and this was much more intuitive/ niftier.

Re: Django Admin - m2m widget with blank=true, null=true - How to unselect all FKs?

2010-04-18 Thread Victor Hooi
Jani, Aha, that worked, thanks =). Don't know why I didn't think about using Ctrl...lol. However, do you think it'd be obvious to new users, to use ctrl? Cheers, Victor On Apr 19, 2:46 pm, Jani Tiainen wrote: > On 04/19/2010 06:58 AM, Victor Hooi wrote: > > > >

Where to set proxy settings for Django?

2010-04-18 Thread Victor Hooi
heya, This is a fairly trivial thing, but anyhow: We're working on a Django app behind a corporate proxy/firewall. We have a model with URLField, and by default, verify_true is false. So of course, Django wants to punch out to the web to check if the URL exists. Now if I define "http_proxy" befo

Re: Django Admin - m2m widget with blank=true, null=true - How to unselect all FKs?

2010-04-19 Thread Victor Hooi
nd there is quite little you can do about it. > > -- > > Jani Tiainen > > On 04/19/2010 08:45 AM, Victor Hooi wrote: > > > > > > > Jani, > > > Aha, that worked, thanks =). > > > Don't know why I didn't think about using Ctrl...lol. >

M2M with Intermediary - Django Admin Support - Doesn't appear?

2010-05-13 Thread Victor Hooi
heya, I have a Django app that keeps track of newspapers articles, and the companies mentioned in them (this is slightly simplified, but it' Each article has a m2m relationship with firm. Originally, this was just a direct m2m, however, I found I needed to add a "rating" to each firm that's menti

PostgreSQL backend - Ident authentication failed?

2010-06-20 Thread Victor Hooi
Hi, We have a Django application that we just moved from a Ubuntu 9.04 server to 10.04. We're running Apache 2.2/WSGI, with PostgreSQL as the backend. My settings.py file: 'DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_ps

Re: PostgreSQL backend - Ident authentication failed?

2010-06-20 Thread Victor Hooi
ver using verbatim (rsync). Also, is this recommended practice, to use "www-data" as the backend database username? Cheers, Victor On Jun 21, 3:54 pm, Torsten Bronger wrote: > Hall chen! > > Victor Hooi writes: > > [...] > > > I created a blank PostgreSQL database

Re: PostgreSQL backend - Ident authentication failed?

2010-06-21 Thread Victor Hooi
#x27;t any such change, although I don't have a 9.04 system around to verify. Anyhow, is this the recommended configuration, what I have now? Just want to know the right way of doing things? Cheers, Victor On Jun 21, 4:54 pm, Torsten Bronger wrote: > Hall chen! > > Victor Hooi writ

Apache + Gunicorn + Django? Sample Configs?

2010-06-21 Thread Victor Hooi
Hi, I'm currently deploying Django on Apache with WSGI. Anyhow, I've heard really good things about the Gunicorn (http:// gunicorn.org/) WSGI server, so I was hoping to try it out. I'm running Ubuntu 10.04, so I've installed the packages from the official PPA (https://launchpad.net/~bchesneau/+a

Re: M2M with Intermediary - Django Admin Support - Doesn't appear?

2010-06-24 Thread Victor Hooi
heya, Nuno: Thanks for the advice. I know how to add normal inlines to the home page for a model, via the "inlines" list in admin.py. However, how exactly do I add an inline formset to the Add Article page? I can override the template for the Add Article page, however, I don't think that's what

m2m with intermediary - model design? Disappears from Django-Admin?

2010-06-24 Thread Victor Hooi
heya, NB: This is a followup to this: http://groups.google.com/group/django-users/browse_thread/thread/0fdc1dfb1fddb97b/6b559dc4abf5d4ea but I thought I'd also ask about the model design. To provide some background, we have a Django app that contains a list of journal articles. Each "Article"

Re: m2m with intermediary - model design? Disappears from Django-Admin?

2010-06-24 Thread Victor Hooi
name', 'subject__name', 'source_publication__name', 'page_number', 'url') However, there's still no visible widget for "FirmRating" on the "Add Article" page. I can't tell just from the docs, but is this inline o

Re: m2m with intermediary - model design? Disappears from Django-Admin?

2010-06-24 Thread Victor Hooi
e that in my inline, it says "FirmRating object" right above the select box:' http://twitpic.com/1zo4im/full Any way to hide/tweak that text? Cheers, Victor On Jun 25, 10:09 am, Victor Hooi wrote: > heya, > > Also, I should add I did try using the inlines as described in the &

Re: m2m with intermediary - model design? Disappears from Django-Admin?

2010-06-24 Thread Victor Hooi
rib/admin/#modeladmin-me...). > > As for the name "FirmRating object", define a unicode method on your > class, eg: > > def __unicode__(self): >     return "%s - %s: %s) % (self.article, self.firm, self.rating) > > Cheers, > Brenton > > On Jun 25, 10:

Django-Admin - radio_fields with add/change pages, but not list_display page?

2010-06-29 Thread Victor Hooi
Hi, I have a Django application with an "Article" model. I'm using the radio_fields in django-admin with two of the ForeignKey fields that are linked to Article. Currently the related tables have five and twenty entries each, so this UI works quite well on the Add/Change pages. However, I'm also

Newbie Question - django-jython - how to "run" the app?

2010-07-01 Thread Victor Hooi
heya, I've trying to get my Django app to run on a Tomcat 5.x server, using django-jython. I'm a bit of a newbie in the Java/Tomcat world though. Firstly, I'm currently using PostgreSQL. However, to make things easier on the target server, I was just going to use SQLite3 - the app will only be us

Error in Admin - can't seem to chain __unicode__'s for ForeignKeys

2010-07-08 Thread Victor Hooi
heya, I have a small Django app that contains a list of Df (disk-free) reports. "DfReport" has a ForeignKey to "Filesystem" model, which has a ForeignKey to "Device". (i.e. Devices has filesystems, each filesystem has a DfReport). I'm getting an error in the admin when I attempt to display the l

Model Validation - Prevent Datetimefield overlaps?

2010-08-30 Thread Victor Hooi
heya, I have a model that contains a whole bunch of bytes in/out for datetime ranges. I.e.: class BandwidthUsageEntry(models.Model): start_of_usage_block = models.DateTimeField() end_of_usage_block = models.DateTimeField() bytes_in = models.IntegerField() bytes_out = models.Intege

Using localflavor with admin?

2010-10-27 Thread Victor Hooi
Hi, Is there any way to combine the localflavor module (http:// docs.djangoproject.com/en/dev/ref/contrib/localflavor/) with Django's in-built admin module? For example, I'd like to create a model with say, a Postcode and phone- number field, and have these validated in the admin, as per the rule

Converting Django to Desktop App? (Multiple Instances)

2010-10-29 Thread Victor Hooi
Hi, This is a bit of a strange scenario. We have a simple Django application used to maintain a database of newspaper/journal articles. We're extensively using the django-admin as part of this app. Currently, we're having issues getting a production environment with Python provisioned (corporate

Re: Using localflavor with admin?

2010-11-01 Thread Victor Hooi
ustralia: http://code.djangoproject.com/browser/django/trunk/django/contrib/localflavor/au Is there a particular reason for this? Or any way of achieving the same effect? Cheers, Victor On Oct 29, 5:48 am, Frank Wiles wrote: > On Thu, Oct 28, 2010 at 12:23 AM, Victor Hooi wrote: > > Hi, > >

Reverse Query Name Clash?

2010-11-01 Thread Victor Hooi
Hi, I'm getting a error about reverse query name clashes with my models. We have a Django app to manage conferences and conference attendees. In our models.py, two of the models we have are: 1. Person, representing people attending people attending a conference. Each person also has a "church"

Re: Using localflavor with admin?

2010-11-01 Thread Victor Hooi
er/django/trunk/django/contrib/localflavor/au Is there a particular reason for this? Or any way of achieving the same effect? On Oct 29, 5:48 am, Frank Wiles wrote: > On Thu, Oct 28, 2010 at 12:23 AM, Victor Hooi wrote: > > Hi, > > > Is there any way to combine the localflavor m

ReportLab and Django - templates? ; FK object has no attribute split

2010-11-17 Thread Victor Hooi
Hi, I'm trying to use ReportLab to produce a PDF output for one of my views. My first question is - at the moment, I'm building up the PDF inside my view. Is this really the recommended way of doing it? It's like I've got presentation code inside my view (controller). Isn't there a cleaner way of

Re: ReportLab and Django - templates? ; FK object has no attribute split

2010-11-18 Thread Victor Hooi
>   You might want to take a look, it worked well enough for simple PDF pages. > >   Cheers > >     Jirka > > On 18/11/2010, Victor Hooi wrote: > > > > > > > > > Hi, > > > I'm trying to use ReportLab to produce a PDF output for one of my &

Serve different page to IE7/8?

2010-11-21 Thread Victor Hooi
Hi, We're currently development a small Django webapp for use internally. The page renders fine on Firefox and Webkit-based browsers. However, many of our users are still on Internet Explorer 7, and the CSS/HTML we're using seems to bork really badly on that. I'm definitely not a web-designer by

Django - Alternative to using NULLs? (for integer and FK fields).

2010-11-29 Thread Victor Hooi
Hi, I'm wondering what the community's stance on using NULL in Django is? Say for example you have: class Person(models.Model): street_address = models.CharField(max_length=50, blank=True) suburb = models.CharField(max_length=30) postcode = models.IntegerField()

Re: Django - Alternative to using NULLs? (for integer and FK fields).

2010-11-29 Thread Victor Hooi
On Nov 30, 3:11 pm, Lachlan Musicman wrote: > On Tue, Nov 30, 2010 at 12:28, Victor Hooi wrote: > > Hi, > > > I'm wondering what the community's stance on using NULL in Django is? > > > Say for example you have: > > >    class Person(models.Model)

Issues importing models in between apps

2010-11-29 Thread Victor Hooi
Hi, I had an application with a fairly large models.py file, which I split up into separate apps to make it easier to manage. Two of the apps are called "conferences" and "people", each with their own models.py. These two are fairly tightly entwined, they each refer to each other. At the top of

Re: Django - Alternative to using NULLs? (for integer and FK fields).

2010-11-29 Thread Victor Hooi
can make sure I'm on the same page? Cheers, Victor On Nov 30, 5:02 pm, Mike Dewhirst wrote: > On 30/11/2010 4:26pm, Victor Hooi wrote: > > > heya, > > > Phone Number - Yup, you're both right, I'll be using CharField now, > > and model validation to make

Re: Issues importing models in between apps

2010-11-30 Thread Victor Hooi
-models-in-separate-files/ However, I'll need to add a Meta/app_label to each and every single model in that file - is that right? Or is there a better way of splitting up a models.py file across multiple files, or of somehow organising this? Cheers, Victor On Nov 30, 10:44 pm, bruno desth

Re: Issues importing models in between apps

2010-11-30 Thread Victor Hooi
recommend, to make the design more logical and the models.py less unwieldly/large? Cheers, Victor On Nov 30, 10:44 pm, bruno desthuilliers wrote: > On 30 nov, 07:01, Victor Hooi wrote: > > > Hi, > > > I had an application with a fairly large models.py file, which I split > &g

django-extensions - "Error: no module named django_extensions"

2010-12-08 Thread Victor Hooi
heya, I original thought to post this in the django-extensions group, however that seems like a fairly low-traffic group, so I thought I'd post here in the hopes somebody here might be able to figure it out. Basically, I've installed django-extensions via Pip pip install django-extensions Whene

Re: django-extensions - "Error: no module named django_extensions"

2010-12-08 Thread Victor Hooi
heya, Thanks for the reply. I'm fairly sure it is in the PYTHONPATH. I'm using virtualenvs and pip to install, so it should be there in the system-wide Python directory for that environment. Also, as per my first post, I can import it fine from a Python shell, it's just it seems to act up wit

Generic Relations and Django Admin?

2010-01-18 Thread Victor Hooi
heya, I'm trying to use an "Address" model as a generic relation against multiple other models (e.g. in a "User Profile", for each User, as well as for "Building", "Institution", and various other ones). So I've added the content_type, object_id and content_object fields to Address. class Addres

Re: Generic Relations and Django Admin?

2010-01-19 Thread Victor Hooi
dels.ForeignKey(UserProfile) but that doesn't work for hospitals, or say institutions, or anything else that needs an address. So I can't just pick one. Or is my design off? Cheers, Victor On Jan 19, 6:03 pm, greatlemer wrote: > On Jan 19, 5:25 am, Victor Hooi wrote: > > > > >

Re: Generic Relations and Django Admin?

2010-01-19 Thread Victor Hooi
filled. How do people normally do this sort of thing, with a polymorphic object that's referenced by multiple other objects? Cheers, Victor On Jan 19, 5:59 pm, Raffaele Salmaso wrote: > Victor Hooi wrote: > > class AddressAdmin(VersionAdmin): > >     pass > > class A

Re: Generic Relations and Django Admin?

2010-01-20 Thread Victor Hooi
t; > class Hostpital(models.Model): >     name = models.CharField(max_length=20) >     address = ForeignKey(Address) > > class YourUserClass(models.Model): >     # all kinds of fields >     address = ForeignKey(Address) > > Using Django's ORM system you then can get related

Re: Generic Relations and Django Admin?

2010-01-20 Thread Victor Hooi
this? (The traceback in the ticket is quite different to the traceback I'm getting). Cheers, Victor Cheers, Victor On Jan 19, 9:55 pm, Daniel Roseman wrote: > On Jan 19, 10:35 am, Victor Hooi wrote: > > > heya, > > > Thanks for the reply =). > > > I tried th

Fixtures Initial Data - Split Into Multiple Files?

2010-01-20 Thread Victor Hooi
heya, This is a small question, is there any way for the initial_data.json/ xml/sql file to reference other files, or split it up across multiple files? Basically, I want to split up my existing monolithic files, into a separate json file for each section (I'm basically using this to populate all

Scripting Import of CSV data?

2010-02-23 Thread Victor Hooi
heya, I have a Django app that will need to grab CSV data being sent to an email address into it's own database. I'm assuming if I can get IMAP access to the mailbox, I can just script all of that part in Python. However, what's the best way of scheduling the process, so that it'll regularly chec

Tagging - Extending by adding a rating?

2010-03-21 Thread Victor Hooi
heya, I have a small Django app we're writing to hold reviews of newspaper articles. With each article, there's an arbitrary number of companies or keywords associated with those articles. And for each of those companies/keywords, there's either a rating (out of 10), or possibly no rating (i.e. N

Re: Tagging - Extending by adding a rating?

2010-03-21 Thread Victor Hooi
ith an intermediary model holding the ratings: > > http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-o... > > - Paulo > > > > On Mon, Mar 22, 2010 at 2:41 AM, Victor Hooi wrote: > > heya, > > > I have a small Django app we're writing to hold

Re: Tagging - Extending by adding a rating?

2010-04-06 Thread Victor Hooi
his TaggedItem model, through a Ratings intermediary table. I > have no idea if that would work (and keep all the django-tagging features), > but that's something you can look into. > > Best, > Paulo > > > > On Mon, Mar 22, 2010 at 3:21 AM, Victor Hooi wrote: &

DB Adapter for HTML5 Client Database Storage?

2010-04-07 Thread Victor Hooi
heya, This is a bit of random musing, but I was wondering, how big a project is it to write a DB adapter for the Client-side Client-side Database Storage API in HTML5? That is, there are already efforts to integrate in things like CouchDB and MongoDB models, surely using HTML5's client-side Stora

Inline and ForeignKeys - Weird ordering?

2010-04-14 Thread Victor Hooi
heya, We're creating a small app to manage data-entry of publicat articles in Django. Each article has a category, a subject, a list of firms (as in the companies mentioned), etc. I'm trying to add firm as an inline to article, however, I think I've got the ordered in the model all wrong, as it'

Re: Inline and ForeignKeys - Weird ordering?

2010-04-15 Thread Victor Hooi
ines here, and having the "Add Firm" embedded on that page (without having to open a new window), or should I reverse the way my FK is? Cheers, Victor On Apr 15, 3:58 pm, Victor Hooi wrote: > heya, > > We're creating a small app to manage data-entry of publicat article

Re: Anyone want to take over maintaining Instant Django?

2012-02-26 Thread Victor Hooi
Hi, Whatever happened to this? @sidmitra - did you manage to take over maintainership of this project? If not, @cjl - do you still have the scripts for this? Cheers, Victor On Thursday, 15 July 2010 23:25:44 UTC+10, sidmitra wrote: > > > I would be willing to take it on or we can also do it as

Bulk Creating Django Models from CSV File?

2012-04-01 Thread Victor Hooi
Hi, I have several large CSV files that I'm hoping to parse, and use to create Django objects. Each line looks might look something like this: "Server Hostname", "Classification", "Country", "Operating System" "foo.bar.com", "Prod", "Australia", "Solaris" "alex.john.com", "Dev", "UK", "Linux"

Python-requests seems to 404 with Django/Tasty-pie?

2012-10-02 Thread Victor Hooi
Hi, I have a Django app that's serving up a RESTful API using tasty-pie. I'm using Django's development runserver to test. When I access it via a browser it works fine, and using Curl also works fine: curl "http://localhost:8000/api/v1/host/?name__regex=&format=json"; On the console with run

Re: Python-requests seems to 404 with Django/Tasty-pie?

2012-10-02 Thread Victor Hooi
test connection shows; > > foxx@test01.internal [~] > nc -p8000 -l > GET /api/v1/host/?name__regex=&format=json HTTP/1.1 > Host: localhost:8000 > Accept-Encoding: identity, deflate, compress, gzip > Accept: */* > User-Agent: python-requests/0.11.1 > > So, from

set_test_cookie() on every page?

2011-09-29 Thread Victor Hooi
Hi, I've read the Django docs on setting test cookies (https://docs.djangoproject.com/en/dev/topics/http/sessions/#setting-test-cookies), and I'm still a bit confused. One of our views sets a session variable to remember the object a user is currently viewing (we figured it wasn't worth stori

View decorator for common navigation elements?

2011-09-29 Thread Victor Hooi
Hi, We have a common navigation bar on nearly every page (view) that contains a dropdown - this dropdown is populated with items from a database table. This dropdown also has AJAX behaviour attached to it. I'm thinking I can create a decorator that will retrieve the list from the database, and

Re: set_test_cookie() on every page?

2011-09-30 Thread Victor Hooi
heya, John - thanks for the reply. In this case, it's an JQuery .post() call linked to a dropdown menu (https://groups.google.com/d/topic/django-users/tw0lM-QkdGw/discussion). The dropdown is a common navigation element on every page. It's used to set a session variable that stores which objec

Re: View decorator for common navigation elements?

2011-09-30 Thread Victor Hooi
heya, I do like the idea of just including a custom template tag =). Hmm, can custom template tags interact with models or query the database like that? Firstly, Is it possible, and secondly, is it considered good practice? Cheers, Victor -- You received this message because you are subscri

__unicode__ and u'%s'?

2011-10-01 Thread Victor Hooi
heya, What's the recommended best practice for printing model fields in __unicode__? Currently, I'm using (simply because the Django docs do): def __unicode__(self): return u'%s' % (self.name) What's the rationale behind using the unicode literal u'%s'? Is it always needed, versus

Re: View decorator for common navigation elements?

2011-10-02 Thread Victor Hooi
heya, This SO post seems to suggest that data and template tags shouldn't mix... http://stackoverflow.com/questions/5046046/where-put-database-interaction-in-django-templatetags Not sure how I feel about that myself - I see the philosophical argument behind it, but I don't see another more effi

Using render() with Form?

2011-10-03 Thread Victor Hooi
heya, I was previously using the following to render a form: from django.shortcuts import render_to_response, RequestContext ... def upload_file(request): ... return render_to_response('upload_form.html', {'form': form}, context_instance=RequestContext(request)) I can confirm that this works fi

Re: Using render() with Form?

2011-10-03 Thread Victor Hooi
heya, Aha, thanks guys. I can confirm that works fine now. That'll teach me to read the API docs a bit better...lol, I just assumed it was a 1-to-1 swap with render_to_response, didn't check the arguments =). Cheers, Victor -- You received this message because you are subscribed to the Google

Import CSV to create multiple Models - Model Manager or in View?

2011-10-03 Thread Victor Hooi
heya, I'm coding up a Django form which will let the user upload a CSV file, then create and save multiple Model instances for each row in the CSV file. At the moment, I'm trying to decide where to put the code that parses the CSV file and creates/saves the models. I don't think it'd be an ins

Re: Import CSV to create multiple Models - Model Manager or in View?

2011-10-03 Thread Victor Hooi
heya, @Shawn: Hmm, that looks like quite an interesting approach - so the ModelForm would handle the validation logic? =) Me likes! Haha. I can parse the CSV and get the field names to match up (or just do a simple transform to get them to match). However, how do I then pass this information i

TemplateView compatible with permission_required decorator?

2011-10-05 Thread Victor Hooi
Hi, I'm attempting to use one of the new class-based TemplateView with the permission_required decorator: @permission_required('foo.count_peas') class Pea(TemplateView): template_name = "pea.html" However, when I do that, I get an error: Exception Type: AttributeError at /someurl/ Exceptio

Permission_require decorator, and redirecting to Login Page

2011-10-05 Thread Victor Hooi
heya, I'm using the permission-required decorator with the inbuilt login view. When I login as a user who has the appropriate permissions, it logs in fine, and all is good. When I try to login as a user with valid credentials but lacking the appropriate permission, it simply keeps redirecting

Re: Django - how to create a private subpage?

2011-10-11 Thread Victor Hooi
heya, I might be misunderstanding your requriements, but could you use the @user_passes_test decorator with a has_perm check? @user_passes_test(lambda u: u.has_perm('private_pages.foo')) https://docs.djangoproject.com/en/dev/topics/auth/ You can probably make the lambda a bit smarter, instead

Storing regex raw string literal in Django model?

2011-10-13 Thread Victor Hooi
Hi, I have Django model and in one of the fields I need to store a regex string that I can later use. class Foo(models.Model): name = models.CharField(max_length=30, unique=True) regex_string = models.TextField() So for example, the regex_string field might be set to: r'\d{2}' I the

Changes to default project layout?

2011-11-08 Thread Victor Hooi
heya, *NB: Not sure if this belongs in dev or general, but I'm assuming here - please let me know if I'm wrong.* I just noticed there was a change made to startproject/startapp, and the default Django layout in trunk (yes, I'm a bit behind the curve...haha). https://code.djangoproject.com/chan

Re: Changes to default project layout?

2011-11-08 Thread Victor Hooi
heya, Also, I noticed that there's no models.py file in the first app that startproject creates - I assume this is by design, right? Hmm, what's the rationale behind it? Cheers, Victor -- You received this message because you are subscribed to the Google Groups "Django users" group. To view

Django

2011-12-01 Thread Victor Hooi
Hi, I'm writing a Django application to mange some XML configuration files through the Django-admin. Currently, I'm converting the XML values/hierarchies into Django models. After this, we also need to code an import - to import in configuration files and populate Django models based on them,

Re: Django

2011-12-01 Thread Victor Hooi
heya, Damn, I didn't edit the subject - apologies - if there's a moderator, can you change it to "Using Django to edit XML configuration files" please? Thanks, Victor -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on

Re: Django

2011-12-02 Thread Victor Hooi
Hi, The XML files are all configuration files, storing things like boolean configuration flags, timeout values, username/passwords, IP addresses and ports etc. Some of them will maps somewhat logically to the relational model - for example, they'll be a configuration for an application, as wel

Re: Bulk import of data

2011-12-05 Thread Victor Hooi
heya, Hmm, I was previously under the impression that for these sorts of things (importing and instantiating models from CSV), the recommended way to create a ModelForm, and pass each line of the CSV through that, and have that handle model validation for you. In our case, we have a CSV file,

Django Forms and Twitter Bootstrap - Add fieldset, div wrapper and CSS labels to Django Forms?

2011-12-11 Thread Victor Hooi
Hi, I'm attempting to use Django forms with Twitter's CSS library Bootstrap (http://twitter.github.com/bootstrap/): The default form outputted by {{ form.as_p }} doesn't seem to be enough to be formatted nicely with Bootstrap. You need to add a , as well as class="control-label" to each . So

Re: django/Data Base Advice

2012-01-02 Thread Victor Hooi
Hi, Do you mean learning more about Django in general, or about the models.py/database portion specifically? If you haven't done much web-development before, or used any MVC frameworks, I suggest you start by reading up on those - there's plenty of guides to that online. In terms of learning

Using STATIC_URL in CSS/JS files?

2012-01-02 Thread Victor Hooi
Hi, In Django, you can use {{ STATIC_URL }} in your HTML templates to point to the correct path for static files, however I'm wondering if there's any way to use it inside of CSS/JS files? E.g. I have a CSS file that points to a PNG sprite, and I'd like a way to get it to point to {{ STATIC_UR

Highlighting Active Navigation Link - correct approach?

2012-01-08 Thread Victor Hooi
hi, I have a project where I'm using Bootstrap (www.github.com/twitter/bootstrap) with Django. I need to add a CSS class ("active") to highlight the active navigation link. Anyhow, I did some Googling: http://www.turnkeylinux.org/blog/django-navbar http://ilostmynotes.blogspot.com/2010/03/dja

Model method versus overriding save()

2012-12-07 Thread Victor Hooi
Hi, I have a "ranking" field for an item that returns an integer between 1 to 10 based on a number of criteria of each item. My question is - what are the pros and cons of using a model method to return this, versus overriding the save() method and saving it directly into a normal IntegerField

Re: Model method versus overriding save()

2012-12-09 Thread Victor Hooi
t;> >> with reality, but if you're doing the query on that _so_ much, >> >> then its usualyl worth it. >> >> >> >> Also, with the right database and a trigger, that's something the >> >> database can en

Storing versioned maps of application connections?

2013-03-02 Thread Victor Hooi
Hi, We have a legacy Django application that parses configuration files for several in-house applications, builds up a map of those applications, including any network connections between them (based on IP address and port), then stores them in Django models. Each application object will store

Using django-devserver with Werzbeug to debug an app - interactive debugger not being trigged?

2013-03-14 Thread Victor Hooi
Hi, I'm trying to use django-devserver (https://github.com/dcramer/django-devserver) to debug localshop (https://github.com/mvantellingen/localshop), a Django-based Pypi server. I've installed django-devserver and werzbeug. I then added 'devserver' to INSTALLED_APPS, and have started it up: (

Deployment best practices - reasons?

2013-04-29 Thread Victor Hooi
Hi, I'm currently looking at tidying up deployment for a Django app we use internally. There's a couple of things that I know are best-practices, or it's just how I normally deploy Django apps, but I need to come up with strong cases for all of them. As in any organisation, if it ain't broke,

Store arbitrary key-value pairs in model?

2013-04-29 Thread Victor Hooi
Hi, I have a Django application that will need to store arbitraty Basically, there are a series of "job scripts" that are submitted by users and then run. Each of these jobs scripts may have an arbitrary number of key-value pairs attached to them (for example, output directory, or search term,

Design for storing likes/dislikes?

2013-07-16 Thread Victor Hooi
Hi, We have a list of users, who are going to like/dislike various widgets. My question is regarding how to store the like/dislikes. Essentially, there can be three states between a user and a widget - like, dislike, and unrated, so it's not just a straight Boolean. I'm thinking of just doing

  1   2   >