Re: Questions about UnicodeDecodeError

2012-04-03 Thread Ian Clelland
On Monday, April 2, 2012, Ali Mesdaq wrote:

> I did have UTF-8 in the db before but then when I was inserting(done by a
> script) values in I would get errors. I really want to avoid doing
> conversions before I insert the data so I can maintain the data in the
> exact format as it was seen in.


This, in general, isn't going to be possible. Even if you get it to the
point where it looks like its working, you may still end up with silent
data corruption, and not be able to retrieve your data when you need it.

If your database column only supports ASCII, and you cant change the
database, then your best option is probably going to be to use a strict
ASCII encoding, like base64 or base85. If you are pretty sure that the data
is *mostly* ASCII, then you could go with something like quoted-printable.
The point, though, is that you need to do *something* to your data to
coerce it into the ASCII range before you put it in the database.

As long as you remember to encode the data on save, and decode it (once!)
before displaying it, you should be able to get it to work.

Ian


>  I may be forced into doing that it seems
> to make django even work. I tried to get my app to work by creating the
> __unicode__ method return a string of "blah" and it still dies on me.
>
> Thanks,
> Ali Mesdaq
> Security Researcher
> Cell:  +1 (619) 952-8488  |  Fax:  +1 (408) 321-9818
> Email:  ali.mes...@fireeye.com
>
>
> Next Generation Threat Protection
> http://www.FireEye.com 
>
>
>
>
>
>
>
> On 4/1/12 3:04 PM, "Bill Freeman"  wrote:
>
> >If you can, switch to UTF-8 in the db.  Web traffic can arrive in a
> >variety of
> >encodings, and while the headers tell the server how to make unicode out
> >of it, but by having the db set for ASCII, you limit what you can store
> >(since
> >not all unicode characters can be converted to ASCII.
> >
> >On Fri, Mar 30, 2012 at 7:45 PM, Ali Mesdaq 
> >wrote:
> >> I have a situation where I am reading data that I have no control over
> >>and
> >> inserting it into a db. The data is http headers. I am storing them in
> >> postgres db in a text field and the db encoding is SQL_ASCII. Since the
> >> data can be anything even non compliant http headers with anything for
> >>its
> >> values I don't want to modify the data before I store it in the db.
> >> However this is causing issues with certain values causing the
> >> UnicodeDecodeError. For example I have a specific case where the user
> >> agent is set to 'KC\xd4\xda\xcf\xdf\xc9\xfd\xbc\xb6'. I have been trying
> >> to look for a way to deal with these cases gracefully in the models
> >> __unicode__ method but nothing I have tried has worked.
> >>
> >> Thanks,
> >> Ali Mesdaq
> >> Security Researcher
> >> Cell:  +1 (619) 952-8488  |  Fax:  +1 (408) 321-9818
> >> Email:  ali.mes...@fireeye.com
> >>
> >>
> >> Next Generation Threat Protection
> >> http://www.FireEye.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.
> >>
> >
> >--
> >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.
>
>

-- 
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: Model validation fails, when inherited model redeclare parent field

2012-04-03 Thread shiva
Jani, thank you.

2012/4/4 Jani Tiainen :
> Hi,
>
> You'ew hitting limitation of Django ORM which prohibits overriding fields.
>
> https://docs.djangoproject.com/en/1.3/topics/db/models/#field-name-hiding-is-not-permitted
>
>
> 4.4.2012 6:34, shiva kirjoitti:
>
>> Hello!
>>
>> In our apps (that use Django 1.2.7) we use following models:
>>
>> class BaseRegistration(models.Model):
>>        exhibition = models.ForeignKey(...)
>>        year = models.IntegerField(...)
>>        user = models.ForeignKey('auth.User')
>>
>> class BarcodeRegistration(BaseRegistration):
>>        class Meta:
>>                abstract = True
>>
>> class EventRegistration(BarcodeRegistration):
>>        event = models.ForeignKey(...)
>>
>> I append *validate_unique* by *user* and *event* fields in
>> EventRegistration class:
>>
>> class EventRegistration(BarcodeRegistration):
>>        event = models.ForeignKey(...)
>>        user = models.ForeignKey('auth.User')
>>
>>        class Meta:
>>                unique_together = ('event', 'user')
>>
>> But in django command manage.py validate fails with error:
>>
>> exhibition.eventregistration: "unique_together" refers to user. This
>> is not in the same model as the unique_together statement.
>>
>> After some "pdb'ing" of django.core.management.validation,
>> django.db.models.base, and django.db.models.options I found, that is
>> happend because:
>>
>> In [13]: EventRegistration._meta.get_field('user') in
>> EventRegistration._meta.parents.keys()[0]._meta.local_fields
>> Out[13]: True
>>
>> In [14]: EventRegistration._meta.get_field('user') in
>> EventRegistration._meta.local_fields
>> Out[14]: False
>>
>> Is it's something wrong with our code?
>>
>> Thanks
>>
>> --
>> Shavrin Ivan
>>
>
> --
> 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: Model validation fails, when inherited model redeclare parent field

2012-04-03 Thread Jani Tiainen

Hi,

You'ew hitting limitation of Django ORM which prohibits overriding fields.

https://docs.djangoproject.com/en/1.3/topics/db/models/#field-name-hiding-is-not-permitted


4.4.2012 6:34, shiva kirjoitti:

Hello!

In our apps (that use Django 1.2.7) we use following models:

class BaseRegistration(models.Model):
exhibition = models.ForeignKey(...)
year = models.IntegerField(...)
user = models.ForeignKey('auth.User')

class BarcodeRegistration(BaseRegistration):
class Meta:
abstract = True

class EventRegistration(BarcodeRegistration):
event = models.ForeignKey(...)

I append *validate_unique* by *user* and *event* fields in
EventRegistration class:

class EventRegistration(BarcodeRegistration):
event = models.ForeignKey(...)
user = models.ForeignKey('auth.User')

class Meta:
unique_together = ('event', 'user')

But in django command manage.py validate fails with error:

exhibition.eventregistration: "unique_together" refers to user. This
is not in the same model as the unique_together statement.

After some "pdb'ing" of django.core.management.validation,
django.db.models.base, and django.db.models.options I found, that is
happend because:

In [13]: EventRegistration._meta.get_field('user') in
EventRegistration._meta.parents.keys()[0]._meta.local_fields
Out[13]: True

In [14]: EventRegistration._meta.get_field('user') in
EventRegistration._meta.local_fields
Out[14]: False

Is it's something wrong with our code?

Thanks

--
Shavrin Ivan



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



Help. ORM Trigger After Insert.

2012-04-03 Thread Ganesh Kumar
Hi Guys,

I am new to the ORM concepts in Django. My Django application writing
on table. it's working fine. But I want writing table the same copy of
writing data stored in another table . Guys help me the concepts in
mysql Triggers in After insert. the same way achieve in django ORM.
guide me.

-Ganesh.
Did I learn something today? If not, I wasted it.

-- 
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-admin change form page validation

2012-04-03 Thread kenneth gonsalves
On Sat, 2012-03-31 at 09:25 +0530, Nikhil Verma wrote:
> How can i do this kind validation where fields are dependent on each
> other

https://docs.djangoproject.com/en/1.4/ref/contrib/admin/#adding-custom-validation-to-the-admin

docs are wonderful
-- 
regards
Kenneth Gonsalves


-- 
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: Profiling Django (WAS Django database-api)

2012-04-03 Thread Javier Guerra Giraldez
On Tue, Apr 3, 2012 at 5:25 PM, Andre Terra  wrote:
> To make things a little more complicated, the task involves writing a large
> amount of data to a temp database, handling it and then saving some
> resulting queries to the permanent DB. This makes it a tad harder to analyze
> what goes on in the first part of the code.

i haven't had that kind of problem, but these are the things i would try:

- time-limiting logs.  if the last call was too recent, just discard
the message (for some log levels, those used in the inner loops)

- send the logfiles to fast devices (maybe even in ram, like tmpfs in
Linux) and aggressively rotate them (so they don't accumulate
needlessly)

- log to a fast database (like Redis) and do automated analysis every
hour or maybe even every minute, discarding the raw log entries.

- log to a listening process that checks if each (time limited) entry
is out of the ordinary. if so, keep it for analysis. if not, discard
it.  'ordinary' could mean if some indicator is growing or reducing as
expected, or just changed from the last, or stable, or whatever you
could expect from your intended calculations.

-- 
Javier

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



Model validation fails, when inherited model redeclare parent field

2012-04-03 Thread shiva
Hello!

In our apps (that use Django 1.2.7) we use following models:

class BaseRegistration(models.Model):
exhibition = models.ForeignKey(...)
year = models.IntegerField(...)
user = models.ForeignKey('auth.User')

class BarcodeRegistration(BaseRegistration):
class Meta:
abstract = True

class EventRegistration(BarcodeRegistration):
event = models.ForeignKey(...)

I append *validate_unique* by *user* and *event* fields in
EventRegistration class:

class EventRegistration(BarcodeRegistration):
event = models.ForeignKey(...)
user = models.ForeignKey('auth.User')

class Meta:
unique_together = ('event', 'user')

But in django command manage.py validate fails with error:

exhibition.eventregistration: "unique_together" refers to user. This
is not in the same model as the unique_together statement.

After some "pdb'ing" of django.core.management.validation,
django.db.models.base, and django.db.models.options I found, that is
happend because:

In [13]: EventRegistration._meta.get_field('user') in
EventRegistration._meta.parents.keys()[0]._meta.local_fields
Out[13]: True

In [14]: EventRegistration._meta.get_field('user') in
EventRegistration._meta.local_fields
Out[14]: False

Is it's something wrong with our code?

Thanks

--
Shavrin Ivan

-- 
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 Contrib Auth + Class Based Generic Views

2012-04-03 Thread Matheus Ashton
urls.py:

urlpatterns = patterns('',
url(r'^/login$', LoginView.as_view()),
url(r'^$', HomeView.as_view(), {}, 'home'),
)

settings.py:

  LOGIN_URL='/login/'

views.py:

class LoginView(FormView):
  form_class = LoginForm
  template_name = "auth/form.html"

  def post(self, request, *args, **kwargs):
form = self.get_form(self.get_form_class())
if form.is_valid():
  user = self.request['login']
  password = self.request['password']
  try:
auth = Authenticator()
auth.authenticate(user, password, self.request)
return self.form_valid(form)
  def get_success_url(self):
return reverse('home')

class HomeView(TemplateView):
   template_name = 'user/home.html'


components.py:

class Authenticator():
  def authenticate(self, user, password, request = None):
self.user = auth.authenticate(username=user, password=password)
if request:
  return self.login(request)

return self.user

  def login(self, request):
if self.user is not None:
  if self.user.is_active:
auth.login(request, self.user)
return self.user
  else:
raise UserDisabledException("Usuario inativo")
else:
  raise InvalidLoginException("Usuario/Senha invalidos")

class UserDisabledException(Exception):
  def __init__(self, value):
self.value = value

  def __str__(self):
return repr(self.value)

class InvalidLoginException(Exception):
  def __init__(self, value):
self.value = value

  def __str__(self):
return repr(self.value)


Thanks again :)

2012/4/3 Sergiy Khohlov 

