Re: current transaction is aborted, commands ignored until end of transaction block

2013-05-30 Thread ryan west
Hi Andreas,

The reason that you are seeing this likely is because of a bug in the way 
django handled Postgres autocommit. This has been documented 
here: 
https://docs.djangoproject.com/en/dev/releases/1.5/#behavior-of-autocommit-database-option-on-postgresql-changed

Regards,

Ryan

On Friday, May 24, 2013 1:55:57 AM UTC-7, Andréas Kühne wrote:
>
> Hi all,
>
> I am working on upgrading our system from django 1.3.1 to django 1.5.1, 
> and have run into a huge problem. The site we are running has multilingual 
> support and the platform has multiple top level domain sites connected to 
> it. Running locally on my machine I get an error when I try to switch 
> languages. 
>
> The error is : "current transaction is aborted, commands ignored until end 
> of transaction block", so I guess that something is not being commited 
> correctly to the database. If i change the database setttings to 
> "autocommit = True" then the site works perfectly. It doesn't matter which 
> page I go to, when there is a database lookup it will not work. It does 
> work in english (default language) and oddly enough swedish (can be because 
> that is "our" language, which I test first).
>
> I was wondering if there is anyone out there that has any ideas why a 
> change from 1.3.1 to 1.5.1 would result in these errors or if anyone has 
> any suggestions on what this could be?
>
> Regards,
>
> Andréas
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django - Tastypie update

2013-05-30 Thread ryan west
Are you using a PUT request to make this change?

If you are making a PUT request, as far as I know, Tastypie will attempt to 
replace the resource with what you are sending.

If you only want to update 1 field on the resource, look at making a PATCH 
request.

On Thursday, May 30, 2013 6:10:33 AM UTC-7, Hélio Miranda wrote:
>
> Hi
> I am using the tastypie with mongoengine, and my problem is when I edit a 
> field in a collection, when I save, references to other collection are 
> deleted ...
> Does anyone know why?
> I can only edit a field without changing the other?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Best practices to create multiple users profiles using Auth

2011-09-27 Thread ryan west
I actually just wrote a blog post about why I think extending
contrib.auth.models.User is a better solution to using a OneToOneField
(or a ForeignKey), you can find it here:

http://ryanwest.info/blog/2011/django-tip-5-extending-contrib-auth-models-user/

Please let me know what you think.

Regards,

Ryan

On Sep 27, 5:13 am, Santiago Basulto 
wrote:
> Hello friends,
>
> i'm new with django. I've something to ask you.
>
> I'm building a website similar to eBay where i've different "kinds" of
> users. These are: CustomerUser and SellerUser. Both of them has
> different data to be saved.
>
> While reading docs and django book i noted the UserProfile
> "trick" (https://docs.djangoproject.com/en/1.3/topics/auth/#storing-
> additional-information-about-users) to store additional info about my
> users. The problem is that i've two different users, not just one.
>
> I'm wondering what would be the best choice. I've think that i could
> use some inheritance, keeping the UserProfile strategy.
>
> class UserProfile(models.Model):
>     # some common data
>     user = models.OneToOneField(User)
>
> class Seller(UserProfile):
>     #specific Seller data
>
> class Customer(UserProfile):
>     #specific Customer data
>
> I tried to make that work, but i coulnd. I ran into several errors.
>
> After that i thought i could include oneToOne info in the UserProfile,
> similiar to:
>
> class UserProfile(models.Model):
>     is_seller = models.BooleanField()
>     is_customer = models.BooleanField()
>     seller_info = models.OneToOneField(SellerInfo)
>     customer_info = models.OneToOneField(CustomerInfo)
>     user = models.OneToOneField(User)
>
> class SellerInfo(models.Model):
>     #specific Seller data
>
> class CustomerInfo(models.Model):
>     #specific Customer data
>
> I think this should work, but also think that would be a "weird and
> ugly" solution.
>
> Have you expirienced this kind of problem? Can you help me with some
> idea please?
>
> Thank you very much!

-- 
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: absolute url in template and url name

2010-11-24 Thread ryan west
if you have a view let's say views.activate that corresponds to the
URL at let's say /account/activate/2, you can use the template tag {%
url views.activate params_for_url_capturing %}

Cheers

On Nov 24, 8:01 am, robos85  wrote:
> Hi,
> I'm writing an email sending module based on on templates. I have no
> idea how to put absolute url to my template (for 
> examplehttp://domain.com/account/activate/2). I have special url for this,
> named account_activation.
> I know how to pass variables but how to create that url?
> Shouls I use {{ url }} tag? It creates relative paths starting
> with /    :/

-- 
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...@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: No stylesheet in administration panel

2010-05-18 Thread ryan west
Just a django noob, but are you sure that the path for media is set
correctly in your settings.py file?

For instance, my media settings look like:

MEDIA_ROOT = '/home/ryanisnan/ryanwest.info/public/media'
MEDIA_URL = '/media/'
ADMIN_MEDIA_PREFIX = '/media/'

It could be that your MEDIA_ROOT are specified incorrectly, or
ADMIN_MEDIA_PREFIX is wrong too.You can also path to that folder
manually and check to see if the .css files are all installed
correctly.

-- 
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...@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: Installing 3rd party django applications on a shared environment

2010-05-18 Thread ryan west
Hey Tom,

Any idea why ./activate would be failing "Permission Denied"?

Ryan

-- 
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...@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: Installing 3rd party django applications on a shared environment

2010-05-18 Thread ryan west
Thanks Tom,

I'll have a look at that.

Ryan

>
> Google for virtualenv.
>
> Cheers
>
> Tom
>
> --
> 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...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Installing 3rd party django applications on a shared environment

2010-05-18 Thread ryan west
Disclaimer: This may be more of a python/shared hosting issue, but
alas I'm posting here.

Hey all,

I'm currently just trying to install some 3rd party django apps so I
can use them in my project.  I already have django up and running, I'm
hosting on Dreamhost using passenger.  I don't have my own python
installation, so I'm using dreamhost's shared.

I have built a custom app, and project, and they work perfect, however
I can't seem to install 3rd party apps (using the python setup.py
install method).

