Re: to_field can not use primary key of related object.

2012-08-23 Thread Jani Tiainen

23.8.2012 9:30, yillkid kirjoitti:


HI all.
I write a model:
class UserGroup(models.Model):
 groups = models.ForeignKey(Group, to_field='id')

and when I into admin backend:














According to the Django  document the combobox item should be a "id"
field in Group model,
but it is not, why ?


Where from the documenttion you got impression of that? As documentation 
states:


"Foreginkey.to_field
The field on the related object that the relation is to. By default, 
Django uses the primary key of the related object"


There is nothing about representation in a select field on a form. It 
still uses ID as a value to post. But what you see is just a 
representation of the __unicode__ method. There is way to change that 
behaviour for a particular form field if needed.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

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



Re: database error and connection._rollback

2012-08-23 Thread Mike Dewhirst

On 23/08/2012 4:27pm, akaariai wrote:

On 23 elo, 08:30, Mike Dewhirst  wrote:

This ... [1]

from django.db import connection
connection._rollback()

... solved a problem for me in unit testing when I catch a deliberate
DatabaseError.

Django 1.4
Python 2.7
PostgreSQL 9.1

My question: Is it safe enough to use a method with a leading underscore?


Generally no. In this specific case you might be safe. However, if you
use _commit() in Django's standard TestCase you might make your
testing DB dirty and some other test could break because of that. This
kind of bug is horrible to debug.


Is there a better method?


Use TransactionTestCase


Thanks - much appreciated

Mike


which is meant for this kind of testing. In

