Re: [django-users] Error when registering a new user - Django 1.5

2013-03-22 Thread Leonardo S
I did it and aparently it worked:

*# forms.py*
*class UserCreateForm(UserCreationForm):*
*
*
*
def clean_username(self):
username = self.cleaned_data["username"]
try:
self._meta.model._default_manager.get(username=username)
except self._meta.model.DoesNotExist:
return username
raise
forms.ValidationError(self.error_messages['duplicate_username'])
*
*
*
*class Meta:*
*model = get_user_model()*
*fields = ('email', 'password1', 'password2', 'first_name',
'last_name', 'bio', 'username')*
*
*
From:
https://groups.google.com/forum/?fromgroups=#!topic/django-users/kOVEy9zYn5c
Should not it be the UserCreationForm standard?


2013/3/23 Leonardo S 

> Hi,
>
> I am getting an error when registering a new user in a Django 1.5 app.
> It is the postgres' log:
>
> *BRT ERROR:  relation "auth_user" does not exist at character 280*
> *BRT COMMAND:  SELECT "auth_user"."id", "auth_user"."password",
> "auth_user"."last_login", "auth_user"."is_superuser",
> "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name",
> "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active",
> "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."username" =
> E'teste'*
> *
> *
> My code is very simple:
> *
> *
> *# models.py*
> *class User(AbstractUser):*
> *bio = models.CharField(max_length=255, blank=True, null=True)*
> *objects = UserManager()*
>
> *# forms.py*
> *class UserCreateForm(UserCreationForm):*
> *class Meta:*
> *model = get_user_model()*
> *fields = ('email', 'password1', 'password2', 'first_name',
> 'last_name', 'bio', 'username')*
>
> *# views.py*
> *class UserCreateView(CreateView):*
> *form_class = UserCreateForm*
> *model = get_user_model()*
> *
> *
> I think that UserCreationForm yet search for auth_user table.
> A possible solution would be this:
>
> *# models.py*
> *class User(AbstractUser):*
> *bio = models.CharField(max_length=255, blank=True, null=True)*
> *objects = UserManager()*
> *class Meta:*
> * db_table = u'auth_user'*
>
> But i would like to use a correct Django 1.5 approach to register a new
> user.
> Can anyone spot the problem?
>
> Regards,
>   Leonardo
>

-- 
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: Im having trouble accessing irc.freenode.net

2013-03-22 Thread hugh Manchu
geez Im not sure if I have an IRC Client.. its absense would explain this
 ... thanks alot Bill will look into this.
will let you know as soo as I can
Hugh


On Fri, Mar 22, 2013 at 6:40 AM, Bill Freeman  wrote:

> Do you have an IRC client, such as the chatzilla plug in for firefox?
> Your screenshot is unreadable to me, but if you're just going to
> irc.freenode.net in your browser, it's not likely to work, since HTTP and
> IRC are different protocols.
>
> On Fri, Mar 22, 2013 at 1:19 AM, Lightning  wrote:
>
>>  'Where to get help:
>>
>> If you’re having trouble going through this tutorial, please post a
>> message to django-users  or
>> drop by #django on irc.freenode.net to chat with other Django users who
>> might be able to help.'
>>
>>
>> 
>>
>> I need help with django related issues, including this one,
>>
>> Can someone please help me with this ? Thanks is advance
>>
>> --
>> 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.
>>
>>
>>
>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/Tz1-DNtS_g0/unsubscribe?hl=en
> .
> To unsubscribe from this group and all its topics, 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.
>
>
>

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




[django-users] Error when registering a new user - Django 1.5

2013-03-22 Thread Leonardo S
Hi,

I am getting an error when registering a new user in a Django 1.5 app.
It is the postgres' log:

*BRT ERROR:  relation "auth_user" does not exist at character 280*
*BRT COMMAND:  SELECT "auth_user"."id", "auth_user"."password",
"auth_user"."last_login", "auth_user"."is_superuser",
"auth_user"."username", "auth_user"."first_name", "auth_user"."last_name",
"auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active",
"auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."username" =
E'teste'*
*
*
My code is very simple:
*
*
*# models.py*
*class User(AbstractUser):*
*bio = models.CharField(max_length=255, blank=True, null=True)*
*objects = UserManager()*

*# forms.py*
*class UserCreateForm(UserCreationForm):*
*class Meta:*
*model = get_user_model()*
*fields = ('email', 'password1', 'password2', 'first_name',
'last_name', 'bio', 'username')*

*# views.py*
*class UserCreateView(CreateView):*
*form_class = UserCreateForm*
*model = get_user_model()*
*
*
I think that UserCreationForm yet search for auth_user table.
A possible solution would be this:

*# models.py*
*class User(AbstractUser):*
*bio = models.CharField(max_length=255, blank=True, null=True)*
*objects = UserManager()*
*class Meta:*
* db_table = u'auth_user'*

But i would like to use a correct Django 1.5 approach to register a new
user.
Can anyone spot the problem?

Regards,
  Leonardo

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




Andrew Godwin to add native migrations to Django's core

2013-03-22 Thread Shawn Milochik
http://www.kickstarter.com/projects/andrewgodwin/schema-migrations-for-django

I've been using South for a long time and have met Andrew a few times.
He's a genuinely nice guy and has put years of free work into
open-source software.

I encourage anyone who appreciates his work to throw in a few pounds
to show their support, although the goal has already been met.

Sorry if I missed this, but I don't think it was posted yet in this group.

-- 
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: field lookups problem

2013-03-22 Thread Roberto López López

Hi Anssi, thanks for your answer.

I already thought about that, but checking the code from
django.db.models.base.Model#__eq__() is not telling me the same:

def __eq__(self, other):
return isinstance(other, self.__class__) and self._get_pk_val()
== other._get_pk_val()



On 03/22/2013 05:02 PM, akaariai wrote:
> On 22 maalis, 15:44, Roberto López López  wrote:
>> Hi,
>>
>> I have a problem with my data model while doing field lookups. This is
>> my models.py:
>>
>> from django.db import models, IntegrityError
>>
>> # Create your models here.
>>
>> class Model1(models.Model):
>> title = models.CharField(max_length=15)
>> models2 = models.ManyToManyField('Model2', through='ThroughModel')
>>
>> def __unicode__(self):
>> return self.title
>>
>> class Model2(models.Model):
>> title = models.CharField(max_length=15)
>>
>> def __unicode__(self):
>> return self.title
>>
>> class ThroughModel(models.Model):
>> model1 = models.ForeignKey(Model1)
>> model2 = models.ForeignKey(Model2)
>> lead = models.BooleanField(default=False)
>>
>> def __unicode__(self):
>> return u'{0} - {1} - {2}'.format(self.model1, self.model2,
>> self.lead)
>>
>> Testing it on the django shell:
>>
> m1 = Model1.objects.create(title='blabla')
> m2 = Model2.objects.create(title='blabla2')
> m1.__eq__(m2)
>> False # OBVIOUSLY>>> t = 
>> ThroughModel.objects.create(model1=m1, model2=m2)
> ThroughModel.objects.filter(model1__exact=m1)
>> []# OK>>> 
>> ThroughModel.objects.filter(model1__exact=m2)
>>
>> []# NOT OK!!!
>>
>> Am I missing anything? Can anyone spot the problem?
>>
>> Thanks for your advice.
>>
>> Regards,
>>
>> Roberto
> The problem here is that Django doesn't do any verification that the
> given model values for lookups are of correct type.  My bet is that
> m1.pk == m2.pk. So, Django will create a query using m2.pk in
> model1__exact=m2, and this is the reason you get the results you get.
>
>  - Anssi
>

