Re: Question regarding subdomains of a single project

2010-06-23 Thread Micky Hulse
> Check out this from djangosnippets: http://djangosnippets.org/snippets/1509/ > It allows you to specify multiple URLconfs and then choose which you > .. Anyone know if the ticket mentioned in the comments (#5034) of the above djangosnippet has been resolved? -- You received this message be

Template tag does not like parameters with filters ({% with foo as bar %} question)

2010-07-20 Thread Micky Hulse
Hello, I am using this Djangosnippet: == {% with my_date|date:"Y" as year %} ... {% with my_date|date:"m" as month %} ... {% get_calendar for month year as calendar %} ... ... == The above works, but when I try this: == {% g

Re: custom tag and filtered value

2010-07-21 Thread Micky Hulse
> The django sources for the standard tags show the method, make > sure you are calling parser.compile_filter() on the relevant arg. Thanks David! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...

Re: Template tag does not like parameters with filters ({% with foo as bar %} question)

2010-07-21 Thread Micky Hulse
Hi, > Is my above assumption correct? If so, is there an easy fix? Someone else asked the same question a few hours after I posted my question: They were much more to the point. :) I need to train myself to look at the django source before asking for help here. Than

Re: admin list_filter: limit choices to model values?

2012-02-01 Thread Micky Hulse
Related to my original question: On top of needing to limit list_filter in the admin, I also needed to limit the user choices in my FK to auth.user. This bit of code does just that: Just thought I would share the code to help others. I am wondering if I can app

Re: admin list_filter: limit choices to model values?

2012-02-02 Thread Micky Hulse
On Wed, Feb 1, 2012 at 1:59 PM, Micky Hulse wrote: > Anywho... Anyone know when Django 1.4 is scheduled to be released? <http://bit.ly/zEbdFW> [quote] The Django 1.4 roadmap Before the final Django 1.4 release, several other preview/development releases will be made available. Th

Re: Generating a list of available templates

2012-02-10 Thread Micky Hulse
On Fri, Feb 10, 2012 at 6:40 AM, Patrick Wellever wrote: > I guess the main question is, is there some function I can use to return a > directory on the template path? I'm interested in this also. I too have my own static pages app and have always thought it would be easier for folks to choose f

Re: dropdown select box in django

2012-02-20 Thread Micky Hulse
Your code looks good to me. Maybe you need to restart apache (or similar)? This is typically the format I use for choice fields: LIVE_STATUS = 1 DRAFT_STATUS = 2 HIDDEN_STATUS = 3 STATUS_CHOICES = ( (LIVE_STATUS, u'Live'), (DRAFT_STATUS, u'Draft'), (HIDDEN_STATUS, u'Hidden'), ) statu

[1.4c2] The storage backend of the staticfiles finder doesn't have a valid location.

2012-03-21 Thread Micky Hulse
I must be overlooking something obvious. My error: The static files collect just fine (currently, I just have admin files to collect); the above error just shows up every time I run collectstatic. Settings: STATIC_ROOT = '/home/billy/webapps/xyz_static/' STATIC_URL =

Re: [1.4c2] The storage backend of the staticfiles finder doesn't have a valid location.

2012-03-22 Thread Micky Hulse
Hi Bill, thanks so much for you pro help and quick reply, I really appreciate it! :) On Thu, Mar 22, 2012 at 4:32 AM, Bill Freeman wrote: > Just a shot in the dark, but you probably want to leave DefaultStorageFinder > commented out ... That did the trick! Thank you so much, I owe you one. :) H

myproject/wsgi.py vs. myproject.wsgi?

2012-03-24 Thread Micky Hulse
Hello, This is is probably a silly question, but... I just installed a fresh copy ofDjango 1.4 (mod_wsgi 3.3/Python 2.7) on my WebFaction server. In 1.3, the command startproject (IIRC) generated a myproject.wsgi that lived next to myporject folder. In the 1.4 installer, the wsgi file i

Re: myproject/wsgi.py vs. myproject.wsgi?