TransactionTestCase you can safely use .commit() and .rollback(). The
cost is slower test execution. See: [https://docs.djangoproject.com/en/
dev/topics/testing/#django.test.TransactionTestCase].

  - Anssi



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



Re: How to use Django with Apache and mod_wsgi

2012-08-23 Thread Joris


Op woensdag 22 augustus 2012 23:05:03 UTC+2 schreef stikic het volgende:
>
> Then do I have to delete 00_default_vhost.conf file?
> What name can I give to this new created file? 
>
> Well you have not referred or included 00_default_vhost.conf in your 
httpd.conf so this file is not actually read by the web server! This is 
confirmed in your output of apache2ctl -S. 
Together with the observation that there is no "NameVirtualHost" OR a 
"DocumentRoot"  directive in the httpd.conf you supplied, suggests you 
either are not supplying us with all the config info you have OR you have a 
really weird apache set up. Anyway, your issue is clearly with Apache and 
not Django, so it  may be better if you ask these questions in a dedicated 
forum.

jb

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/0jfFwWZsQckJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: What is the easy way to install DJango?

2012-08-23 Thread Jani Tiainen

23.8.2012 2:08, Demian Brecht kirjoitti:




 Or installing the M$ VC++ Express edition compatible with the
version used for the Python build 
--
 Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.com 
HTTP://wlfraed.home.netcom.com/


Sure (or MinGW if I'm not mistaken) but the question was asking about an
"easy" way. I'm not sure that setting up a full build environment on a
Windows machine would qualify it to be such. Of course, that's entirely
subjective and not really related to the question at hand ;)

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


And even with those you will end up problems. One common 3rd party 
library that has extensions is PIL. And there is not really easy way to 
build PIL with all dependencies on windows machine - specially PNG 
support is a tricky one. Also for few build scripts there seem to be 
problem of passing different compiler than msvc for windows. So 
everything is not simple.


These parts are way simpler in *nix like environments - except in RHEL...

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

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



How to use URL namespaces in tests?

2012-08-23 Thread e.generalov
Url patterns which provided by a django application should be 
addressedexternally in 
the form of "namespace:name". I guess it will be connected to the project as 
follows:

project/urls.py

urlpatterns = patterns('',
url('^something/', include('django_something.urls', 
namespace='something')))

URL patterns module in the application looks like:

django_something/urls.py

urlpatterns = patterns('',
url('^$', show, name='show'))

and I write a test:

django_something/tests.py

class ShowViewTest(TestCase):
urls = 'django_something.urls'

def test_should_render_something_template(self):
url = reverse('something:show') # !!!
response = self.client.get(url)
self.assertIn('something.html', set([t.name for t in 
response.templates]))

This test failes with exception "django NoReverseMatch 'something' is not a 
registered namespace" . How can I specify namespace 'something' in this 
case?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/gu-nerRvUugJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: GeometryField in OSMGeoAdmin

2012-08-23 Thread geonition
Hi,

It is very convenient for me to use GeometryField as I can save any 
geometry type into the same field. The database logic will become more 
complex if I am required to create a separate table or field for e.g. 
points and linestrings.

Still looking for a workaround, or is there a reason for me not to save all 
geometries into the same field?

On Thursday, August 23, 2012 2:27:48 AM UTC+3, Melvyn Sopacua wrote:
>
> On 22-8-2012 10:31, geonition wrote: 
>
> > I have a problem with GeometryField not showing the saved geometry in 
> the 
> > admin interface. The problem is that the GeometryField has a type of 
> > 'GEOMETRY' when the value saved might have the type of e.g. 'POINT'. 
>
> The GeometryField is like the normal Field class: the base class for 
> actual fields you should be using in your model, like PointField. The 
> docs are not very clear on this issue. 
> -- 
> Melvyn Sopacua 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/WJauvt8Cs1QJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: What is the easy way to install DJango?

2012-08-23 Thread baldyeti

Overall it is  less problematic to get any python library
to work on linux than windows, no doubt.

But an alternative which I have not seen mentioned yet is using
the ActiveState python distribution. Their "pypm" package manager
can tap into their repository of pre-built extensions
(see http://code.activestate.com/pypm/)
Maybe an option for those stuck on windows, at least for development.
I am unsure about the redistribution terms, though, and win64 builds
are reserved to (paying) customers.

Demian Brecht wrote, On 2012-08-22 16:29:

Er, it's easy to install on Windows until you want to install a package
that has C extensions. Then, you're either scouring the web for
pre-builts (which can be a pain depending on your architecture and your
level of paranoia about the contents of the binaries) or you're
installing a GNU toolchain on a Windows machine, which is far from easy
for someone new(er) to Python development (unless they come from a Linux
environment anyway). Examples of such modules are MySQLdb and pycrypto.

I also +1 getting used to Linux for Python/Django development. Makes the
world a happier place ;)




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



Re: CACHE_MIDDLEWARE_ANONYMOUS_ONLY does not work if user is not printed by view or template

2012-08-23 Thread Alexis Bellido
Hi,

Yeah, the optimization approach makes sense but it's misleading as the 
settings says CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True, which makes you think 
that every view that is requested by an authenticated user is non-cached.

I haven't finished working on my templates and views yet but I will 
probably need to access the user context variable from most of my templates 
so this shouldn't be a big problem.

I tried referring request.user in the view (something as simple as u = 
request.user) but that didn't help, I had to code "print request.user" to 
show a non-cached view. Could it be because of lazy loading which doesn't 
even grab the User object when I just assign it to a variable? What kind of 
assignment or operation should I try with the User object on my view to 
bypass lazy loading if that's the case?

What I've done for now is writing a decorator that checks the user and if 
it's authenticated does the same thing that the never_cache decorator does. 
 I've published my code here:

https://gist.github.com/3418108

But now that I think about what you said I think simply bypassing the lazy 
loading and somehow accessing the User object on the view would be a 
simpler solution.

Thanks for the ideas!

On Thursday, August 23, 2012 2:40:47 AM UTC-3, ke1g wrote:
>
> I guess this is probably because the request.user object is created on 
> demand 
> (is a python "property").  The intent, I presume, is to not bother 
> fetching the session, 
> etc., unless it is used, as an optimization. 
>
> You should find that simply referring to request.user in the view 
> helps.  If so, then 
> you may want to add such to the views you want to leave uncached.  An 
> alternative 
> is to add a middleware that does this, which will incur the lookup 
> costs for all views. 
>
> Bill 
>
> On Tue, Aug 21, 2012 at 1:27 PM, Alexis Bellido 
> > 
> wrote: 
> > Hello, 
> > 
> > I am working on a Django 1.4 project and writing one simple application 
> > using per-site cache as described here: 
> > 
> > https://docs.djangoproject.com/en/dev/topics/cache/#the-per-site-cache 
> > 
> > I have correctly setup a local Memcached server and confirmed the pages 
> are 
> > being cached. 
> > 
> > Then I set CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True because I don't want 
> to 
> > cache pages for authenticated users. 
> > 
> > I'm testing with a simple view that returns a template with 
> > render_to_response and RequestContext to be able to access user 
> information 
> > from the template and the caching works well so far, meaning it caches 
> pages 
> > just for anonymous users. 
> > 
> > And here's my problem. I created another view using a different template 
> > that doesn't access user information and noticed that the page was being 
> > cached even if the user was authenticated. After testing many things I 
> found 
> > that authenticated users were getting a cached page if the template 
> didn't 
> > print something from the user context variable. It's very simple to 
> test: 
> > print the user on the template and the page won't be cached for an 
> > authenticated user, remove the user on the template, refresh the page 
> while 
> > authenticated and check the HTTP headers and you will notice you're 
> getting 
> > a cached page. You should clear the cache between changes to see the 
> problem 
> > more clearly. 
> > 
> > I tested a little more and found that I could get rid of the user in the 
> > template and print request.user right on the view (which prints to the 
> > development server console) and that also fixed the problem of showing a 
> > cached page to an authenticated user but that's an ugly hack. 
> > 
> > A similar problem was reported here but never got an answer: 
> > 
> > https://groups.google.com/d/topic/django-users/FyWmz9csy5g/discussion 
> > 
> > I can probably write a conditional decorator to check if 
> > user.is_authenticated() and based on that use @never_cache on my view 
> but it 
> > seems like that defeats the purpose of using per-site cache, doesn't it? 
> > 
> > Any suggestions will be appreciated. 
> > 
> > Thanks! 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Django users" group. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msg/django-users/-/dZx3IJsXp9EJ. 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > To unsubscribe from this group, send email to 
> > django-users...@googlegroups.com . 
> > For more options, visit this group at 
> > http://groups.google.com/group/django-users?hl=en. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/6PEC48IRA7oJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this g

Models relationship

2012-08-23 Thread Fernando Andreacci
Hello,

I'm a new Django user, and I have the following question:

I have one Model called *factory, *with several fields like (name, address, 
phone, etc).

Each factory can be a customer, a supplier or both.

Ex:
Factory1 is a customer of Factory2, and Factory1 is a supplier of Factory3.

How can I set up the models to hold this information?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/C0KQX7HoCTUJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



error in the order form

2012-08-23 Thread Владислав Иванов
Developing an order form. Shows the error "to" argument must be a list or 
tuple
Please tell me that I not correct? I need the user to be online to complete 
this form and the order came to my email

*views.py*

#-*-coding:utf-8-*-

from django.db import models

from django import forms

from django.shortcuts import render

from django.http import HttpResponseRedirect

from django.core.mail import mail_admins

from django.core.context_processors import csrf



class ContactForm(forms.Form):

name = forms.CharField(max_length=500)

email = forms.EmailField()

phone = forms.CharField(max_length=25)

gorod_vuz = forms.CharField(max_length=500)

tip = forms.CharField(max_length=100)

predmet = forms.CharField(max_length=100)

tema = forms.CharField(max_length=300)

stranits = forms.CharField(max_length=3)

srok = forms.CharField(max_length=20)

summa = forms.CharField(max_length=20)

message = forms.CharField(widget=forms.Textarea)



def contact(request):

if request.method == 'POST':

form = ContactForm(request.POST)

if form.is_valid():

name = form.cleaned_data['name']

email = form.cleaned_data['email']

phone = form.cleaned_data['phone']

gorod_vuz = form.cleaned_data['gorod_vuz']

tip = form.cleaned_data['tip']

predmet = form.cleaned_data['predmet']

tema = form.cleaned_data['tema']

stranits = form.cleaned_data['stranits']

srok = form.cleaned_data['srok']

summa = form.cleaned_data['summa']


 recipients = ['ref...@yandex.ru']


 from django.core.mail import send_mail

send_mail(name, email, tema, summa)

return HttpResponseRedirect('/thanks/')

else:

form = ContactForm()

return render(request, 'zakaz/form.html', {

'form': form,

})


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/ALNYDdTFwbwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: error in the order form

2012-08-23 Thread Amyth Arora
The reason you are getting this error is because the 'TO' argument
you're passing to send_mail is not a list but a string.

you're calling the send_mail function using send_mail(name, email,
tema, summa) and here the TO argument you are passing is 'email' which
is not a list of recipients but the string produced by email =
form.cleaned_data['email'] this statement.

