Re: If you have multiple custom users - what should you set AUTH_USER_MODEL to?

2017-06-19 Thread 'Victor Hooi' via Django users
un 2017 at 17:53 James Schneider wrote: > > > On Jun 18, 2017 10:11 PM, "Victor Hooi" wrote: > > Hi, > > Say you have multiple custom users, each inheriting from AbstractUser. The > docs mention setting AUTH_USER_MODEL: > > > https://docs.djangoprojec

If you have multiple custom users - what should you set AUTH_USER_MODEL to?

2017-06-18 Thread Victor Hooi
Hi, Say you have multiple custom users, each inheriting from AbstractUser. The docs mention setting AUTH_USER_MODEL: https://docs.djangoproject.com/en/1.11/topics/auth/customizing/#substituting-a-custom-user-model However, what happens if you have *multiple* custom users - which would you set

Re: Canonical way of handling multiple types of users? (Profiles vs subclassing django.contrib.auth.models.AbstractUser)

2017-06-18 Thread Victor Hooi
with Google Admin well? Ideally we'd want different sections to edit teachers, vs students vs parents - but not sure if this is possible. On Wed, 14 Jun 2017 at 21:45 Mike Dewhirst wrote: > On 14/06/2017 8:59 PM, Victor Hooi wrote: > > Resurrecting a slightly old thread =), but

Re: Canonical way of handling multiple types of users? (Profiles vs subclassing django.contrib.auth.models.AbstractUser)

2017-06-14 Thread Victor Hooi
gt;> >> 1. different types of users (requirement: a user can only be one type) >> 2. one type of user with additional information from different sources >> 3. different types of users, but users can be multiple types >> >> Obviously the third is the hardest. >&

Canonical way of handling multiple types of users? (Profiles vs subclassing django.contrib.auth.models.AbstractUser)

2016-11-08 Thread Victor Hooi
Hi, What is the current canonical way to handle multiple user-profiles in Django? For example - say you have "Teachers", "Students", "Parents" - you may have slightly different fields for each one and/or different behaviour. Students will have things like grades, Parents may have 1-to-many Stu

Re: I can't run django server nor activate the virtualenv

2014-04-28 Thread Victor Hooi
Hi Fred, Are there any lines *below* the error message you pasted? The last line I can see is: File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", > line 40, in import_module __import__(name) Is there anything else? Cheers, Victor On Monday, 28 April 2014 03:03:40

Using filter_horizontal with InlineAdmin - should work, right?

2014-04-07 Thread Victor Hooi
Hi, I'm hacking up a system to manage attendees at a camp. I have a Person model (which might be better as a customer UserModel, still not sure). There are multiple types of people - e.g. camp attendees, staff, supervisors etc. Each person that is a camp attendee will also have an "Attendance

Loading data from Django into RedShift - ORM vs SQL?

2013-10-17 Thread Victor Hooi
Hi, We have a Django eCommerce site, from where we want to load transactional data into Amazon RedShift (i.e. basically ETL). This would probably be a batch load run either once a day, or at intervals throughout the day. (I'm also curious about whether it's possible to stream the data in, but

Aggregation and count - only counting certain related models? (i.e. adding a filter on the count)

2013-09-24 Thread Victor Hooi
Hi, I'm trying to use aggregation to count the number of "likes" on an item. The likes for an item are stored in a related model, called LikeStatus: class Item(models.Model): > ... > class ItemLikeStatus(models.Model): > LIKE_STATUS_CHOICES = ( > ('L', 'Liked'), > ('U', 'Unli

Re: Using environment variables in settings.py - good practice? How to handle missing variables gracefully?

2013-09-18 Thread Victor Hooi
x27;, 'default_value') > > Regards, > Dig > On Sep 19, 2013 1:37 PM, "Victor Hooi" > > wrote: > >> Hi, >> >> I have several settings in my Django settings.py file that are specific >> >> Currently, I'm grabbing thes

Using environment variables in settings.py - good practice? How to handle missing variables gracefully?