> Please provide your urls.py  and  your view which is used for this 
>
> 2012/4/3 Matheus Ashton :
> > Hello Everybody,
> >
> > I'm having a problem using the django.contrib.auth app and class based
> > generic views in Django 1.3 / 1.4:
> >
> > After submitting the login form, my view receives the post data and
> tries to
> > authenticate the user and then redirect to a success page. Ok nothing
> new..
> > The problem is: My HomeView wich extends the TemplateView, receive the
> > redirect from the login form and uses a render_to_response function to
> > render the template, and that is my problem, because render_to_response
> does
> > not create a RequestContext object, the one I need to show the newly
> > authenticated user data, because that is a requirement for
> > django.contrib.auth app, if the request is not a RequestContext, the
> > authenticated user data, is not passed to the template
> > (
> https://docs.djangoproject.com/en/1.4/topics/auth/#authentication-data-in-templates)
> ..
> >
> > Does someone can help me with this problem?
> >
> > PS: Sorry about my English, it is not my first language
> >
> > Thanks :D
> >
> > --
> > 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/-/ywPX8VH5CUQJ.
> > 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.
>
>

-- 
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: where do you host your django app and how to you deploy it?!

2012-04-03 Thread Mario Gudelj
EC2 with Ubuntu instance with Postgre+nginx

On 3 April 2012 20:57, N.Aleksandrenko  wrote:

> What about cloud solutions?
>
> On Mon, Apr 2, 2012 at 2:38 PM, Jani Tiainen  wrote:
> > 2.4.2012 13:48, fix3d kirjoitti:
> >
> >> Where do you host your django app and how to you deploy it?!
> >>
> >> Please share personal exp.
> >>
> >
> > We're deploying to our own application server cluster.
> >
> > And we're using fabric to run actual deployment.
> >
> > --
> >
> > Jani Tiainen
> >
> >
> > --
> > 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.
>
>

-- 
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: custom manager to control access

2012-04-03 Thread Mike Dewhirst

On 3/04/2012 7:00pm, Tom Evans wrote:

On Tue, Apr 3, 2012 at 9:43 AM, Mike Dewhirst  wrote:

I'm trying to make a custom manager for a few models. The objective is to
limit user access to information in the database belonging to the company of
which they are a member.

I think I want to say:

class Something(models.Model):
...
objects = MemberManager()

But when I run manage.py runserver I get:

AttributeError: 'MemberManager' object has no attribute '_inherited'

Here is the code:

from django.db import models
from company.models import *

class MemberManager(models.Manager):
"""
The manager in every model using this manager must return ONLY
rows belonging to the User's company. company.models.Member is
the table which links a member (ie user) to a particular company
in company.models.Company. Each member can be connected to exactly
zero or one company. If zero raise BusinessRuleViolation exception
otherwise return the company with which to filter query sets using
the user's company.
"""
def __init__(self, request=None):
self.user = None
if request and request.user and request.user.is_authenticated():
self.user = request.user

def get_company(self):
if self.user:
user_row = Member.objects.get(user=self.user)
return user_row.company

def get_query_set(self):
coy = self.get_company()
if coy:
return super(MemberManager,
 self).get_query_set().filter(company=coy)
raise BusinessRuleViolation('User must be a company Member')


 From the research I've done it seems I should not have the __init__() in
this and indeed if I experimentally factor it out it the error goes away.

The doc string says what I'm trying to do but maybe there is a better way
than a custom manager.

Thanks for any pointers

Mike


Two things:

1) You get the exception because you do not call the parent class's
constructor, and thus the manager instance is not set up with the
appropriate values. Your __init__() method on a derived class should
look more like this:

def __init__(self, *args, **kwargs):
 super(self, MyClassName).__init__(*args, **kwargs)
 # your stuff

2) Managers are not instantiated with the current request object, so
your approach will not work anyway. You could use something like
thread locals, but that is a hack (and won't work if/when you run
outside of the request/response cycle).

I have now discarded the idea :)

I'm not very comfortable with thread locals. I need a bullet-proof 
approach which makes data from other companies invisible to members of 
this company. I suppose a view decorator is the way to go but I would 
have preferred a deeper model-level approach.


Thanks

Mike



Cheers

Tom



--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-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: dynamically adding form fields

2012-04-03 Thread Andre Terra
Hi Matt,

Search the docs for inlines, inline formsets and inline formset factories,
and you'll find exactly what you need [0].

Read them carefully cause it's easy to make mistakes and debugging inlines
has always been frustrating for me.

Good luck and happy coding.

Cheers,
AT

[0] https://docs.djangoproject.com/en/dev/topics/forms/modelforms/

On Apr 3, 201
>
> I'm working on a complex form and not sure if there is an elegant way to
> handle it in django.
>
> The form creates an invoice and it uses jQuery to dynamically add/remove
> extra form fields into the HTML for line items.  Each line item contains
> several fields including description, unit price, quantity etc.
>
> On the server I need to create all these line item objects and set the
> foreign key back to the invoice model object.  It needs to validate
> everything and return errors for the appropriate fields.
>
> I'd like to use a ModelForm or Form for the whole invoice but not sure how
> to represent the line item fields.
>
> Suggestions?
> 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/-/xaYRsc5sZxwJ.
> 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: Profiling Django (WAS Django database-api)

2012-04-03 Thread Andre Terra
Hey Javier,

Thanks for the reply. My problem with the logs in the past was that they
tended to make the task even slower (due to recursion) but I guess that's
probably because I didn't call the logging from the appropriate places in
the code.

To make things a little more complicated, the task involves writing a large
amount of data to a temp database, handling it and then saving some
resulting queries to the permanent DB. This makes it a tad harder to
analyze what goes on in the first part of the code.

I'll try logging again over the weekend and see how that works.. I just
wish there were third party apps and tools for debugging this sort of
problem.

Thanks again for your input.

Cheers,
AT

On Apr 3, 2012 3:47 PM, "Javier Guerra Giraldez"  wrote:
>
> On Tue, Apr 3, 2012 at 8:21 AM, Andre Terra  wrote:
> > I have some complex and database intensive asynchronous tasks running
under
> > celery which take a LONG time to complete and I'd just love to be able
to
> > keep track of the queries they generate in order to optimize and
possibly
> > remove the biggest bottlenecks.
>
> the easiest would be to write detailed logs, which _can_ be analysed
> in real time, not only 'after the fact'.
>
> my second idea would be to hack the log output so instead of writing
> to a file, it would store messages (probably with some structure) to
> some comfortable database.  I'd use Redis, but i guess MongoDB or even
> an SQL-based DB could work too.  then you can easily filter and
> aggregate times according to task type, when it happened, etc.
>
> --
> Javier
>
> --
> 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.



dynamically adding form fields

2012-04-03 Thread Matt Warren
I'm working on a complex form and not sure if there is an elegant way to 
handle it in django.

The form creates an invoice and it uses jQuery to dynamically add/remove 
extra form fields into the HTML for line items.  Each line item contains 
several fields including description, unit price, quantity etc.

On the server I need to create all these line item objects and set the 
foreign key back to the invoice model object.  It needs to validate 
everything and return errors for the appropriate fields.  

I'd like to use a ModelForm or Form for the whole invoice but not sure how 
to represent the line item fields.

Suggestions?
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/-/xaYRsc5sZxwJ.
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.



AttributeError at /admin/coltrane/entry/add/ 'Entry' object has no attribute 'pubdate'

2012-04-03 Thread laurence Turpin
Hello,

I'm trying to learn Django from the book "Practical Django Projects 2nd 
Edition"
 I'm using Django 1.3.1 and Python 2.7.2 on Windows 7
Also I'm using Eclipse Indigo with pydev 

The current project I'm working on is to create a Weblog called coltrane.
coltrane is an application that exists in a project called 
"cmswithpythonanddjango"

Inside the models.py is a class called Entry which holds the fields used to 
Enter a weblog entry.
When I go to localhost:8000/admin/I get the option to add and Entry.
I can select this option fill out sample data, but when I try to save it.
I get the following error.

AttributeError at /admin/coltrane/entry/add/

'Entry' object has no attribute 'pubdate'


There is a field called pub_date in Entry

It's as if I have made a typing error somewhere and typed pubdate instead of 
pub_date.

Below is the models.py, views.py , url.py , and admin.py files


//

Here is my models.py

/

from django.db import models
import datetime
from tagging.fields import TagField
from django.contrib.auth.models import User
from markdown import markdown