the send_mail library is capable of sending email to multiple
recipients and that is why it accepts the 'TO' argument to be a list
or a tuple. [No matter if your list contains only 1 email address.]

The Solution

i don't know where are you using the recipients list, but to send the
mail you can do this:

under the line  recipients = ['ref...@yandex.ru']
add this  recipients = recipients.append(email)

i also realized the 'From' argument you are passing is using the Name
of the user filling the form, however it should be an email address
that you want users to see when they recieve and email. [Even though
name will work as the argument should be a string.] but i would
suggest you to use your own email address or the email add that you
want to send mails from. so you can add another line under that:

add this  from = 'yourem...@yourdomain.com'


and change >>> send_mail(name, email, tema, summa)

to  send_mail(from, recipients, subject, message)

and you should have it working.


On Thu, Aug 23, 2012 at 6:01 PM, Владислав Иванов  wrote:
> Developing an order form. Shows the error "to" argument must be a list or
> tuple
> Please tell me that I not correct? I need the user to be online to complete
> this form and the order came to my email
>
> views.py
>
> #-*-coding:utf-8-*-
>
> from django.db import models
>
> from django import forms
>
> from django.shortcuts import render
>
> from django.http import HttpResponseRedirect
>
> from django.core.mail import mail_admins
>
> from django.core.context_processors import csrf
>
>
>
> class ContactForm(forms.Form):
>
> name = forms.CharField(max_length=500)
>
> email = forms.EmailField()
>
> phone = forms.CharField(max_length=25)
>
> gorod_vuz = forms.CharField(max_length=500)
>
> tip = forms.CharField(max_length=100)
>
> predmet = forms.CharField(max_length=100)
>
> tema = forms.CharField(max_length=300)
>
> stranits = forms.CharField(max_length=3)
>
> srok = forms.CharField(max_length=20)
>
> summa = forms.CharField(max_length=20)
>
> message = forms.CharField(widget=forms.Textarea)
>
>
>
> def contact(request):
>
> if request.method == 'POST':
>
> form = ContactForm(request.POST)
>
> if form.is_valid():
>
> name = form.cleaned_data['name']
>
> email = form.cleaned_data['email']
>
> phone = form.cleaned_data['phone']
>
> gorod_vuz = form.cleaned_data['gorod_vuz']
>
> tip = form.cleaned_data['tip']
>
> predmet = form.cleaned_data['predmet']
>
> tema = form.cleaned_data['tema']
>
> stranits = form.cleaned_data['stranits']
>
> srok = form.cleaned_data['srok']
>
> summa = form.cleaned_data['summa']
>
>
> recipients = ['ref...@yandex.ru']
>
>
> from django.core.mail import send_mail
>
> send_mail(name, email, tema, summa)
>
> return HttpResponseRedirect('/thanks/')
>
> else:
>
> form = ContactForm()
>
> return render(request, 'zakaz/form.html', {
>
> 'form': form,
>
> })
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/ALNYDdTFwbwJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.



-- 
Thanks & Regards


Amyth [Admin - Techstricks]
Email - aroras.offic...@gmail.com, ad...@techstricks.com
Twitter - @a_myth_
http://techstricks.com/

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



Re: CACHE_MIDDLEWARE_ANONYMOUS_ONLY does not work if user is not printed by view or template

2012-08-23 Thread Alexis Bellido
Ok, I just confirmed my "problem" was caused by Django lazy loading the 
User object.

To confirm it, I just added something like this to my view:

test_var = "some text" + request.user

And I got an error message telling me I couldn't concatenate an str to a 
SimpleLazyObject. At this point the lazy loading logic hasn't got a real 
User object yet.

To bypass the lazy loading, hence return a non-cache view for authenticated 
users, I just needed to access some method or attribute to triggers an 
actual query on the User object. I ended up with this, which I think it's 
the simplest way:

bypass_lazyload = request.user.is_authenticated()

My conditional_cache decorator is no longer needed, although it was an 
interesting exercise.

I may not need to do this when I finish working with my views as I'll 
access some user methods and attributes on my templates anyway but it's 
good to know what was going on.

Regards.

