Re: how to tricking LogEntry model ?

2013-03-02 Thread Bino Oetomo
Nevermind.

I Solved this problem by another route.

Subclass the ModelAdmin, and overide : log_addition, log_change, 
log_deletion method.

Sincerely
-bino-

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




FastCGI Recipe for shared hosting

2013-03-02 Thread Tim Johnson
* Tom Evans  [130301 06:44]:
> Apache httpd with mod_fastcgi:
> 
> RewriteCond %{REQUEST_URI} !^/media
> RewriteCond %{REQUEST_URI} !^/
> # repeat for any other directories you want httpd to serve
> RewriteRule ^/(.*)$ /app.fcgi/$1 [QSA,L]
> FastCGIExternalServer /path/to/your/htdocs/app.fcgi -socket
> /path/to/your/webapp/run/app.socket
The following :
##
RewriteCond %{REQUEST_URI} !^/media
RewriteCond %{REQUEST_URI} !^/
RewriteRule ^/(.*)$ /app.fcgi/$1 [QSA,L]
FastCGIExternalServer app.fcgi -socket app.socket
##
When applied to http://www.lyxx.com/freestuff/002.html (htaccess
validator) generates an error on the last line.

Tom are you using the FastCGIExternalServer in .htaccess or in
httpd.conf?

Bear in mind that I do not have access to httpd.conf on this shared
hoster and in
https://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/ I
read wherre FastCGIExternalServer is referred to as an addition to
httpd.conf.

-- 
Tim 
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com

-- 
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: Request for comments on a new Open Source Paas platform for Django

2013-03-02 Thread Christopher Glass
Hi Patrick,

Great to hear you're interested in writing a Django charm for juju! I have 
toyed around with the idea, but never got around to implementing something 
good.
I started looking at the current Django charm a little while ago, and while 
it works to some extend I think we could make really great things happen 
with a little work.

As far as feedback for your point goes, here are a few points and 
suggestion I'd like to add to the discussion:

- Most of the Django websites will likely live in private git/bzr/whatever 
repositories, and so in the workflow you outlined, you need to somehow push 
the *private identifier* to the running juju instance. In the "standard" 
scenario that means pushing your private ssh key to the instance, so it can 
git clone from a private repository on github... I think it's safe to say 
that most people will at least frown at the idea :)
Maybe we should instead make this a "push" process?

- It seems a little strange to me to run gunicorn on another machine. Most 
of the Django project I have encountered run Django with gunicorn on the 
webservers themselves (add gunicorn to INSTALLED_APPS and then "manage.py 
run_gunicorn"). Perhaps we should be a little more opinionated about things 
and for the sake of scaling simplicity deploy nginx or apache locally too 
(wither with a charm subordinate or at install), so that we can 
load-balance to all of the servers easily with any frontend (that means all 
webservers would serve static files, which might not be optimal, but we can 
refine that later).

- We should absolutely define a cache relation (redis or memcached).

Theses points would make the whole workflow look like the following (the 
juju syntax might be a little wrong, but please bear with me :) )

  juju bootstrap

  juju deploy --config my_django_conf.yaml cs:django_server my_django_site
  juju deploy cs:postgresql # or mysql,mongodb, etc
  juju deploy cs:memcached # or redis if that's still popular
  juju deploy cs:haproxy

  juju add-relation my_django_site postgresql
  juju add-relation my_django_site memcached
  juju add-relation my_django_site haproxy # strictly speaking that's 
optional if you have only one django machine

  juju expose haproxy

  # when needed (I hope we all need it someday!)
  juju add-unit my_django_site
  juju add-unit memcached
  juju add-unit postgresql

So now we would have a running django server with no code.
But if it's a push process, we can implement many of the config changes as 
git hooks, which makes the workflow continue with:

  cd my-django-site
  git init . # If that's not done already of course
  git add .
  git commit -m "produciton push yay!"
  git remote add production 
git+ssh://my_django_site/some_configurable_url.git
  git push production master # or of course whatever branch you put in the 
config.yaml