2012-03-26 Thread Micky Hulse
On Mon, Mar 26, 2012 at 5:14 AM, Reinout van Rees wrote: > In 1.3, there was no wsgi file. So either you added it yourself or > webfaction automatically adds it. > 1.4 started adding that wsgi.py file. It should be a drop-in replacement for > the one you have now, basically. > (Only thing to watch

Does adding editable=False to model require a data migration?

2012-04-27 Thread Micky Hulse
Quick question: Does adding editable=False to an existing model field require a data migration? Thanks! M -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from t

Re: Does adding editable=False to model require a data migration?

2012-04-27 Thread Micky Hulse
>From the docs: editable Field.editable If False, the field will not be editable in the admin or via forms automatically generated from the model class. Default is True. So, it reads like I can add the editable argument to the field without having to migrate my data? Thank you. Cheers, M -- Y

Re: Does adding editable=False to model require a data migration?

2012-04-28 Thread Micky Hulse
Hi Jerome! Thanks for your help, I really appreciate it. :) On Apr 28, 2012, at 7:59 AM, Jerome Baum wrote: > Sounds like it. If you are using South then you can also run > "manage.py schemamigration --auto" and South will tell you > whether it thinks a schema migration is required. If it isn't

Re: {% spaceless %} abuse (?)

2012-07-05 Thread Micky Hulse
On Thu, Jul 5, 2012 at 5:00 PM, Russell Keith-Magee wrote: > Good question. I'm not really sure *what* it's supposed to be used > for. Trimming whitespace to reduce page size is one possible use; the If you develop for IE6, there's the IE6 whitespace bug. One fix, that I know of, is to remove all

Re: Problem on 'if' on templates

2012-07-25 Thread Micky Hulse
On Jul 25, 2012, at 3:11 PM, fnando wrote: > Hello, beginner here. I'm getting an error at the IF statement, line 2 of > this snippet: Could it be that you're using object as the loop variable, and object is also the global var? I might change it to: for item in object.list And use {{ item

Re: html compress advice

2012-07-26 Thread Micky Hulse
Hi, On Thu, Jul 26, 2012 at 2:29 PM, Phil wrote: > Just looking for some advice/ wisdom really. While not a direct answer to your question, there was a discussion on the group recently on the topic of the spaceless tag: "{% spaceless %} abuse (?)"

What does this code do? Also, testing decorator via terminal?

2012-08-31 Thread Micky Hulse
Hello, Silly question, but... What does this code do: if isinstance(objects, HttpResponse): return objects ... full code found here: I'd like to add: if objects.status_code != 200:

Re: What does this code do? Also, testing decorator via terminal?

2012-08-31 Thread Micky Hulse
On Fri, Aug 31, 2012 at 9:17 PM, Micky Hulse wrote: > I'd like to add: > if objects.status_code != 200: > return objects > ... which is found via this code: > <https://gist.github.com/871954> Doh! After a bit of trial and error, I given up on trying to merge tho

Re: What does this code do? Also, testing decorator via terminal?

2012-09-01 Thread Micky Hulse
Hi Kurtis! Many thanks for your reply, I really appreciate the help! :) On Fri, Aug 31, 2012 at 11:38 PM, Kurtis Mullins wrote: > All that is doing is checking to see if the object named "objects" is an > HttpResponse object. Ah, ok! I think you've kicked me in the right direction here. > that

Re: What does this code do? Also, testing decorator via terminal?

2012-09-04 Thread Micky Hulse
On Sat, Sep 1, 2012 at 10:47 PM, Melvyn Sopacua wrote: > More precise, if it's an object instance that has HttpResponse as a > class in it's inheritance chain. > Thanks Melvyn! I really appreciate the help and description/clarification. :) -- You received this message because you are subscribe

Re: CSS question

2011-08-21 Thread Micky Hulse
be from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- Micky Hulse Web Content Editor The Register-Guard 3500 Chad Drive Eugene, OR 97408 Phone: (541) 338-2621

Re: CSS question

2011-08-21 Thread Micky Hulse
P.S. There's a great CSS listserv here: -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-use

Re: CSS question

2011-08-22 Thread Micky Hulse
Hi Cal, On Mon, Aug 22, 2011 at 12:49 AM, Cal Leeming [Simplicity Media Ltd] wrote: > OP - let me know if you resolved your issue. If not, ill show you the > standard way of doing it. I have always considered vertical-align pretty standard. ;) > For the record - vertical align in some usages is

Static images for use in admin widget

2011-09-06 Thread Micky Hulse
Hello, Within an admin field widget that I am developing, I need to access a static image from my app. For example, I have a Google map and I would like to access "crosshair.gif" from the apps' static folder (er, the collectstatic folder). Inside the widget's render() function, I have a formatte

Re: Static images for use in admin widget