On Thursday, August 23, 2012 2:40:47 AM UTC-3, ke1g wrote:
>
> I guess this is probably because the request.user object is created on 
> demand 
> (is a python "property").  The intent, I presume, is to not bother 
> fetching the session, 
> etc., unless it is used, as an optimization. 
>
> You should find that simply referring to request.user in the view 
> helps.  If so, then 
> you may want to add such to the views you want to leave uncached.  An 
> alternative 
> is to add a middleware that does this, which will incur the lookup 
> costs for all views. 
>
> Bill 
>
> On Tue, Aug 21, 2012 at 1:27 PM, Alexis Bellido 
> > 
> wrote: 
> > Hello, 
> > 
> > I am working on a Django 1.4 project and writing one simple application 
> > using per-site cache as described here: 
> > 
> > https://docs.djangoproject.com/en/dev/topics/cache/#the-per-site-cache 
> > 
> > I have correctly setup a local Memcached server and confirmed the pages 
> are 
> > being cached. 
> > 
> > Then I set CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True because I don't want 
> to 
> > cache pages for authenticated users. 
> > 
> > I'm testing with a simple view that returns a template with 
> > render_to_response and RequestContext to be able to access user 
> information 
> > from the template and the caching works well so far, meaning it caches 
> pages 
> > just for anonymous users. 
> > 
> > And here's my problem. I created another view using a different template 
> > that doesn't access user information and noticed that the page was being 
> > cached even if the user was authenticated. After testing many things I 
> found 
> > that authenticated users were getting a cached page if the template 
> didn't 
> > print something from the user context variable. It's very simple to 
> test: 
> > print the user on the template and the page won't be cached for an 
> > authenticated user, remove the user on the template, refresh the page 
> while 
> > authenticated and check the HTTP headers and you will notice you're 
> getting 
> > a cached page. You should clear the cache between changes to see the 
> problem 
> > more clearly. 
> > 
> > I tested a little more and found that I could get rid of the user in the 
> > template and print request.user right on the view (which prints to the 
> > development server console) and that also fixed the problem of showing a 
> > cached page to an authenticated user but that's an ugly hack. 
> > 
> > A similar problem was reported here but never got an answer: 
> > 
> > https://groups.google.com/d/topic/django-users/FyWmz9csy5g/discussion 
> > 
> > I can probably write a conditional decorator to check if 
> > user.is_authenticated() and based on that use @never_cache on my view 
> but it 
> > seems like that defeats the purpose of using per-site cache, doesn't it? 
> > 
> > Any suggestions will be appreciated. 
> > 
> > Thanks! 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Django users" group. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msg/django-users/-/dZx3IJsXp9EJ. 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > To unsubscribe from this group, send email to 
> > django-users...@googlegroups.com . 
> > For more options, visit this group at 
> > http://groups.google.com/group/django-users?hl=en. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/uzyHfkEIe7UJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Problems Adding Django South Tool

2012-08-23 Thread Fyodor Wolf
What was your Solution???

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/kW9P46ybVnYJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Can somebody help me on how to handle this scenario?

2012-08-23 Thread Nirmal Sharma
Thanks everybody for your help.
I will try what you have suggested and will come back with some more 
questions.

On Wednesday, August 22, 2012 4:57:47 PM UTC-7, Melvyn Sopacua wrote:
>
> Hi Nirmal, 
>
> I'll try to answer your question instead of assuming you're working with 
> django's auth system. 
>
> On 22-8-2012 7:13, Nirmal Sharma wrote: 
>
> > class People (models.Model): 
> > person_name  = models.CharField(max_length=150) 
> > 
> > 
> > class comments (models.Model): 
> > comment  = models.CharField(max_length=1000)   
> > root_comment =  models.ForeignKey('self', null=True, blank=True, 
> > related_name="children") 
> > People_id = models.ForeignKey(People) 
> ^^^ 
> That's bad practice, because you're not designing a database, you're 
> designing a model that is built from things, not id's. So name this 
> field person or commentator or written_by: 
> written_by = models.ForeignKey(People) 
>
> Same applies on numerous fields below. The reason it's bad practice is 
> because when you request an attribute the name of the attribute should 
> describe what you get. When you request comments.people_id the 
> expectation is that you get an id, while in actuality you get a model 
> instance. 
>
> > class comment_feedback (models.Model): 
> > feedback_People_id = models.ForeignKey(People) 
> > comment_id =   models.ForeignKey(comments) 
> > feedback_type_id =  models.CharField(max_length=20, 
> > choices=FEEDBACK_CHOICES) 
> > class Meta: 
> > unique_together = [("feedback_People_id", "info_id")] 
> > 
> > We are trying build a html page that will do the following. 
> > Once a user logs in, he can write a new comment (that would result in an 
> > insert into comments table) 
> > Alternatively he can do one of the following: 
> > select a comment of some other peoples and give his feedback (that 
> > would result in an insert into comment_feedback table) 
> > select a comment and write his own comment with a feedback on the 
> > original comment (that would result in an insert into comments table 
> with 
> > root_comment as the original comment and an insert into comment_feedback 
> > table for the original comment) 
>
> Here's how to dissect your problem description: 
> - The person can do three things ("actions") that he cannot do at the 
> same time: the obvious solution is to use three different forms in the 
> same HTML page or use popup windows for action 2 and 3. 
> - The second and third option are mostly a UI problem, because how does 
> the user select the comment she's providing feedback for. Unless you put 
> a form below each comment (which will make the page possibly incredibly 
> long), you need to do some JavaScript programming that shows the form 
> below the right comment and stores the comment being commented on in 
> some hidden variables in that form. This is where I would hire a UI 
> programmer. 
>
> > We tried doing this inlineformset_factory and nested formsets. However 
> we 
> > are quite confused on how to proceed with this. Also the 
> comment_feedback 
> > table has 2 foreign keys. 
> That isn't a problem as long as the foreign keys are to different 
> tables. inlineformset_factory will find the foreign key that goes from 
> parent_model to model in it's function signature. It uses 
> _get_foreign_key() in forms/models.py for that. 
>
> > How do we handle this at the form and template level? 
>
> Like I said, the selection process is mostly a UI nightmare. If you 
> solve that, creating the forms for it will be much easier to grasp. 
> -- 
> Melvyn Sopacua 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/72cZbiUA9qkJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: custom field for callable python object like class or function

2012-08-23 Thread Michael Palumbo
I did not know the pickle module. This is interesting. Thanks.
However, after playing with it, I am not sure it fits totally my need 
because I'd like humans to be able to write a string like 
"modulea.moduleb.MyClass" in the admin or so.

So I kept trying making a custom field (instead of a Model) by creating a 
custom 
field, formfield and widget.
The list view works well, even though it displays  instead of modulea.moduleb.MyClass... 
The add page works as well, I can add a model with the value "
modulea.moduleb.MyClass" in the field and then it works.
BUT I have an issue with the detail page of a model.
I get a TypeError because my field has a class reference (which is 
callable) and the code below then instances it!


   - 
   