class Category(models.Model):
title = models.CharField(max_length=250, help_text="Maximum 250 
characters.")
slug = models.SlugField(help_text="Suggested value automatically 
generated from title. Must be unique.")
description = models.TextField()

class Meta:
ordering = ['title']
verbose_name_plural = "Categories"

def __unicode__(self):
return self.title

def get_absolute_url(self):
return "/categories/%s/" % self.slug

class Entry(models.Model):
LIVE_STATUS = 1
DRAFT_STATUS = 2
HIDDEN_STATUS = 3
STATUS_CHOICES = (
(LIVE_STATUS, 'Live'),
(DRAFT_STATUS, 'Draft'),
(HIDDEN_STATUS, 'Hidden')
)

# Core fields
title = models.CharField(max_length=250, help_text = "Maximum 250 
characters. ")
excerpt = models.TextField(blank=True, help_text = "A short summary of 
the entry. Optional.")
body = models.TextField()
pub_date = models.DateTimeField(default = datetime.datetime.now)

# Fields to store generated HTML
excerpt_html = models.TextField(editable=False, blank=True)
body_html = models.TextField(editable=False, blank=True)

# Metadata
author = models.ForeignKey(User)
enable_comments = models.BooleanField(default=True)
featured = models.BooleanField(default=False)
slug = models.SlugField(unique_for_date = 'pub_date', help_text = 
"Suggested value automatically generated from title. Must be unique.")
status = models.IntegerField(choices=STATUS_CHOICES, 
default=LIVE_STATUS, help_text = "Only entries with live status will be 
publicly displayed.")

# Categorization.
categories = models.ManyToManyField(Category)
tags = TagField(help_text = "Separate tags with spaces.")
   
class Meta:
verbose_name_plural = "Entries"
ordering = ['-pub_date']

def __unicode__(self):
return self.title

def save(self, force_insert=False, force_update=False):
self.body_html = markdown(self.body)
if self.excerpt:
self.excerpt_html = markdown(self.excerpt)
super(Entry, self).save(force_insert, force_update)

def get_absolute_url(self):
return "/weblog/%s/%s/" % 
(self.pub_date.strftime("%Y/%b/%d").lower(), self.slug)

///

Here is the views.py

//

from django.shortcuts import render_to_response

from cmswithpythonanddjango.coltrane.models import Entry

def entries_index(request):
return render_to_response('coltrane/entry_index.html', { 'entry_list': 
Entry.objects.all() })

///

Here is the url.py

/

Re: Profiling Django (WAS Django database-api)

2012-04-03 Thread Javier Guerra Giraldez
On Tue, Apr 3, 2012 at 8:21 AM, Andre Terra  wrote:
> I have some complex and database intensive asynchronous tasks running under
> celery which take a LONG time to complete and I'd just love to be able to
> keep track of the queries they generate in order to optimize and possibly
> remove the biggest bottlenecks.

the easiest would be to write detailed logs, which _can_ be analysed
in real time, not only 'after the fact'.

my second idea would be to hack the log output so instead of writing
to a file, it would store messages (probably with some structure) to
some comfortable database.  I'd use Redis, but i guess MongoDB or even
an SQL-based DB could work too.  then you can easily filter and
aggregate times according to task type, when it happened, etc.

-- 
Javier

-- 
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: 404 page not found

2012-04-03 Thread Homer
I fixed it by changing the urlconf to r'^bedroom/'. Thanks!! 

在 2012年4月3日星期二UTC-4上午10时17分03秒,Sebastian写道:
>
> On Mon, 2 Apr 2012 17:14:00 -0700 (PDT)
> Homer  wrote:
>
> > I met "404" page not found when I try to enter 127.0.0.1:8000/cn/bedroom. 
> > It says on the webpage that "C:/Django/final/media/bedroom" does not 
> > exist". Why would this happen?
>
> I am positive the problem is with your URL patterns:
>
> > # urls.py
> > urlpatterns = patterns('',
> > …
> > url(r'^cn/', include('final.photo.urls')),
> > url(r'^cn/(?P.*)$', 'django.views.static.serve',
> > {'document_root': settings.MEDIA_ROOT}),
> > )
> > 
> > # photo/urls.py
> > urlpatterns = patterns('',
> > url(r'^$', List),
> > url(r'^/bedroom/', Detail),
> > )
>
> Trying to access 'cn/bedroom' _should_ redirect to view Detail, I guess.
>
> But what happens is that 'cn/' gets stripped via the main level pattern,
> including 'final.photo.urls'. There no match is found due to the leading
> '/' in the second pattern: r'^/bedroom/'. Thus the search continues with
> 'cn/(?P.*)$' in the top-level URL patterns which tries to access a
> non-existing media file in settings.MEDIA_ROOT.
>
> Therefore, to fix the issue, you should remove the leading forward slash
> '/' in the second pattern in your photo/urls.py.
>
> For reference, see the notes section in
>
>   https://docs.djangoproject.com/en/1.4/topics/http/urls/#example
>   – "There's no need to add a leading slash, because every URL has that.
>   For example, it's ^articles, not ^/articles."
>
> Best wishes,
> Sebastian.
>
>

-- 
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/-/C7ZtIKebjJ0J.
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: 404 page not found

2012-04-03 Thread Homer
If I split them up, I cannot see my pictures on the webpage since the links 
of them becomes "http://127.0.0.1:8000/cn/simages/XXX.jpg";. But my pictures 
stored in "http://127.0.0.1:8000/media/simages/XXX.jpg";... That's why I mix 
them up...

在 2012年4月3日星期二UTC-4上午10时09分11秒,Tom Evans写道:
>
> On Tue, Apr 3, 2012 at 1:14 AM, Homer  wrote:
> > I met "404" page not found when I try to enter 127.0.0.1:8000/cn/bedroom.
> > It says on the webpage that "C:/Django/final/media/bedroom" does not 
> exist".
> > Why would this happen?
> >
> > urls.py:
> >
> > from django.conf.urls.defaults import *
> > from final import settings
> > from django.contrib import admin
> > admin.autodiscover()
> >
> > urlpatterns = patterns('',
> >
> > url(r'^admin/', include(admin.site.urls)),
> > url(r'^cn/', include('final.photo.urls')),
> > url(r'^cn/(?P.*)$', 'django.views.static.serve',
> > {'document_root': settings.MEDIA_ROOT}),
> > )
> > photo/urls.py:
> >
> > from django.conf.urls.defaults import *
> > from final.photo.views import List, Detail
> > urlpatterns = patterns('',
> > url(r'^$', List),
> > url(r'^/bedroom/', Detail),
> > )
> >
>
> You have conflicting URL space, you have configured "^cn/" to be both
> where your static files are served from, and also where your views are
> served from. Split the two up, and use the correct URL, and you should
> not have any problems. Eg:
>
> urlpatterns = patterns('',
> url(r'^admin/', include(admin.site.urls)),
> url(r'^photos/', include('final.photo.urls')),
> url(r'^docs/(?P.*)$', 'django.views.static.serve',
> {'document_root': settings.MEDIA_ROOT}),
> )
>
> I'm not sure why people are interested in your
> TEMPLATE_CONTEXT_PROCESSORS settings when the request isn't even
> making it to the view...
>
> Cheers
>
> Tom
>
>

-- 
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/-/B5lBiyNWrI4J.
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: 404 page not found

2012-04-03 Thread Homer
OK.
# Django settings for final project.



DEBUG = True

TEMPLATE_DEBUG = DEBUG



ADMINS = (

# ('Your Name', 'your_em...@example.com'),

)



MANAGERS = ADMINS



DATABASES = {

'default': {

'ENGINE': 'django.db.backends.sqlite3', # Add 
'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.

'NAME': 'C:/Django/final/data.db',  # Or path 
to database file if using sqlite3.

'USER': '',  # Not used with sqlite3.

'PASSWORD': '',  # Not used with sqlite3.

'HOST': '',  # Set to empty string for 
localhost. Not used with sqlite3.

'PORT': '',  # Set to empty string for default. 
Not used with sqlite3.

}

}



# Local time zone for this installation. Choices can be found here:

# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name

# although not all choices may be available on all operating systems.

# On Unix systems, a value of None will cause Django to use the same

# timezone as the operating system.

# If running in a Windows environment this must be set to the same as your

# system time zone.

TIME_ZONE = 'America/Chicago'



# Language code for this installation. All choices can be found here:

# http://www.i18nguy.com/unicode/language-identifiers.html

LANGUAGE_CODE = 'en-us'



SITE_ID = 1



# If you set this to False, Django will make some optimizations so as not

# to load the internationalization machinery.

USE_I18N = True



# If you set this to False, Django will not format dates, numbers and

# calendars according to the current locale

USE_L10N = True



# Absolute filesystem path to the directory that will hold user-uploaded 
files.

# Example: "/home/media/media.lawrence.com/media/"

MEDIA_ROOT = 'C:/Django/final/media/'



# URL that handles the media served from MEDIA_ROOT. Make sure to use a

# trailing slash.

# Examples: "http://media.lawrence.com/media/";, "http://example.com/media/";

MEDIA_URL = '/media/'



# Absolute path to the directory static files should be collected to.

# Don't put anything in this directory yourself; store your static files

# in apps' "static/" subdirectories and in STATICFILES_DIRS.

# Example: "/home/media/media.lawrence.com/static/"

STATIC_ROOT = ''



# URL prefix for static files.

# Example: "http://media.lawrence.com/static/";

STATIC_URL = '/static/'



# URL prefix for admin static files -- CSS, JavaScript and images.

# Make sure to use a trailing slash.

# Examples: "http://foo.com/static/admin/";, "/static/admin/".

ADMIN_MEDIA_PREFIX = '/static/admin/'



# Additional locations of static files

STATICFILES_DIRS = (

# Put strings here, like "/home/html/static" or "C:/www/django/static".

# Always use forward slashes, even on Windows.

# Don't forget to use absolute paths, not relative paths.

)



# List of finder classes that know how to find static files in

# various locations.

STATICFILES_FINDERS = (

'django.contrib.staticfiles.finders.FileSystemFinder',

'django.contrib.staticfiles.finders.AppDirectoriesFinder',

#'django.contrib.staticfiles.finders.DefaultStorageFinder',

)



# Make this unique, and don't share it with anybody.

SECRET_KEY = 'zg*^7-e5e(#wu6-543z0y#em+xvjo092h^%@*&qed^hqqa!2i5'



# List of callables that know how to import templates from various sources.

TEMPLATE_LOADERS = (

'django.template.loaders.filesystem.Loader',

'django.template.loaders.app_directories.Loader',

# 'django.template.loaders.eggs.Loader',

)



MIDDLEWARE_CLASSES = (

'django.middleware.common.CommonMiddleware',

'django.contrib.sessions.middleware.SessionMiddleware',

'django.middleware.csrf.CsrfViewMiddleware',

'django.contrib.auth.middleware.AuthenticationMiddleware',

'django.contrib.messages.middleware.MessageMiddleware',

)



ROOT_URLCONF = 'final.urls'



TEMPLATE_DIRS = ("C:/Django/final/photo/templates"

# Put strings here, like "/home/html/django_templates" or 
"C:/www/django/templates".

# Always use forward slashes, even on Windows.

# Don't forget to use absolute paths, not relative paths.

)



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',

'final.photo',

# Uncomment the next line to enable admin documentation:

# 'django.contrib.admindocs',

)



# A sample logging configuration. The only tangible logging

# performed by this configuration is to send an email to

# the site admins on every HTTP 500 error.

# See http://docs.djangoproject.com/en/dev/topics/logging for

# more details on how to customize your logging configuration.

LOGGING = {

'version': 1,

'disable_existing_loggers': False,

'handlers': {

'm

Re: Django: 404 page not found

2012-04-03 Thread Homer
OK.
# Django settings for final project.



DEBUG = True

TEMPLATE_DEBUG = DEBUG



ADMINS = (

# ('Your Name', 'your_em...@example.com'),

)



MANAGERS = ADMINS



DATABASES = {

'default': {

'ENGINE': 'django.db.backends.sqlite3', # Add 
'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.

'NAME': 'C:/Django/final/data.db',  # Or path 
to database file if using sqlite3.

'USER': '',  # Not used with sqlite3.

'PASSWORD': '',  # Not used with sqlite3.

'HOST': '',  # Set to empty string for 
localhost. Not used with sqlite3.

'PORT': '',  # Set to empty string for default. 
Not used with sqlite3.

}

}



# Local time zone for this installation. Choices can be found here:

# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name

# although not all choices may be available on all operating systems.

# On Unix systems, a value of None will cause Django to use the same

# timezone as the operating system.

# If running in a Windows environment this must be set to the same as your

# system time zone.

TIME_ZONE = 'America/Chicago'



# Language code for this installation. All choices can be found here:

# http://www.i18nguy.com/unicode/language-identifiers.html

LANGUAGE_CODE = 'en-us'



SITE_ID = 1



# If you set this to False, Django will make some optimizations so as not

# to load the internationalization machinery.

USE_I18N = True



# If you set this to False, Django will not format dates, numbers and

# calendars according to the current locale

USE_L10N = True



# Absolute filesystem path to the directory that will hold user-uploaded 
files.

# Example: "/home/media/media.lawrence.com/media/"

MEDIA_ROOT = 'C:/Django/final/media/'



# URL that handles the media served from MEDIA_ROOT. Make sure to use a

# trailing slash.

# Examples: "http://media.lawrence.com/media/";, "http://example.com/media/";

MEDIA_URL = '/media/'



# Absolute path to the directory static files should be collected to.

# Don't put anything in this directory yourself; store your static files

# in apps' "static/" subdirectories and in STATICFILES_DIRS.

# Example: "/home/media/media.lawrence.com/static/"

STATIC_ROOT = ''



# URL prefix for static files.

# Example: "http://media.lawrence.com/static/";

STATIC_URL = '/static/'



# URL prefix for admin static files -- CSS, JavaScript and images.

# Make sure to use a trailing slash.

# Examples: "http://foo.com/static/admin/";, "/static/admin/".

ADMIN_MEDIA_PREFIX = '/static/admin/'



# Additional locations of static files

STATICFILES_DIRS = (

# Put strings here, like "/home/html/static" or "C:/www/django/static".

# Always use forward slashes, even on Windows.

# Don't forget to use absolute paths, not relative paths.

)



# List of finder classes that know how to find static files in

# various locations.

STATICFILES_FINDERS = (

'django.contrib.staticfiles.finders.FileSystemFinder',

'django.contrib.staticfiles.finders.AppDirectoriesFinder',

#'django.contrib.staticfiles.finders.DefaultStorageFinder',

)



# Make this unique, and don't share it with anybody.

SECRET_KEY = 'zg*^7-e5e(#wu6-543z0y#em+xvjo092h^%@*&qed^hqqa!2i5'



# List of callables that know how to import templates from various sources.

TEMPLATE_LOADERS = (

'django.template.loaders.filesystem.Loader',

'django.template.loaders.app_directories.Loader',

# 'django.template.loaders.eggs.Loader',

)



MIDDLEWARE_CLASSES = (

'django.middleware.common.CommonMiddleware',

'django.contrib.sessions.middleware.SessionMiddleware',

'django.middleware.csrf.CsrfViewMiddleware',

'django.contrib.auth.middleware.AuthenticationMiddleware',

'django.contrib.messages.middleware.MessageMiddleware',

)



ROOT_URLCONF = 'final.urls'



TEMPLATE_DIRS = ("C:/Django/final/photo/templates"

# Put strings here, like "/home/html/django_templates" or 
"C:/www/django/templates".

# Always use forward slashes, even on Windows.

# Don't forget to use absolute paths, not relative paths.

)



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',

'final.photo',

# Uncomment the next line to enable admin documentation:

# 'django.contrib.admindocs',

)



# A sample logging configuration. The only tangible logging

# performed by this configuration is to send an email to

# the site admins on every HTTP 500 error.

# See http://docs.djangoproject.com/en/dev/topics/logging for

# more details on how to customize your logging configuration.

LOGGING = {

'version': 1,

'disable_existing_loggers': False,

'handlers': {

'm

Re: Need help

2012-04-03 Thread Andre Terra
It could be a regression bug.

To be honest, I don't see a reason why '' should become 'localhost'
automagically. I'd much prefer if users were forced to write 'localhost'
rather than having Django do it (and fail) for them.

Explicit is better than implicit.

If you haven't yet, please file a bug report:
https://code.djangoproject.com/newticket


Cheers,
AT


On Tue, Apr 3, 2012 at 12:25 PM, thongor  wrote:

> Wow this post is really old but this also solved my problem strangely
> enough.
>
> On Thursday, June 25, 2009 2:48:32 PM UTC-4, amy wrote:
>>
>> I had this same problem...the user and pass were fine but no users
>> could authenticate on any DB, regardless of settings.
>>
>> Turns out my issue was only that I needed to add the string
>> "localhost" to the host parameter.
>>
>> It's odd since the comments specifically state to leave it blank for
>> localhost...but oh well. It worked.
>>
>> DATABASE_HOST = 'localhost' # Set to empty string for
>> localhost. Not used with sqlite3.
>>
>> Odd.
>>
>> On May 31, 6:14 am, Tim Chase  wrote:
>> > mizan rahman wrote:
>> > > No, i've checked that i've created a user named "djangouser" and the
>> > > problem still exist what will i do? Plz help me
>> >
>> > and you've checked that the password in settings.py is correct?
>> > You only confirmed one of the two problems I suggested.
>> >
>> > If both are correct, you may have to include the section of your
>> > pg_hba.conf that defines access permissions.  It usually looks
>> > something like
>> >
>> > ##**##**##
>> > local   all postgres  ident sameuser
>> >
>> > # TYPE  DATABASEUSERCIDR-ADDRESS  METHOD
>> >
>> > # "local" is for Unix domain socket connections only
>> > local   all all   ident sameuser
>> > # IPv4 local connections:
>> > hostall all 127.0.0.1/32  md5
>> > # IPv6 local connections:
>> > hostall all ::1/128   md5
>> > ##**##**##
>> >
>> > along with information about how your connecting in Django (to
>> > localhost, to the local machine by IP address, to a remote
>> > machine, etc)
>> >
>> > -tkc
>>
>  --
> 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/-/BI0mwz_xsrsJ.
> 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: Problems with Virtualenv and Django 1.4 -- deployment on uwsgi.

2012-04-03 Thread Roberto De Ioris

> Since I've upgraded the version of Django and started a new project on
> it, I cannot make it work properly with uwsgi.
>
> The problem is that django doesn't import apps from project tree. My
> settings.py looks like this:
>
> 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',
> #Practical apps:
> 'engine.blog',
> )
>
> My config for uwsgi looks like this (parsed by yaml):
>
> uwsgi:
> uid: www-data
> gid: www-data
> socket: /tmp/wsgi_dev.sosek.net.sock
> module: django.core.handlers.wsgi:WSGIHandler()
> chdir: /home/sosek/nginx/dev.sosek.net/apps/engine
> env: DJANGO_SETTINGS_MODULE=engine.settings
> virtualenv: /home/sosek/.virtualenvs/dev.sosek.net
> pythonpath: /home/sosek/nginx/dev.sosek.net/apps
>

you should update your module directive to

module: engine.wsgi

Check latest official Django docs on uWSGI

https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/uwsgi/

-- 
Roberto De Ioris
http://unbit.it

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



Problems with Virtualenv and Django 1.4 -- deployment on uwsgi.

2012-04-03 Thread Maciej Szlosarczyk
Since I've upgraded the version of Django and started a new project on
it, I cannot make it work properly with uwsgi.

The problem is that django doesn't import apps from project tree. My
settings.py looks like this:

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',
#Practical apps:
'engine.blog',
)

My config for uwsgi looks like this (parsed by yaml):

uwsgi:
uid: www-data
gid: www-data
socket: /tmp/wsgi_dev.sosek.net.sock
module: django.core.handlers.wsgi:WSGIHandler()
chdir: /home/sosek/nginx/dev.sosek.net/apps/engine
env: DJANGO_SETTINGS_MODULE=engine.settings
virtualenv: /home/sosek/.virtualenvs/dev.sosek.net
pythonpath: /home/sosek/nginx/dev.sosek.net/apps

When I use from inside of the virtualenv "python manage.py runserver"
i get something like:
Error: No module named blog

For UWSGI, most recent calls look like this:
File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/site-
packages/django/template/defaultfilters.py", line 718, in date
return format(value, arg)
  File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/
site-packages/django/utils/dateformat.py", line 310, in format
return df.format(format_string)
  File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/
site-packages/django/utils/dateformat.py", line 33, in format
pieces.append(force_unicode(getattr(self, piece)()))
  File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/
site-packages/django/utils/dateformat.py", line 214, in r
return self.format('D, j M Y H:i:s O')
  File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/
site-packages/django/utils/dateformat.py", line 33, in format
pieces.append(force_unicode(getattr(self, piece)()))
  File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/
site-packages/django/utils/encoding.py", line 71, in force_unicode
s = unicode(s)
  File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/
site-packages/django/utils/functional.py", line 121, in __unicode_cast
return func(*self.__args, **self.__kw)
  File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/
site-packages/django/utils/translation/__init__.py", line 86, in
ugettext
return _trans.ugettext(message)
  File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/
site-packages/django/utils/translation/trans_real.py", line 278, in
ugettext
return do_translate(message, 'ugettext')
  File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/
site-packages/django/utils/translation/trans_real.py", line 268, in
do_translate
_default = translation(settings.LANGUAGE_CODE)
  File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/
site-packages/django/utils/translation/trans_real.py", line 183, in
translation
default_translation = _fetch(settings.LANGUAGE_CODE)
  File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/
site-packages/django/utils/translation/trans_real.py", line 160, in
_fetch
app = import_module(appname)
  File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/
site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
ImportError: No module named blog
[pid: 7174|app: 0|req: 4/4] 78.8.143.124 () {40 vars in 1834 bytes}
[Tue Apr  3 17:54:33 2012] GET / => generated 0 bytes in 42 msecs
(HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)

-- 
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: Problemas con syncdb

2012-04-03 Thread Ivo Marcelo Leonardi Zaniolo
Its not a bug. Im using 1.4 too and got no error.

Att
Ivo Marcelo Leonardi Zaniolo
Sent from mobile
imarcelolz.blogspot.com.br
On Apr 3, 2012 11:29 AM, "DIEGO CENZANO PRADO" 
wrote:

> Thank you for your feedback. I was using django 1.4. I have changed to the
> previous version and it is working. Maybe a bug in the new version?
>
> El martes 3 de abril de 2012 16:12:04 UTC+2, imarcelolz escribió:
>>
>> Try to setup the absolute path on "NAME".
>>
>> *Um Abraço!*
>> *Ivo Marcelo Leonardi Zaniolo*
>> *imarcelolz.blogspot.com*
>>
>>
>> 2012/4/3 DIEGO CENZANO PRADO 
>>
>>> I am trying to do the tutorial and I get an error doing 'python
>>> manage.py syncdb'. I am using the DATABASES as it is created and I've try
>>> to use sqlite3 and mysql backends. I tried it in windows and in unix.
>>> Rasult is always the same:
>>>  raise ImproperlyConfigured("**settings.DATABASES is improperly
>>> configured. "
>>> django.core.exceptions.**ImproperlyConfigured: settings.DATABASES is
>>> improperly configured. Please supply the ENGINE value. Check settings
>>> documentation for more details.
>>> But settings.py is:
>>> DATABASES = {
>>> 'default': {
>>> 'ENGINE': 'django.db.backends.sqlite3', # Add
>>> 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
>>> 'NAME': 'polls.db',   **   # Or path to
>>> database file if using sqlite3.
>>> 'USER': '',  # Not used with sqlite3.
>>> 'PASSWORD': '',  # Not used with sqlite3.
>>> 'HOST': '',  # Set to empty string for
>>> localhost. Not used with sqlite3.
>>> 'PORT': '',  # Set to empty string for
>>> default. Not used with sqlite3.
>>> }
>>> }
>>> ¿Any idea?
>>>
>>> --
>>> 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/-/Yl-**oyPgbgLYJ
>>> .
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to django-users+unsubscribe@*
>>> *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/-/L99DVyecFWoJ.
> 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: Need help

2012-04-03 Thread thongor
Wow this post is really old but this also solved my problem strangely 
enough. 

On Thursday, June 25, 2009 2:48:32 PM UTC-4, amy wrote:
>
> I had this same problem...the user and pass were fine but no users 
> could authenticate on any DB, regardless of settings. 
>
> Turns out my issue was only that I needed to add the string 
> "localhost" to the host parameter. 
>
> It's odd since the comments specifically state to leave it blank for 
> localhost...but oh well. It worked. 
>
> DATABASE_HOST = 'localhost' # Set to empty string for 
> localhost. Not used with sqlite3. 
>
> Odd. 
>
> On May 31, 6:14 am, Tim Chase  wrote: 
> > mizan rahman wrote: 
> > > No, i've checked that i've created a user named "djangouser" and the 
> > > problem still exist what will i do? Plz help me 
> > 
> > and you've checked that the password in settings.py is correct? 
> > You only confirmed one of the two problems I suggested. 
> > 
> > If both are correct, you may have to include the section of your 
> > pg_hba.conf that defines access permissions.  It usually looks 
> > something like 
> > 
> > ## 
> > local   all postgres  ident sameuser 
> > 
> > # TYPE  DATABASEUSERCIDR-ADDRESS  METHOD 
> > 
> > # "local" is for Unix domain socket connections only 
> > local   all all   ident sameuser 
> > # IPv4 local connections: 
> > hostall all 127.0.0.1/32  md5 
> > # IPv6 local connections: 
> > hostall all ::1/128   md5 
> > ## 
> > 
> > along with information about how your connecting in Django (to 
> > localhost, to the local machine by IP address, to a remote 
> > machine, etc) 
> > 
> > -tkc 
>

-- 
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/-/BI0mwz_xsrsJ.
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: Problemas con syncdb

2012-04-03 Thread DIEGO CENZANO PRADO
Thank you for your feedback. I was using django 1.4. I have changed to the 
previous version and it is working. Maybe a bug in the new version?

El martes 3 de abril de 2012 16:12:04 UTC+2, imarcelolz escribió:
>
> Try to setup the absolute path on "NAME".
>
> *Um Abraço!*
> *Ivo Marcelo Leonardi Zaniolo*
> *imarcelolz.blogspot.com*
>
>
> 2012/4/3 DIEGO CENZANO PRADO 
>
>> I am trying to do the tutorial and I get an error doing 'python manage.py 
>> syncdb'. I am using the DATABASES as it is created and I've try to use 
>> sqlite3 and mysql backends. I tried it in windows and in unix. Rasult is 
>> always the same:
>>  raise ImproperlyConfigured("settings.DATABASES is improperly configured. 
>> "
>> django.core.exceptions.ImproperlyConfigured: settings.DATABASES is 
>> improperly configured. Please supply the ENGINE value. Check settings 
>> documentation for more details.
>> But settings.py is:
>> DATABASES = {
>> 'default': {
>> 'ENGINE': 'django.db.backends.sqlite3', # Add 
>> 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
>> 'NAME': 'polls.db',  # Or path to database 
>> file if using sqlite3.
>> 'USER': '',  # Not used with sqlite3.
>> 'PASSWORD': '',  # Not used with sqlite3.
>> 'HOST': '',  # Set to empty string for 
>> localhost. Not used with sqlite3.
>> 'PORT': '',  # Set to empty string for 
>> default. Not used with sqlite3.
>> }
>> }
>> ¿Any idea?
>>
>> -- 
>> 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/-/Yl-oyPgbgLYJ.
>> 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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/L99DVyecFWoJ.
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: 404 page not found

2012-04-03 Thread Sebastian Goll
On Mon, 2 Apr 2012 17:14:00 -0700 (PDT)
Homer  wrote:

> I met "404" page not found when I try to enter 127.0.0.1:8000/cn/bedroom . 
> It says on the webpage that "C:/Django/final/media/bedroom" does not 
> exist". Why would this happen?

I am positive the problem is with your URL patterns:

> # urls.py
> urlpatterns = patterns('',
> …
> url(r'^cn/', include('final.photo.urls')),
> url(r'^cn/(?P.*)$', 'django.views.static.serve',
> {'document_root': settings.MEDIA_ROOT}),
> )
> 
> # photo/urls.py
> urlpatterns = patterns('',
> url(r'^$', List),
> url(r'^/bedroom/', Detail),
> )

Trying to access 'cn/bedroom' _should_ redirect to view Detail, I guess.

But what happens is that 'cn/' gets stripped via the main level pattern,
including 'final.photo.urls'. There no match is found due to the leading
'/' in the second pattern: r'^/bedroom/'. Thus the search continues with
'cn/(?P.*)$' in the top-level URL patterns which tries to access a
non-existing media file in settings.MEDIA_ROOT.

Therefore, to fix the issue, you should remove the leading forward slash
'/' in the second pattern in your photo/urls.py.

For reference, see the notes section in

  https://docs.djangoproject.com/en/1.4/topics/http/urls/#example
  – "There's no need to add a leading slash, because every URL has that.
  For example, it's ^articles, not ^/articles."

Best wishes,
Sebastian.

-- 
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: Problemas con syncdb

2012-04-03 Thread Sandro Dutra
 # Or *path to database file* if using *sqlite3*.

2012/4/3 DIEGO CENZANO PRADO 

> I am trying to do the tutorial and I get an error doing 'python manage.py
> syncdb'. I am using the DATABASES as it is created and I've try to use
> sqlite3 and mysql backends. I tried it in windows and in unix. Rasult is
> always the same:
>  raise ImproperlyConfigured("settings.DATABASES is improperly configured. "
> django.core.exceptions.ImproperlyConfigured: settings.DATABASES is
> improperly configured. Please supply the ENGINE value. Check settings
> documentation for more details.
> But settings.py is:
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.sqlite3', # Add
> 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
> 'NAME': 'polls.db',  # Or path to database
> file if using sqlite3.
> 'USER': '',  # Not used with sqlite3.
> 'PASSWORD': '',  # Not used with sqlite3.
> 'HOST': '',  # Set to empty string for
> localhost. Not used with sqlite3.
> 'PORT': '',  # Set to empty string for
> default. Not used with sqlite3.
> }
> }
> ¿Any idea?
>
> --
> 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/-/Yl-oyPgbgLYJ.
> 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: Problemas con syncdb

2012-04-03 Thread Andre Terra
I guess you could check if you're actually looking at the right file.

$ python manage.py shell

>>> import settings

>>> print settings.__file__



Cheers,
AT

On Tue, Apr 3, 2012 at 10:28 AM, DIEGO CENZANO PRADO  wrote:

> I am trying to do the tutorial and I get an error doing 'python manage.py
> syncdb'. I am using the DATABASES as it is created and I've try to use
> sqlite3 and mysql backends. I tried it in windows and in unix. Rasult is
> always the same:
>  raise ImproperlyConfigured("settings.DATABASES is improperly configured. "
> django.core.exceptions.ImproperlyConfigured: settings.DATABASES is
> improperly configured. Please supply the ENGINE value. Check settings
> documentation for more details.
> But settings.py is:
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.sqlite3', # Add
> 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
> 'NAME': 'polls.db',  # Or path to database
> file if using sqlite3.
> 'USER': '',  # Not used with sqlite3.
> 'PASSWORD': '',  # Not used with sqlite3.
> 'HOST': '',  # Set to empty string for
> localhost. Not used with sqlite3.
> 'PORT': '',  # Set to empty string for
> default. Not used with sqlite3.
> }
> }
> ¿Any idea?
>
> --
> 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/-/Yl-oyPgbgLYJ.
> 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: Django: 404 page not found

2012-04-03 Thread Tom Evans
On Tue, Apr 3, 2012 at 1:14 AM, Homer  wrote:
> I met "404" page not found when I try to enter 127.0.0.1:8000/cn/bedroom .
> It says on the webpage that "C:/Django/final/media/bedroom" does not exist".
> Why would this happen?
>
> urls.py:
>
> from django.conf.urls.defaults import *
> from final import settings
> from django.contrib import admin
> admin.autodiscover()
>
> urlpatterns = patterns('',
>
>     url(r'^admin/', include(admin.site.urls)),
>     url(r'^cn/', include('final.photo.urls')),
>     url(r'^cn/(?P.*)$', 'django.views.static.serve',
>         {'document_root': settings.MEDIA_ROOT}),
> )
> photo/urls.py:
>
> from django.conf.urls.defaults import *
> from final.photo.views import List, Detail
> urlpatterns = patterns('',
>     url(r'^$', List),
>     url(r'^/bedroom/', Detail),
> )
>

You have conflicting URL space, you have configured "^cn/" to be both
where your static files are served from, and also where your views are
served from. Split the two up, and use the correct URL, and you should
not have any problems. Eg:

urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)),
    url(r'^photos/', include('final.photo.urls')),
    url(r'^docs/(?P.*)$', 'django.views.static.serve',
        {'document_root': settings.MEDIA_ROOT}),
)

I'm not sure why people are interested in your
TEMPLATE_CONTEXT_PROCESSORS settings when the request isn't even
making it to the view...

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: 404 page not found

2012-04-03 Thread Sergiy Khohlov
Could you please add your setting.py from root of the your project  to
your letter ?

2012/4/3 Homer :
> I add the section you provided to my settings.py but it still does not
> work...
>
> 在 2012年4月3日星期二UTC-4上午8时57分57秒,skhohlov写道:
>>
>> this  section from my last project :
>>
>>
>> TEMPLATE_CONTEXT_PROCESSORS = (
>>
>> 'django.core.context_processors.request',
>> 'django.core.context_processors.debug',
>> 'django.core.context_processors.i18n',
>> 'django.core.context_processors.media',
>> 'django.core.context_processors.static',
>> 'django.contrib.auth.context_processors.auth',
>> 'django.contrib.messages.context_processors.messages',
>> )
>>
>>  You have problem without'django.core.context_processors.media'
>> with media content , take a look at
>> https://docs.djangoproject.com/en/dev/howto/static-files/
>>
>>
>> 2012/4/3 Homer :
>> > Sorry, I did not find "TEMPLATE_CONTEXT_PROCESSORS" in my settings.py. I
>> > do
>> > not know whether it is related to the version of Django. I am using
>> > Django
>> > 1.3 right now.
>> >
>> > 在 2012年4月3日星期二UTC-4上午2时20分30秒,skhohlov写道:
>> >>
>> >> please post section of the  setting.py  file
>> >>
>> >> TEMPLATE_CONTEXT_PROCESSORS
>> >>
>> >>  Has this file
>> >>
>> >> 'django.core.context_processors.static',
>> >>
>> >> 2012/4/3 Homer :
>> >> > I think "media_root" works well since I also used pictures on my
>> >> > another
>> >> > page. Maybe there is something wrong in my urlconf...
>> >> >
>> >> > 在 2012年4月2日星期一UTC-4下午8时41分02秒,St@n写道:
>> >> >>
>> >> >> check your Media_root in settings.py.
>> >> >>
>> >> >> It could be a missing stroke.
>> >> >>
>> >> >> Best Regards,
>> >> >>
>> >> >> Stanwin Siow
>> >> >>
>> >> >>
>> >> >>
>> >> >> On Apr 3, 2012, at 8:14 AM, Homer wrote:
>> >> >>
>> >> >> I met "404" page not found when I try to enter
>> >> >> 127.0.0.1:8000/cn/bedroom .
>> >> >> It says on the webpage that "C:/Django/final/media/bedroom" does not
>> >> >> exist".
>> >> >> Why would this happen?
>> >> >>
>> >> >> urls.py:
>> >> >>
>> >> >> from django.conf.urls.defaults import *
>> >> >> from final import settings
>> >> >>
>> >> >> from django.contrib import admin
>> >> >>
>> >> >> admin.autodiscover()
>> >> >>
>> >> >> urlpatterns = patterns('',
>> >> >>
>> >> >> url(r'^admin/', include(admin.site.urls)),
>> >> >>
>> >> >> url(r'^cn/', include('final.photo.urls')),
>> >> >>
>> >> >> url(r'^cn/(?P.*)$', 'django.views.static.serve',
>> >> >>
>> >> >> {'document_root': settings.MEDIA_ROOT}),
>> >> >>
>> >> >> )
>> >> >> photo/urls.py:
>> >> >>
>> >> >> from django.conf.urls.defaults import *
>> >> >>
>> >> >> from final.photo.views import List, Detail
>> >> >>
>> >> >> urlpatterns = patterns('',
>> >> >>
>> >> >> url(r'^$', List),
>> >> >> url(r'^/bedroom/', Detail),
>> >> >>
>> >> >> )
>> >> >>
>> >> >> photo/views.py:
>> >> >>
>> >> >>
>> >> >> from django.template import loader, Context, RequestContext
>> >> >>
>> >> >> from django.http import HttpResponse
>> >> >>
>> >> >> from final.photo.models import Image, Audio, Pinyin, SImage
>> >> >>
>> >> >> from django.shortcuts import render_to_response
>> >> >>
>> >> >> def List(request):
>> >> >>
>> >> >> ShowSImage = SImage.objects.all()
>> >> >> ShowLink = Image.objects.all()
>> >> >>
>> >> >> context = RequestContext(request, {
>> >> >>
>> >> >>  'ShowSImage': ShowSImage, 'ShowLink': ShowLink
>> >> >>
>> >> >> })
>> >> >>
>> >> >> return render_to_response('list.html', context)
>> >> >>
>> >> >> def Detail(request):
>> >> >> ShowImage = Image.objects.all()
>> >> >> ShowPinyin = Pinyin.objects.all()
>> >> >> ShowAudio = Audio.objects.all()
>> >> >> context = RequestContext(request, {
>> >> >> 'ShowAudio': ShowAudio, 'ShowImage': ShowImage,
>> >> >> 'ShowPinyin':
>> >> >> ShowPinyin
>> >> >> })
>> >> >> return render_to_response('detail.html', context)
>> >> >> detail.html:
>> >> >>
>> >> >> {% extends "base.html" %}
>> >> >>
>> >> >> {% block title %}{{ item.title }}{% endblock %}
>> >> >>
>> >> >> {% block content %}
>> >> >>
>> >> >> {{ item.title }}
>> >> >> 
>> >> >> {% if object.caption %}{{ object.caption }}{% endif %}
>> >> >>
>> >> >> {% endblock %}
>> >> >> Thanks in advance!
>> >> >>
>> >> >>
>> >> >> --
>> >> >> 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/-/V1uKDrAvYS0J.
>> >> >> 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 vi

Re: Django: 404 page not found

2012-04-03 Thread Homer
I add the section you provided to my settings.py but it still does not 
work... 

在 2012年4月3日星期二UTC-4上午8时57分57秒,skhohlov写道:
>
> this  section from my last project :
>
>
> TEMPLATE_CONTEXT_PROCESSORS = (
>
> 'django.core.context_processors.request',
> 'django.core.context_processors.debug',
> 'django.core.context_processors.i18n',
> 'django.core.context_processors.media',
> 'django.core.context_processors.static',
> 'django.contrib.auth.context_processors.auth',
> 'django.contrib.messages.context_processors.messages',
> )
>
>  You have problem without'django.core.context_processors.media'
> with media content , take a look at
> https://docs.djangoproject.com/en/dev/howto/static-files/
>
>
> 2012/4/3 Homer :
> > Sorry, I did not find "TEMPLATE_CONTEXT_PROCESSORS" in my settings.py. I 
> do
> > not know whether it is related to the version of Django. I am using 
> Django
> > 1.3 right now.
> >
> > 在 2012年4月3日星期二UTC-4上午2时20分30秒,skhohlov写道:
> >>
> >> please post section of the  setting.py  file
> >>
> >> TEMPLATE_CONTEXT_PROCESSORS
> >>
> >>  Has this file
> >>
> >> 'django.core.context_processors.static',
> >>
> >> 2012/4/3 Homer :
> >> > I think "media_root" works well since I also used pictures on my 
> another
> >> > page. Maybe there is something wrong in my urlconf...
> >> >
> >> > 在 2012年4月2日星期一UTC-4下午8时41分02秒,St@n写道:
> >> >>
> >> >> check your Media_root in settings.py.
> >> >>
> >> >> It could be a missing stroke.
> >> >>
> >> >> Best Regards,
> >> >>
> >> >> Stanwin Siow
> >> >>
> >> >>
> >> >>
> >> >> On Apr 3, 2012, at 8:14 AM, Homer wrote:
> >> >>
> >> >> I met "404" page not found when I try to enter
> >> >> 127.0.0.1:8000/cn/bedroom .
> >> >> It says on the webpage that "C:/Django/final/media/bedroom" does not
> >> >> exist".
> >> >> Why would this happen?
> >> >>
> >> >> urls.py:
> >> >>
> >> >> from django.conf.urls.defaults import *
> >> >> from final import settings
> >> >>
> >> >> from django.contrib import admin
> >> >>
> >> >> admin.autodiscover()
> >> >>
> >> >> urlpatterns = patterns('',
> >> >>
> >> >> url(r'^admin/', include(admin.site.urls)),
> >> >>
> >> >> url(r'^cn/', include('final.photo.urls')),
> >> >>
> >> >> url(r'^cn/(?P.*)$', 'django.views.static.serve',
> >> >>
> >> >> {'document_root': settings.MEDIA_ROOT}),
> >> >>
> >> >> )
> >> >> photo/urls.py:
> >> >>
> >> >> from django.conf.urls.defaults import *
> >> >>
> >> >> from final.photo.views import List, Detail
> >> >>
> >> >> urlpatterns = patterns('',
> >> >>
> >> >> url(r'^$', List),
> >> >> url(r'^/bedroom/', Detail),
> >> >>
> >> >> )
> >> >>
> >> >> photo/views.py:
> >> >>
> >> >>
> >> >> from django.template import loader, Context, RequestContext
> >> >>
> >> >> from django.http import HttpResponse
> >> >>
> >> >> from final.photo.models import Image, Audio, Pinyin, SImage
> >> >>
> >> >> from django.shortcuts import render_to_response
> >> >>
> >> >> def List(request):
> >> >>
> >> >> ShowSImage = SImage.objects.all()
> >> >> ShowLink = Image.objects.all()
> >> >>
> >> >> context = RequestContext(request, {
> >> >>
> >> >>  'ShowSImage': ShowSImage, 'ShowLink': ShowLink
> >> >>
> >> >> })
> >> >>
> >> >> return render_to_response('list.html', context)
> >> >>
> >> >> def Detail(request):
> >> >> ShowImage = Image.objects.all()
> >> >> ShowPinyin = Pinyin.objects.all()
> >> >> ShowAudio = Audio.objects.all()
> >> >> context = RequestContext(request, {
> >> >> 'ShowAudio': ShowAudio, 'ShowImage': ShowImage, 'ShowPinyin':
> >> >> ShowPinyin
> >> >> })
> >> >> return render_to_response('detail.html', context)
> >> >> detail.html:
> >> >>
> >> >> {% extends "base.html" %}
> >> >>
> >> >> {% block title %}{{ item.title }}{% endblock %}
> >> >>
> >> >> {% block content %}
> >> >>
> >> >> {{ item.title }}
> >> >> 
> >> >> {% if object.caption %}{{ object.caption }}{% endif %}
> >> >>
> >> >> {% endblock %}
> >> >> Thanks in advance!
> >> >>
> >> >>
> >> >> --
> >> >> 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/-/V1uKDrAvYS0J.
> >> >> 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 view this discussion on the web visit
> >> > https://groups.google.com/d/msg/django-users/-/Os90mGtKgrIJ.
> >> >
> >> > To post to this group, send email to django-users@googlegroups.com.
> >> > To unsubscribe from this group, send email to
> >> > django-users+unsubscr...@googlegroups.c

Problemas con syncdb

2012-04-03 Thread DIEGO CENZANO PRADO
I am trying to do the tutorial and I get an error doing 'python manage.py 
syncdb'. I am using the DATABASES as it is created and I've try to use 
sqlite3 and mysql backends. I tried it in windows and in unix. Rasult is 
always the same:
 raise ImproperlyConfigured("settings.DATABASES is improperly configured. "
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is 
improperly configured. Please supply the ENGINE value. Check settings 
documentation for more details.
But settings.py is:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 
'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'polls.db',  # Or path to database file 
if using sqlite3.
'USER': '',  # Not used with sqlite3.
'PASSWORD': '',  # Not used with sqlite3.
'HOST': '',  # Set to empty string for 
localhost. Not used with sqlite3.
'PORT': '',  # Set to empty string for default. 
Not used with sqlite3.
}
}
¿Any idea?

-- 
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/-/Yl-oyPgbgLYJ.
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.



Profiling Django (WAS Django database-api)

2012-04-03 Thread Andre Terra
While I know of the two methods mentioned by Anssi, I've often wondered how
to profile my code from a project level.

I have some complex and database intensive asynchronous tasks running under
celery which take a LONG time to complete and I'd just love to be able to
keep track of the queries they generate in order to optimize and possibly
remove the biggest bottlenecks.

"Real time" updates would be great, but I can settle for after-the-fact
logs. I know of django-debug-toolbar [0] but since these aren't happening
in a view, I'm not sure that app can help.

Any suggestions? Thanks in advance!

Cheers,
André Terra

[0] http://pypi.python.org/pypi/django-debug-toolbar
 On Apr 3, 2012 6:13 AM, "KasunLak"  wrote:

-- 
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: 404 page not found

2012-04-03 Thread Sergiy Khohlov
 this  section from my last project :


TEMPLATE_CONTEXT_PROCESSORS = (

'django.core.context_processors.request',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
)

 You have problem without'django.core.context_processors.media'
with media content , take a look at
https://docs.djangoproject.com/en/dev/howto/static-files/


2012/4/3 Homer :
> Sorry, I did not find "TEMPLATE_CONTEXT_PROCESSORS" in my settings.py. I do
> not know whether it is related to the version of Django. I am using Django
> 1.3 right now.
>
> 在 2012年4月3日星期二UTC-4上午2时20分30秒,skhohlov写道:
>>
>> please post section of the  setting.py  file
>>
>> TEMPLATE_CONTEXT_PROCESSORS
>>
>>  Has this file
>>
>> 'django.core.context_processors.static',
>>
>> 2012/4/3 Homer :
>> > I think "media_root" works well since I also used pictures on my another
>> > page. Maybe there is something wrong in my urlconf...
>> >
>> > 在 2012年4月2日星期一UTC-4下午8时41分02秒,St@n写道:
>> >>
>> >> check your Media_root in settings.py.
>> >>
>> >> It could be a missing stroke.
>> >>
>> >> Best Regards,
>> >>
>> >> Stanwin Siow
>> >>
>> >>
>> >>
>> >> On Apr 3, 2012, at 8:14 AM, Homer wrote:
>> >>
>> >> I met "404" page not found when I try to enter
>> >> 127.0.0.1:8000/cn/bedroom .
>> >> It says on the webpage that "C:/Django/final/media/bedroom" does not
>> >> exist".
>> >> Why would this happen?
>> >>
>> >> urls.py:
>> >>
>> >> from django.conf.urls.defaults import *
>> >> from final import settings
>> >>
>> >> from django.contrib import admin
>> >>
>> >> admin.autodiscover()
>> >>
>> >> urlpatterns = patterns('',
>> >>
>> >> url(r'^admin/', include(admin.site.urls)),
>> >>
>> >> url(r'^cn/', include('final.photo.urls')),
>> >>
>> >> url(r'^cn/(?P.*)$', 'django.views.static.serve',
>> >>
>> >> {'document_root': settings.MEDIA_ROOT}),
>> >>
>> >> )
>> >> photo/urls.py:
>> >>
>> >> from django.conf.urls.defaults import *
>> >>
>> >> from final.photo.views import List, Detail
>> >>
>> >> urlpatterns = patterns('',
>> >>
>> >> url(r'^$', List),
>> >> url(r'^/bedroom/', Detail),
>> >>
>> >> )
>> >>
>> >> photo/views.py:
>> >>
>> >>
>> >> from django.template import loader, Context, RequestContext
>> >>
>> >> from django.http import HttpResponse
>> >>
>> >> from final.photo.models import Image, Audio, Pinyin, SImage
>> >>
>> >> from django.shortcuts import render_to_response
>> >>
>> >> def List(request):
>> >>
>> >> ShowSImage = SImage.objects.all()
>> >> ShowLink = Image.objects.all()
>> >>
>> >> context = RequestContext(request, {
>> >>
>> >>  'ShowSImage': ShowSImage, 'ShowLink': ShowLink
>> >>
>> >> })
>> >>
>> >> return render_to_response('list.html', context)
>> >>
>> >> def Detail(request):
>> >> ShowImage = Image.objects.all()
>> >> ShowPinyin = Pinyin.objects.all()
>> >> ShowAudio = Audio.objects.all()
>> >> context = RequestContext(request, {
>> >> 'ShowAudio': ShowAudio, 'ShowImage': ShowImage, 'ShowPinyin':
>> >> ShowPinyin
>> >> })
>> >> return render_to_response('detail.html', context)
>> >> detail.html:
>> >>
>> >> {% extends "base.html" %}
>> >>
>> >> {% block title %}{{ item.title }}{% endblock %}
>> >>
>> >> {% block content %}
>> >>
>> >> {{ item.title }}
>> >> 
>> >> {% if object.caption %}{{ object.caption }}{% endif %}
>> >>
>> >> {% endblock %}
>> >> Thanks in advance!
>> >>
>> >>
>> >> --
>> >> 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/-/V1uKDrAvYS0J.
>> >> 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 view this discussion on the web visit
>> > https://groups.google.com/d/msg/django-users/-/Os90mGtKgrIJ.
>> >
>> > 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 view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/70nj8U1BxCoJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+uns

Re: Django: 404 page not found

2012-04-03 Thread Homer
Sorry, I did not find "TEMPLATE_CONTEXT_PROCESSORS" in my settings.py. I do 
not know whether it is related to the version of Django. I am using Django 
1.3 right now.

在 2012年4月3日星期二UTC-4上午2时20分30秒,skhohlov写道:
>
> please post section of the  setting.py  file
>
> TEMPLATE_CONTEXT_PROCESSORS
>
>  Has this file
>
> 'django.core.context_processors.static',
>
> 2012/4/3 Homer :
> > I think "media_root" works well since I also used pictures on my another
> > page. Maybe there is something wrong in my urlconf...
> >
> > 在 2012年4月2日星期一UTC-4下午8时41分02秒,St@n写道:
> >>
> >> check your Media_root in settings.py.
> >>
> >> It could be a missing stroke.
> >>
> >> Best Regards,
> >>
> >> Stanwin Siow
> >>
> >>
> >>
> >> On Apr 3, 2012, at 8:14 AM, Homer wrote:
> >>
> >> I met "404" page not found when I try to enter 
> 127.0.0.1:8000/cn/bedroom .
> >> It says on the webpage that "C:/Django/final/media/bedroom" does not 
> exist".
> >> Why would this happen?
> >>
> >> urls.py:
> >>
> >> from django.conf.urls.defaults import *
> >> from final import settings
> >>
> >> from django.contrib import admin
> >>
> >> admin.autodiscover()
> >>
> >> urlpatterns = patterns('',
> >>
> >> url(r'^admin/', include(admin.site.urls)),
> >>
> >> url(r'^cn/', include('final.photo.urls')),
> >>
> >> url(r'^cn/(?P.*)$', 'django.views.static.serve',
> >>
> >> {'document_root': settings.MEDIA_ROOT}),
> >>
> >> )
> >> photo/urls.py:
> >>
> >> from django.conf.urls.defaults import *
> >>
> >> from final.photo.views import List, Detail
> >>
> >> urlpatterns = patterns('',
> >>
> >> url(r'^$', List),
> >> url(r'^/bedroom/', Detail),
> >>
> >> )
> >>
> >> photo/views.py:
> >>
> >>
> >> from django.template import loader, Context, RequestContext
> >>
> >> from django.http import HttpResponse
> >>
> >> from final.photo.models import Image, Audio, Pinyin, SImage
> >>
> >> from django.shortcuts import render_to_response
> >>
> >> def List(request):
> >>
> >> ShowSImage = SImage.objects.all()
> >> ShowLink = Image.objects.all()
> >>
> >> context = RequestContext(request, {
> >>
> >>  'ShowSImage': ShowSImage, 'ShowLink': ShowLink
> >>
> >> })
> >>
> >> return render_to_response('list.html', context)
> >>
> >> def Detail(request):
> >> ShowImage = Image.objects.all()
> >> ShowPinyin = Pinyin.objects.all()
> >> ShowAudio = Audio.objects.all()
> >> context = RequestContext(request, {
> >> 'ShowAudio': ShowAudio, 'ShowImage': ShowImage, 'ShowPinyin':
> >> ShowPinyin
> >> })
> >> return render_to_response('detail.html', context)
> >> detail.html:
> >>
> >> {% extends "base.html" %}
> >>
> >> {% block title %}{{ item.title }}{% endblock %}
> >>
> >> {% block content %}
> >>
> >> {{ item.title }}
> >> 
> >> {% if object.caption %}{{ object.caption }}{% endif %}
> >>
> >> {% endblock %}
> >> Thanks in advance!
> >>
> >>
> >> --
> >> 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/-/V1uKDrAvYS0J.
> >> 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 view this discussion on the web visit
> > https://groups.google.com/d/msg/django-users/-/Os90mGtKgrIJ.
> >
> > 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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/70nj8U1BxCoJ.
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: where do you host your django app and how to you deploy it?!

2012-04-03 Thread N.Aleksandrenko
What about cloud solutions?

On Mon, Apr 2, 2012 at 2:38 PM, Jani Tiainen  wrote:
> 2.4.2012 13:48, fix3d kirjoitti:
>
>> Where do you host your django app and how to you deploy it?!
>>
>> Please share personal exp.
>>
>
> We're deploying to our own application server cluster.
>
> And we're using fabric to run actual deployment.
>
> --
>
> Jani Tiainen
>
>
> --
> 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: Is this a bug? - Translation in error messages django.forms.models._update_errors()

2012-04-03 Thread david_aa
Sorry, my django version: 1.4.0



El martes 3 de abril de 2012 12:33:32 UTC+2, david_aa escribió:
>
> First at all, my apologies if this message is off-topic. I'm not sure if 
> this is a bug and I can't find any related ticket in 
> code.djangoproject.com
>
> The problem is the following:
>
> I've defined in my model some fields with the attribute verbose_name 
> marked for translation:
>
> class Item():
> name = models.CharField(max_length=75, verbose_name=_('name'))
>
> When I access to validation errors, the field's name is not translated.
>
> I've found that editing the method _update_errors() in 
> django/forms/models.py the field names are properly translated, here is the 
> diff:
>
> 254c254
> < self._errors.setdefault(k, self.error_class()).extend(v)
> ---
> > self._errors.setdefault(_(k), 
> self.error_class()).extend(v)
>
> My question: is this a bug? Shall I report it?
>
> Thanks in advance and excuse my newbie questions.
>
> -- 
> David.
>
>
>
>
>

-- 
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/-/LoISEE8fRn8J.
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: querysets

2012-04-03 Thread MikeKJ

FORGET THIS, I was having a brain fart

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



Is this a bug? - Translation in error messages django.forms.models._update_errors()

2012-04-03 Thread david_aa
First at all, my apologies if this message is off-topic. I'm not sure if 
this is a bug and I can't find any related ticket in code.djangoproject.com

The problem is the following:

I've defined in my model some fields with the attribute verbose_name marked 
for translation:

class Item():
name = models.CharField(max_length=75, verbose_name=_('name'))

When I access to validation errors, the field's name is not translated.

I've found that editing the method _update_errors() in 
django/forms/models.py the field names are properly translated, here is the 
diff:

254c254
< self._errors.setdefault(k, self.error_class()).extend(v)
---
> self._errors.setdefault(_(k), 
self.error_class()).extend(v)

My question: is this a bug? Shall I report it?

Thanks in advance and excuse my newbie questions.

-- 
David.




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



querysets

2012-04-03 Thread MikeKJ
Although I use the queryset I dont really understand the object
return, when the object is returned just what is returned
like
list = This.objects.all()
list is [, http://groups.google.com/group/django-users?hl=en.



Re: django admin form customization

2012-04-03 Thread anand jeyahar
Hi al,

>
>     1. I have customized the admin change form to display as inline
> form  a child table/model fields. Now how do i get this form to
> display existing child rows too? I guess, i will have to customize the
> views.py for the admin app right??
>  If so how can point django to pick up the custom views.py file?
> I know i should use template/ for the html template files.

Sorry. It was a bad post. Double sorry for the double posting too.

 I had a obsolete, hanging media = .js file assignment.
Once i removed the inline forms do display the existing data from the
child table.

-- 
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 database-api

2012-04-03 Thread KasunLak
Hi,

Thanks you very much for the informative answer! It clears all the
questions I had in my mind. Because I have some idea to build a tool
to draw the model (UML) --> Generate Django Model code --> and then we
can deploy it to db. Moreover I was thinking that if it possible to
customize (edit existing methods, add new methods..) the generated
database api it would be good.

Thanks again,
Kasun

On Apr 3, 1:41 pm, akaariai  wrote:
> On Apr 3, 11:27 am, KasunLak  wrote:
>
> > Hi,
>
> > No, sorry for not giving more details. What I am asking is once we
> > syncdb the generated scripts (create table). Can we see the method
> > implementation of database access api?
>
> > For example: If we have created and deployed a model called Poll
> > (tutorial example in django site)
>
> > p = Poll.objects.get(pk=1).
>
> > Can we see the implementation of this get(pk) method? I think these
> > are some objects in the database, just wonder this is possible?
>
> If you mean what SQL it generates there are two methods inbuilt to
> django. If you have settings.DEBUG = True, you can use:
>
> > p = Poll.objects.get(pk=1).
> > django.db import connection
> > print connection.queries[-1]
>
> Another option:> print Poll.objects.filter(pk=1).query
>
> This one does work only for QuerySet, so if the method you are
> interested in executes the query immediately (like .get()), then you
> can't use this method.
>
> Neither of the above will give you correctly quoted querystring, as
> that is simply not available to Django. The database backend libraries
> do the quoting, and Django can't get the quoted query string back from
> the libraries.
>
> If you want to see the Python code implementation, look at django/db/
> models/query.py, which uses django/db/models/sql/query.py. Be warned:
> the sql/query.py will take some time to understand, it is one of the
> most complex pieces of code in Django.
>
>  - 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: custom manager to control access

2012-04-03 Thread Tom Evans
On Tue, Apr 3, 2012 at 9:43 AM, Mike Dewhirst  wrote:
> I'm trying to make a custom manager for a few models. The objective is to
> limit user access to information in the database belonging to the company of
> which they are a member.
>
> I think I want to say:
>
> class Something(models.Model):
>    ...
>    objects = MemberManager()
>
> But when I run manage.py runserver I get:
>
> AttributeError: 'MemberManager' object has no attribute '_inherited'
>
> Here is the code:
>
> from django.db import models
> from company.models import *
>
> class MemberManager(models.Manager):
>    """
>    The manager in every model using this manager must return ONLY
>    rows belonging to the User's company. company.models.Member is
>    the table which links a member (ie user) to a particular company
>    in company.models.Company. Each member can be connected to exactly
>    zero or one company. If zero raise BusinessRuleViolation exception
>    otherwise return the company with which to filter query sets using
>    the user's company.
>    """
>    def __init__(self, request=None):
>        self.user = None
>        if request and request.user and request.user.is_authenticated():
>            self.user = request.user
>
>    def get_company(self):
>        if self.user:
>            user_row = Member.objects.get(user=self.user)
>            return user_row.company
>
>    def get_query_set(self):
>        coy = self.get_company()
>        if coy:
>            return super(MemberManager,
>                         self).get_query_set().filter(company=coy)
>        raise BusinessRuleViolation('User must be a company Member')
>
>
> From the research I've done it seems I should not have the __init__() in
> this and indeed if I experimentally factor it out it the error goes away.
>
> The doc string says what I'm trying to do but maybe there is a better way
> than a custom manager.
>
> Thanks for any pointers
>
> Mike
>

Two things:

1) You get the exception because you do not call the parent class's
constructor, and thus the manager instance is not set up with the
appropriate values. Your __init__() method on a derived class should
look more like this:

def __init__(self, *args, **kwargs):
super(self, MyClassName).__init__(*args, **kwargs)
# your stuff

2) Managers are not instantiated with the current request object, so
your approach will not work anyway. You could use something like
thread locals, but that is a hack (and won't work if/when you run
outside of the request/response cycle).

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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 database-api