2011-09-06 Thread Micky Hulse
On Tue, Sep 6, 2011 at 10:54 PM, Tomas Neme wrote: > this looks awful to me. Can't you stick that into a .js file and include > that? Doh, yah... If my django-fu skills were better, then maybe I could! :) I should have posted the original code: I am m

Re: Static images for use in admin widget

2011-09-07 Thread Micky Hulse
Hi Tomas, Thanks again for your tips and code samples, I really appreciate it. I really liked that technique of using __init__.py to add a constant to the settings.py file. Very cool! I get what you mean now when you say "I think hardcoding the 'app/' directory is the usual way to do this, you s

When is a good time to use db_index? Rule of thumb?

2011-09-15 Thread Micky Hulse
Hello, I have been using this great category/tag model: https://github.com/praekelt/django-category/blob/master/category/models.py ... and I noticed that the author added a db_index on the SlugField of the Category model. I hate to admit it, but I don't think I have ever explicitly used db_inde

Re: When is a good time to use db_index? Rule of thumb?

2011-09-16 Thread Micky Hulse
Thank you Micah, Donald and Doug! I really appreciate the help! :) That really helps to clear things up for me. Have a great weekend. Cheers, Micky -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us

Admin coding guidelines order?

2011-09-17 Thread Micky Hulse
Hello, I follow the rules on this page for my models (and other files/code): But are what about the admin.py file? Sometimes my admin classes can get pretty cluttery (form, display_on_top, prepopulated_fie

Re: Admin coding guidelines order?

2011-09-17 Thread Micky Hulse
On Sat, Sep 17, 2011 at 4:10 PM, Micky Hulse wrote: > But are what about the admin.py file? How's this for organization(?): <https://gist.github.com/1224591> I guess I am curious how other folks would go about organizing things. :) Thanks! Micky -- You received this message b

Re: Admin coding guidelines order?

2011-09-18 Thread Micky Hulse
On Sat, Sep 17, 2011 at 7:14 PM, Micky Hulse wrote: > How's this for organization(?): Bare bones example: <https://gist.github.com/1224591#file_admin_template.py> Note on comments: Trying to follow similar guidelines for comments as found here: <http://tinyurl.com/9qc29

Re: Custom model field/form: __init__() got multiple values for keyword argument 'baz'

2011-09-20 Thread Micky Hulse
On Tue, Sep 20, 2011 at 3:36 PM, Michal Petrucha wrote: > Well, the problem is that your defined fields.TestField.__init__ takes > baz as either a keyword argument, or as the first positional arg. As > with related fields, to pass the verbose name in this case you have to > specify it as a keyword

Re: Custom model field/form: __init__() got multiple values for keyword argument 'baz'

2011-09-21 Thread Micky Hulse
On Wed, Sep 21, 2011 at 6:08 AM, Michal Petrucha wrote: > The remedy is simple, instead of kwargs.get use kwargs.pop. Ahhh, I see! Thanks so much for the explanation and clarification. Much appreciated. Have an excellent day! Cheers, Micky -- You received this message because you are subscri

Re: Dealing with misc parts of a project

2011-09-22 Thread Micky Hulse
On Thu, Sep 22, 2011 at 8:54 AM, Simon Connah wrote: > So do you just tend to create a new misc app to hold all these little bits > and pieces or is there a convention for such things? I asked a similar question here: For

[Django 1.3] django.views.generic.TemplateView example

2011-09-30 Thread Micky Hulse
Code: When using the new class-based generic views, is there a faster way for me to pass URL params to the template? Thanks! Micky -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send e

Re: What is the right way to use S3 as a storage backend?

2011-10-05 Thread Micky Hulse
Not sure if this will be of any help, but I switched from django-storages to this: I switched mostly because SORL was not working well with my S3 buckets... CuddlyBuddly has this:

Re: [Django 1.3] django.views.generic.TemplateView example

2011-10-05 Thread Micky Hulse
Ack! Russ, I missed this e-mail! I am so sorry for the late reply! Thanks so much for helping me out, I really appreciate it. :) On Fri, Sep 30, 2011 at 9:08 PM, Russell Keith-Magee wrote: > There's no need to subclass TemplateView and provide your own implementation > of get_context_data() - th

Re: Ajax replacement in django

2011-10-12 Thread Micky Hulse
On Wed, Oct 12, 2011 at 7:39 AM, lankesh87 wrote: > Actually my project guide is asking me to search for ajax replacement > in django. So that way we dont have to use ajax. Perhaps it's a trick question? Maybe you project guide does not like the "Ajax" buzzword? :) Just call it XHR:

Re: Ajax replacement in django

2011-10-12 Thread Micky Hulse
On Wed, Oct 12, 2011 at 9:54 AM, Chandrakant Kumar wrote: > But, isn't HTML5 is still work in progress? I mean, how will it behave on > older browsers? Good point. I guess it depends on the requirements of the project. >From what I read, this sounds like a school project, so why not take the tim

[1.3] get_FOO_display() and prepopulated_fields?

2011-10-18 Thread Micky Hulse
Hello, Are there any tricks to getting the display value of a choice field to work with prepopulated_fields slug creation in the admin? class Team(Base): MALE = 1 FEMALE = 2 GENDER_CHOICES = ( (MALE, u'Men'), (FEMALE, u'Women'), ) slug = models.SlugField(_(

Need help upgrading old view/url to new syntax...

2011-11-10 Thread Micky Hulse
Hello, I am in the process of upgrading this "old" functional code: urls_old.py: views_old.py: Here's what I have so far: urls.py: views.py:

Re: Need help upgrading old view/url to new syntax...

2011-11-10 Thread Micky Hulse
Hi Andres, thanks so much for the quick reply, I really appreciate it. On Thu, Nov 10, 2011 at 1:00 PM, Andres Reyes wrote: > See https://gist.github.com/1356199/bd1af5e81d51ef32a3f4aa29a7a9120c9a8ffe85 > The problem is that you're overriding get_queryset when you should be > overriding get_objec

Re: Need help upgrading old view/url to new syntax...

2011-11-10 Thread Micky Hulse
On Thu, Nov 10, 2011 at 3:47 PM, Micky Hulse wrote: > Whoa! That works perfectly! Ack! I spoke too soon. My context variable name of "user" conflicted with the current logged-in user (looks like there's already a "user" variable floating around at the template lev

Treebeard admin issues: Fieldsets break code...

2011-12-20 Thread Micky Hulse
Hello, I am building a simple flat pages app and I am running into problems using Treebeard. For those not familiar with Treebeard: Treebeard example app: Ok, here's my code:

Re: Treebeard admin issues: Fieldsets break code...

2011-12-20 Thread Micky Hulse
On Tue, Dec 20, 2011 at 5:42 PM, Micky Hulse wrote: > Traceback: > <http://dpaste.com/675982/> Sorry, moved here: <http://dpaste.com/675984/> Let me know if I can provide more trace info. Thanks! -- You received this message because you are subscribed to the Google Gro

admin list_filter: limit choices to model values?

2012-01-13 Thread Micky Hulse
Hi. Not sure where to start... Just hoping someone can give me a kick in the right direction. I have built a flat page app that allows for an author FK (optional field). When I setup the admin to allow author as a list_filter, the actual filter list of authors is way to long to be useful. Would

Re: admin list_filter: limit choices to model values?

2012-01-13 Thread Micky Hulse
Maybe simpler: Is there an easy way to limit the list_filter to folks with "Superuser status"? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, se

Re: admin list_filter: limit choices to model values?

2012-01-25 Thread Micky Hulse
On Fri, Jan 13, 2012 at 3:35 PM, Micky Hulse wrote: > Would it be possible for me to setup my list_filter to only show > author names that have been assigned to my flat pages? For example, > let's say I have 10 pages, and two of those pages have the been FK'd > to "bjo

Re: admin list_filter: limit choices to model values?

2012-01-25 Thread Micky Hulse
On Wed, Jan 25, 2012 at 2:18 PM, Micky Hulse wrote: > I'm now trying to figure out how to browse Django source for version 1.3. :) Cool, found 1.3 source: django/branches/releases/1.3.X <https://code.djangoproject.com/browser/django/branches/releases/1.3.X> Looks like maybe Filte

[Django 1.3] list_display, __unicode__ and sorting

2012-11-30 Thread Micky Hulse
Hello, Would the below be an OK way to sort __unicode__ in the admin list_display? Model: def uni_sort(self): return self.__unicode__() uni_sort.admin_order_field = 'sort' uni_sort.short_description = _(u'name') Admin: list_display = ('uni_sort', 'parent', 'name', 'slug',) ... To save

JSONResponseMixin: Best handle "context" before dumping it to JSON?

2012-12-11 Thread Micky Hulse
Hello, I'm modifying a version of this code (JSONResponseMixin): ... so it can handle jsonp and caching (so far so good)... I was just curious, the comments say: # Note: This is *EXTREMELY* naive; in reality

Re: JSONResponseMixin: Best handle "context" before dumping it to JSON?

2012-12-12 Thread Micky Hulse
ion is to use Django's serializers [2]; this mechanism includes > built-in support for serialising querysets and objects, which removes the > need for a lot of special handling. Ah, great info! Thank you for pointing me in the right direction. I plan on reading through these docs tonight.

Re: JSONResponseMixin: Best handle "context" before dumping it to JSON?

2012-12-12 Thread Micky Hulse
again for the pro help an assistance! I owe you one! ;) Have a nice night. Cheers, Micky -- Micky Hulse Web Content Editor The Register-Guard 3500 Chad Drive Eugene, OR 97408 Phone: (541) 338-2621 Fax: (541) 683-7631 Web: <http://www.registerguard.com> -- You received this message because y

Model's optional __unicode__() return values?

2012-12-14 Thread Micky Hulse
Hello, This is probably a dumb question, but... What's the best way to handle optional __unicode__() return values? In this situation, I'm wanting to return the __unicode__ values from other models. I've found myself doing a lot of this: def __unicode__(self): return _(u'%s%s%s') % (self.t

Re: Model's optional __unicode__() return values?

2012-12-14 Thread Micky Hulse
Hi Chris! Thanks so much for your quick reply, I really appreciate it. On Fri, Dec 14, 2012 at 3:41 PM, Chris Cogdon wrote: > oops... that should be "if x is not None", not "where x is not None"... > Clearly I am still half in SQL mode :) Sweet!!! Works perfectly: return ' | '.join ([unicode(x)

2 projects, 2 apps, bad templates ...

2013-01-24 Thread Micky Hulse
Noob alert! :D I work on a server where we have multiple Django projects that all share one Django installation. Each project has it's own subdomain. At this time, we aren't using virtual envs. Situation: 1. I built a basic application (let's call it FOOAPP) inside of DjangoProjectA; after usi

Re: 2 projects, 2 apps, bad templates ...

2013-01-24 Thread Micky Hulse
Hi Tomas! Thank you for your reply, I really appreciate it. :) On Thu, Jan 24, 2013 at 6:12 PM, Tomas Neme wrote: > Use virtualenvs. That's basic for any serious python development > you'll want to do. Totally agree. Setting up virtualenv's are our long term goal. > Besides that, you might add

Re: 2 projects, 2 apps, bad templates ...

2013-01-25 Thread Micky Hulse
Hi Tomas! A million thanks for you help! On Thu, Jan 24, 2013 at 7:34 PM, Tomas Neme wrote: > really, it should be your SHORT term goal. Without airing our dirty laundry, I can't argue with that. I will push a little harder to get us to convert our projects to envs sooner than later. :) > As fo

Re: 2 projects, 2 apps, bad templates ...

2013-01-25 Thread Micky Hulse
On Thu, Jan 24, 2013 at 7:38 PM, Tomas Neme wrote: > just to clarify: > Whoa, that really helps clarify the setup!!! Very helpful! Thank you Tomas!!! Until we can convert to virtual envs, your suggested solution(s) and fixes should make me sleep easier at night. Have an awesome day! :) Cheers

Admin: Model ordering and relationship conditional __unicode__ return values?

2011-04-19 Thread Micky Hulse
Hello, Couple of noob questions: 1. Is it possible to order the models of my app manually (vs. alphabetically) when viewing the app page? See attached "ordering.png". 2. Relationship models: How can I return different __unicode__ values based on the relationship that I am viewing. [code] cl

Re: Admin: Model ordering and relationship conditional __unicode__ return values?

2011-04-20 Thread Micky Hulse
Hello, On Tue, Apr 19, 2011 at 1:28 PM, Micky Hulse wrote: > 1. > Is it possible to order the models of my app manually (vs. > alphabetically) when viewing the app page? > 2. > Relationship models: How can I return different __unicode__ values > based on the relationship tha

Re: Custom select_related()

2011-06-07 Thread Micky Hulse
Hi Martin! Thanks so much for the quick reply, I really appreciate your help. :) On Tue, Jun 7, 2011 at 1:48 AM, Martin wrote: > Why not create a Manager? > Give it a method foo1_related() which then returns something like > self.foo1_set.filter( your filters ) and a similar method foo2_related (

Re: ManyToManyField limit_choices_to that instance via Django admin.

2011-06-07 Thread Micky Hulse
Hi Ryan! Thanks so much for the reply, I really appreciate the help. :) On Tue, Jun 7, 2011 at 12:17 PM, Ryan wrote: > This is possible, but I'm not sure if you could do it via limit_choices_to. > The admin docs shows how to accomplish this here: Oooh, interesting. I will experiment with that so

[Django 1.2] Admin ForeignKey edit link?

2011-06-08 Thread Micky Hulse
Hi, Looks like ticket #13165 is the way to go, but I thought I would ask the group before I consider applying the patch. I would love to have an "edit" pencil link for my model's FKs. Other than applying the patch, are there any good work-arounds out there? I was considering extending/overridin

Re: [Django 1.2] Admin ForeignKey edit link?

2011-06-08 Thread Micky Hulse
On Wed, Jun 8, 2011 at 12:51 PM, Micky Hulse wrote: > Looks like ticket #13165 is the way to go, but I thought I would ask > the group before I consider applying the patch. Ooops, here's the link to the ticket: <https://code.djangoproject.com/ticket/13165> -- You received thi

Re: Need help getting this snippet to work in Django 1.2...

2011-06-13 Thread Micky Hulse
Hi Alex! Thanks for the reply, I really appreciate it. :) On Sun, Jun 12, 2011 at 9:01 PM, Alex Kamedov wrote: > It'll be better to use validators with IntegerField > In this case you can specify allowed year range. Ooh, great tip! That looks very useful and possibly a little more simple/straigh