Of course, that requires a non-trivial amount of git triggers to be 
written, and we should put some requirements.pip.txt file and 
requirements.apt.txt or whatever in the project tree, but I think that's 
acceptable.
The whole thing basically follows what many PaaS providers already do, so I 
guess most Django developers with some sites in production probably are 
familiar with the workflow. 

This would just add the juju coolness to it :)

Hope this fuels the discussion,

- Chris

On Friday, March 1, 2013 8:13:36 PM UTC+1, Patrick wrote:
>
> Hi,
>
> I'm building a Juju based Open Source Paas platform for Django and
> I need your help because it is a hard task to make a PAAS system
> that is flexible enough to deploy any projects and at the same time
> simple to use.
>
> For the ones that don't know Juju, it's a service orchestration software
> compatible with LXC (local), EC2, HPCloud, OpenStack and Baremetal/Maas
> developed by Canonical (the company that makes Ubuntu).
>
> Check out the web site for more details: https://juju.ubuntu.com/
>
> So quickly, here's how it would works:
>
> After installing Juju and configuring it with for your favourite cloud 
> provider you
> will need to create a configuration file in the YAML format named 
> my_django_conf.yaml
> in this example::
>
>   my_django_site:
>   vcs: git
>   repos_url: https://github.com/my_username/my_site.git 
>   site_secret_key: abcdefgh123456789
>   use_virtualenv: True
>
> Then you will need these commands to bootstrap and launch all the servers::
>
>   juju bootstrap
>
>   juju deploy --config my_django_conf.yaml my_django_site
>   juju deploy postgresql # or mysql,mongodb, etc
>   juju deploy gunicorn # Or mod_wsgi, etc
>
>   juju add-relation my_django_site postgresql
>   juju add-relation my_django_site gunicorn
>
>   juju expose gunicorn # Open the tcp port in the firewall
>
> You will end up with 3 servers running. One will be the controller
> and one for each service (django and the database). 
> Gunicorn will be a special charm that will be installed on your Django 
> server.
> After that, adding a new Django node would be a

empty static_url

2013-03-02 Thread Phil
Hi,

I'm using django1.4.3

I have a django project with 3 apps. All 3 apps templates extend 
'app.html'. On 2 of my projects the CSS loads fine, but on third one the 
CSS doesn't get loaded because it's not adding '/static/' to the url to the 
CSS. So instead of '/static/css/style.css' I'm getting '/css/style.css' ...



STATIC_URL is working on the 2 projects that use generic views, but not on 
the other one. So how can 'STATIC_URL' be blank and how can this be fixed? 
I tried adding the following to my index.html template but no joy...

{% load static %}
{% get_static_prefix as STATIC_PREFIX %}

-- 
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: IntegrityError after updating to custom user field: django_admin_log still has fk to auth_user

2013-03-02 Thread Peter of the Norse
This sound like a South kind of problem. Your tables were created with a 
foreign key from django_admin_log to auth_user, but you’re not longer using 
auth_user. You’ll have to drop the foreign key and recreate it to remove this 
error.

On Feb 27, 2013, at 4:17 PM, Ben Roberts wrote:

> This ring any bells? I updated my existing site to utilize my new Django 1.5 
> custom user field, and now I can't update anything in Admin because i get the 
> following error: (django_admin_log still has a fk to auth_user, apparently!) 
> Any way to resolve this?
> 
> 
> 
> Traceback (most recent call last):
> 
>   File 
> "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py",
>  line 115, in get_response
> response = callback(request, *callback_args, **callback_kwargs)
> 
>   File 
> "/app/.heroku/python/lib/python2.7/site-packages/newrelic-1.10.0.28/newrelic/api/object_wrapper.py",
>  line 220, in __call__
> self._nr_instance, args, kwargs)
> 
>   File 
> "/app/.heroku/python/lib/python2.7/site-packages/newrelic-1.10.0.28/newrelic/hooks/framework_django.py",
>  line 475, in wrapper
> return wrapped(*args, **kwargs)
> 
>   File 
> "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/admin/options.py",
>  line 372, in wrapper
> return self.admin_site.admin_view(view)(*args, **kwargs)
> 
>   File 
> "/app/.heroku/python/lib/python2.7/site-packages/django/utils/decorators.py", 
> line 91, in _wrapped_view
> response = view_func(request, *args, **kwargs)
> 
>   File 
> "/app/.heroku/python/lib/python2.7/site-packages/django/views/decorators/cache.py",
>  line 89, in _wrapped_view_func
> response = view_func(request, *args, **kwargs)
> 
>   File 
> "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/admin/sites.py",
>  line 202, in inner
> return view(request, *args, **kwargs)
> 
>   File 
> "/app/.heroku/python/lib/python2.7/site-packages/django/utils/decorators.py", 
> line 25, in _wrapper
> return bound_func(*args, **kwargs)
> 
>   File 
> "/app/.heroku/python/lib/python2.7/site-packages/django/utils/decorators.py", 
> line 91, in _wrapped_view
> response = view_func(request, *args, **kwargs)
> 
>   File 
> "/app/.heroku/python/lib/python2.7/site-packages/django/utils/decorators.py", 
> line 21, in bound_func
> return func(self, *args2, **kwargs2)
> 
>   File 
> "/app/.heroku/python/lib/python2.7/site-packages/django/db/transaction.py", 
> line 223, in inner
> return func(*args, **kwargs)
> 
>   File 
> "/app/.heroku/python/lib/python2.7/site-packages/django/db/transaction.py", 
> line 217, in __exit__
> self.exiting(exc_value, self.using)
> 
>   File 
> "/app/.heroku/python/lib/python2.7/site-packages/django/db/transaction.py", 
> line 281, in exiting
> commit(using=using)
> 
>   File 
> "/app/.heroku/python/lib/python2.7/site-packages/django/db/transaction.py", 
> line 152, in commit
> connection.commit()
> 
>   File 
> "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/__init__.py",
>  line 241, in commit
> self._commit()
> 
>   File 
> "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py",
>  line 242, in _commit
> six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), 
> sys.exc_info()[2])
> 
>   File 
> "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py",
>  line 240, in _commit
> return self.connection.commit()
> 
>   File 
> "/app/.heroku/python/lib/python2.7/site-packages/newrelic-1.10.0.28/newrelic/hooks/database_dbapi2.py",
>  line 68, in commit
> return self._nr_connection.commit()
> 
> IntegrityError: insert or update on table "django_admin_log" violates foreign 
> key constraint "django_admin_log_user_id_fkey"
> DETAIL:  Key (user_id)=(2) is not present in table "auth_user".
> 
> -- 
> 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.
>  
>  

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.




how to save manytomany relation data to database through form....

2013-03-02 Thread Iftikhar Ali
i am having one tag class and one user in which user contained a tag 
element which has manytomany relation with tag class

can you guyz tell me how to save this tag using form

i attached the form.py model.py and view.py

my problem is the tag element i can't access through the form and don't 
understand how to save it... i tried lot's ya can you guyz help.

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


from django import forms
from application.homepage.models import Tag

class RegistrationForm(forms.Form):
	name = forms.CharField()
	dob = forms.DateTimeField()
	email= forms.EmailField()
	alternate_email=forms.EmailField()
	permission=forms.DecimalField()
	password = forms.CharField()
	phone=forms.DecimalField()
	#pic = forms.ImageField()
	about= forms.CharField(widget=forms.Textarea)
	profile_view= forms.DecimalField()
	location= forms.CharField(widget=forms.Textarea)
	website = forms.CharField()
	reputation=forms.DecimalField()#tags= forms.CharField(widget=forms.CheckboxSelectMultiple(choices=choice))
	tags= forms.ModelMultipleChoiceField(queryset=Tag.objects.all(),widget=forms.SelectMultiple())
	num_of_que_asked= forms.DecimalField()
	num_of_que_answered= forms.DecimalField()
	doj = forms.DateField(widget=forms.DateInput)from thumbs import ImageWithThumbsField
from django.db import IntegrityError
from django.db import models