c:\Users\Mike\Dropbox\development\tools\virtualenvs\django-1.4\lib\site-packages\django\forms\forms.py
in as_widget
   1. 
  
  else:
  
  2. 
  
  attrs['id'] = self.html_initial_id
  
  3. 
  
  4. 
  
  if not only_initial:
  
  5. 
  
  name = self.html_name
  
  6. 
  
  else:
  
  7. 
  
  name = self.html_initial_name
  
  1. 
  
  return widget.render(name, self.value(), attrs=attrs)
  
  ...
   1. 
  
  2. 
  
  def as_text(self, attrs=None, **kwargs):
  
  3. 
  
  """
  
  4. 
  
  Returns a string of HTML for representing this as an .
  
  5. 
  
  """
  
  6. 
  
  return self.as_widget(TextInput(), attrs, **kwargs)
  
  ▼ Local vars 
   VariableValueauto_id
   
   u'id_mapper_class'
   
   widget
   
   
   
   name
   
   'mapper_class'
   
   self
   
   
   
   only_initial
   
   False
   
   attrs
   
   {'id': u'id_mapper_class'}
   
   - 
   
c:\Users\Mike\Dropbox\development\tools\virtualenvs\django-1.4\lib\site-packages\django\forms\forms.py
in value
   1. 
  
  """
  
  2. 
  
  Returns the value for this BoundField, using the initial value if
  
  3. 
  
  the form is not bound or the data otherwise.
  
  4. 
  
  """
  
  5. 
  
  if not self.form.is_bound:
  
  6. 
  
  data = self.form.initial.get(self.name, self.field.initial)
  
  7. 
  
  if callable(data):
  
  1. 
  
  data = data()
  
  ...
   1. 
  
  else:
  
  2. 
  
  data = self.field.bound_data(
  
  3. 
  
  self.data, self.form.initial.get(self.name, 
self.field.initial)
  
  4. 
  
  )
  
  5. 
  
  return self.field.prepare_value(data)
  
  6. 
  
  ▼ Local vars 
   VariableValueself
   
   
   
   data
   
   
   
   

   - 


I overrided the render method of the widget but the errors comes from 
self.value() of the BoundField.
How can I fix that? override that?

Any other idea?

Thanks.



Le jeudi 23 août 2012 03:27:09 UTC+2, Melvyn Sopacua a écrit :
>
> On 23-8-2012 0:37, Michael Palumbo wrote: 
> > ok thanks, so you'd rather do it with a Model than a custom field. 
> > I actually started to make a custom field but I had a few issues while 
> > displaying it in the admin so that's why I asked the question then. 
>
> You can pickle an object and store the result in a blob-type field or 
> encode it and put it in a TextArea field: 
>  
> It's basically what the session module is doing. Perhaps look there for 
> inspiration: 
> <
> https://docs.djangoproject.com/en/1.4/topics/http/sessions/#technical-details>
>  
>
>
> -- 
> Melvyn Sopacua 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Ak8G-USkBmUJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: custom field for callable python object like class or function

2012-08-23 Thread Michael Palumbo
Maybe using a Model like Kurtis mentioned will be better (and easier) than 
making a custom field... ?


Le jeudi 23 août 2012 18:49:55 UTC+2, Michael Palumbo a écrit :
>
> I did not know the pickle module. This is interesting. Thanks.
> However, after playing with it, I am not sure it fits totally my need 
> because I'd like humans to be able to write a string like 
> "modulea.moduleb.MyClass" in the admin or so.
>
> So I kept trying making a custom field (instead of a Model) by creating a 
> custom 
> field, formfield and widget.
> The list view works well, even though it displays  'modulea.moduleb.MyClass'> instead of modulea.moduleb.MyClass... 
> The add page works as well, I can add a model with the value "
> modulea.moduleb.MyClass" in the field and then it works.
> BUT I have an issue with the detail page of a model.
> I get a TypeError because my field has a class reference (which is 
> callable) and the code below then instances it!
>
>
>- 
>
> c:\Users\Mike\Dropbox\development\tools\virtualenvs\django-1.4\lib\site-packages\django\forms\forms.py
> in as_widget
>1. 
>   
>   else:
>   
>   2. 
>   
>   attrs['id'] = self.html_initial_id
>   
>   3. 
>   
>   4. 
>   
>   if not only_initial:
>   
>   5. 
>   
>   name = self.html_name
>   
>   6. 
>   
>   else:
>   
>   7. 
>   
>   name = self.html_initial_name
>   
>   1. 
>   
>   return widget.render(name, self.value(), attrs=attrs)
>   
>   ...
>1. 
>   
>   2. 
>   
>   def as_text(self, attrs=None, **kwargs):
>   
>   3. 
>   
>   """
>   
>   4. 
>   
>   Returns a string of HTML for representing this as an  type="text">.
>   
>   5. 
>   
>   """
>   
>   6. 
>   
>   return self.as_widget(TextInput(), attrs, **kwargs)
>   
>   ▼ Local vars 
>VariableValueauto_id
>
>u'id_mapper_class'
>
>widget
>
>
>
>name
>
>'mapper_class'
>
>self
>
>
>
>only_initial
>
>False
>
>attrs
>
>{'id': u'id_mapper_class'}
>
>- 
>
> c:\Users\Mike\Dropbox\development\tools\virtualenvs\django-1.4\lib\site-packages\django\forms\forms.py
> in value
>1. 
>   
>   """
>   
>   2. 
>   
>   Returns the value for this BoundField, using the initial value 
> if
>   
>   3. 
>   
>   the form is not bound or the data otherwise.
>   
>   4. 
>   
>   """
>   
>   5. 
>   
>   if not self.form.is_bound:
>   
>   6. 
>   
>   data = self.form.initial.get(self.name, self.field.initial)
>   
>   7. 
>   
>   if callable(data):
>   
>   1. 
>   
>   data = data()
>   
>   ...
>1. 
>   
>   else:
>   
>   2. 
>   
>   data = self.field.bound_data(
>   
>   3. 
>   
>   self.data, self.form.initial.get(self.name, 
> self.field.initial)
>   
>   4. 
>   
>   )
>   
>   5. 
>   
>   return self.field.prepare_value(data)
>   
>   6. 
>   
>   ▼ Local vars 
>VariableValueself
>
>
>
>data
>
>
>
>
>
>- 
>
>
> I overrided the render method of the widget but the errors comes from 
> self.value() of the BoundField.
> How can I fix that? override that?
>
> Any other idea?
>
> Thanks.
>
>
>
> Le jeudi 23 août 2012 03:27:09 UTC+2, Melvyn Sopacua a écrit :
>>
>> On 23-8-2012 0:37, Michael Palumbo wrote: 
>> > ok thanks, so you'd rather do it with a Model than a custom field. 
>> > I actually started to make a custom field but I had a few issues while 
>> > displaying it in the admin so that's why I asked the question then. 
>>
>> You can pickle an object and store the result in a blob-type field or 
>> encode it and put it in a TextArea field: 
>>  
>> It's basically what the session module is doing. Perhaps look there for 
>> inspiration: 
>> <
>> https://docs.djangoproject.com/en/1.4/topics/http/sessions/#technical-details>
>>  
>>
>>
>> -- 
>> Melvyn Sopacua 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/NOxnCEnchLsJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googl