Re: Need help getting this snippet to work in Django 1.2...

2011-06-13 Thread Micky Hulse
On Mon, Jun 13, 2011 at 9:44 AM, Micky Hulse wrote: > Ooh, great tip! That looks very useful and possibly a little more > simple/straight-forward than using a form field. Too easy! https://gist.github.com/1023327 Thanks for the help Martin and Alex, I really appreciate it! :) Have an a

Re: __unicode__() addition not working in basic poll application.

2011-06-14 Thread Micky Hulse
On Tue, Jun 14, 2011 at 11:01 AM, Kyle Latham wrote: Poll.objects.all() > [] What do you get when you try: >>> p = Poll.objects.all()[0] >>> p >>> type(p) >>> dir(p) Try this too: >>> p = Poll.objects.all() >>> for x in p: . . .print x (indent this line four spaces, hit return key onc

Re: When to use a model property vs. method?

2011-06-16 Thread Micky Hulse
On Thu, Jun 16, 2011 at 11:07 AM, Micky Hulse wrote: > Just hoping some of the pro Django/Python users on this list could > school me on this one. :D Actually, here's an example that I am working on now. In my model, I have a CharField that holds the latitude/longitude with value

When to use a model property vs. method?

2011-06-16 Thread Micky Hulse
Hello, Just curious what the rule-of-thumb is for when it comes to using model methods vs. properties. For example: [code] @property def is_modified(self): if self.modified > self.created: return True return False def get_separator(self): return ' :: ' [/code] I feel like

Re: When to use a model property vs. method?

2011-06-16 Thread Micky Hulse
Hi Bruno! Thank you so much for your help. I really appreciate the pro assistance. :) On Thu, Jun 16, 2011 at 1:42 PM, bruno desthuilliers wrote: > > This could be written much more simply as "return self.modified > > self.created" > Omg, thanks! That's way better. :D >> def get_separator(sel