class  Tag(models.Model):
	name = models.CharField(max_length=64, primary_key=True)
	about= models.TextField()
	created_date =  models.DateTimeField(auto_now_add=True)
	editor = models.CharField(max_length=64)
	active= models.BooleanField()
	verified= models.BooleanField()
	rating= models.DecimalField(max_digits=8,decimal_places=0)
	date_modified = models.DateTimeField(auto_now_add=True)
	def __str__(self):
		#return (self.name,self.about,self.created_date,self.editor,self.active,self.verified,self.rating,self.viewed,self.date_created)
		return (self.name)
	class Admin:
		pass

class User(models.Model):
	name = models.CharField(max_length=64)
	dob = models.DateTimeField(auto_now_add=True)
	email= models.EmailField(verbose_name='your e-mail')
	alternate_email=models.EmailField()
	permission=models.DecimalField(max_digits=3,decimal_places=0,blank=True, null=True)
	password = models.CharField(max_length=32)
	phone=models.DecimalField(max_digits=11,decimal_places=0)
	pic = ImageWithThumbsField(upload_to='images',blank=True, null=True)
	about= models.TextField()
	profile_view= models.DecimalField(max_digits=8,decimal_places=0)
	location= models.TextField()
	website = models.URLField(max_length=64)
	reputation=models.DecimalField(max_digits=3,decimal_places=0,blank=True, null=True)
	tags= models.ForeignKey(Tag, blank=True, null=True)
	num_of_que_asked= models.DecimalField(max_digits=8,decimal_places=0)
	num_of_que_answered= models.DecimalField(max_digits=8,decimal_places=0)
	doj = models.DateTimeField(auto_now_add=True)
	def __str__(self):
		#return (self.name,self.dob,self.email,self.about,self.profile_view,self.location,self.website,self.tags,self.num_of_que_asked,self.num_of_que_answered,self.doj)
		return (self.name)
	class Admin:
		pass
	
	
	


class Tips(models.Model):
	heading = models.CharField(max_length=64)
	description= models.TextField()
	verified= models.BooleanField(blank=True)
	creation_date = models.DateTimeField(auto_now_add=True)
	modified_date = models.DateTimeField(auto_now_add=True)
	tags = models.ManyToManyField(Tag)
	active= models.BooleanField(blank=True)
	created_by = models.CharField(max_length=64)
	rating= models.DecimalField(max_digits=8,decimal_places=0)
	viewed= models.DecimalField(max_digits=8,decimal_places=0,blank=True, null=True)
	def __str__(self):
		#return (self.heading,self.about,self.verified,self.creation_date,self.modified_date,self.tags,self.created_by,self.rating,self.viewed)
		return (self.heading)
	class Admin:
		pass# Create your views here.
from django.shortcuts import render_to_response, get_object_or_404
from application.homepage.models import Tips,User,Tag
from django.http import HttpResponse
from django.template import RequestContext
from application.homepage.forms import RegistrationForm

def index(request):
	userlist=Tips.objects.all()
	mrel=userlist[0].tags.all()
	return render_to_response('homepage/index.html',{'userlist':userlist, 'mrel':mrel})
	
	
def register(request):
	
	if request.method == 'POST':
		reg_form=RegistrationForm(request.POST, request.FILES)
		taglist=[]
		print "working"
		if reg_form.is_valid():
		  success=True
		  try:
	

Re: error in filling data in database through admin page

2013-03-02 Thread Николай Федосов

https://docs.djangoproject.com/en/dev/topics/db/models/

starting from:


   Extra fields on many-to-many relationships




01.03.2013 19:13, C. Kirby пишет:
It would be helpful to see the model definition(s) and the admin.py if 
you wrote one


On Friday, March 1, 2013 1:06:34 AM UTC-6, Avnesh Shakya wrote:

hi,
 i have got one error during adding data in database though
admin page, actually it was working fine, but i made some
attributes optional, now it's generating error..
i m adding m models.py ,
error--

" needs to have a value for field "course" before 
this many-to-many relationship can be used.

plz help me..

thanks in 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: Django URLs with/without proxy server

