I've use something like this:
class Car(models.Model):
#some fields
photo = models.ImageField(upload_to='cars')
def delete(self, *args, **kwargs):
storage, path = self.photo.storage, self.photo.path
super(Car, self).delete(*args, **kwargs)
storage.delete(path)
checking somewhere if I already encrypted, but
couldn't figure out where. Not sure if this is the best way though...
On Tuesday, September 18, 2012 9:51:23 AM UTC-4, lingrlongr wrote:
>
> I'm trying to make an encrypted field. I'm using some of the code from
> the boo
I'm trying to make an encrypted field. I'm using some of the code from the
book Pro Django. Generally speaking, it works, but it fails when using
Django's admin interface. Here's the code:
class EncryptedTextFieldDescriptor(property):
def __init__(self, field):
self.field = field
Woops, I forgot to include the super's save method call in my
example. Just want to make sure no one thinks that was the problem...
def save(self, *args, **kwargs):
if not self.considered.filter(id=self.requested.id):
self.considered.add(self.requested)
super(Person, self).save(*ar
I have these models:
class Widget(models.Model):
name
class Person(models.Model):
requested = models.ForeignKey(Widget, related_name='requested')
considered = models.ManyToManyField(Widget,
related_name='considered')
def save(self, *args, **kwargs):
if not self.considered
Hi All,
Django comes with its own authentication scheme, which includes the
User model. So let's say I created my Django app, and I connect some
of my models to the User model using the ForeignKey field type. If I
delete a User object, I now have objects that used to refer to a valid
User, but n
A lifesaver you are! Thx DR!
On Apr 25, 4:37 pm, Daniel Roseman wrote:
> On Monday, April 25, 2011 9:16:18 PM UTC+1, lingrlongr wrote:
>
> > I have a view that subclasses uses django.views.generic UpdateView.
> > In my template, I'm trying to access a form field's
I have a view that subclasses uses django.views.generic UpdateView.
In my template, I'm trying to access a form field's required
property. For example:
{% for field in form %}
{{ field.required }}
{% endfor %}
Nothing outputs when the template is rendered. Does the "required"
attribute not g
s... Perhaps
instead, raise a ValidationError exception from the Store's save()
method?
What are your thoughts?
On Aug 11, 3:58 pm, Nick wrote:
> Are you trying to create a save function that evaluates all the
> weights and returns an error if they are more than 1?
>
> On Aug 10,
I 'm trying to create a form dynamically. This works just fine, but
there's no way for the form to offer any customized validation, by way
of the clean() method.
def get_dept_weight_form(store):
fields = {}
s = Store.objects.get(pk=store.id)
for d in store.department_set.all():
with a forms.ModelMultipeChoiceField, and probably with
> other stuff. Doesn't it do what you need? Or are you just reinventing
> the wheel.
>
> And, of course, your code as shown doesn't work because Cat and
> Category are not based on django.db.models.Model .
>
> On
Forgo the most important part. I want to be prompted with a
checkboxes that show which categories are selected, as well as the
ones that aren't.
On Aug 6, 2:13 pm, lingrlongr wrote:
> Having difficulty getting the check_test to work. Can't find any
> examples out there
Having difficulty getting the check_test to work. Can't find any
examples out there that help. I'll probably have to give a little
background. I simplified where able to...
class Cat:
name = CharField
class Category:
name = ForeignKey(Cat)
weight = DecimalField
item = ForeignKey('Item'
pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Tue, Dec 9, 2008 at 1:58 PM, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > I have a function called get_urls that returns a list of absolute_urls
> > for various models in the same project. This function is
I have a function called get_urls that returns a list of absolute_urls
for various models in the same project. This function is used for
another model in a way so that when a particular model appears on the
site, I can choose which part of the site this model links to.
# utils.py
def get_urls():
What's the best way to always set a User foreign key to the current
user using the admin site? For example:
# models.py
class MyModel(models.Model):
my_data = models.CharField(max_length=50)
user = models.ForeignKey(User)
When this was saved/updated in the admin, "user" should always eq
I want to show a formset as just text in a table in the admin. So I'm
trying to override the tabular.html template. How can I just extract
the value of the field, instead of showing the widget. Here's that
particular part of the template:
{% for fieldset in inline_admin_form %}
Before the new forms and admin came, I could've sworn that the
prepopulate_from (now prepopulated_fields) stuff worked when creating
a new object in the admin, __AND__ when you edit an existing object.
Can someone confirm if this should work for editing objects too?
Currently, it does not.
Keith
Thank you both. There WAS something I forgot in the . I got so
absorbed in making the the section its own block that I forgot
to close the tag.
On Sep 18, 7:13 pm, "Daniele Procida" <[EMAIL PROTECTED]>
wrote:
> On Thu, Sep 18, 2008, lingrlongr <[EMAIL PROTECTED]> wrot
Strangest thing...
I primarily use and develop on Ubuntu and use Firefox. So I went to
check out how many bugs IE was generous enough to give me to fix.
Using the Django development server, I can connect fine from a Windows
computer and view the site using Firefox. When I use IE (tested 6 &
7),
t_image_path
>
> Cheers,
>
> On Sep 18, 10:20 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > According to the documentation, I can make the upload_to argument a
> > callable (which must receive 2 args):
>
> > class Product(models.Model):
> > num
According to the documentation, I can make the upload_to argument a
callable (which must receive 2 args):
class Product(models.Model):
number = models.CharField(max_length=20)
image = models.ImageField(upload_to='')
I want to build a path so it looks like this (with respect to
MEDIA_URL)
SLEngine On
> SSLCertificateFile /etc/apache2/holdenweb.com.crt
> SSLCertificateKeyFile /etc/apache2/holdenweb.com.key
>
> regards
> Steve
>
> lingrlongr wrote:
> > Hmmm I played around a bit more. I don't think this is a Django
> >
mething my host has set up somewhere in the config...
keith
On Sep 17, 10:34 am, lingrlongr <[EMAIL PROTECTED]> wrote:
> I can't view my site over ssl. If I go tohttp://www.mysite.com, the
> site works. If I go tohttps://www.mysite.com, I get a secure
> connection, but
I can't view my site over ssl. If I go to http://www.mysite.com, the
site works. If I go to https://www.mysite.com, I get a secure
connection, but my django app isn't get served, but rather /var/www/
index.html is. Here's my apache config for mysite:
ServerName mysite.com
ServerAlias
Are we still on this!?!? There are SPAM filters (like Spam Assassin)
that automatically add this in the subject if it this an email is
SPAM. Relax!
On Sep 14, 9:19 pm, n00m <[EMAIL PROTECTED]> wrote:
> Next time you open your own thread
> let me know:
> I'll mark it as ***SPAM***
> and we'll se
Ah, I figured it out.
class ProductImage(models.Model):
image = models.ImageField(upload_to='images', height_field='height',
width_field='width')
Example:
>>> p = ProductImage.objects.all()[0]
>>> p.image.height
250
>>> p.image.width
Can someone explain how to use the height_field and width_field for an
ImageField as it would relate to this model:
class ProductImage(models.Model):
image = models.ImageField(upload_to='images')
The explanation in the documentation is:
Name of a model field which will be auto-populated with t
The Formwizard gave me MANY problems. What exactly is happening?
Here's what I was experiencing:
http://groups.google.com/group/django-users/browse_thread/thread/764ddb2d1b5d92d8/7ae5c2633564bd49#7ae5c2633564bd49
keith
On Sep 11, 4:46 am, David Reynolds <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> I am
slight change...
(r'^about/$', 'django.views.generic.simple.direct_to_template', {
'template': 'main.html',
'extra_context': {
'about': True,
}
}),
On Sep 8, 3:44 pm, "Abdallah El Guindy" <[EMAIL PROTECTED]>
wrote:
> Hey all,
>
> I want to use the generic view direct_to_template and to
Take a look here:
http://www.djangoproject.com/documentation/shortcuts/#render-to-response
keith
On Sep 4, 2:44 pm, Cortland Klein <[EMAIL PROTECTED]> wrote:
> I have two templates, one called via a Generic View and one via my own
> View. They both extend a base.html view that has {{MEDIA_URL
Maybe I'm experiencing this?
http://code.djangoproject.com/ticket/8808
I don't even understand what that ticket is about. And I'm not using
parse_params or get_template...
On Sep 3, 4:06 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
> I'm desperate here. I'
York: 2008-09-03 23:32:54.726363
America/Denver: 2008-09-03 23:32:54.726409
EST+05EDT,M4.1.0,M10.5.0: 2008-09-03 19:32:54.726451
So if there's any Westhosters out there, you'll benefit from this.
On Aug 25, 11:30 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
> Here's
I'm desperate here. I'm having serious problems with the form
wizard.
In url.py I have:
url(r'refinance/$', RefinanceWizard([RefinanceForm_1,
RefinanceForm_2, DummyForm, DummyForm]), name='refinance'),
So you can see that I have 4 steps. The purpose of the DummyForm is
just a place holder
thing happened at all.
>
> On 9月3日, 下午10时59分, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > You are including the tiny_mce library after you reference it. Try
> > switching the order to:
>
> > js = (
> > '/app_media/tiny_mce/tiny_mce
3, 11:45 am, bin <[EMAIL PROTECTED]> wrote:
> didn't work
>
> what should i fill in my MEDIA_URL in settings.py?
>
> is it like this: MEDIA_URL = './appmedia/'
>
> On 9月3日, 下午11时32分, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > woops try this:
You are including the tiny_mce library after you reference it. Try
switching the order to:
js = (
'/app_media/tiny_mce/tiny_mce.js',
'/app_media/textareas.js',
)
On Sep 3, 10:50 am, bin <[EMAIL PROTECTED]> wrote:
> Hi all
>
> i wanna embed a richtext
Thanks Malcolm. That really cleared things up for me! Now I can
relax, just a little, for the holiday weekend. That was really
driving me nuts!
On Aug 29, 6:06 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Fri, 2008-08-29 at 15:00 -0700, lingrlongr wrote:
> >
etc...
If I set the PythonPath in my apache conf like this, ___the site
works_:
PythonPath "['/home/django/proj','/home/django/proj/loan'] + sys.path"
Thoughts?
On Aug 29, 11:51 am, lingrlongr <[EMAIL PROTECTED]> wrote:
> Thanks Malcolm. How do
This sounds like the same problem I'm having I have a post
going here too!
http://groups.google.com/group/django-users/browse_thread/thread/c30b4395f5153cf3/dad6e7a1ebef3175#dad6e7a1ebef3175
On Aug 29, 2:54 pm, Aaron <[EMAIL PROTECTED]> wrote:
> Hi, strange enough, I was having a simil
python2.5/site-packages', '/usr/local/python/lib/
python2.5/site-packages/PIL']
And like I said, what's strange is that if I run the development
server @ my web host, it works fine!
Keith
On Aug 29, 12:57 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Thu,
I had all my imports for my apps relative to the app, not the
project. Since my last SVN checkout this evening, everything on the
site I'm working on is broken. I would get an error stating (app
after app) that the module app_name.models (etc) could not be found.
The import syntax was:
from app
Yes, Malcolm. You understood it correctly. I'll probably just add a
quick MY_CHOICES_2 tuple that has these "-" values until I see
what the plan is.
On Aug 28, 9:40 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Thu, 2008-08-28 at 21:32 -0400, Steve Hold
Submitted ticket #8663 for the following:
When a ModelForm? is used to display a form for a Model, the fields
defined with a choices option insert a "---" value for the first
option when the form is rendered. If you override a field and manually
specify the choices for a Select widget, this "
Anyone else ever do anything like this?
On Aug 26, 10:13 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
> Is there a way for me to quickly make certain fields in a ModelForm
> class required. I know this looks back to the model for that
> information...
>
> In my case I
Also, convention seems to be to spell out the field names. Because of
a different namespaces, you shouldn't have to worry about too much
name clashing. And if you don't provide an ID for your model, one is
automatically created for you. For example:
class Category(models.Model):
name =
Your problem is here:
def category_entry(request, category):
entries_in_cat = Entry.objects.filter(entry_cat=category)
return render_to_response('blog/index.html', locals())
Remember, the value of "category" is a string. One way or another you
need adjust the filter. Something
If manage.py is not in your PATH (it most likely isn't), you need to
qualify the location. You can just use this command from within your
project directory:
./manage.py runserver
./ means current directory.
HTH
Keith
On Aug 27, 6:42 pm, Sonny <[EMAIL PROTECTED]> wrote:
> When I type ' python
You could also check out westhost.com. They offer VPS pretty cheap
too. I successfully set up Django there a number of times already. I
usually use the development (SVN) version, but since an svn client
isn't installed there, I just "svn update" locally then FTP the
tarball up there when I want
calls the database once instead of
> > twice. Beautiful! Thank you. I'm going to try the query you
> > suggested.
>
> > queryset=Artist.objects.select_related().all()
>
> > I'd like to just pull in the albums, artwork, and tracks related to
> >
The error is generated because you have two fields in the Swap model
that refer to the User model, and two that refer to the Shifts model.
As the error states you need to specify the related_name value for
those ForeignKeys. Take a look at the documentation for related_name
here:
http://www.djan
Is there a way for me to quickly make certain fields in a ModelForm
class required. I know this looks back to the model for that
information...
In my case I'm using a FormWizard to display a series of forms. The
fields shows in some steps are dependent on answers to previous
questions. So, in
Start with urls.py. Are you doing this anywhere?
import models
If you have a lot of apps, you could remove all but one from
INSTALLED_APPS, test manage.py, repeat, until you find the offending
app. The just go through the files in the app and make sure you are
properly defining any imports.
It makes me wonder now though. If I can just include a bunch of
morsels on a page, why even bother using flatpages anymore?? That
just makes things more difficult to maintain. Thoughts?
On Aug 21, 5:19 am, Itai Tavor <[EMAIL PROTECTED]> wrote:
> At first glance (and, quite possibly, second and
e information.
>>> from datetime import datetime
>>> datetime.today()
datetime.datetime(2008, 8, 25, 21, 26, 21, 383524)
Keith
On Aug 25, 11:11 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
> I'm a little confused about the TIME_ZONE setting in settings.py. I
> ori
I'm a little confused about the TIME_ZONE setting in settings.py. I
originally had it set to 'America/New_York', because that's the time
zone where I'm located, but I noticed the times were ~4 hours off when
I would save an object that had a DateTimeField(auto_now_add=True)
field in the model. I
)
o.site = Site.objects.get_current()
o.save()
Inheriting from a form doesn't seem to work. But I'll work on that...
class A(ApplicationForm)
class B(A) <-- not working - fields don't populate from parent obj
On Aug 23, 9:40 pm, lingrlongr <[EMAIL PROTECTED]> wrot
elForm):
> def __init__(self, *args, **kwargs):
> super(myForm, self).__init__(*args, **kwargs)
> self.fields.keyOrder = ['foo', 'bar',...]
>
> 2. in the same way you could use
> self.fields['foo'].label = self.fields['foo'].help_text
>
the model's help_text as the field label?
Keith
On Aug 22, 4:24 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
> Ah, so I guess ModelForm will work with the FormWizard? I'll have to
> look through that documentation. Reading documentation is easier than
> pulling my hair o
Recommended fix @ http://code.google.com/p/django-morsels/issues/detail?id=1
On Aug 22, 2:51 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
> If I change my view to this, it works:
>
> # views.py
> def myview(request):
> return object_list(
> request,
>
Ah, so I guess ModelForm will work with the FormWizard? I'll have to
look through that documentation. Reading documentation is easier than
pulling my hair out! =)
Thanks Rajesh.
On Aug 22, 4:14 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
> Hi Keith,
>
>
>
> > I'm using the form wizard for a
On Aug 22, 12:50 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
> I can't get this to work at all. Seems to bomb here:
>
> class MorselManager(models.Manager):
> def get_for_current(self, context, name, inherit=False):
> if not context.has_key('request
I'm using the form wizard for a project. All the field names in
models.py coincide with the field names in forms.py. There is ONE
field that is consistently, yet sporadically, causing problems and I
cannot see why.
# models.py
class PurchaseApplication(BasicApplication):
down_payment_assets
I can't get this to work at all. Seems to bomb here:
class MorselManager(models.Manager):
def get_for_current(self, context, name, inherit=False):
if not context.has_key('request'): <-- key never
seems to exist
return None
I have a morsel defined with a URL of "
Also note, if your intentions were to grab all that information and
just send the artist to the template, I think you'd get better
performance if your queryset in the view looked like this:
queryset=Artist.objects.select_related().all()
Keith
On Aug 22, 11:17 am, lingrlongr <[EMAIL P
erse the process so I can get all the artist vars plus
> the data I need from the track and album tables? Thanks a bunch,
> you've been very helpful already.
>
> Charlie
>
> On Aug 22, 12:26 am, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > One more note. You wou
Take a look at django-logging.
http://code.google.com/p/django-logging/wiki/Overview
On Aug 22, 4:26 am, [EMAIL PROTECTED] wrote:
> Hi All,
>
> Can anybody tell me if there's a possibility to see output of the
> regular print command when used in a view? fo instance to a log file
> with a "tail
One more note. You wouldn't NEED to explicitly grab all those vars,
as you can get them in a template too. I just wanted to show you the
relation.
If you sent the track to the template, you can get the artist by
using:
{{ track.album.artist }}
Keith
On Aug 22, 12:24 am, lingrlongr &l
The only part you have that is redundant is the "artist" in your
"Track" class. You can find out the artist because a track is related
to an album, which in turn, is related to an artist.
Some of the code you'd maybe see in a view would be:
# views.py
from django.shortcuts import get_object_or_
69 matches
Mail list logo