Using Tag Filters in a generic view

2012-08-23 Thread miked
I have create a generic view and in that view I have specified 
context_object_name of errata_id_list in this case.  This generic view is tied 
to a query set of a model and in the view I specify the list of keys I would 
like to display.  Here is a snippit from the template:


{% for record in errata_id_list %}

{% for key in keys %}
{{record|dict_lookup:key}}
{% endfor %}
<
{% endfor %}

The template tag file dict_lookup is:

def dict_lookup(dict, key):
  return dict[key]
register.filter('dict_lookup',dict_lookup)


The odd thing is that the parameter "record" when passed to the template tag 
file seems to resolve to the primary key of the object.  I am expecting the 
parameter "record" to be a dictionary containing all fields within a record.

Is there anyway to get this within the template.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/LcBesDR2N3oJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: GeometryField in OSMGeoAdmin

2012-08-23 Thread Satinderpal Singh
Hi,
I also start working on the the OSM in Geodjango and i am not much
familiar with it. I installed libraries like geos and starts a project
by following the instructions in the geodjango gide. But it only
tells, how to install libraries, my question is that how will i make
map in my project? Is there any documentation available for that?
Please tell me any possible way to deploy OSM to my project. Thanks in
advance.

-- 
Satinderpal Singh
http://satindergoraya.blogspot.in/

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



Django-tables2

2012-08-23 Thread Roberto Ferreira Junior
Hi All,

 

I would like to ask something, I´m trying to render a table
using Django-tables2 and that table has a link column that I want to link
with another page, I cant figure out how can I link my model, and pass my PK
to url.py.  Here’s My code:

 

 

## Models.py:  ##



 

class Projetos(models.Model):

 

#FIELDS

nome_projeto = models.CharField("Projeto", max_length=150, null='true',)

desc_oferta = models.CharField("Descrição da oferta", max_length=500,
null='true',) #aumentar

integrador = models.CharField("Integrador", max_length=150,
null='true',)

contend_provider = models.CharField("Contend Provider", max_length=150,
null='true',)

marca_servico = models.CharField("Marca do Serviço", max_length=150,
null='true',)

valor_retry = models.IntegerField("Valor de retry", null='true',)

la =  models.IntegerField("Large account", null='true',)

lanc_comercial = models.DateField("Lançamento comercial", null='true')

term_projeto = models.DateField("Término do projeto", null='true')

data_acordo = models.DateField("Data de Acordo", null='true')

data_revisao = models.DateField("Data de Revisão", null='true')

ura_id =  models.IntegerField("URA ID", null='true')

ura_desc = models.CharField("Descição URA",max_length=150, null='true')

 



## tables.py  ##



 

TEMPLATE = '''

 

   Edit

 

     upload

 

'''

 

 

class ProjetosMain(tables.Table):

 

pdb.set_trace()

nome_projeto = tables.Column(verbose_name='Projeto',orderable=False)

integrador =
tables.Column(verbose_name='Integrador',orderable=False)

contend_provider = tables.Column(verbose_name='CP',orderable=False)

status = tables.Column(verbose_name='Status',orderable=False)

term_projeto =
tables.Column(verbose_name='Vigencia',orderable=False)

 

Acoes = tables.TemplateColumn(TEMPLATE)

 

class Meta:

attrs = {'class': 'bordered'}

#

##  url.py ##

#

 

urlpatterns = patterns('',

 

# Main Page portal

(r'^$', portal_main_page),

 

# Home Page

(r'home/$', portal_main_page),

 

# Project Page

url(r'projetos/$', projetos_main_page),

url(r'projetos/?P\d{1,2,3,4}/edit/', project_edit,
name="project_edit"),

url(r'projetos/?P\d{1,2,3,4}/docs/', project_docs,
name="project_docs"),

 

# Upload File

(r'^uploadfile/$', uploadfile),

(r'^uploadsuccess/$', uploadsuccess),

 

)

 

 

Best Regards / Muito Obrigado,

--

Roberto Ferreira Junior

  robefe...@gmail.com

11 98009942

 

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



Re: Models relationship

2012-08-23 Thread Kurtis Mullins
Hello Fernando,

Just as a quick example, you could do something like this:

class Factory(models.Model):
# Assuming suppliers and customers are just two sides of the same
relationship
suppliers = models.ManyToManyField("self", related_name="customers")

Then simply query accordingly:

factory_a = Factory.objects.create()
factory_b = Factory.objects.create()
factory_c = Factory.objects.create()
factory_b.customers.add(factory_a)
factory_c.suppliers.add(factory_a)

Documentation:
https://docs.djangoproject.com/en/dev/ref/models/fields/#manytomanyfield
https://docs.djangoproject.com/en/dev/topics/db/queries/#many-to-many-relationships
https://docs.djangoproject.com/en/dev/topics/db/examples/many_to_many/

On Thu, Aug 23, 2012 at 8:20 AM, Fernando Andreacci wrote:

> Hello,
>
> I'm a new Django user, and I have the following question:
>
> I have one Model called *factory, *with several fields like (name,
> address, phone, etc).
>
> Each factory can be a customer, a supplier or both.
>
> Ex:
> Factory1 is a customer of Factory2, and Factory1 is a supplier of Factory3.
>
> How can I set up the models to hold this information?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/C0KQX7HoCTUJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Distinct Values in ModelChoiceField

2012-08-23 Thread Joseph Mutumi
@Melvyn Thank you. It actually worked out as you said. It needed a redesign.

On Wed, Aug 22, 2012 at 1:44 PM, Sithembewena Lloyd Dube
wrote:

> @Melvyn, thanks - that makes sense.
>
>
> On Wed, Aug 22, 2012 at 3:18 AM, Melvyn Sopacua wrote:
>
>> On 22-8-2012 3:04, Sithembewena Lloyd Dube wrote:
>>
>> > I found your response to the OP interesting, yet I cannot quite follow
>> it.
>> > Even if he sets a unique attribute (presumably Boolean/ Checkbox?)
>>
>> Nope, this unique attribute:
>> 
>>
>> By design, the foreign key will now not contain duplicates so distinct
>> is no longer necessary.
>> --
>> Melvyn Sopacua
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>
>
> --
> Regards,
> Sithembewena Lloyd Dube
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: What happens when you use ``select_for_update`` with ``select_related``?

2012-08-23 Thread Joseph Mutumi
I'm not sure but you can look at the generated query and post it to the
relevant database mailing list?

Go in through: manage.py shell then follow instructions in FAQ
https://docs.djangoproject.com/en/dev/faq/models/#how-can-i-see-the-raw-sql-queries-django-is-running


On Mon, Aug 20, 2012 at 6:02 AM, Yo-Yo Ma  wrote:

> Given a model ``Employee`` with a foreign key ``company`` pointing to a
> model called ``Company``, would the following example lock both the
> ``Employee`` and ``Company`` rows that were selected?
>
> employee =
> Employee.objects.select_for_update().select_related('company').get(pk=1)
>
> Or, would only the ``Employee`` row be locked?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/Ps3gJ6JiSnMJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: runserver error: "No module named app3"

2012-08-23 Thread Alexis Bellido
I'd suggest you decouple your apps from your projects. If you want to have 
everything under the same tree you could, I don't do it that way though.

You could have a tree like this:

/home/user
--proj
proj (this contains settings.py in Django 1.4)
app1
app2
--app3

You already noticed that Django 1.4 has an inner proj directory which 
contains settings.py but notice the outer directory doesn't need to be 
called proj, you could rename it and everything will work. In fact, you 
could change the inner directory name too if you update the corresponding 
variables in settings.py (ROOT_URLCONF and WSGI_APPLICATION are the two 
ones that come to mind).

In my example tree I have app1 and app2 under the outer proj and at the 
same level with the inner proj and I have app3 at the same level with the 
outer proj but that doesn't matter much because as long as you have app1, 
app2 and app3 in your PYTHONPATH you will able to do something like this:

INSTALLED_APPS = (
...
...
'app1',
'app2',
'app3',
)

If you are not using virtualenv and pip yet you should, it helps a lot.

Notice you don't need to include use proj (such as in 'proj.app1') and this 
is the way to go if you want to reuse your apps in other projects.

Good luck!

On Wednesday, August 22, 2012 6:16:15 PM UTC-3, Bill Beal wrote:
>
> Hi all,
>
> I have a Django project with apps that works OK on a Mac with Django 1.3 
> and Python 2.6, and I'm trying to move it to a Linux box with Django 1.4 
> and Python 2.7.  I created an empty project 'proj' with apps 'app1', 
> 'app2', 'app3' on the Linux system and carefully merged settings.py, 
> urls.py etc. with the initial files that were created.  When I run 'python 
> manage.py runserver' it says "Error: no module named app3" if app3 is the 
> last in the list of installed apps (see below), but if I swap app2 and app3 
> it claims app2 (now the last one in the list) is missing.  The error 
> message seems to be lying to me, and I don't know where to look for the 
> error.  In the settings.py file I have
>
> INSTALLED_APPS = (
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.sites',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> # Uncomment the next line to enable the admin:
> 'django.contrib.admin',
> # Uncomment the next line to enable admin documentation:
> 'django.contrib.admindocs',
> 'django.django-adminfiles',
> 'proj.app1',
> 'proj.app2',
> 'proj.app3',
> )
>
> I've looked around for anything on "Error: No module named xxx", but 
> haven't found any that seem to relate to this behavior.  Has anyone seen 
> this kind of error dependent on the order of the apps?  Is there any way I 
> can force a more informative error?  I tried adding an empty module name at 
> the end, and it gave me an error trace, but I couldn't figure out anything 
> from  it.  My directory tree looks like this:
>
> proj/
> manage.py
> proj/proj/
> __init__.py
> settings.py
> urls.py
> wsgi.py
> proj/app1/
> __init__.py
> forms.py
> models.py
> tests.py
> views.py
> proj/app2/
> __init__.py
> forms.py
> models.py
> tests.py
> views.py
> proj/app3/
> __init__.py
> forms.py
> models.py
> tests.py
> views.py
> proj/templates/
> . . .
>
> Django 1.4 seems to have a second proj directory under the first level 
> proj directory.  I didn't see this in 1.3.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/pdq0xqjRk_QJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: GeometryField in OSMGeoAdmin

2012-08-23 Thread Melvyn Sopacua
On 23-8-2012 10:41, geonition wrote:

> It is very convenient for me to use GeometryField as I can save any 
> geometry type into the same field. The database logic will become more 
> complex if I am required to create a separate table or field for e.g. 
> points and linestrings.
> 
> Still looking for a workaround, or is there a reason for me not to save all 
> geometries into the same field?