2012-04-03 Thread akaariai
On Apr 3, 11:27 am, KasunLak  wrote:
> Hi,
>
> No, sorry for not giving more details. What I am asking is once we
> syncdb the generated scripts (create table). Can we see the method
> implementation of database access api?
>
> For example: If we have created and deployed a model called Poll
> (tutorial example in django site)
>
> p = Poll.objects.get(pk=1).
>
> Can we see the implementation of this get(pk) method? I think these
> are some objects in the database, just wonder this is possible?

If you mean what SQL it generates there are two methods inbuilt to
django. If you have settings.DEBUG = True, you can use:
> p = Poll.objects.get(pk=1).
> django.db import connection
> print connection.queries[-1]

Another option:
> print Poll.objects.filter(pk=1).query
This one does work only for QuerySet, so if the method you are
interested in executes the query immediately (like .get()), then you
can't use this method.

Neither of the above will give you correctly quoted querystring, as
that is simply not available to Django. The database backend libraries
do the quoting, and Django can't get the quoted query string back from
the libraries.

If you want to see the Python code implementation, look at django/db/
models/query.py, which uses django/db/models/sql/query.py. Be warned:
the sql/query.py will take some time to understand, it is one of the
most complex pieces of code in Django.

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



custom manager to control access

2012-04-03 Thread Mike Dewhirst
I'm trying to make a custom manager for a few models. The objective is 
to limit user access to information in the database belonging to the 
company of which they are a member.