I have to use this method because I don't have acces to easy_install
for example, because the shared /usr/ directory is off limits to me.

python setup.py install fails because it doesn't see my custom install
directory on the PYTHONPATH (obviously).  I've tried modifying the
setup.py script to append the directory to the path before running,
but still no success.

Is there any way to do this?  It seems like overkill that I would have
to have my own installation of python running just to get 3rd party
apps to work, considering I can get mine going great.

Thanks in advance!

Ryan

-- 
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...@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: Django Project & App Structure

2010-05-14 Thread ryan west
Hey Scott, thanks for the reply!

I just figured that out the hard way actually, but I appreciate your
response.

My new directory structure now looks like:

/home/website/djangoprojects/mydjangoproject/
--- /
manage.py
--- /
settings.py
--- /
urls.py

/home/website/djangoapps/mydjangoapp/
-- /models.py
-- /admin.py
-- /urls.py
-- /view.py

My webserver (dreamhost) runs passenger, so I had to update my
passenger_wsgi.py file to include path of my projects (/home/website/
djangoprojects) as well as my apps (/home/website/djangoapps).

The tricky (at first) part came when I needed to fill the DB of my
project w/ tables required by my app(s).  To do this, I had to add the
same paths above to my manage.py file, so that when it was executed
the paths would be in there for the script to find and import the
model information.

Voila, I now have created an app that is independent of it's
surrounding project.  The only thing left is the fact that my app has
templates, which I understand is a no-no when making reusable apps.
I'll start working on that later, as I'm satisfied now with no strict
backwards dependencies.

Thanks again Scott.

I will be writing a blogpost about this shortly on how to create a
reusable django app on a shared webserver such as Dreamhost - in an
attempt to gather disparate information into one, easy to follow and
up to date post.  I will post back with the perma when it's done.

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



Django Project & App Structure

2010-05-13 Thread ryan west
So, I apologize for another topic focused on Django project and app
structure, but every resource I've found is either outdated or
incomplete.

What I am trying to accomplish is the creation & incorporation of
pluggable django applications that are NOT dependent in ANY way on the
project that uses them.  For those of you that have tried the official
django tutorial, you can see that the tutorial has new users creating
apps that are heavily dependent upon their surrounding project(s).

In an attempt to resolve this issue myself, I have come up with the
following directory structure, but am still having some issues:

/home/website/djangoproject/settings.py
 /urls.py
 /manage.py

/home/website/djangoapp/models.py
 /admin.py
 /url.py
 /views.py
 /templates/

In my application (located in djangoapp/), none of the files reference
the external project (djangoproject/), as it should be.  In my
djangoproject/settings.py file, I have djangoapp added in the
INCLUDED_APPS variable.

In the django admin interface, I can then see forms for my
corresponding models.  I can't actually do anything yet in the admin
interface however, as the corresponding tables in the database have
not been created yet (I haven't run syncdb yet).

When I try to run syncdb, manage.py returns an error saying that my
app (djangoapp) could not be found.  I've tried to add the URL of the
app to the system path so that it would be accessible from external
directories - to do this I've tried adding the absolute URL of my app
to my project's settings.py file, but either it doesn't work, or I'm
doing it wrong:

sys.path.append('/home/website/djangoapp')

Does anyone know how I might continue with this approach, or,
alternatively, does anyone know of a better, simpler approach to
including applications in their existing Django projects without
backwards dependencies?

Thanks.

-- 
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...@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: ValueError on deleting a model object with an ImageField through Admin Interface

2010-05-13 Thread ryan west
I found the solution to my own problem.  When the page was reloading,
I am guessing that the actual entity had not been deleted yet, and the
method __unicode__(self) was being called, requesting access of
self.image (which did not exist, because that HAD been deleted).

A simple modification to the method seems to have fixed the problem:

def __unicode__(self):
if (self.image):
return self.image.path
else:
return 'No image exists... I should be deleted any moment!'

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



ValueError on deleting a model object with an ImageField through Admin Interface

2010-05-13 Thread ryan west
I'm having a silly issue with the admin interface and an ImageField in
one of my models.  A simple model I have contains an ImageField, and
many objects of this model are related to some other model (Project,
not shown).  I can add/view images just fine, but when I try to delete
an image, I get a value error saying:

"ValueError at /admin/projects/project/1/
The 'image' attribute has no file associated with it."

The entry correctly deletes from my DB (on successive loads of the
admin page, I no longer see the entry), the file does not delete from
my directory however, and this error pops up.  Any thoughts on why?

I have tried with & without my custom delete function, with the same
results.  Help would be appreciated, thanks.

Ryan

# ProjectImage Model
def get_project_image_path(instance, filename):
   return os.path.join('projects', instance.project.name_slug,
filename)

class ProjectImage(models.Model):
   project = models.ForeignKey(Project, verbose_name='project',
help_text='The project that this image is related to.')
   image = models.ImageField(upload_to=get_project_image_path)
   description = models.CharField(max_length=128, help_text='The image
description is a small text blurb used to help readers identify what
they\'re looking at when viewing an image.', blank=True)

   class Meta:
  verbose_name='project image'
  verbose_name_plural='project images'

   def __unicode__(self):
  return self.image.path

   def delete(self):
  default_storage.delete(self.image.path)
  super(ProjectImage, self).delete()

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