-- 
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: Python path in new 1.4 project structure?

2013-03-22 Thread Bill Freeman
!!! PONTIFICATION ALERT !!!

Don't do that.

I believe that it has always been a goal of project structure that the
directories on the python path be either in the default python places
(/something/something/lib/python2.X/site-packages/ unless  you're using a
Debian provided python) or in a directory specific to your Django project.
Further, this is a good thing, since it prevents you from being confused by
spurious .py files which might be, for example, in your home directory, if
your configuration is like Carston's.  (What's more, he would be tricked
when running under mod_wsgi, but not when using runserver - very
confusing.)  So putting your home directory on sys.path strikes me as a *BAD
THING*(tm).

The new way, Django 1.4+, is actually simple to understand.  The directory
containing manage.py is by default named the same as the directory
containing settings.py, urls.py, wsgi.py, etc. (it doesn't have to be:
rename it, and fix any wsgi file where you've added it to sys.path, and
everything still works).  This upper directory is still a place that is
specific to the project, so even if it is a sub directory of your home
directory, you will be unlikely to put spurious modules in it.  Because we
cd to it first, when we run a manage.py command, this directory is
automatically added to sys.path (you can always import stuff from the
current directory as of the starting of python).  Since settings.py,
urls.py, etc., are in a sub directory named for the project,
DJANGO_SETTINGS_MODULE can be set to PROJECTNAME.settings, and in
settings.py you can refer to urls.py, wsgi.py, as PROJECTNAME.urls,
PROJECTNAME.wsgi, etc.  If you have modules or packages to add that you
want to qualify, when referenced, with the project name, put them in the
lower directory, with settings.py.  If you have modules or packages that
you don't want to qualify with the the project name, say because you figure
that you will eventually put them in site-packages and use them from
multiple projects, maybe offering them on pypi, put them in the upper
directory with manage.py.  The only directory that you need to add to
sys.path in your wsgi configuration (not to be confused with
PROJECTNAME/wsgi.py) is the directory containing manage.py (you may need to
add more if you are using a virtual environment, but that's another
story).  Note that the upper directory need not be a package (need not
contain an __init__.py file).  Easy enough to understand, and nicely
flexible.

In pre-1.4 Django, settings.py and urls.py are in the same directory as
manage.py, and a trick is necessary to allow you to set
DJANGO_SETTINGS_MODULE to PROJECTNAME.settings and to import urls.py as
PROJECTNAME.urls (you could import them as simply settings and urls, but
that leads to other issues).  To do this, stuff from django used by
manage.py (but not in general) temporarily adds the parent directory of the
one containing settings.py and urls.py, the only one named for the project,
to sys.path, imports PROJECTNAME (the directory must be a package, that is,
contain an __init__.py file), and then removes the directory from sys.path
again.  Later, when trying to import PROJECTNAME.settings or
PROJECTNAME.urls, python, since sys.modules already has a package named
PROJECTNAME, imports from within it, despite the fact that it is no longer
on sys.path.  sys.path is only used for looking up the first thing in the
dot separated list of names to be imported, and never imports anything
twice.  When doing a wsgi deployment, later, some folks, like Carston, get
it to work by adding the parent directory (permanently) to sys.path.  This
is fine so long as there are no non-project related modules or packages in
that parent directory (and you are sure that there never will be), though
there might be some edge cases where this makes deployment behave
differently then when using runserver (sys.path is different).  The
cleanest thing is to make things like when manage.py runs:  1. Insert the
directory containing manage.py onto the front of sys.path; 2. insert the
parent directory on to sys.path; 3. import PROJECTNAME; and 4. remove the
parent directory from sys.path.

Bill

On Fri, Mar 22, 2013 at 2:40 PM, Carsten Fuchs wrote:

> Hi all,
>
> I'm currently migrating my Django project that was still in the "old"
> project layout to the new default project layout as shown at
>  apps/#your-project-and-your-**reusable-app
> >
>
> My WSGI file was written as described at
> 
> >
>
> The instructions there say:
>
>> The directory added to sys.path would be the directory containing the
>> package for the Django site created by running:
>>
>> django-admin.py startproject mysite
>>
>> In other words, it 

As posted on StackOverflow

2013-03-22 Thread Christos Jonathan Hayward
After a day or so of losing at trying to make pinax-social-network 1.0 have
the merits of Pinax social-project 0.5 or .7, I'd like to ask how to cut
with the grain instead of against it.

The earlier version came as a fully functional site: you could override and
customize if you want, but it came "batteries included", as a room with
well-chosen pegs on the walls, pictures hanging on the hooks, and furniture
as needed. You could replace as much of the room's initial contents as you
wanted, but it came as a furnished room.

Pinax-social-network 1.0 is not a furnished room. It has pegs, and the pegs
are about as well-placed as you could ask for, but if you want pictures on
those pegs, it's on you to put pictures on the pegs. And there is space you
can put furniture in the room; the room is left empty so you can put
whatever furniture you want in. And the room comes with elegantly placed
lorem ipsum graffiti on the walls, to motivate you to paint or wallpaper
the walls to meet your taste. It comes "batteries removed."

So... what are the resources, and how does one go about, making a social
network here? Do I just take it as a bit of Django putty? I expect I'd do a
lot of reinventing the wheel if I just use Django knowledge. Is there a
tutorial that shows how to make a live site out of one of Pinax's projects?

I spent a bit of time reading about Liferat Liferay before remembering how
painful it was even when I knew it well. The problem here may just be that
I am ignorant about Pinax, and ignorance is a changeable condition.

So let's say I know something about Python, something about Django and
something about older, fully assembled versions of Pinax, but not how to
take a starter Pinax project and make a finished site out of it. I'm
ignorant on that point. How can I cure my ignorance? What resources are out
there so I can get what was so easily in reach in older versions of Pinax?

-- 
[image: Christos Jonathan Hayward] 
Christos Jonathan Hayward, an Orthodox Christian author.

*Amazon * • Author
Bio
 • *Email * •
Facebook
 • Fan Page  • Google
Plus
 • LinkedIn  •
*Professional
* • Twitter  •
*Web
* • What's New? 
If you read just *one* of my books, you'll want *The Best of Jonathan's
Corner *.

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




RuntimeError: maximum recursion depth exceeded in cmp

2013-03-22 Thread tarik setia



I was following the very first tutorial on django website. When i started 
the server i got an error "RuntimeError: maximum recursion depth exceeded 
in cmp" as shown in image
Please help.

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




Python path in new 1.4 project structure?

2013-03-22 Thread Carsten Fuchs

Hi all,

I'm currently migrating my Django project that was still in the "old" 
project layout to the new default project layout as shown at



My WSGI file was written as described at


The instructions there say:

The directory added to sys.path would be the directory containing the package 
for the Django site created by running:

django-admin.py startproject mysite

In other words, it should be the directory you were in when 'django-admin.py' 
was run.


That is, in the WSGI file I had a line