Well, the reason is that it's kind of like XML. As long as it validates,
programs don't complain, but to do anything useful with it you have to
understand the structure and capabilities of the specific dialect.
And this is exactly what is biting you. As soon as you try to do
something useful with it, you need to know exactly what you stored. This
applies to the admin but certainly also to queries:
What exactly have you stored in relation to the rest of the fields? For
a house, you store a point, for a street a line string, for a
state/province a polygon - so what exactly is in the table and if you it
contains addresses does the geometry field apply to the address/house,
to the street or to the province?

I don't really understand the fear of using multiple tables, but I do
see many problems trying to make sense of your data if a field is
polymorphic. The reason you put stuff into a database is to organize
things so you can explore relationships between all the bits pieces.
That implies you need to cut things up first.
-- 
Melvyn Sopacua

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



Re: django.db.utils.DatabaseError when resyncing django app models

2012-08-23 Thread Melvyn Sopacua
On 23-8-2012 4:53, Mhlanga Bothin wrote:
> 
> On 23/08/2012, at 10:59 AM, Melvyn Sopacua wrote:
> 
>> On 23-8-2012 2:37, Mhlanga Bothin wrote:
>>
>>> Thanks a lot for your help. I am not adding any classes to the app on
>>> the second sync, correct me if I am wrong but django only resyncs new
>>> classes?
>>
>> Yes and no. The permissions are a special case, they are also updated if
>> you add permissions to a model's Meta class. Is there any difference at
>> all between the first and second sync? Or can you reproduce this with an
>> entirely empty database and just run syncdb twice in a row?
>>
>> -- 
>> Melvyn Sopacua
> 
> 
> Thanks. There is no difference between the first sync and the second sync.
> 
> Procedure:
> 
> Drop data base
> Create new data base
> syncdb
> syncdb: Error
> 
> :(
> 
> Is there any other debug output that I can look through?

Well, the only difference between a pristine run and the one following
is that the superuser doesn't exist. But probably the attached patch can
show you what's going on.

-- 
Melvyn Sopacua

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

diff -r d34ef21d60a1 django/contrib/auth/management/__init__.py
--- a/django/contrib/auth/management/__init__.pyFri Aug 17 17:07:54 
2012 +0200
+++ b/django/contrib/auth/management/__init__.pyFri Aug 24 01:47:35 
2012 +0200
@@ -28,6 +28,10 @@
 from django.contrib.contenttypes.models import ContentType
 
 app_models = get_models(app)
+if verbosity :
+self.stderr.write(
+'Models for {}: {}'.format(app, app_models)
+)
 
 # This will hold the permissions we're looking for as
 # (content_type, (codename, name))


Django-tables2

2012-08-23 Thread MattDale
Your answer is LinkColumn instead of TemplateColumn. You can pass Args and 
kwargs with this in your table. I'll post an example of this when I get home. 
It's quite simple. I love django-tables2!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/viAnr_W9aK8J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: GeometryField in OSMGeoAdmin

2012-08-23 Thread geonition
Hi,

I do see your point Melvyn but my use case only requires to save different 
types of geometries and visualize them. Anything more usefull is just extra. 
This works fine when i build the map myself but the OpenLayersWidget has this 
geomtype restriction.

The complexity in saving geometries of different type to different fields 
instead of one comes from the additional logic of checking the geometry type 
and choosing the field/model accordingly, retrieving the geometry requires some 
additional logic, require one geometry to exist but only one --> additional 
logic I also agree that this might not be too hard or too complex but as 
the django website tells me "a framework for perfectionist with deadlines" 
where I a perfectionist on meeting deadlines feel like doing it the simplest 
way possible. But for now I solved the issue creating my own view and adding a 
link "view geometry" to the change list (the work amount mostly copy paste old 
stuff and simple examples).

Thanks for your help! At least now I know that the GeometryField is not 
supposed to work in the admin and the reasons behind it = we cannot do anything 
usefull with it. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/vYUmYE8Iu2wJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How to set language switcher links of django?

2012-08-23 Thread kevon wang
Every language show its own language links in one page, such as the
Language switcher links of FaceBook and Google.
Language switcher links like this :

   - English (US) 
   - Español 
   - Português (Brasil) 
   - Français (France) 
   - Deutsch 
   - Italiano 
   - العربية 
   - हिन्दी 
   - 中文(简体) 
   - 日本語 

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



Re: Django-tables2

2012-08-23 Thread Alex Strickland

On 2012/08/24 01:49 AM, MattDale wrote:


I love django-tables2!


May I ask why? I'm not trolling, I'd like to know more about it.

--
Regards
Alex

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



After form validation, need to post and call a perl program to display to a log file

2012-08-23 Thread Pervez Mulla
Hi,

I have written code for form validation for different filed .

Once validation happened (its working good), I wanna call perl script to
disply it content to lof file ...


How can I do this ..??

Please help me
Pervez

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



database file doesn't increase in size

2012-08-23 Thread heni yemun
Hi,
When i create a user account, fill the fields with some value and save() it 
in the database file *myfile.db* for example, the file doesn't show any 
change in size. So how do i know if i'm actually saving it and can later 
access the values?  Or is there another problem i should deal with first? 
THANK YOU!!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/PAsutRO3wfwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Using Tag Filters in a generic view

2012-08-23 Thread Carlos Palol
Hi, please share your view class.

Cheers



On Thursday, 23 August 2012 18:56:37 UTC+2, miked wrote:
>
> I have create a generic view and in that view I have specified 
> context_object_name of errata_id_list in this case.  This generic view is 
> tied to a query set of a model and in the view I specify the list of keys I 
> would like to display.  Here is a snippit from the template: 
>
>
> {% for record in errata_id_list %} 
>  
> {% for key in keys %} 
> {{record|dict_lookup:key}} 
> {% endfor %} 
> < 
> {% endfor %} 
>
> The template tag file dict_lookup is: 
>
> def dict_lookup(dict, key): 
>   return dict[key] 
> register.filter('dict_lookup',dict_lookup) 
>
>
> The odd thing is that the parameter "record" when passed to the template 
> tag file seems to resolve to the primary key of the object.  I am expecting 
> the parameter "record" to be a dictionary containing all fields within a 
> record. 
>
> Is there anyway to get this within the template.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/S-03r-cVRjEJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.