Re: When to use a model property vs. method?

2011-06-16 Thread Micky Hulse
How's this for a rule-of-thumb(?): 1. Use a property (class/instance attribute) when an argument(s) is not needed. 2. If an argument(s) is needed (for runtime(?) calculations and/or class/instance attributes need to be sanitized/checked/other), then use a method (or getter/setter/descriptor). No

Re: When to use a model property vs. method?

2011-06-16 Thread Micky Hulse
I am reading through Chapter5+ of Dive Into Python now... Seems like that should cover all of my questions! :D Sorry to bug the list with my ramblings. Thanks again Bruno! Have a great day all! Cheers, Micky -- You received this message because you are subscribed to the Google Groups "Django

Re: When to use a model property vs. method?

2011-06-17 Thread Micky Hulse
Hi Tom and Bruno! Thank you so much for your pro help and assistance. I really appreciate it. :) Replying to both of you in this one e-mail... See inline replies below. On Fri, Jun 17, 2011 at 1:42 AM, Tom Evans wrote: > Access it with MyModel.SEPARATOR or my_model_instance.SEPARATOR Ahhh, I se

Re: When to use a model property vs. method?

2011-06-20 Thread Micky Hulse
Thanks to everyone (Bruno, Tom, Ethan and Masklinn) for the extremely informative and very helpful replies. I really appreciate all of the professional help. I have a lot to research and need to practice some of these newly learned techniques/concepts... I may be back with more (this time, Django

WMD-editor: Where's wmd/urls.py?

2011-06-21 Thread Micky Hulse
Anyone here using django-wmd-editor? https://github.com/jpartogi/django-wmd-editor If so, could you tell me what its url.py file is supposed to look like? :D Maybe I am missing something obvious here, but wmd/urls.py does not exist... What am I missing? Thanks so much! Micky -- You received t

Re: WMD-editor: Where's wmd/urls.py?

2011-06-22 Thread Micky Hulse
On Wed, Jun 22, 2011 at 1:20 AM, Kevin Renskers wrote: > I think it's an error in the documentation. Since there are no views, it's > probable that there are no urls as well. Hehe, that's a great point! I did not think about looking inside the views.py file. :( Thanks Kevin! Cheers, Micky --

Re: WMD-editor: Where's wmd/urls.py?

2011-06-22 Thread Micky Hulse
On Wed, Jun 22, 2011 at 1:20 AM, Kevin Renskers wrote: > I think it's an error in the documentation. Since there are no views, it's > probable that there are no urls as well. Everything works perfectly if I ignore the part about the urls.py file. :D Thanks Kevin! Have a great day. Cheers, Mick

Re: What are the advantages of Model inheritance?

2011-06-23 Thread Micky Hulse
On Thu, Jun 23, 2011 at 2:17 PM, bruno desthuilliers wrote: > FWIW, I have been using model inheritance - abstract and concrete - in > half a dozen projects, with about 30 model subclasses in one of them, > and it JustWorks(tm). That sounds pretty sweet! :D I would love to see some examples. I

Global generic files? Best practice(s)?

2011-06-28 Thread Micky Hulse
uot;: What's your preferred approach to handling generic/global code? When using a "global" app how do you package apps that have files that are not inside app structure? Would you change re-factor/re-arrange your code/files or would you include the "global" app in your package/pa

Re: Global generic files? Best practice(s)?

2011-06-29 Thread Micky Hulse
Hi Andre! Thanks so much for the reply, I really appreciate the help! :) On Wed, Jun 29, 2011 at 9:51 AM, Andre Terra wrote: > If you're using it for multiple apps, but just one project and the apps are > project-specific, then this code could very well lie in your project's > utils.py or any ot