sys.path.append('/home/carsten')

where my actual project root was '/home/carsten/Zeiterfassung', and 
therefore all project-related import statements or targets in the 
urlpatterns began with 'Zeiterfassung. ...'



However, with the new project layout, it seems that the correct way to 
make it work is *contrary* to the description in the 
IntegrationWithDjango article:


Is it right that the python path should now include the project root 
directory?


That is, in my case, I now need

sys.path.append('/home/carsten/Zeiterfassung')

in the WSGI file, because e.g. settings.py is now really at 
'/home/carsten/Zeiterfassung/Zeiterfassung/settings.py'.


It also means that I have to change all my old import statements ("Lori" 
is the app name) from


from Zeiterfassung.Lori.models import XY

to

from Lori.models import XY

Is that right, and in the sense of the new project layout?


I'm asking all this because this being contrary to the 
IntegrationWithDjango made me unsure, and 
 
uses both "mysite.com" and "mysite", and says



The WSGIPythonPath line ensures that your project package is available for 
import on the Python path; in other words, that import mysite works.


but it's still not clear to me if this really expresses the same meaning 
as I understood it above.


Best regards,
Carsten



--
Dipl.-Inf. Carsten Fuchs

Carsten Fuchs Software
Industriegebiet 3, c/o Rofu, 55768 Hoppstädten-Weiersbach, Germany
Internet: http://www.cafu.de | E-Mail: i...@cafu.de

Cafu - the open-source game and graphics engine for multiplayer 3D action

--
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: POSTing JSON to Tastypie from Android

2013-03-22 Thread Bill Freeman
Have you tried a breakpoint in the view?  Might it be a CSRF problem?

On Fri, Mar 22, 2013 at 2:22 PM, Pratik Mandrekar  wrote:

> Hello,
>
> I'm unable to get the POST json to tastypie from an android http client to
> work.
>
> *I have tried with HttpURLConnection*
>
> urlConnection = (HttpURLConnection) url.openConnection();
>
>
> urlConnection.setDoInput(true)**;
>
> urlConnection.setDoOutput(**true);
>
> urlConnection.**setRequestProperty("Content-**Type", "application/json");
>
> byte [] encoded = Base64.encode((username+":"+**password).getBytes("UTF-8"),
> Base64.DEFAULT);
>
> urlConnection.**setRequestProperty("**Authorization", "Basic "+ new
> String(encoded, "UTF-8"));
>
>
> JSONObject jsonObject = new JSONObject();
>
> jsonObject.put("key1", "value1");
>
> jsonObject.put("key2", "value2");
>
>  outputStreamWriter = urlConnection.getOutputStream(**);
>
> outputStreamWriter.write(**jsonObject.toString().**getBytes());
>
> outputStreamWriter.flush();
>
>
>
>
> *And I have tried with Apache HttpClient*
>
> HttpClient client=new DefaultHttpClient();
>
> HttpPost post = new HttpPost(url);
>
>
>
> post.setHeader("accept", "application/json");
>
> post.addHeader("Content-Type", "application/json");
>
> post.addHeader("Authorization"**, "Basic "+ new String(encoded, "UTF-8"));
>
>
>
> ArrayList localArrayList = new ArrayList();
>
> localArrayList.add(new BasicNameValuePair("json",**
> jsonObject.toString()));
>
>
>
>  lotlisting.setEntity(new UrlEncodedFormEntity(**localArrayList));
>
>  String str = EntityUtils.toString(**localDefaultHttpClient.**
> execute(lotlisting).getEntity(**));
>
>
> StringEntity se = new StringEntity( jsonObject.toString());
>
> se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
>
>
>
>  post.setEntity(se);
>
>
>
>  HttpResponse response = client.execute(post);
>
>
> I hit the same issue with both of them i.e the POST data as seen as
> Querydict in Django, does not have any data. This makes it an invalid json
> and it throws a JSON could not be decoded error.
>
> I have tried playing with all the parameters with little luck. Note that *get
> works perfectly*, even with parameters.
>
> Has anyone been successfully able to post json from an android client to
> django/tastypie? If yes, could you please share what worked for you?
>
> Thanks.
>
> Pratik
>
> --
> 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.
>
>
>

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




POSTing JSON to Tastypie from Android

2013-03-22 Thread Pratik Mandrekar
Hello,

I'm unable to get the POST json to tastypie from an android http client to 
work.

*I have tried with HttpURLConnection*

urlConnection = (HttpURLConnection) url.openConnection();


urlConnection.setDoInput(true);

urlConnection.setDoOutput(true);

urlConnection.setRequestProperty("Content-Type", "application/json");

byte [] encoded = Base64.encode((username+":"+password).getBytes("UTF-8"), 
Base64.DEFAULT); 

urlConnection.setRequestProperty("Authorization", "Basic "+ new 
String(encoded, "UTF-8"));


JSONObject jsonObject = new JSONObject();

jsonObject.put("key1", "value1");

jsonObject.put("key2", "value2");

 outputStreamWriter = urlConnection.getOutputStream();

outputStreamWriter.write(jsonObject.toString().getBytes());

outputStreamWriter.flush(); 

 


*And I have tried with Apache HttpClient*

HttpClient client=new DefaultHttpClient();

HttpPost post = new HttpPost(url);



post.setHeader("accept", "application/json");

post.addHeader("Content-Type", "application/json");

post.addHeader("Authorization", "Basic "+ new String(encoded, "UTF-8"));



ArrayList localArrayList = new ArrayList();

localArrayList.add(new BasicNameValuePair("json",jsonObject.toString()));

  

 lotlisting.setEntity(new UrlEncodedFormEntity(localArrayList));

 String str = 
EntityUtils.toString(localDefaultHttpClient.execute(lotlisting).getEntity());


StringEntity se = new StringEntity( jsonObject.toString());  

se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));



 post.setEntity(se);



 HttpResponse response = client.execute(post); 


I hit the same issue with both of them i.e the POST data as seen as 
Querydict in Django, does not have any data. This makes it an invalid json 
and it throws a JSON could not be decoded error.

I have tried playing with all the parameters with little luck. Note that *get 
works perfectly*, even with parameters. 

Has anyone been successfully able to post json from an android client to 
django/tastypie? If yes, could you please share what worked for you?

Thanks.

Pratik

-- 
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 on Mediatemple DV (4.0) in Virtualenv

2013-03-22 Thread Bill Freeman
The ones I've done were for a previous employer, so I don't have access, so
the stuff below is from memory and untested, but here's a relevant
documentation reference:
  http://httpd.apache.org/docs/current/rewrite/flags.html#flag_p
See particularly the performance warning and maybe learn to use ProxyPass
or ProxyPassMatch instead of the stuff below.


...
RewriteEngine On
RewriteRule /(.*) http://localhost:8000/$1 [P]
...


