Replacing description field in syndication RSS feed

2009-10-14 Thread simong

I can create an RSS feed using the documentation for syndication and
have tried to extend it using the MediaRSS format as described here:
http://www.djangosnippets.org/snippets/1648/.

This works up to a point: I'm testing with Firefox and it still
doesn't display the media: extensions, but that's by the by at the
moment. I would like to put a thumbnail image in the description
field, and replace the content with my product description, but I
can't work out how to override the default description field. I have
tried defining description() and item_description() in my code but
neither seems to work. I would try using the template system but the
documentation is seemingly nonexistent for this. Cany anyone shed any
light on what I should be doing?

Thanks
Simon
--~--~-~--~~~---~--~~
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-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Passing a dynamic ChoiceField response to a ForeignKey instance

2009-05-15 Thread simong

There's probably a very simple answer to this but I can't see it at
the moment:

This model:

class Product(models.Model):
user = models.ForeignKey(User, related_name="product_list",
editable=False)
productid = models.CharField(max_length=40, blank=True)
prodname = models.CharField(max_length=255, verbose_name='Product
name')
proddesc = models.TextField(blank=True, verbose_name='Description')
prodtopcat = models.ForeignKey(ProductTopCategory,
verbose_name='Product Main Category')
prodsubcat = models.ForeignKey(ProductSubCategory,
verbose_name='Product Sub Category')
unit = models.ForeignKey(Units, verbose_name='Unit')
video = models.ManyToManyField('Video', blank=True,
verbose_name='Video')
costperunit = models.DecimalField(max_digits=6, decimal_places=2,
verbose_name='Cost per unit')
costperlot = models.DecimalField(max_digits=6, decimal_places=2,
verbose_name='Cost per lot')
available = models.BooleanField(default=True)
featured = models.BooleanField(blank=True, null=True)

is used to generate a ModelForm with two modified fields that enable
the field 'prodsubcat' to be dynamically populated based on the
selection of 'prodtopcat'.

class DynamicChoiceField(forms.ChoiceField):
def clean(self, value):
return value

class ProductForm(ModelForm):
prodsubcat = DynamicChoiceField(widget=forms.Select(attrs=
{'disabled': 'true'}), choices =(('-1', 'Select Top Category'),))

I took this from an item I found on the web. I think setting the
'disabled' attribute is all I actually need.

The dynamic lookup is performed using jQuery.getJSON with this view:

def feeds_subcat(request, cat_id):
from django.core import serializers
json_subcat = serializers.serialize("json",
ProductSubCategory.objects.filter(prodcat = cat_id), fields=('id',
'shortname', 'longname'))
return HttpResponse(json_subcat, mimetype="application/javascript")

and the SELECT HTML is generated like this:

options += '' + j[i].fields
['longname'] + '';

This all works, but on submitting the form, I get the error 'Cannot
assign "u'17'": "Product.prodsubcat" must be a "ProductSubCategory"
instance' where "u'17'" is the option value of id_prodsubcat

What type of variable should I be passing (I assume int) and where
should I be converting it? In validation, in the pre-save signal, in
the save signal? Or should I be trying to convert it on the form
itself? Where is the ForeignKey instance save process documented?

TIA
Simon
--~--~-~--~~~---~--~~
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-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



fail_message 'changed' when updating form

2009-04-03 Thread simong

I have this model to add new products to a database:

--
class Product(models.Model):
user = models.ForeignKey(User)
productid = models.CharField(max_length=40, blank=True)
prodname = models.CharField(max_length=255, verbose_name='Product
name')
proddesc = models.TextField(blank=True, verbose_name='Description')
prodtype = models.ForeignKey(Prodtype, verbose_name='Product Type')
unit = models.ForeignKey(Units, verbose_name='Unit')
image = models.ManyToManyField('Image', blank=True,
verbose_name='Image')
video = models.ManyToManyField('Video', blank=True,
verbose_name='Video')
costperunit = models.DecimalField(max_digits=6, decimal_places=2,
verbose_name='Cost per unit')
costperlot = models.DecimalField(max_digits=6, decimal_places=2,
verbose_name='Cost per lot')
available = models.BooleanField(default=True)
featured = models.BooleanField(blank=True, null=True)
def __unicode__(self):
return self.prodname
--
It has a ModelForm with a custom __init__ definition to get an
associated list of video files:

--
class ProductForm(ModelForm):
def __init__(self, user, *args, **kwargs):
super(ProductForm, self).__init__(*args, **kwargs)
self.fields['video'].queryset = Video.objects.filter(user=user)

class Meta:
model = Product
exclude = ('user', 'productid', 'available', 'featured')
--

If I use this model and model form to edit a product using this view,
which I know is a bit hacky, but will be tidied up eventually:

--
def edit_product(request, prodid):
if request.user.is_authenticated():
user = request.user
try:
product = Product.objects.get(id = prodid)
except Product.DoesNotExist:
pass
if request.method == 'POST':
productform = ProductForm(request.POST, 
instance=product)
productform.user = user
if productform.is_valid:
productid = productform.save()
return 
HttpResponseRedirect('/product/'+productid )
else:
return 
render_to_response('products/base_newproduct.html',
{ 'productform': productform })
else:
productform = ProductForm(request.user or None, 
instance=product)
errormsg = ''
return render_to_response('products/base_newproduct.html',
{ 'productform': productform })

--

On submitting the query, I get and AttributeError: 'ProductForm'
object has no attribute 'cleaned_data'

I understand why this is returned as I'm not handling the is_valid
statement. However, there are no errors coming back that I can see,
either in the 500 response or if I run the query from a shell. From
the traceback I get this:

--
Traceback:
File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py"
in get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "/usr/lib/python2.5/site-packages/django/contrib/auth/
decorators.py" in __call__
  67. return self.view_func(request, *args, **kwargs)
File "/var/www/stocktube/products/views.py" in edit_product
  49.   productid = productform.save()
File "/usr/lib/python2.5/site-packages/django/forms/models.py" in save
  319. return save_instance(self, self.instance,
self._meta.fields, fail_message, commit)
File "/usr/lib/python2.5/site-packages/django/forms/models.py" in
save_instance
  43. cleaned_data = form.cleaned_data

Exception Type: AttributeError at /products/edit/1/
Exception Value: 'ProductForm' object has no attribute 'cleaned_data'

--
and the response from the cleaned_data request (doesn't format
properly but read alternate lines)

commit
True
exclude
None
fail_message
'changed'
fields
None
form

instance

models

opts


>From the shell I get this:


--
Traceback (most recent call
last)

/home/simong/projects/stocktube/ in ()

/usr/lib/python2.5/site-packages/django/forms/models.py in save(self,
commit)
317 else:
318 fail_message = 'changed'
--> 319 return save_instance(self, self.instance,
self._meta.fields, fail_message, commit)
320
321 class ModelForm(BaseModelForm):

/usr/lib/python2.5/site-packages/django/forms/models.py in
save_instance(form, instance, fields, fail_message, commit, exclude)
 41  

django-profile instance data on custom form

2009-03-12 Thread simong

I'm creating a profile form that includes first_name and last_name
fields that write to the User model  and additional fields that write
to my user profile model derived from Alex S's post here:
http://groups.google.com/group/django-users/msg/00e49ca16c63762c

class UserProfileForm(forms.Form):
first_name = forms.CharField(max_length=128, required=False)
last_name = forms.CharField(max_length=128, required=False)
# userprofile form
address1 = forms.CharField(widget=forms.TextInput(attrs={ 'size':
'40' }), required=False)
address2 = forms.CharField(widget=forms.TextInput(attrs={ 'size':
'40' }), required=False)
address3 = forms.CharField(widget=forms.TextInput(attrs={ 'size':
'40' }), required=False)
towncity = forms.CharField(widget=forms.TextInput(attrs={ 'size':
'40' }), required=False)
adminregion  = forms.CharField(widget=forms.TextInput(attrs={ 
'size':
'40' }), required=False)
country = forms.CharField(max_length=128, required=False)
postcode = forms.CharField(max_length=10, required=False)
telno = forms.CharField(max_length=20, required=False)
email = forms.EmailField(required=False)

I have implemented a save() method but haven't tested it yet.

The urlpattern for this is:

(r'^profiles/edit/$', 'profiles.views.edit_profile', { "form_class":
UserProfileForm }, "profile_edit_profile")

I can draw an instance of the form using django-profile's
profile_edit_profile view but this is not currently populating the
form with existing profile data. Following the django-profile docs, I
have created an __init__ function for the form as follows:

def __init__(self, instance, *args, **kwargs):
super(UserProfileForm, self).__init__(instance, *args, **kwargs)
self.instance = instance

This returns a form because it creates an 'instance' keyword but
doesn't populate it with data from profile_obj as called in views.py.
Do I need to call profile_obj in my init function and how, or is it
something else, or am I looking in the wrong direction. Document
pointers are welcome as I can't find anything specific.

Thanks
Simon
--~--~-~--~~~---~--~~
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-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Datetime and apache log files show wrong timezone

2009-01-24 Thread simong



On Jan 24, 2:30 pm, Graham Dumpleton 
wrote:
> On Jan 24, 8:46 pm, simong  wrote:
>
>
>
> > My apologies in advance if this isn't a direct django issue but I
> > can't work out where the problem is coming from.
>
> > My server's system time runs Centos 5 and is set to Europe/London:
>
> > -bash-3.2$ date
> > Sat Jan 24 12:26:14 GMT 2009
> > -bash-3.2$ date -u
> > Sat Jan 24 12:26:17 UTC 2009
> > -bash-3.2$ /sbin/hwclock --show
> > Sat 24 Jan 2009 12:31:34 PM GMT  -0.984663 seconds
>
> > /etc/sysconfig/clock is set thusly:
>
> > ZONE="Europe/London"
> > UTC=true
> > ARC=false
>
> > My django application timezone is set to 'Europe/London':
>
> > TIME_ZONE = 'Europe/London'
>
> > The application creates a datestamp to log when an order has been
> > requested using datetime.datetime.now() but it and the apache logs are
> > still using EST, which was what the machine was set to on build (no
> > idea why, it's based in Germany):
>
> > xxx.xxx.xxx.xxx - - [24/Jan/2009:07:16:19 -0500] "GET /media/images/
> > bground_bottom_right.png HTTP/1.1" 200 116555 
> > "http://www.popfood.co.uk/media/css/common.css"; "Mozilla/5.0 (Macintosh; U;
> > Intel Mac OS X 10.5; en-US; rv:1.9.0.5) Gecko/2008120121 Firefox/3.0.5
> > Ubiquity/0.1.5"
>
> > The server has a Plesk control panel which provides a editable
> > configuration file for the domain called vhost.conf which should
> > override anything in the Plesk-generated config files, so I have
> > added
> > SetEnv TZ Europe/London to that and restarted apache to no effect.
>
> That will not do anything as it only modified process environment
> variables for CGI script processes execed from Apache.
>
> If you are seeing the wrong timzone from what you are setting, it is
> most likely because you are running multiple applications in same
> Apache instance and each is wanting to use a different timezone. These
> could be multiple Django instances, or even PHP applications.
>
> Short answer is you can't run multiple applications in same Apache
> which have different timezone requirements.
>
> Graham
>

For your information SetEnv does work in mod_python. It is referred to
in the djangoproject documentation for setting up a server using
mod_python here: 
http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#howto-deployment-modpython

Simon
--~--~-~--~~~---~--~~
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-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Datetime and apache log files show wrong timezone

2009-01-24 Thread simong



On Jan 24, 2:30 pm, Graham Dumpleton 
wrote:
> On Jan 24, 8:46 pm, simong  wrote:
>
>
>
> > My apologies in advance if this isn't a direct django issue but I
> > can't work out where the problem is coming from.
>
> > My server's system time runs Centos 5 and is set to Europe/London:
>
> > -bash-3.2$ date
> > Sat Jan 24 12:26:14 GMT 2009
> > -bash-3.2$ date -u
> > Sat Jan 24 12:26:17 UTC 2009
> > -bash-3.2$ /sbin/hwclock --show
> > Sat 24 Jan 2009 12:31:34 PM GMT  -0.984663 seconds
>
> > /etc/sysconfig/clock is set thusly:
>
> > ZONE="Europe/London"
> > UTC=true
> > ARC=false
>
> > My django application timezone is set to 'Europe/London':
>
> > TIME_ZONE = 'Europe/London'
>
> > The application creates a datestamp to log when an order has been
> > requested using datetime.datetime.now() but it and the apache logs are
> > still using EST, which was what the machine was set to on build (no
> > idea why, it's based in Germany):
>
> > xxx.xxx.xxx.xxx - - [24/Jan/2009:07:16:19 -0500] "GET /media/images/
> > bground_bottom_right.png HTTP/1.1" 200 116555 
> > "http://www.popfood.co.uk/media/css/common.css"; "Mozilla/5.0 (Macintosh; U;
> > Intel Mac OS X 10.5; en-US; rv:1.9.0.5) Gecko/2008120121 Firefox/3.0.5
> > Ubiquity/0.1.5"
>
> > The server has a Plesk control panel which provides a editable
> > configuration file for the domain called vhost.conf which should
> > override anything in the Plesk-generated config files, so I have
> > added
> > SetEnv TZ Europe/London to that and restarted apache to no effect.
>
> That will not do anything as it only modified process environment
> variables for CGI script processes execed from Apache.
>
> If you are seeing the wrong timzone from what you are setting, it is
> most likely because you are running multiple applications in same
> Apache instance and each is wanting to use a different timezone. These
> could be multiple Django instances, or even PHP applications.
>
> Short answer is you can't run multiple applications in same Apache
> which have different timezone requirements.
>
> Graham
>

Nope, there is one other django application running on the server and
it's set to Europe/London too. There's nothing else on the machine
that uses any scripting.

A further search suggests setting a PythonOption for mod_python might
work.

Simon
--~--~-~--~~~---~--~~
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-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Datetime and apache log files show wrong timezone

2009-01-24 Thread simong

My apologies in advance if this isn't a direct django issue but I
can't work out where the problem is coming from.

My server's system time runs Centos 5 and is set to Europe/London:

-bash-3.2$ date
Sat Jan 24 12:26:14 GMT 2009
-bash-3.2$ date -u
Sat Jan 24 12:26:17 UTC 2009
-bash-3.2$ /sbin/hwclock --show
Sat 24 Jan 2009 12:31:34 PM GMT  -0.984663 seconds

/etc/sysconfig/clock is set thusly:

ZONE="Europe/London"
UTC=true
ARC=false


My django application timezone is set to 'Europe/London':

TIME_ZONE = 'Europe/London'

The application creates a datestamp to log when an order has been
requested using datetime.datetime.now() but it and the apache logs are
still using EST, which was what the machine was set to on build (no
idea why, it's based in Germany):

xxx.xxx.xxx.xxx - - [24/Jan/2009:07:16:19 -0500] "GET /media/images/
bground_bottom_right.png HTTP/1.1" 200 116555 "http://
www.popfood.co.uk/media/css/common.css" "Mozilla/5.0 (Macintosh; U;
Intel Mac OS X 10.5; en-US; rv:1.9.0.5) Gecko/2008120121 Firefox/3.0.5
Ubiquity/0.1.5"

The server has a Plesk control panel which provides a editable
configuration file for the domain called vhost.conf which should
override anything in the Plesk-generated config files, so I have
added
SetEnv TZ Europe/London to that and restarted apache to no effect.

I built python 2.5.2 by hand on the server as it came with 2.4 so I am
wondering if the timezone is statically set somewhere in either the
python or apache build, but does anyone have any other suggestions
related to django, python or apache as to why I can't override the
timezone setting?

Thanks
Simon
--~--~-~--~~~---~--~~
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-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ModelForm fails with TypeError on save

2008-10-20 Thread simong



On Oct 20, 12:28 pm, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Oct 20, 11:12 am, simong <[EMAIL PROTECTED]> wrote:
>
>
>
> >         if request.method == 'POST':
> >                 orderform = OrderForm(request.POST)
> >                 if orderform.is_valid():
> >                         preorder = orderform.save(commit=False)
> >                         orderno  = '%04d' % (preorder.id)
> >                         preorder.orderno = orderno
> >                         preorder.cartid = cartid
> >                         preorder.save()
>
> > I do the uncommited save to get pk to pad it for an order number.
> > However, at orderform.save, I am now getting the eternally helpful
> > error
>
> > : coercing to Unicode: need string or
> > buffer, NoneType found.
>
> I assume the error is happening at the line:
> orderno  = '%04d' % (preorder.id)
> I'm not sure what you're expecting to happen here. You explicitly call
> commit=False on the form save, so the model isn't saved to the
> database and preorder won't have an id. Then you attempt to use that
> non-existent id - unsurprisingly, Python can't convert None into a
> four-digit number.
>
> If your 'orderno' field is simply a four-digit padded version of the
> pk field, you would probably be better of providing a model method to
> get that, rather than saving it twice to the database.
>

I agree that's not pretty, but it has been working for a while. I
added the TextArea widgets in for styling yesterday and now it's
stopped. I don't know if the two are related and I can't see why they
should be. I agree that it should be a model method though so I will
try that approach.

s/
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ModelForm fails with TypeError on save

2008-10-20 Thread simong

I have a model like this:

class OrderProfile(models.Model):
cartid = models.CharField(max_length=128, null=True, blank=True)
orderno = models.CharField(max_length=48, null=True, blank=True)
userid = models.CharField(max_length=128, null=True, blank=True)
userfirstname = models.CharField(max_length=128, null=True,
verbose_name='Name')
userlastname = models.CharField(max_length=128, null=True,
verbose_name='Name')
address1 = models.CharField(max_length=128, null=True,
verbose_name='Address')
address2 = models.CharField(max_length=128, null=True, blank=True,
verbose_name='')
address3 = models.CharField(max_length=128, null=True,
verbose_name='Locality')
towncity = models.CharField(max_length=128, null=True,
verbose_name='Town/City')
adminregion = models.CharField(max_length=128, null=True,
verbose_name='District/County', blank=True)
postcode = models.CharField(max_length=10, null=True,
verbose_name='Postcode')
telno = models.CharField(max_length=20, null=True,
verbose_name='Telephone')
email = models.CharField(max_length=128, verbose_name='Email',
null=True)
def __unicode__(self):
return self.orderno

I have a ModelForm derived from it like this:

class OrderForm(ModelForm):
address1 = forms.CharField(widget=forms.TextInput(attrs={ 'size':
'40' }))
address2 = forms.CharField(widget=forms.TextInput(attrs={ 'size':
'40' }), required=False)
address3 = forms.CharField(widget=forms.TextInput(attrs={ 'size':
'40' }))
towncity = forms.CharField(widget=forms.TextInput(attrs={ 'size':
'40' }))
adminregion = forms.CharField(widget=forms.TextInput(attrs={ 'size':
'40' }))
class Meta:
model = OrderProfile
exclude = ('cartid', 'orderno', 'userid')

as an aside, and which doesn't appear to be documented, I had to add
'required=False' to the address2 widget as setting it overrides the
settings in the model, which I suppose is correct on one level, but
for me isn't expected behaviour. But I'm not interested in that now.

The code to process the form is simple:

if request.method == 'POST':
orderform = OrderForm(request.POST)
if orderform.is_valid():
preorder = orderform.save(commit=False)
orderno  = '%04d' % (preorder.id)
preorder.orderno = orderno
preorder.cartid = cartid
preorder.save()

I do the uncommited save to get pk to pad it for an order number.
However, at orderform.save, I am now getting the eternally helpful
error

: coercing to Unicode: need string or
buffer, NoneType found.

The POST data I am sending is correct and the error occurs whether
address2 is empty or not. I can replicate this either in a form, where
it fails because preorder.id returns the error, or on the command
line, where the traceback gives no particular help with what is
failing. None of the excluded fields in the form are required in the
db table (in fact I've modified that so that all fields except id are
null). I can see why the error might happen, but I'm not sure if I'm
missing something. Any suggestions?

Thanks
Simon
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: TemplateSyntaxError 'No module named admin_urls' in 1.0 stable

2008-09-04 Thread simong



On Sep 4, 3:53 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Thu, Sep 4, 2008 at 10:00 AM, simong <[EMAIL PROTECTED]> wrote:
> > It might have been in part a caching problem in Firefox: to clarify,
> > I'm testing this on my laptop running Ubuntu 8.04 using apache2 with
> > local name resolution using names against localhost, which is fairly
> > non-standard but is the easiest way to do it on a machine that moves
> > around. I have since tested the project with django's built-in web
> > server and while I got the same problem at first, forcing a reload of
> > the page in Firefox has made it go away in the top levels of the admin
> > section.
>
> > However, I have just experimented with adding a user, which worked,
> > and then granting admin rights, and the problem has returned. The
> > traceback is pasted here:http://dpaste.com/75889/
>
> > However, making other changes to user information doesn't raise the
> > error.
>
> > I also have treemenus installed and that is getting an ImportError
> > with the same value, but that could be because I haven't updated
> > treemenus: the traceback is here:http://dpaste.com/75891/
>
> I'm not familiar with the url resolver code, but the traceback seems to
> indicate you've got a module somewhere in what is referenced from your root
> urls.py that references a module named 'admin_urls'.  I'd grep for that
> string in the trees of all your installed apps to see where it is coming
> from.  I don't believe it exists in Django itself.  I don't know if it ever
> did, but if it did ensuring that you installed 1.0 cleanly (that is, removed
> any old version before installing 1.0...you didn't answer that part of my
> question?) would guarantee any old remnants of a previous Django are not
> causing the problem.  If you do really have a clean 1.0 install than I think
> this has to be coming from one of your installed apps.

I think I see it now - it's coming from treemenus, which I presumably
need to reconfigure as well. Oops..

Thanks for your help
Simon
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: TemplateSyntaxError 'No module named admin_urls' in 1.0 stable

2008-09-04 Thread simong

On Sep 4, 2:02 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Thu, Sep 4, 2008 at 7:04 AM, simong <[EMAIL PROTECTED]> wrote:
>
> > I am trying to migrate a project to 1.0 and I'm currently updating the
> > admin system. When I try to load the /admin/ URL I get this error:
>
> > Exception Type:         TemplateSyntaxError
> > Exception Value:        Caught an exception while rendering: No module
> > named
> > admin_urls
>
> > The error is coming from line 25 in /usr/lib/python2.5/site-packages/
> > django/contrib/admin/templates/admin/base.html
>
> > which is shown here:http://dpaste.com/75851/
>
> > The problem is with the tag {% url django-admindocs-docroot as
> > docsroot %}, which as far as I can see, doesn't exist in 1.0. I have
> > installed Django 1.0 from scratch, and the only other possible
> > weirdness is that I have the admin directory configured as admin_media
> > in settings.py, which is a symlink to /usr/lib/python2.5/site-package/
> > django/contrib/admin
>
> > Next step would appear to be to try and move my code to a 1.0 project,
> > but this would appear to be a bug in the admin templates.
>
> That named url does exist:
>
> http://code.djangoproject.com/browser/django/tags/releases/1.0/django...
>
> This is more likely a migration problem than a bug in 1.0. I have tested
> admin in configurations both with and without the django.contrib.admindocs
> application listed in INSTALLED_APPS and have not run into this.
>
> When you installed 1.0 did you first remove any old installed django?
>
> Is there a more complete traceback that might give a clue where this
> admin_urls reference is coming from?  I can't find that string anywhere in
> the 1.0 tree nor 0.96.
>

It might have been in part a caching problem in Firefox: to clarify,
I'm testing this on my laptop running Ubuntu 8.04 using apache2 with
local name resolution using names against localhost, which is fairly
non-standard but is the easiest way to do it on a machine that moves
around. I have since tested the project with django's built-in web
server and while I got the same problem at first, forcing a reload of
the page in Firefox has made it go away in the top levels of the admin
section.

However, I have just experimented with adding a user, which worked,
and then granting admin rights, and the problem has returned. The
traceback is pasted here: http://dpaste.com/75889/

However, making other changes to user information doesn't raise the
error.

I also have treemenus installed and that is getting an ImportError
with the same value, but that could be because I haven't updated
treemenus: the traceback is here: http://dpaste.com/75891/
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



TemplateSyntaxError 'No module named admin_urls' in 1.0 stable

2008-09-04 Thread simong

I am trying to migrate a project to 1.0 and I'm currently updating the
admin system. When I try to load the /admin/ URL I get this error:

Exception Type: TemplateSyntaxError
Exception Value:Caught an exception while rendering: No module named
admin_urls

The error is coming from line 25 in /usr/lib/python2.5/site-packages/
django/contrib/admin/templates/admin/base.html

which is shown here: http://dpaste.com/75851/

The problem is with the tag {% url django-admindocs-docroot as
docsroot %}, which as far as I can see, doesn't exist in 1.0. I have
installed Django 1.0 from scratch, and the only other possible
weirdness is that I have the admin directory configured as admin_media
in settings.py, which is a symlink to /usr/lib/python2.5/site-package/
django/contrib/admin

Next step would appear to be to try and move my code to a 1.0 project,
but this would appear to be a bug in the admin templates.

Simon

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Get and set encryption in Model Forms

2008-08-18 Thread simong

On Aug 11, 1:42 am, jonknee <[EMAIL PROTECTED]> wrote:
> On Aug 10, 11:29 am, simong <[EMAIL PROTECTED]> wrote:
>
> > The code executes correctly and writes the record to the database but
> > doesn't encrypt the credit card number.
>
> You're not following the snippet you linked to, the view code you
> posted shows that you're writing ccno directly. The example you linked
> to writes to the property. It might be easier to do in a custom save()
> method because the ModelForm one is automatically writing the ccno
> value.
>
> And in any event, you may want to rethink about saving credit card
> numbers at all. Especially like this where it's attached to an order.
> It's a big liability for little payoff (just save the info you get
> back from the payment gateway and you can do stuff like refunds and
> most support subscriptions). PCI compliance isn't easy and if you slip
> up you can easily lose the ability to accept credit cards and that
> will most likely devastate your business.

Finally got back to looking at this, thanks both for the tip.

I agree that it's not a good idea to save credit card numbers even
when encrypted but the client isn't using a payment gateway, just
their shop card machine so it's a way of transmitting the number so
that they can process it by hand.

Simon
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---