Re: Global generic files? Best practice(s)?

2011-06-30 Thread Micky Hulse
you food for thought while also bumping the thread so > that other developers will weigh in. Definitely! Thanks so much I really appreciate it! :) Have a great day. Cheers, Micky -- Micky Hulse Web Content Editor The Register-Guard 3500 Chad Drive Eugene, OR 97408 Phone: (541) 338-2621 Fax: (5

Re: How to use the django-users mailing list properly and doing your homework..

2011-07-01 Thread Micky Hulse
Don't forget about GitHub Gists! https://gist.github.com/ Considering a lot of Django projects are already hosted there... Seems like a natural fit to me. :) Also, Gist has the "fork" feature. -- You received this message because you are subscribed to the Google Groups "Django users" group. T

Re: Global generic files? Best practice(s)?

2011-07-01 Thread Micky Hulse
.. It's just nice to know how it's done. Thanks for the inspiration! > Again, congrats and best of luck! You too! Thanks again Andre, I really appreciate the help and advice. :) Cheers, Micky -- Micky Hulse Web Content Editor The Register-Guard 3500 Chad Drive Eugene, OR 97408 Phone:

Re: How to use the django-users mailing list properly and doing your homework..

2011-07-07 Thread Micky Hulse
I personally have a dedicated gMail account for lists, which forwards everything to my main gMail account, and then all list e-mails get filtered into a "lists" label/folder. Here's some (random) thoughts from a (self proclaimed) listserv veteran and Django/Python noob: 1. Am I the only one th

Re: Getting a subclass from an abstract Model

2011-07-08 Thread Micky Hulse
Try adding the below to your base class: objects = models.Manager() # Admin uses this manager. Sent from my iPhone -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsu

Re: Simple example of custom user profile fields?

2011-07-12 Thread Micky Hulse
This tutorial helped me: http://www.turnkeylinux.org/blog/django-profile Note: The above tutorial uses an FK to User model... The Django docs suggest a OneToOne field. Hope that helps. Micky -- You received this message because you are subscribed to the Google Groups "Django users" group. To

Re: Simple example of custom user profile fields?

2011-07-12 Thread Micky Hulse
On Tue, Jul 12, 2011 at 7:57 PM, Brent wrote: > Unfortunately, no matter what kind of path I put for > AUTH_PROFILE_MODULE, the same error appears. I don't know your setup, but have your tried restating Apache? That's probably a stupid question/suggestion, but maybe worth a shot? -- You receive

Re: Fieldsets in Admin Inline

2011-07-25 Thread Micky Hulse
On Mon, Jul 25, 2011 at 2:57 PM, Juergen Schackmann wrote: > is there a way to define fieldsets in the Inline? > If could not find anything in the docs, but to me the idea sounds quite > reasonable; so I am wondering if I just dont find it?!?!?! Not tested myself, but have you tried the normal fi

Re: Re: Fieldsets in Admin Inline

2011-07-26 Thread Micky Hulse
Awesome! Glad that helped and thanks for the warning. One of these days I will need this functionality myself. :) Have a great day! Cheers, Micky -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users

Re: Best way to test handle optional FKs in model __str__?

2015-01-17 Thread Micky Hulse
Hi Vijay! Thank you so much for the reply/help, I really appreciate it. :) On Sat, Jan 17, 2015 at 7:01 AM, Vijay Khemlani wrote: > I don't think there is a way in Python to do that directly > you could have a utility method that catches the exception, for example Great, that's what I wanted to

Re: Best way to test handle optional FKs in model __str__?

2015-01-17 Thread Micky Hulse
On Sat, Jan 17, 2015 at 12:58 PM, Micky Hulse wrote: > Great, that's what I wanted to know. Thank you for pushing me in the > right direction and for the sample code. Thanks again Vijay! After doing a bit of research, I slightly modified your code (I needed an easy way to check nested

Re: Best way to test handle optional FKs in model __str__?

2015-01-17 Thread Micky Hulse
Hi James! Thank you for the reply and for the example code! On Sat, Jan 17, 2015 at 2:52 PM, James Schneider wrote: > You can reroll your original example like this: > Much more pythonic, IMO. Ah, that's great! I was actually wondering what the pythonic way of doing this might be. While it's mor

Re: Best way to test handle optional FKs in model __str__?

2015-01-17 Thread Micky Hulse
On Sat, Jan 17, 2015 at 3:00 PM, James Schneider wrote: > Yes, it's a bit more verbose, but much easier to follow. Hope it helps. Definitely! Thanks again! Python rocks. :) Cheers, M -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubsc

Re: Best way to test handle optional FKs in model __str__?

2015-01-17 Thread Micky Hulse
On Sat, Jan 17, 2015 at 6:15 PM, Tim Chase wrote: > I'm pretty sure that getattr() takes an optional 3rd field for the > default, so you could use Great point, that's very useful. Thanks for clarifying! It looks like attrgetter doesn't have similar functionality, but there's this (found after a

Re: Best way to test handle optional FKs in model __str__?

2015-01-17 Thread Micky Hulse
On Sat, Jan 17, 2015 at 8:09 PM, James Schneider wrote: > You can definitely do it that way if all you need to do is check if values > exist and provide a default if they don't. I do this all the time for my > __str__() methods as well. > You also mentioned similar situations that may require more

Django 1.7.4, PostgreSQL: Migrate FK to M2M?

2015-02-18 Thread Micky Hulse
Hi, I was just curious if anyone could give me tips on how to migrate an FK to M2M whist retaining the FK selected data? Long story short, I've played around with adding adding a M2M field with a `related_name`, migrating, deleting FK, then re-naming the M2M and removing `related_name`, but I eve

Re: Django 1.7.4, PostgreSQL: Migrate FK to M2M?

2015-02-18 Thread Micky Hulse
Hi Andrew, many thanks for the quick reply and help! :) On Wed, Feb 18, 2015 at 8:56 PM, Andrew Pinkham wrote: > When I had to migrate FK->M2M, I found that hand-hacking a migration file was > the way to go. I wrote a multiple operation migration class that did the > following: > .. > Hope

  1   2   >