(and please don't take my ellipses (is that the correct plural?) literally.)

The trick is the P flag at the end, which you can read about in the docs
referenced above.  Of course replace 8000 with whatever port your gunicorn
or secondary apache or nginx is listening on (but you can test with
runserver).  The square brackets are literal and required.

If you're not used to rewrite espressions, the first argument is a regular
expression matched against the path part of the request, where .* matches
any number of unspecified characters, and the parentheses "capture" a part
of the path (everything after the leading slash).  This capture begins with
the FIRST open parenthesis in the pattern, so it is available as $1 in the
the second argument, which builds the URL to which we are proxying.  (If
you actually need parentheses in the regular expression, you escape them
with backslash.)

Good luck, Bill

On Fri, Mar 22, 2013 at 1:01 PM, Tim Walzer wrote:

> I have both mod_rewrite and mod_proxy available to me.
>
> Also, the server is running nginx which seems to be the preferred way of
> running gunicorn, but I am having trouble getting the nginx config to play
> nice.
>
> Would you be able to provide a sample of your reverse proxy config and
> maybe that will help me see what I'm doing wrong?
>
> Thanks.
>
> On Thursday, March 21, 2013 11:42:49 AM UTC-6, ke1g wrote:
>
>> Have you considered a reverse proxy to something like gunicorn?
>>
>> The way that I know how to do this involves mod_rewrite - I don't know of
>> of the top of my head whether it also requires mod_proxy.  Are these
>> available to you.  I understand that gunicorn is to be preferred to
>> fastcgi, which I haven't used.  I haven't actually set up gunicorn, but
>> have done reverse proxy configuration for it (a skill acquired while
>> suffering under plone).
>>
>> Another approach is your own separate Apache build, assuming you have
>> development tools and either the ability to run this in place of the
>> provided apache or the ability to proxy, as above, but this time to your
>> private Apache.
>>
>> Still, if its true that the best these guys can provide is python2.4 and
>> mod_python, maybe it is time to switch.  I'm pretty happy with my linode.
>> For shared hosting I've deployed a lot of sites to webfaction, and have no
>> complaints.  EC2, if I recall, is a bit dear, but you can roll your own
>> distro for it, if necessary.  There's a big wonderful world out there.
>>
>> Bill
>>
>> On Thu, Mar 21, 2013 at 10:38 AM, Tim Walzer wrote:
>>
>>> Thats what I was afraid of.  Unfortunately Media Temple DVs come
>>> pre-installed with Plesk which in turn comes pre-installed with weird
>>> versions of different software packages, none of which are mod_wsgi.  At
>>> this point I have not figured out a way to install mod_wsgi without
>>> breaking the entire thing.  Maybe its time to move on to a different host.
>>>
>>> On Thursday, March 14, 2013 3:37:22 PM UTC-6, Tim Walzer wrote:

 I am currently trying to install Django on a Mediatemple DV (4.0)
 server and have the installation be within a virtualenv.  The django app
 will be run from a subdomain, *parts.domain.com*, while the root
 domain *domain.com* is serving a wordpress site.

 I have django installed inside the virtualenv at */var/www/vhosts/
 domain.com/parts/env/* The virtual environment is *'env'.  *The server
 is running python 2.4.3, but I needed at least 2.6, so I installed 2.6
 inside the virtual env and that worked perfectly for setting up the initial
 django site.  Now the problem comes with the running of django.

 I created a vhost.conf file under */var/www/vhosts/parts.do
 main.com/conf*
 *
 *
 
SetHandler python-program
 PythonPath 
 "['/var/www/vhosts/domain.com/parts/env/bin',
 '/var/www/vhosts/domain.com/**pa**rts/env/store']
 + sys.path"
 PythonHandler virtualproject
 SetEnv DJANGO_SETTINGS_MODULE store.settings
 

  The path to virtualproject, referenced in the PythonHandler line, is *
 /var/www/vhosts/domain.com/parts/env/bin/virtualproject.py.  *

 The contents of that file are:

 *activate_this = '/var/www/vhosts/domain.com/pa
 rts/env/bin/activate_this.py'*
 *execfile(activate_this, dict(__file__=activate_this))*
 *
 *
 *from 

Re: Django on Mediatemple DV (4.0) in Virtualenv

2013-03-22 Thread Tim Walzer
I have both mod_rewrite and mod_proxy available to me.

Also, the server is running nginx which seems to be the preferred way of 
running gunicorn, but I am having trouble getting the nginx config to play 
nice.

Would you be able to provide a sample of your reverse proxy config and 
maybe that will help me see what I'm doing wrong?

Thanks.

On Thursday, March 21, 2013 11:42:49 AM UTC-6, ke1g wrote:
>
> Have you considered a reverse proxy to something like gunicorn?
>
> The way that I know how to do this involves mod_rewrite - I don't know of 
> of the top of my head whether it also requires mod_proxy.  Are these 
> available to you.  I understand that gunicorn is to be preferred to 
> fastcgi, which I haven't used.  I haven't actually set up gunicorn, but 
> have done reverse proxy configuration for it (a skill acquired while 
> suffering under plone).
>
> Another approach is your own separate Apache build, assuming you have 
> development tools and either the ability to run this in place of the 
> provided apache or the ability to proxy, as above, but this time to your 
> private Apache.
>
> Still, if its true that the best these guys can provide is python2.4 and 
> mod_python, maybe it is time to switch.  I'm pretty happy with my linode.  
> For shared hosting I've deployed a lot of sites to webfaction, and have no 
> complaints.  EC2, if I recall, is a bit dear, but you can roll your own 
> distro for it, if necessary.  There's a big wonderful world out there.
>
> Bill
>
> On Thu, Mar 21, 2013 at 10:38 AM, Tim Walzer 
>  > wrote:
>
>> Thats what I was afraid of.  Unfortunately Media Temple DVs come 
>> pre-installed with Plesk which in turn comes pre-installed with weird 
>> versions of different software packages, none of which are mod_wsgi.  At 
>> this point I have not figured out a way to install mod_wsgi without 
>> breaking the entire thing.  Maybe its time to move on to a different host.
>>
>> On Thursday, March 14, 2013 3:37:22 PM UTC-6, Tim Walzer wrote:
>>>
>>> I am currently trying to install Django on a Mediatemple DV (4.0) server 
>>> and have the installation be within a virtualenv.  The django app will be 
>>> run from a subdomain, *parts.domain.com*, while the root domain *
>>> domain.com* is serving a wordpress site.
>>>
>>> I have django installed inside the virtualenv at */var/www/vhosts/
>>> domain.com/parts/env/* The virtual environment is *'env'.  *The server 
>>> is running python 2.4.3, but I needed at least 2.6, so I installed 2.6 
>>> inside the virtual env and that worked perfectly for setting up the initial 
>>> django site.  Now the problem comes with the running of django.
>>>
>>> I created a vhost.conf file under */var/www/vhosts/parts.domain.com/conf
>>> *
>>> *
>>> *
>>> 
>>>SetHandler python-program
>>> PythonPath 
>>> "['/var/www/vhosts/domain.com/**parts/env/bin',
>>>  
>>> '/var/www/vhosts/domain.com/**parts/env/store']
>>>  
>>> + sys.path"
>>> PythonHandler virtualproject
>>> SetEnv DJANGO_SETTINGS_MODULE store.settings
>>> 
>>>
>>>  The path to virtualproject, referenced in the PythonHandler line, is *
>>> /var/www/vhosts/domain.com/parts/env/bin/virtualproject.py.  *
>>>
>>> The contents of that file are:
>>>
>>> *activate_this = '/var/www/vhosts/domain.com/
>>> parts/env/bin/activate_this.py'*
>>> *execfile(activate_this, dict(__file__=activate_this))*
>>> *
>>> *
>>> *from django.core.handlers.modpython import handler*
>>> *
>>> *
>>> The activate_this.py file is the one that comes with the virtualenv 
>>> installation
>>>
>>> When I go to the site *parts.domain.com*, I get the following error in 
>>> the apache logs:
>>>
>>> [Thu Mar 14 17:29:45 2013] [error] [client ] PythonHandler 
>>> virtualproject: Traceback (most recent call last):
>>> [Thu Mar 14 17:29:45 2013] [error] [client ] PythonHandler 
>>> virtualproject:   File "/usr/lib64/python2.4/site-**
>>> packages/mod_python/apache.py"**, line 287, in HandlerDispatch\n   
>>>  log=debug)
>>> [Thu Mar 14 17:29:45 2013] [error] [client ] PythonHandler 
>>> virtualproject:   File "/usr/lib64/python2.4/site-**
>>> packages/mod_python/apache.py"**, line 464, in import_module\n   
>>>  module = imp.load_module(mname, f, p, d)
>>> [Thu Mar 14 17:29:45 2013] [error] [client ] PythonHandler 
>>> virtualproject:   File "/var/www/vhosts/domain.com/**
>>> parts/env/bin/virtualproject.**py",
>>>  
>>> line 4, in ?\nfrom django.core.handlers.modpython import handler
>>> [Thu Mar 14 17:29:45 2013] [error] [client ] PythonHandler 
>>> virtualproject: ImportError: No module named django.core.handlers.modpython
>>>
>>> I can only think that this is happening because apache is attempting to 
>>> use the system default python2.4 instead of the one in my virtualenv where 
>>> django is installed.  How do I fix this?
>>>
>>  -- 
>> You 