I think I want to say:

class Something(models.Model):
...
objects = MemberManager()

But when I run manage.py runserver I get:

AttributeError: 'MemberManager' object has no attribute '_inherited'

Here is the code:

from django.db import models
from company.models import *

class MemberManager(models.Manager):
"""
The manager in every model using this manager must return ONLY
rows belonging to the User's company. company.models.Member is
the table which links a member (ie user) to a particular company
in company.models.Company. Each member can be connected to exactly
zero or one company. If zero raise BusinessRuleViolation exception
otherwise return the company with which to filter query sets using
the user's company.
"""
def __init__(self, request=None):
self.user = None
if request and request.user and request.user.is_authenticated():
self.user = request.user

def get_company(self):
if self.user:
user_row = Member.objects.get(user=self.user)
return user_row.company

def get_query_set(self):
coy = self.get_company()
if coy:
return super(MemberManager,
 self).get_query_set().filter(company=coy)
raise BusinessRuleViolation('User must be a company Member')


From the research I've done it seems I should not have the __init__() 
in this and indeed if I experimentally factor it out it the error goes away.


The doc string says what I'm trying to do but maybe there is a better 
way than a custom manager.


Thanks for any pointers

Mike

--
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 database-api

2012-04-03 Thread KasunLak
Hi,