2013-09-18 Thread Victor Hooi
Hi, I have several settings in my Django settings.py file that are specific Currently, I'm grabbing these from environment variables in settings.py: import os > ... > # TODO - We need to gracefully catch if these aren't set. > SOME_VARIABLE = os.environ['SOME_VARIABLE'] This includes things l

Using PredictionIO with Django - where to put client creation?

2013-09-09 Thread Victor Hooi
Hi, I have a Django app that I'm using with PredictionIO (http://prediction.io/), which is a wrapper around Apache Mahout. They also have a Python client that sends data to the backend server: http://pythonhosted.org/PredictionIO/predictionio.html As part of this, I've attached post_save signa

Re: Bulk-creating two ForeignKey linked models - id field for relationship isn't set properly?

2013-08-20 Thread Victor Hooi
wrote: > This is a known limitation of `bulk_create`: objects used for bulk > creation are not assigned a primary > key<https://code.djangoproject.com/ticket/19527> > . > > Le mardi 20 août 2013 05:57:52 UTC-4, Victor Hooi a écrit : > >> Hi, >> >> *1. Bu

Re: Bulk-creating two ForeignKey linked models - id field for relationship isn't set properly?

2013-08-20 Thread Victor Hooi
doing that extra lookup is going to be any better than just iterating through and doing a save() each round and avoiding bulk_create() altogether. Cheers, Victor On Tuesday, 20 August 2013 22:51:57 UTC+10, Daniel Roseman wrote: > > On Tuesday, 20 August 2013 12:10:34 UTC+1, Victor Hooi

Re: Bulk-creating two ForeignKey linked models - id field for relationship isn't set properly?

2013-08-20 Thread Victor Hooi
seman wrote: > > On Tuesday, 20 August 2013 10:57:52 UTC+1, Victor Hooi wrote: > >> Hi, >> >> *1. Bulk Creating Products/ProductImages* >> >> I have a Django custom management command that bulk-loads a list of >> products and product images from a JSON

Bulk-creating two ForeignKey linked models - id field for relationship isn't set properly?

2013-08-20 Thread Victor Hooi
Hi, *1. Bulk Creating Products/ProductImages* I have a Django custom management command that bulk-loads a list of products and product images from a JSON file. I have a Product model, along with an ProductImage model - each Product may have many ProductImages. class Product(models.Model): >

Representing infinity or "no limit" in an integer field?

2013-08-19 Thread Victor Hooi
Hi, I have a Django IntegerField that I'm using to store the purchase limit for a product. purchase_limit = models.IntegerField() I also need to represent no limit (i.e. infinity) as well in that field. I was thinking of just using NULL to represent no limit. purchase_limit = models.IntegerF

Re: Model verbose name appears to split up on capitalisation (e.g. "iOS") - any way to suppress this?

2013-08-14 Thread Victor Hooi
workaround, right? Is it documented anywhere in the Django docs, or is it considered too much of an edge case? Cheers, Victor On Thursday, 15 August 2013 15:08:00 UTC+10, Mike Dewhirst wrote: > > On 15/08/2013 2:06pm, Victor Hooi wrote: > > For example, verbose_name-Plural on the

Re: Model verbose name appears to split up on capitalisation (e.g. "iOS") - any way to suppress this?

2013-08-14 Thread Victor Hooi
where it's getting it's verbose form from: <https://lh3.googleusercontent.com/-SyhDu2sXyRM/UgxTmrTck4I/Xx4/3IxlNTqQHZw/s1600/Screen+Shot+2013-08-15+at+2.05.22+PM.png> Cheers, Victor On Thursday, 15 August 2013 12:50:40 UTC+10, Ramiro Morales wrote: > > On Wed, Aug 14, 2013 a

Model verbose name appears to split up on capitalisation (e.g. "iOS") - any way to suppress this?

2013-08-14 Thread Victor Hooi
Hi, I have a Django model: class iOSClient(models.Model): > ... > class meta: > ... > verbose_name = 'iOS client' > verbose_name_plural = 'iOS clients' However, when this model appears in the Django Admin, or in say, Django Rest Framework, the human-readable nam