2013-03-02 Thread Bill Freeman
You haven't show project/app1/urls.py (or wherever you're getting
project.app1.urls).  My guess is that it also specifies that each url
begins with "app1/".  Since the root urlconf matches *and consumes* one
"app1/" from the request path, any "app1/" required by app1's urls.py is
required in addition.

Or isn't that your question?

Bill

On Fri, Mar 1, 2013 at 10:57 AM, Barun Saha  wrote:

> I have two Django apps (say, app1 and app2) hosted on the same machine
> using Apache mod_wsgi. These two apps are hosted on two different
> environments:
>
>  1. On a physical server where only these two apps are hosted. They are
> accessed as http://www.example.com/app1/app1/ and
> http://www.example.com/app2/app2/.
>  2. In the second environment there is a proxy server. A separate web page
> on that server is accessed as http://www.domain.com/. This links to the
> above two apps (now hosted on a single virtual machine) as
> http://www.domain.com/id1/ and http://www.domain.com/id2/
>
> The URLconf file looks like:
>
> urlpatterns = patterns('',
> (r'^admin/', include(admin.site.urls)),
> (r'^app1/', include('project.app1.urls')),
> )
>
> The problem is, this URL configurations works in the environment 1, but
> not in the environment 2. Now, if I do something *crazy* in the environment
> 2 such as
>
>  urlpatterns = patterns('',
> (r'^admin/', include(admin.site.urls)),
> (r'^app1/app1/app1/', include('project.app1.urls')),
> (r'^app1/app1/', include('project.app1.urls')),
> (r'^app1/', include('project.app1.urls')),
>  )
>
> then the application works. In the env. 2, the app is accessed as
> http://www.domain.com/id1/app1/app1/.
>
> I couldn't understand why we need to prefix app1 in the URL so many times.
> In other words, why (how) this works.
>
> Could someone clarify on this? Also, note that all configurations need to
> be done on the virtual machine. I don't have access to the proxy server.
>
> (Posted in Stackoverflow:
> http://stackoverflow.com/questions/15159134/django-urls-with-without-proxy-server
> )
>
> --
> 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: Experiences with A/B testing?

2013-03-02 Thread sidmitra
Hi Tomas,
   
 I do have some experience. I would advise you to look at 
http://www.optimizely.com as an alternative first. It's definitely easier 
to setup. Ofcourse coding backend to do A/B tests is always much more 
flexible at the expense of a lot of effort. So over the past year i've 
shifted to Optimizely, and it integrates with crazy egg/mixpanel etc as 
well. The product isn't perfect, but i've found it to be the least 
effort(keeping lean-ness in mind) and i code around the limitations of 
optimizely.



Sid.
http://www.cloudshuffle.com

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




Storing versioned maps of application connections?

2013-03-02 Thread Victor Hooi
Hi,

We have a legacy Django application that parses configuration files for 
several in-house applications, builds up a map of those applications, 
including any network connections between them (based on IP address and 
port), then stores them in Django models.

Each application object will store several things, such as a process name 
(which is unique), the application binary and version, as well as any 
network connections (listening or connecting).

For simplicity (I'm assuming), each day they blow away the existing model 
instances, then reparse all the configuration, and build up a new map with 
new model instances.

I'm looking at using similar to django-reversion to add version control to 
this application (It probably will be django-reversion - I'm not aware of 
any viable alternatives to django-reversion).

Now, obviously, the current blowing away approach isn't going to work with 
Django-reversion.

However, say we do a re-parse, what's the best way of integrating 
django-reversion into the workflow?

I assume we'd need some way of linking an existing application model with 
the new one from each daily re-parse.

We could use the process name (which is unique), do a lookup to see if that 
process name already exists, get it if it does, write our new values to the 
model, then save it.

My understanding is that django-reversion will only pickup on the changed 
fields.

We'd need to do a lookup on every single application and a save though - 
there's probably a smarter way to bulk these? (I know there's bulk create 
in Django, I'm not aware of any bulk updates?).

Are there any performance considerations we should be wary of? (There are 
probably between 100-200 applications).

Cheers,
Victor

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