No, sorry for not giving more details. What I am asking is once we
syncdb the generated scripts (create table). Can we see the method
implementation of database access api?

For example: If we have created and deployed a model called Poll
(tutorial example in django site)

p = Poll.objects.get(pk=1).

Can we see the implementation of this get(pk) method? I think these
are some objects in the database, just wonder this is possible?

thanks

On Apr 3, 12:10 pm, Eugenio Minardi  wrote:
> Hi,
> Do you mean the SQL generated by your model?
>
> In this case you can use
>
> python manage.py sql APPNAME
>
>
>
>
>
>
>
> On Tue, Apr 3, 2012 at 8:45 AM, KasunLak  wrote:
> > Hi all,
>
> > I just wonder is there a way to browse/view the code of database api
> > methods generated? Is there any tool for this?
>
> > Thanks in advance,
> > Kasun
>
> > --
> > 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: Django Contrib Auth + Class Based Generic Views

2012-04-03 Thread Sergiy Khohlov
Please provide your urls.py  and  your view which is used for this 

2012/4/3 Matheus Ashton :
> Hello Everybody,
>
> I'm having a problem using the django.contrib.auth app and class based
> generic views in Django 1.3 / 1.4:
>
> After submitting the login form, my view receives the post data and tries to
> authenticate the user and then redirect to a success page. Ok nothing new..
> The problem is: My HomeView wich extends the TemplateView, receive the
> redirect from the login form and uses a render_to_response function to
> render the template, and that is my problem, because render_to_response does
> not create a RequestContext object, the one I need to show the newly
> authenticated user data, because that is a requirement for
> django.contrib.auth app, if the request is not a RequestContext, the
> authenticated user data, is not passed to the template
> (https://docs.djangoproject.com/en/1.4/topics/auth/#authentication-data-in-templates)..
>
> Does someone can help me with this problem?
>
> PS: Sorry about my English, it is not my first language
>
> Thanks :D
>
> --
> 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/-/ywPX8VH5CUQJ.
> 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: Why using Generic Views?

2012-04-03 Thread Sergiy Khohlov
Generic views helps  to avoid writting some part of the trivial code.
 For example :
you are writing a shop with goods and  a lot of the pages contains
list of the items.  You should  about sorting orders,  page selecting
etc.  If you are using generic views then you might not spend time at
this. Also if you are novice then you might avoid bugs in your code.
(less code , less bugs).
Disadvantages of this is next :
django is moving  from  function based generic view to  class based.
Unfortunately   class based does not have a lot documentation at this
moment.


 thanks, Serge


2012/4/3 abisson :
> Good evening,
>
> I just finished the Django 1.4 Tutorial, and I really don't understand
> the point of Generic Views in Django? As far as I can see, we wrote
> more code than before, and what other example would make the Generic
> Views better than normal views?
>
> Thanks for the clarifications!
>
> --
> 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.



"Expression of Interest" django project

2012-04-03 Thread Alec Taylor
I am thinking to setup an "expression of interest" page with a survey
ending with a "subscribe for updates" button.

The relevant features being:
• View percentages who choice which options in the survey on a graph
• Subscribe for updates equates to newsletter backend
• Twitter Bootstrap theme

It shouldn't be too difficult to build this "from scratch" using:
• django-surveys
• django-chartit
• emencia-django-newsletter
• django-bootstrap

Then I would just put it for anyone to use on either GitHub or BitBucket.

The question I must ask before I begin this project though, is:
"Has someone done this already + have they done it well?"

Thanks for all information,

Alec Taylor

-- 
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 database-api

2012-04-03 Thread Eugenio Minardi
Hi,
Do you mean the SQL generated by your model?

In this case you can use

python manage.py sql APPNAME


On Tue, Apr 3, 2012 at 8:45 AM, KasunLak  wrote:

> Hi all,
>
> I just wonder is there a way to browse/view the code of database api
> methods generated? Is there any tool for this?
>
> Thanks in advance,
> Kasun
>
> --
> 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.



Why using Generic Views?

2012-04-03 Thread abisson
Good evening,

I just finished the Django 1.4 Tutorial, and I really don't understand
the point of Generic Views in Django? As far as I can see, we wrote
more code than before, and what other example would make the Generic
Views better than normal views?

Thanks for the clarifications!

-- 
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: form.Forms + POST + forms.ChoiceField

2012-04-03 Thread Sergiy Khohlov
try to use django generic class view

https://docs.djangoproject.com/en/dev/topics/class-based-views/

Sorting  is added  by adding  next construction to the  your class view:




class  yourclassview(ListView):
"""
model =  yourmodel

context_object_name = 'object_or_list'

template_name = 'yourtemplate.html'

def get_queryset(self):
qs = yourmodel.objects.all().order_by('sortingcriteria
return qs


2012/4/3 Barry Morrison :
> If you could point me to a more recent tutorial, I'm more than willing to go
> through it.
>
> Basically what I have now, is a list of links. I want to sort those links
> based on source (Reddit) then subreddit (Python).  The source and subreddits
> are fed from my DB and I want to select them from a drop-down menu.
>
>
> On Monday, April 2, 2012 1:34:58 PM UTC-7, skhohlov wrote:
>>
>> Ok.
>>  I'm not definitely sure  what  you want  to have but  I'm proposing
>> to do  simple  project with next functionality:
>>
>> 1)  prepare list of the links
>> 2)  ability  to click at the link  and receive some additional
>> information about link
>> 3)  button for deleting of  the link
>> 4)  button for creating new one
>>
>>  Which are be covered :
>>  class based view
>>  generic view
>> passing  values from view to form or template
>>
>>  If you are interested we can start. Also if you would like to add
>> some other areas let me know
>>
>>  Thanks,
>>  Serge
>>
>> 2012/4/2 Barry Morrison :
>> > Too much code? I'd rather too much than not enough, but if it'd help, I
>> > can
>> > cut down on future posts.
>> >
>> > Thanks for the information/guidance.  I'll try your suggestions and post
>> > my
>> > findings.
>> >
>> > Much appreciated!
>> >
>> > On Monday, April 2, 2012 2:18:29 AM UTC-7, skhohlov wrote:
>> >>
>> >> So much code ;-)
>> >>  at first I'm proposing  to add  some code for  form.is_valid block
>> >>  for example :
>> >> if form.is_valid():
>> >>             source = Sources.objects.get(name=source)
>> >>             allPosts = Posts.objects.filter(PostSource=source)
>> >>             subreddits = SubReddits.objects.all()
>> >>             source = form.cleaned_data['foo']
>> >>             return render_to_response('feeds.html',
>> >>                 {'allPosts': allPosts,
>> >>                 'subreddits': subreddits},
>> >>                 context_instance=RequestContext(request))
>> >>   else:
>> >>  print form.error
>> >>
>> >>  This  will help to catch error  with form .
>> >>
>> >>  Also it is not correct to use this construction:
>> >>
>> >> class SourceSelection(forms.Form):
>> >>     sources = Sources.objects.all()
>> >>     foo = forms.ChoiceField(choices=sources)
>> >>
>> >> This mean  that you never add  any sources. or sources object are add
>> >> before starting application. For dynamic  loading objects in the form
>> >> use form constructor.
>> >>  and last one point :
>> >>
>> >>  Please separate views and form in the different files : views.py
>> >> forms.py
>> >>
>> >> 2012/4/2 Barry Morrison :
>> >> > Full Disclosure: I've been using Python for 5-6 months. Django for
>> >> > maybe
>> >> > 3
>> >> >
>> >> > I have this: https://gist.github.com/a934fe08643e0c3ee017
>> >> >
>> >> > In an effort to teach myself, I'm simply building a Django app. For
>> >> > teaching
>> >> > purposes only. It's an aggregator of favorites across multiple sites.
>> >> > Right
>> >> > now, I'm simply dealing with saved items from Reddit.
>> >> >
>> >> > The problem I'm having is the drop-down selector POST'ing and
>> >> > creating a
>> >> > the
>> >> > new URL.
>> >> >
>> >> > http://imgur.com/a/FL32I << Screen shots
>> >> >
>> >> > 1) root or /feeds/
>> >> > 2) Select Reddit from drop-down
>> >> > 3) Displays Reddit items only /feeds/Reddit/
>> >> > 4) Select 'Python' from drop-down, displays items from r/Python with
>> >> > URL
>> >> > /feeds/Reddit/Python
>> >> >
>> >> > This works (manually entering URL's), the drop down does not.
>> >> >
>> >> > I currently get "Error 1" from the gist.
>> >> >
>> >> > On views.py, if I uncomment lines 16 - 19, and comment the lines 21 -
>> >> > 23, I
>> >> > get a different error: "Error2" from the gist.  What I don't
>> >> > understand
>> >> > regarding the 2nd error, is that it is in fact returning: source:
>> >> > u'Reddit'
>> >> > and that exists in the Model, so it makes me think it's expecting
>> >> > something
>> >> > other than u'Reddit'.
>> >> >
>> >> > I'm at a loss, so this is me asking for help.  Sorry for the long
>> >> > post
>> >> > and
>> >> > crazy amounts of information.
>> >> >
>> >> > Any help is GREATLY APPRECIATED!
>> >> >
>> >> > Thanks!
>> >> >
>> >> > POST
>> >> >
>> >> > --
>> >> > 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/-/zXNmsoqAfdMJ.
>> >> > To post to this group, send email to django-users@googlegroups.com.
>>