Re: Returning random model objects - is order_by('?') on Postgres safe to use now?

2013-08-07 Thread Victor Hooi
hould have acceptable performance. If not, it will > be expensive no matter who does the work. > > hth > > - Tom > > On 2013-08-07, at 6:55 PM, Victor Hooi wrote: > > Hi, > > We have some code to return randomised Django model instances. > >

Returning random model objects - is order_by('?') on Postgres safe to use now?

2013-08-07 Thread Victor Hooi
Hi, We have some code to return randomised Django model instances. Initially, I was using random.randint(), and returning objects by index between 0 < max_id. This was based on the Django docs: https://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by specifically, the part: Note:

Re: Using standard Django admin User forms for Custom User model?

2013-08-05 Thread Victor Hooi
09:45:51 UTC+10, Russell Keith-Magee wrote: > > > On Wed, Jul 31, 2013 at 12:36 PM, Victor Hooi > > wrote: > >> Hi, >> >> When you add a Django User through the admin, it presents you with a >> initial screen to enter a username and password (/admin/auth

Using standard Django admin User forms for Custom User model?

2013-07-30 Thread Victor Hooi
Hi, When you add a Django User through the admin, it presents you with a initial screen to enter a username and password (/admin/auth/user/add/), and then handles hashing for you. Also, when you go to edit a User, it gives you a Change Password form (e.g. /admin/auth/user/2/password/) I'm us

Re: Best practice - using Django model's in-built id field?

2013-07-19 Thread Victor Hooi
Hi, Funny you guys should mention that =), after Mike's post, I ended up just using David Cramer's django-uuidfield (https://github.com/dcramer/django-uuidfield) package. (There's also django-shortuuidfield - https://github.com/nebstrebor/django-shortuuidfield). For Postgres, this uses the uu

Re: Design for storing likes/dislikes?

2013-07-19 Thread Victor Hooi
cker to > query on than a ManyToMany, also. > > > > On Tuesday, July 16, 2013 9:24:54 PM UTC-4, donarb wrote: >> >> On Tuesday, July 16, 2013 5:29:47 PM UTC-7, Victor Hooi wrote: >>> >>> Hi, >>> >>> We have a list of users, who are goin

Re: Best practice - using Django model's in-built id field?

2013-07-18 Thread Victor Hooi
Hi, Actually, while we're there - is this a suitable use of AutoField? Or is there a better way to generate unique transactions IDs? python.uuid? Or something better? Cheers, Victor On Friday, 19 July 2013 11:57:21 UTC+10, Victor Hooi wrote: > > Hi, > > Ok, thanks, I&#

Re: Best practice - using Django model's in-built id field?

2013-07-18 Thread Victor Hooi
:25 UTC+10, Mike Dewhirst wrote: > > On 19/07/2013 11:31am, Victor Hooi wrote: > > Hi, > > > > I'm just wondering - is it considered good or bad practice to use a > > Django model's in-built ID field? > > > > Say for example you wanted a unique

Best practice - using Django model's in-built id field?

2013-07-18 Thread Victor Hooi
Hi, I'm just wondering - is it considered good or bad practice to use a Django model's in-built ID field? Say for example you wanted a unique identifier for each transactio - should you be generating your own, or can you use just self.id? Cheers, Victor -- You received this message because y

Re: Design for storing likes/dislikes?

2013-07-18 Thread Victor Hooi
-hate-five-star-ratings/ Cheers, Victor On Thursday, 18 July 2013 06:31:15 UTC+10, arnonym wrote: > > On Tue, 16 Jul 2013 17:29:47 -0700 (PDT) Victor Hooi > > wrote: > > We have a list of users, who are going to like/dislike various > > widgets. > > > > My q

Re: Design for storing likes/dislikes?

2013-07-17 Thread Victor Hooi
m the relationship not being there? Cheers, Victor On Wednesday, 17 July 2013 11:24:54 UTC+10, donarb wrote: > > On Tuesday, July 16, 2013 5:29:47 PM UTC-7, Victor Hooi wrote: >> >> Hi, >> >> We have a list of users, who are going to like/dislike various widgets. &g

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

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,

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,

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: (

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

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

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: 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

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

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"

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

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

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

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

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: 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,

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: 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

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: 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

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

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

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

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

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

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

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: 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

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: 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

__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-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

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

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

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

Re: Importing file to Models - Temporary store to allow confirming?

2011-06-27 Thread Victor Hooi
Shawn, Thanks for the quick reply =). If we go with the third approach, what advantages are there to persisting the models in MongoDB (or something similar like Redid.or Cassandra), as opposed to a traditional RDBMS? (I just want to get a good handle on the issues). Furthermore, is there a

Re: Importing file to Models - Temporary store to allow confirming?

2011-06-27 Thread Victor Hooi
Shawn, Thanks for the quick reply =). If we go with the third approach, what advantages are there to persisting the models in MongoDB (or something similar like Redid.or Cassandra), as opposed to a traditional RDBMS? (I just want to get a good handle on the issues). Furthermore, is there a parti