Re: field lookups problem

2013-03-22 Thread akaariai
On 22 maalis, 15:44, Roberto López López  wrote:
> Hi,
>
> I have a problem with my data model while doing field lookups. This is
> my models.py:
>
> from django.db import models, IntegrityError
>
> # Create your models here.
>
> class Model1(models.Model):
>     title = models.CharField(max_length=15)
>     models2 = models.ManyToManyField('Model2', through='ThroughModel')
>
>     def __unicode__(self):
>         return self.title
>
> class Model2(models.Model):
>     title = models.CharField(max_length=15)
>
>     def __unicode__(self):
>         return self.title
>
> class ThroughModel(models.Model):
>     model1 = models.ForeignKey(Model1)
>     model2 = models.ForeignKey(Model2)
>     lead = models.BooleanField(default=False)
>
>     def __unicode__(self):
>         return u'{0} - {1} - {2}'.format(self.model1, self.model2,
> self.lead)
>
> Testing it on the django shell:
>
> >>> m1 = Model1.objects.create(title='blabla')
> >>> m2 = Model2.objects.create(title='blabla2')
> >>> m1.__eq__(m2)
>
> False                                                 # OBVIOUSLY>>> t = 
> ThroughModel.objects.create(model1=m1, model2=m2)
> >>> ThroughModel.objects.filter(model1__exact=m1)
>
> []            # OK>>> 
> ThroughModel.objects.filter(model1__exact=m2)
>
> []            # NOT OK!!!
>
> Am I missing anything? Can anyone spot the problem?
>
> Thanks for your advice.
>
> Regards,
>
> Roberto

The problem here is that Django doesn't do any verification that the
given model values for lookups are of correct type.  My bet is that
m1.pk == m2.pk. So, Django will create a query using m2.pk in
model1__exact=m2, and this is the reason you get the results you get.

 - Anssi

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




Using HP Vertica: Cannot insert into or update IDENTITY/AUTO_INCREMENT column

2013-03-22 Thread Stan Hu
I'm been trying to get HP Vertica Community Edition working with Django by
updating the django-vertica
package.  For the most
part, it is working.   Upon doing a manage.py
syncdb, I enabled SQL debugging and get this error message:

DEBUG (0.002) INSERT INTO "django_site" ("id", "domain", "name") VALUES (1,
example.com, example.com); args=[1, 'example.com', 'example.com']
ProgrammingError: ('42601', '[42601] ERROR 2444:  Cannot insert into or
update IDENTITY/AUTO_INCREMENT column "id"\n (2444) (SQLPrepare)')

It looks to me that Vertica does not want Django to be including the
primary key in its INSERT call.

What's the best way to fix this?  I see a few options:

1) Write a custom SQLInsertCompiler for the Vertica side and override
as_sql() to do the right thing.

2) Modify SQLInsertCompiler in django.db.models.compiler to omit primary
key fields.   I noticed that in django.db.backends, there is a variable
"supports_unspecified_pk".  This doesn't appear to be used at all.

What's the right way?

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




Up-to-date Pinax Social Network *working*?

2013-03-22 Thread Christos Jonathan Hayward
I'vd found pinax-social-project but it's bleeding; it doesn't offer even a
styled page, just a page that fails to load CSS and JavaScripts and comes
out POSH bare as bare can be.

I've put a tarball of my current version at
http://JonathansCorner.com/project/stornge.tgz, was wondering if you could
give me any help to load static content appropriately (it doesn't work to
copy the line that loads media and change it to point to static values).

-- 
[image: Christos Jonathan Hayward] 
Christos Jonathan Hayward, an Orthodox Christian author.

*Amazon * • Author
Bio
 • *Email * •
Facebook
 • Fan Page  • Google
Plus
 • LinkedIn  •
*Professional
* • Twitter  •
*Web
* • What's New? 
If you read just *one* of my books, you'll want *The Best of Jonathan's
Corner *.

-- 
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: Inspecting form errors in a view

2013-03-22 Thread Rainy


On Thursday, March 21, 2013 9:47:03 PM UTC-4, Aubrey Stark-Toller wrote:
>
> On Thu, Mar 21, 2013 at 03:40:39PM -0700, Rainy wrote: 
> > I believe you can just set self.my_flag = foo in clean method and then 
> > check for 
>
>
> Cheers for the reply. 
>
> I suspect my original mail could have clearer. Just setting attributes 
> when 
> checks fail seems to me to be the best way to do this, but it does mean 
> that 
> if I need to check if, say, an integer field is invalid as it contains a 
> string then I'd to reimplement this validation in the clean method so that 
> it 
> sets the necessary attribute on the form, and so on for any other field 
> clean 
> methods that I may need to use and check. 
>
> I realise this is a little beyond what Django's forms where meant for and 
> I 
> might have to live without some of Django's built-in validation to get 
> this 
> to work, but I'd thought I'd see if anyone here had any thoughts. 
>
> Aubrey 
>


Hi Aubrey,

I'm not sure why you think you'll need to override individual clean methods 
for
fields. You write:

  I have form class that has a relatively lengthy clean method which does 
field 
  validation (as the validity of fields depends on the values of fields) as 
well  
  setting error messages on the form itself.
 
So my suggestion is to check, in that single clean method, which fields have
errors and to set your flags accordingly. 

HTH! -ak

-- 
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 split setting and environment variables

2013-03-22 Thread Bill Freeman
Good point.  Personally, I agree about keeping credentials out of version
control, but I have had an employer who disagrees.  Of course that's only
suitable for a completely private repository.

On Thu, Mar 21, 2013 at 4:58 PM, Alan Johnson  wrote:

> I think hardcoding local machine development passwords is fine, but it's
> still better to store the production passwords in a key-value file that
> stays out of source control and is permissioned such that only authorized
> developers can directly access the server or the credential file. Of course
> any developer with full access to the production servers also has the
> password, but at that point, so what? Exactly how to set it up depends on
> the hosting setup.
>
>
>
> On Thursday, March 21, 2013 2:08:39 PM UTC-4, ke1g wrote:
>
>> Are you doing this for password security?  If so, note that, while not
>> quite as easy as scraping command line argument, your environment is
>> avilable via /dev/mem, and is trivially available to any Trojan that an
>> attacker can convince this shell or any of its children (such as Django or
>> any manage.py app) to execute.
>>
>> Note, too, that, unless you are going to type this each time that you
>> start the server, you have to put it in a file somewhere, be it .bashrc,
>> .bash_profile, or some script file that you use to start django and the
>> management apps.  And if it's in a file, then it is at least as good to
>> have it in settings.py .
>>
>> And if you are willing to type a password, either let settings.py read it
>> to use to decrypt a file with the full credentials, or use one of the
>> password manager apps that settings.py can talk to over the D-bus (linux)
>> or equivalent.
>>
>> But note that security is hard, and most "simple" home grown solutions,
>> very likely including my suggestions above, end up by reducing security.
>>
>> On Thu, Mar 21, 2013 at 10:42 AM, demet8  wrote:
>>
>>> I have a common.py, dev.py, and prod.py for my Django settings files.
>>> All files inherit from common.py. I want to keep my database passwords,
>>> database URL, etc stored as environment variables. I have researched the
>>> topic but I am not sure If I have a clear understanding of it. I am hoping
>>> I can get a more comprehensive answer via this forum. This is what I have
>>> thus far:
>>>
>>>
>>> *In your bash shell type:*
>>>
>>> export SOMEAPP_DB_USER='someapp'
>>> export SOMEAPP_DB_PASSWORD='1234'
>>>
>>> *In my Django settings file type*:
>>>
>>> DATABASE_USER = os.environ.get("SOMEAPP_DB_**USE**R", ")
>>> DATABASE_PASSWORD = os.environ.get("SOMEAPP_DB_**PAS**SWORD", ")
>>>
>>> So are my passwords stored in just a terminal session? or are they being
>>> stored in something like my bash_profile?
>>>
>>
>> A means whereby you have to type them to a shell is to type them as above
>> each time, then run python manage.py runserver, or maybe better, exec
>> python manage.py runserver (the shell that knows the password goes away as
>> a process in this case, so maybe you firist start a secondary bash by
>> typing "bash" at your shell prompt.  Note that this DOES NOT help you in
>> deployment, behind Apache/mod_wsgi, for example, since it would be the
>> shell that started Apache that would have to have these environment
>> variables.  You can add environment variables in the Apache configuration,
>> by the way, but that's just another file that knows your password.
>>
>>>
>>> Thanks.
>>>
>>> --
>>> 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...@**googlegroups.com.
>>> To post to this group, send email to django...@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
>>> .
>>>
>>>
>>>
>>
>>  --
> 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.
>
>
>

-- 
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: Conditionally defined model field in abstract model

2013-03-22 Thread Bill Freeman
Wouldn't it be simpler to have two abstract classes, one, not having the
field, and the other being a sub class of the first, and just adding the
field?

On Thu, Mar 21, 2013 at 5:05 PM, Alan Johnson  wrote:

> I've got an abstract model in my project that I want to use to define a
> field by default on concrete subclasses, but also to allow that field to be
> redefined as something other than the default dynamically.  All of this
> works right now:
>
> class classproperty(object):
> """
> Decorator for making class properties
> """
> def __init__(self, fget):
> self.fget = fget
>
> def __get__(self, owner_self, owner_cls):
> return self.fget(owner_cls)
>
> class BaseModel(models.Model):
> class Meta(object):
> abstract = True
>
> @classproperty
> def _special_attribute_field(self):
> return getattr(self, '_bm_special_attribute_field', 'default')
>
> @property
> def bm_special_attribute(self):
> return getattr(self, self._special_attribute_field)
>
> ...and then there are a bunch of methods that use the latter two functions
> to figure out which field to access.
>
> The problem is that right now, classes inheriting from `BaseModel` have to
> define the `default` field explicitly, even if they don't use
> `_bm_special_attribute_field` to specify something other than the default.
> What I'd like to do is programmatically define `default` on concrete
> submodels *only if* those models don't use `_bm_special_attribute_field` to
> change it to something else, in which case, they should bring their own
> field.  Is there a way to do this, perhaps with metaclasses or something?
> The key thing being that it has to not muck up the Django machinery.
>
> (cross posted from
> http://stackoverflow.com/questions/15249306/django-conditionally-defined-model-field-in-abstract-model,
> if you want to answer for points)
>
> --
> 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.
>
>
>

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

2013-03-22 Thread Tim Cook
Thanks for the reply, Russell.
Responses inline:

On Fri, Mar 22, 2013 at 10:10 AM, Russell Keith-Magee
 wrote:

> However, I'm guessing that this *isn't* the name of the database that you've
> got Django configured to use. If you're following the tutorial (and
> following the same lessons for your project), you will have invoked "CREATE
> DATABASE database_name" at some point -- creating a new database, and *that*
> is the database Django is using.
>

Certainly.  The tutorial DB is 'polls' and my project DB is 'ccdgen'.
They both appear on the same server in PGAdminIII  ccdgen.  They also
both appear on the server (I guess) I setup when I first tried out
Postgres, named 'mydb'.

> So - I'm guessing the solution here is to point PGAdminIII at the database
> you created, instead of the default database. Unfortunately, I haven't used
> PGAdminIII, so I can't give you any practical tips on that front.

I can also see the default postgres DB as well on each of the two servers.

I don't have any valuable data anywhere in the DBs.  Maybe I should
delete all of my DBs and start over?

Thanks,
Tim



-- 

Timothy Cook, MSc   +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

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




field lookups problem

2013-03-22 Thread Roberto López López


Hi,

I have a problem with my data model while doing field lookups. This is
my models.py:

from django.db import models, IntegrityError

# Create your models here.

class Model1(models.Model):
title = models.CharField(max_length=15)
models2 = models.ManyToManyField('Model2', through='ThroughModel')

def __unicode__(self):
return self.title

class Model2(models.Model):
title = models.CharField(max_length=15)

def __unicode__(self):
return self.title

class ThroughModel(models.Model):
model1 = models.ForeignKey(Model1)
model2 = models.ForeignKey(Model2)
lead = models.BooleanField(default=False)

def __unicode__(self):
return u'{0} - {1} - {2}'.format(self.model1, self.model2,
self.lead)




Testing it on the django shell:

>>> m1 = Model1.objects.create(title='blabla')
>>> m2 = Model2.objects.create(title='blabla2')
>>> m1.__eq__(m2)
False # OBVIOUSLY
>>> t = ThroughModel.objects.create(model1=m1, model2=m2)
>>> ThroughModel.objects.filter(model1__exact=m1)
[]# OK
>>> ThroughModel.objects.filter(model1__exact=m2)
[]# NOT OK!!!



Am I missing anything? Can anyone spot the problem?

Thanks for your advice.

Regards,

Roberto


-- 
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: Im having trouble accessing irc.freenode.net

2013-03-22 Thread Bill Freeman
Do you have an IRC client, such as the chatzilla plug in for firefox?  Your
screenshot is unreadable to me, but if you're just going to
irc.freenode.netin your browser, it's not likely to work, since HTTP
and IRC are different
protocols.

On Fri, Mar 22, 2013 at 1:19 AM, Lightning  wrote:

> 'Where to get help:
>
> If you’re having trouble going through this tutorial, please post a
> message to django-users  or
> drop by #django on irc.freenode.net to chat with other Django users who
> might be able to help.'
>
>
> 
>
> I need help with django related issues, including this one,
>
> Can someone please help me with this ? Thanks is advance
>
> --
> 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.
>
>
>

-- 
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: Automated Django benchmarking with New Relic

2013-03-22 Thread Bill Freeman
What people do all the time is edit their settings file on their deployed
box and simple restart django (say by touching the wsgi script, or
restarting apache or nginx or whatever).

On Thu, Mar 21, 2013 at 9:47 PM, Alan Johnson  wrote:

> I've got a Django web app with a complicated data model that's
> experiencing performance issues. Using New Relic, I was pretty much
> instantaneously able to isolate what the problem to a particular query. But
> there are a number of different solutions I can try. What I'd like to do is
> be able to benchmark the efficacy of different solutions in various
> combinations.
>
> In my mind, one way of doing this by hand would be to make a Django model
> that stores configuration flags outside of my settings file, so I could
> change them through the admin instead of redeploying. Then I could monitor
> New Relic and record the metrics into a spreadsheet, or something.
>
> But I feel like that would be a poor reinvention of something people
> probably do all the time. Is there a good methodology for doing this
> without a whole bunch of manual labor? I'd prefer New Relic, since I
> already know how to measure my problem with it, but I'm open to other
> options.
>
> (cross posted at
> http://stackoverflow.com/questions/15558728/django-new-relic-performance-benchmarking/15560582?noredirect=1#15560582,
> in case anyone wants points)
>
> --
> 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.
>
>
>

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

2013-03-22 Thread Bill Freeman
What O/S?  What version of python?  Can you get to python's prompt by just
typing python at a command prompt?  If so, is the version that it printed
when it started the version that you expected?  How about an actual cut and
paste of the error that you are seeing?

Bill

On Thu, Mar 21, 2013 at 9:32 PM, James  wrote:

> Hey there,
>
> Did first Django app and everything worked find, however my computer
> crashed and after restoring it each time I try to execute any .py file in
> command prompt it says syntax error or that the module doesnt exist...
>
> Would you know any reasons for this? Python is still installed and
> everything that was there before the crash is still there.
>
> Thanks!
>
> --
> 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.
>
>
>

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

2013-03-22 Thread Russell Keith-Magee
On Fri, Mar 22, 2013 at 7:46 PM, Tim Cook  wrote:

> HI All,
>
> Sorry I couldn't think of a better subject.  :-)
>
> I am fairly new to Django.  I have done most of the tutorial and
> started reading Two Scoops of Django (TSD).
>
> Of course being impatient I also started my project, in parallel.
>
> Danny made a good point in TSD about using the same database in
> development as in production.  So I went ahead and installed Postgres
> (Ubuntu 12.04)
>
> Restarted the tutorial and the database looks fine in PGAdminIII.  But
> when I check my project database, there are no tables in PGAdminIII.
> However, my project app runs just fine. I can add, update and delete
> records as expected (through the admin interface).
>
> So, I am curious as to why PGAdminIII doesn't show the tables???
>
> This kind of weirdness tells me, from experience,  I have done
> something really silly. But I have no clue what.
> BTW: This is the first time I have used Postgres in about 6 years.  So
> I am almost a newbie with SQL DBs again.


It's difficult to know for certain without seeing your exact setup - but
one likely possibility is that you're using different databases.

You're obviously successfully running the PostgreSQL server, because both
PGAdminIII and Django are connecting to it -- if the server wasn't running,
you'd be getting connection errors. However, a single server can host
multiple databases.

The default PostgreSQL database is called, unsurprisingly, 'postgres' --
that's the database that the psql command line tool connects to by default,
and I'd wager PGAdminIII does the same.

However, I'm guessing that this *isn't* the name of the database that
you've got Django configured to use. If you're following the tutorial (and
following the same lessons for your project), you will have invoked "CREATE
DATABASE database_name" at some point -- creating a new database, and
*that* is the database Django is using.

So - I'm guessing the solution here is to point PGAdminIII at the database
you created, instead of the default database. Unfortunately, I haven't used
PGAdminIII, so I can't give you any practical tips on that front.

Yours,
Russ Magee %-)

-- 
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: How to get ten random records

2013-03-22 Thread Peter of the Norse
Don’t listen to him. .order_by('?') is the right thing. If you’re not sure, 
install django-debug-toolbar. You’ll see that you get "ORDER BY random()". 

Also, while .get() will throw an exception if the QuerySet is empty, nothing 
else will.

On Mar 18, 2013, at 10:46 PM, Mike Dewhirst wrote:

> On 19/03/2013 3:29pm, Christophe Pettus wrote:
>> 
>> On Mar 18, 2013, at 9:03 PM, Mike Dewhirst wrote:
>> 
>>> No really, I want a maximum of ten random records from the database
>>> (Django 1.4, Postgres 9.1).
>> 
>> This is a case where the raw SQL interface might be the right answer:
>> you can just tack an ORDER BY random() clause onto the query.
> 
> Thank you kind sir
> 
> Cheers
> 
> Mike
> 
>> 
>> -- -- Christophe Pettus x...@thebuild.com
>> 
> 

Peter of the Norse
rahmc...@radio1190.org



-- 
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: Are Generic Views limited to querysets that are fixed for any one view?

2013-03-22 Thread Doug S
Sorry, I guess I should have looked a bit harder before posting this 
question,
I've figured it out.
Hopefully this will be of help to someone else.
the discussion here:
http://stackoverflow.com/questions/8925434/django-class-based-generic-views-url-variable-passing
answers my question.
The URL parameters are not available directly as a class attribute in the 
class based generic view
but they can be accessed indirectly in the get_queryset method as so:

def get_queryset(self):
model_group_id=self.kwargs['model_group_id']

( where 'model_group_id' is the URL parameter being accessed )


On Friday, March 22, 2013 8:06:06 AM UTC-4, Doug S wrote:
>
> I'm new to using generic views and the genericness is obviously powerful,
> but I'm wondering how far it goes. If I have a model and want to display 
> it as a list,
> I can use a generic view and even specify the query set it displays for a 
> given view,
> but what if I want to constrain the query set through a url parameter?
> Is that beyond the scope of generic views?
> Can the url parameters be passed to the class based view?
> Best
> Doug
>
>

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




Are Generic Views limited to querysets that are fixed for any one view?

2013-03-22 Thread Doug S
I'm new to using generic views and the genericness is obviously powerful,
but I'm wondering how far it goes. If I have a model and want to display it 
as a list,
I can use a generic view and even specify the query set it displays for a 
given view,
but what if I want to constrain the query set through a url parameter?
Is that beyond the scope of generic views?
Can the url parameters be passed to the class based view?
Best
Doug

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




DB Weirdness

2013-03-22 Thread Tim Cook
HI All,

Sorry I couldn't think of a better subject.  :-)

I am fairly new to Django.  I have done most of the tutorial and
started reading Two Scoops of Django (TSD).

Of course being impatient I also started my project, in parallel.

Danny made a good point in TSD about using the same database in
development as in production.  So I went ahead and installed Postgres
(Ubuntu 12.04)

Restarted the tutorial and the database looks fine in PGAdminIII.  But
when I check my project database, there are no tables in PGAdminIII.
However, my project app runs just fine. I can add, update and delete
records as expected (through the admin interface).

So, I am curious as to why PGAdminIII doesn't show the tables???

This kind of weirdness tells me, from experience,  I have done
something really silly. But I have no clue what.
BTW: This is the first time I have used Postgres in about 6 years.  So
I am almost a newbie with SQL DBs again.

Thanks,
Tim



-- 

Timothy Cook, MSc   +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

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




models.DecimalField causing weird Attribute/Type errors

2013-03-22 Thread Tomas Pelka
Hi all

I'm trying to make one of my first apps running but always getting weird 
errors Attribute/Type for models.DecimalField as well as for DateField.

In case I want to store anything into sqlitedb I always get:

TypeError: 'datetime.datetime' object is unsubscriptable, same for 
Decimal/int

For the case I already have any records in db and just want to display them 
in admin interface:

Request Method: GET  Request URL: http://127.0.0.1:8000/admin/energie/el/  
Django 
Version: 1.5  Exception Type: AttributeError  Exception Value: 

'Decimal' object has no attribute 'encode'

 Exception Location: 
/usr/lib/python2.6/site-packages/Django-1.5-py2.6.egg/django/db/models/base.py 
in __str__, line 433  Python Executable: /usr/bin/python  Python Version: 
2.6.6  Python Path: 

['/home/tpelka/workspace/energie/wsgi/energie',
 '/usr/lib/python2.6/site-packages/ropemode-0.2-py2.6.egg',
 '/usr/lib/python2.6/site-packages/rope-0.9.4-py2.6.egg',
 '/usr/lib/python2.6/site-packages/ropevim-0.4-py2.6.egg',
 '/usr/lib/python2.6/site-packages/mozmill-1.5.20-py2.6.egg',
 '/usr/lib/python2.6/site-packages/ManifestDestiny-0.2.2-py2.6.egg',
 '/usr/lib/python2.6/site-packages/mozrunner-2.5.14-py2.6.egg',
 '/usr/lib/python2.6/site-packages/jsbridge-2.4.16-py2.6.egg',
 '/usr/lib/python2.6/site-packages/Django-1.5-py2.6.egg',
 '/usr/share/qa-tools/python-modules',
 '/usr/lib64/python26.zip',
 '/usr/lib64/python2.6',
 '/usr/lib64/python2.6/plat-linux2',
 '/usr/lib64/python2.6/lib-tk',
 '/usr/lib64/python2.6/lib-old',
 '/usr/lib64/python2.6/lib-dynload',
 '/usr/lib64/python2.6/site-packages',
 '/usr/lib64/python2.6/site-packages/Numeric',
 '/usr/lib64/python2.6/site-packages/gst-0.10',
 '/usr/lib64/python2.6/site-packages/gtk-2.0',
 '/usr/lib64/python2.6/site-packages/webkit-1.0',
 '/usr/lib/python2.6/site-packages',
 '/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info']


Attaching models,py, admin.py and settings.py

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


# -*- coding: utf-8 -*-
from django.contrib import admin
from models import Record, Water, Gas, El

class RecordAdmin(admin.ModelAdmin):
list_display = ('date', 'water', 'gas', 'el', 'note')
search_fields = ['date']

admin.site.register(Record, RecordAdmin)
admin.site.register(Water)
admin.site.register(Gas)
admin.site.register(El)

# -*- coding: utf-8 -*-
from django.db import models
from decimal import Decimal

class Record(models.Model):
date = models.DateField('?as zad?n?')
water = models.ForeignKey('Water', verbose_name='Voda')
gas = models.ForeignKey('Gas', verbose_name='Plyn')
el = models.ForeignKey('El', verbose_name='Elekt?ina')
note = models.TextField('Pozn?mka', blank=True)

def __unicode__(self):
return self.date

class Meta:
ordering = ['date']
verbose_name = 'z?znam'
verbose_name_plural = 'z?znamy'

class Water(models.Model):
water = models.DecimalField('Spot?eba vody', max_digits=5, decimal_places=1)
water_delta = models.DecimalField('Spot?eba vody rozd?l',
max_digits=4, decimal_places=1, default=1)

def __unicode__(self):
return self.water

class Meta:
verbose_name = 'voda'
verbose_name_plural = 'voda'

class Gas(models.Model):
gas = models.DecimalField('Spot?eba plynu', max_digits=8, decimal_places=1)
gas_delta = models.DecimalField('Spot?eba plynu rozd?l',
max_digits=4, decimal_places=1, default=1)

def __unicode__(self):
return self.gas

class Meta:
verbose_name = 'plyn'
verbose_name_plural = 'plyn'

class El(models.Model):
el1 = models.DecimalField('Spot?eba elekt?iny', max_digits=8, decimal_places=1)
el1_delta = models.DecimalField('Spot?eba elekt?iny rozd?l',
max_digits=4, decimal_places=1, default=1)
el2 = models.DecimalField('Spot?eba elekt?iny (no?n? proud)',
max_digits=8, decimal_places=1)
el2_delta = models.DecimalField('Spot?eba elekt?iny (no?n? proud) rozd?l',
max_digits=4, decimal_places=1, default=1)

def __unicode__(self):
return self.el1

class Meta:
verbose_name = 'elekt?ina'
verbose_name_plural = 'elekt?ina'

# -*- coding: utf-8 -*-
# Django settings for openshift project.
import imp, os

# a setting to determine whether we are running on OpenShift
ON_OPENSHIFT = False
if os.environ.has_key('OPENSHIFT_REPO_DIR'):
ON_OPENSHIFT = True

PROJECT_DIR = os.path.dirname(os.path.realpath(__file__))

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
('Tomas Pelka', 'tompe...@gmail.com'),

Up-to-date Pinax social network?

2013-03-22 Thread Christos Jonathan Hayward
I look at http://pinaxproject.com/ and see lots of Legos I could use to
build a social network. Is there a current pre-built or HOWTO social
network project that I could use to get a Pinax social network up and
running in two hours or less, including stupid user mistakes on my part?

I have a Pinax 0.5 social network core, and I could fall back on that if
needed, but that is really a losing solution unless the free-of-effort
social network has been phased out in favor of bigger and better sites.

I know that Pinax was intended as a tabula rasa with batteries/Legos
included and not as a system whose features are best showcased in what
happens to be a social network, but I have more easily gotten a social
network running on 0.5 than more recent releases.

-- 
[image: Christos Jonathan Hayward] 
Christos Jonathan Hayward, an Orthodox Christian author.

*Amazon * • Author
Bio
 • *Email * •
Facebook
 • Fan Page  • Google
Plus
 • LinkedIn  •
*Professional
* • Twitter  •
*Web
* • What's New? 
If you read just *one* of my books, you'll want *The Best of Jonathan's
Corner *.

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