Importing file to Models - Temporary store to allow confirming?

2011-06-25 Thread Victor Hooi
heya, We have a CSV file that we are importing into a Django application, and then creating the appropriate models and relationships. At the first page, we have a file upload form where the user selects a file. We then parse the file, and return a second page showing them what would be created

Templatetag - using date and join together?

2011-02-10 Thread Victor Hooi
Hi, I have a list of Python date objects that I'd like to format and string together. I can use the join templatetag to string them together: {{ date_sequence|join: ", " }} And I can also use the date templatetag to format them: {{ date_sequence|date:" M j" }} However, I can't see to pipe on

Configuration for Nginx and staticfiles

2011-01-31 Thread Victor Hooi
Hi, I'm using Django 1.3 and the included staticfiles app to handle my static media, and Nginx as the webserver. It's currently working, but I have a feeling my paths are more complex than they need to be. I was wondering if anybody could perhaps point out a better way to config this, or any i

Django Admin - list_display doesn't follow FK links?

2011-01-29 Thread Victor Hooi
Hi, I'm trying to use list_display in the django-admin, and I can't seem to find a way to get list_display to follow FK links. My models.py: class Site(models.Model): name = models.CharField(max_length=50, unique=True) description = models.TextField() def __unicode__(self):

ON DELETE CASCADE behaviour on M2M?

2011-01-17 Thread Victor Hooi
Hi, I know that Django's default behaviour on ForeignKey is ON DELETE CASCADE (unless you set on_delete to PROTECT). However, I wasn't sure how this extended to ManyToManyFields. I've just tested with one of my own applications - I have an "Article" object, with m2m to a "Journalist" object. D

Migrating custom view to class-based generic views ; Using staticfiles assets in CSS files?

2011-01-17 Thread Victor Hooi
Hi, I'm currently migrating one of my apps to use the new contrib.staticfiles module in Django 1.3. >From the documentation I can see there's two ways of referring to static files: http://docs.djangoproject.com/en/dev/howto/static-files/ 1. Use {{ STATIC_URL}} 2. Use {% load static %},

Re: Hyphens in Django app/project names?

2011-01-17 Thread Victor Hooi
Russ, Aha, excellent, thanks for clearing that up =). I can see you point - django-registration has a module called "registration", django-extensions has a module called "django_extensions", and django-staticfiles has one called "staticfiles". So it seems like I either go for a single-word mod

Hyphens in Django app/project names?

2011-01-14 Thread Victor Hooi
heya, I'm just wondering whether you are allowed to use hyphens in Django app/project names? When I try to create either an app or a project with hyphens in the name, I get an error: Error: 'django-library' is not a valid app name. Please use only numbers, letters and underscores. However, I

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

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: 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

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: 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

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
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)

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()

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

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 &

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: 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

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
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, > >

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

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

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

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

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

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

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:

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
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

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"

  1   2   >