Django 1.5 b1 django-admin.py error

2012-11-27 Thread Sultan Imanhodjaev
Hello,

I just downloaded and type django-admin.py to start a new project and 
having errors

(devel)ninja devel: django-admin.py startproject hello
> Traceback (most recent call last):
>   File "/Users/sultan/.virtualenvs/devel/bin/django-admin.py", line 5, in 
> 
> management.execute_from_command_line()
>   File 
> "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/core/management/__init__.py",
>  
> line 452, in execute_from_command_line
> utility.execute()
>   File 
> "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/core/management/__init__.py",
>  
> line 391, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File 
> "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/core/management/__init__.py",
>  
> line 262, in fetch_command
> app_name = get_commands()[subcommand]
>   File 
> "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/core/management/__init__.py",
>  
> line 108, in get_commands
> apps = settings.INSTALLED_APPS
>   File 
> "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/conf/__init__.py",
>  
> line 52, in __getattr__
> self._setup(name)
>   File 
> "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/conf/__init__.py",
>  
> line 47, in _setup
> self._wrapped = Settings(settings_module)
>   File 
> "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/conf/__init__.py",
>  
> line 132, in __init__
> raise ImportError("Could not import settings '%s' (Is it on 
> sys.path?): %s" % (self.SETTINGS_MODULE, e))
> ImportError: Could not import settings 'settings' (Is it on sys.path?): No 
> module named settings


But when I just type django-admin.py I have error

(devel)ninja devel: django-admin.py 
> Usage: django-admin.py subcommand [options] [args]
> Options:
>   -v VERBOSITY, --verbosity=VERBOSITY
> Verbosity level; 0=minimal output, 1=normal output,
> 2=verbose output, 3=very verbose output
>   --settings=SETTINGS   The Python path to a settings module, e.g.
> "myproject.settings.main". If this isn't provided, 
> the
> DJANGO_SETTINGS_MODULE environment variable will be
> used.
>   --pythonpath=PYTHONPATH
> A directory to add to the Python path, e.g.
> "/home/djangoprojects/myproject".
>   --traceback   Print traceback on exception
>   --version show program's version number and exit
>   -h, --helpshow this help message and exit
> Traceback (most recent call last):
>   File "/Users/sultan/.virtualenvs/devel/bin/django-admin.py", line 5, in 
> 
> management.execute_from_command_line()
>   File 
> "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/core/management/__init__.py",
>  
> line 452, in execute_from_command_line
> utility.execute()
>   File 
> "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/core/management/__init__.py",
>  
> line 375, in execute
> sys.stdout.write(self.main_help_text() + '\n')
>   File 
> "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/core/management/__init__.py",
>  
> line 241, in main_help_text
> for name, app in six.iteritems(get_commands()):
>   File 
> "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/core/management/__init__.py",
>  
> line 108, in get_commands
> apps = settings.INSTALLED_APPS
>   File 
> "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/conf/__init__.py",
>  
> line 52, in __getattr__
> self._setup(name)
>   File 
> "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/conf/__init__.py",
>  
> line 47, in _setup
> self._wrapped = Settings(settings_module)
>   File 
> "/Users/sultan/.virtualenvs/devel/lib/python2.7/site-packages/django/conf/__init__.py",
>  
> line 132, in __init__
> raise ImportError("Could not import settings '%s' (Is it on 
> sys.path?): %s" % (self.SETTINGS_MODULE, e))
> ImportError: Could not import settings 'settings' (Is it on sys.path?): No 
> module named settings


Why Django cause this error since I simply use django-admin.py?

 

-- 
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/-/ypyN1P3MZWgJ.
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: Speeding up test database creation

2012-11-27 Thread John Maxwell
I just tried changing 'NAME' to ':memory:' and I'm still getting the same
results.

I continued with the tutorial for a while, and it turns out that the unit
tests for the polls app don't have this problem.  So now I'm beginning to
suspect that there's a problem with Django, and the implementation
of LiveServerTestCase doesn't do the usual in-memory database magic (this
may even be by design, though I can't think of any good reasons offhand).

The Selenium-based testing is not proving as useful as the tutorial sells
it, either...  When I use the find_by_name method of the browser object,
and the relevant name isn't to be found, it seems to hang indefinitely
instead of stopping and alerting me of the problem.  So combining these two
considerations, perhaps it's best to stick to unit tests and not bother
with functional tests.

On Tue, Nov 27, 2012 at 3:39 PM, Dennis Lee Bieber wrote:

> On Tue, 27 Nov 2012 13:43:37 -0800 (PST), John Maxwell
>  declaimed the following in
> gmane.comp.python.django.user:
>
> > Hm, I tried commenting out the line
> >
> > 'NAME': '/home/john/database.sqlite',
> >
> > and it still seems to be just as slow, if not slower...
> >
> > On Monday, November 26, 2012 5:56:30 AM UTC-8, Andres Reyes Monge wrote:
> > >
> > > The tutorial uses a sqlite file database not a in memory database, try
> > > omitting the name parameter and it should speed things up
>
> I suspect the best version would be to change the NAME into the
> specific string SQLite3 uses for memory -- ":memory:" (though using ""
> supposedly does the same, and may be what the previous respondent meant)
> --
> Wulfraed Dennis Lee Bieber AF6VN
> wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.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.



[ANNOUNCE] Django 1.5 beta 1 released

2012-11-27 Thread James Bennett
Our second milestone on the road to Django 1.5 came today, with the
release of the first beta package.

Blog post about it is here:

https://www.djangoproject.com/weblog/2012/nov/27/15-beta-1/

Release notes are here:

https://docs.djangoproject.com/en/dev/releases/1.5-beta-1/

And you can get the alpha from the downloads page:

https://www.djangoproject.com/download/

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



Re: How to log a user in automatically after a password reset?

2012-11-27 Thread Russell Keith-Magee
On Wed, Nov 28, 2012 at 4:07 AM, JC Briar wrote:

> When a user has forgotten their password, I use
> django.contrib.auth.views.password_reset to send an email containing a
> temporary link. When the user follows that link, I use
> password_reset_confirm to let them set a new password. So far, so good.
>
> But password_reset_confirm doesn't automatically log the user in – as a
> result, immediately after resetting their password the user has to enter it
> again in order to log in. Most users, I suspect, would find this to be
> obnoxious.
>
> How could this be fixed? According to the auth 
> documentation,
> I need to call authenticate() and login(). But where? I could supply my own
> SetPasswordForm subclass to password_reset_confirm, and make the calls in
> its save() method... except save() doesn't have access to the HttpRequest
> object that login() requires. Or I could define my own
> password_reset_complete view... but then I wouldn't have access to the
> username and password anymore. Are there other options?


What you need to do is write your own password_reset_confirm() method.

You could tackle this three ways, depending on how much custom code you
want to write.

Firstly, reinvent the wheel. Copy and paste the original, and insert your
code to log in the user on success. Simple, and it works, but it's ugly.

Secondly, don't reinvent the wheel :-) The wonderful thing about Django is
that views are just methods - which means you can invoke them:

def my_password_reset_confirm(request):
response = password_reset_confirm(request)
do_stuff()
return response

So - write a custom password_reset_confirm method that does all the usual
reset confirmation, and integrates the calls to authenticate and login().
If the original method returns a HTTPRedirect, you know the reset was
successful, so you can reprocess the POST data to extract the username and
password.

Thirdly, don't reinvent the wheel, and don't reprocess form data either --
exploit duck typing. The existing password_reset_confirm takes the form as
an argument; the only problem is that the form doesn't have access to the
request. password_reset_confirm takes the form class as an argument, but
through the wonders of duck typing, there's nothing that says you need to
provide a form class -- you just need to provide something that takes the
same arguments as a form class constructor.

So, subclass the form so that it *does* take the request as an argument,
and put the login code as part of the form save() method. Then, write a
method that has the same prototype as the constructor for the form that
the password_reset_confirm() method is expecting, but returns an instance
of *your* form, bound with the current request. Abracadabra - you've got
the request object provided to the password reset form!

Yours,
Russ Magee %-)

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



Re: how should I get the request object?

2012-11-27 Thread Russell Keith-Magee
On Tue, Nov 27, 2012 at 12:38 PM, Wade Williams
wrote:

> I share the disdain for global variables as well.
>
> I'm fairly new to Django, and what I'm not understanding is when the
> request object is available for inclusion. I have a custom session backend
> that I've built in order to support a legacy user model and session table
> -- when I tried to simply add the request parameter from this backend, I
> got number of parameter errors, so it seems that it isn't totally available
> all of the time.
>
> Im currently patching this with a similarly horrible settings.request var
> that simply contains the request, so an import of settings makes this work.
>
> But again, that's icky, and horrible, and no, so when exactly can you add
> the request parameter, and when can't you ?
>
>
> Thanks so much for the clarification. Lots of search attempts and still
> not understanding when it's automatically passed in as a parameter / how
> that even gets passed to the method. As far as I can tell, middleware and
> views both have access to the request, but is it simply the wrong thing to
> try and access the request in some other place ?
>
>
I'm afraid I don't even understand the question here. When is it legal to
access the request? Whenever it's been passed in as an argument to whatever
function is in use. When is it passed in as an argument? Whenever it's in
the method prototype.

You say you're putting data on the settings object in order to preserve the
request. Firstly, this scares the bejeezus out of me, above and beyond my
earlier comments about globals. Using thread locals is bad architecture,
but at least it will work. If you're just setting settings.request,
hilarity *will* ensue as soon as you have a real production scenario --
request objects will be shared between threads, meaning all sorts of
session leakage, security problems and more.

Lastly, you say you need the request object for your session backend. I'm
not entirely sure I see why you need the request object for this -- the API
for a session store is based on the idea that a session key can be used to
retrieve session data; it should be independent of a User model. However,
assuming you have a real reason for doing this, the way to get the request
object into the session store is to write a custom SessionMiddleware that
passes in the request object when the session object is instantiated. No
special magic required -- find the place where request is needed, add it to
the method prototype, and add it to the call when the method is used.

There's no "automatic" anything going on here. request is either an
argument on a method, or it isn't. Part of the contract for a view is that
the first argument is the request object. However, that's no different to
saying that the first argument to open() is a file name, or that the first
argument to __getitem__() is the index of the object you want to return. If
you need the request to be available somewhere, then you need to find the
call path from the middleware/view to whatever code needs the request
object.

Yours,
Russ Magee %-)

-- 
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 or am I doing it wrong? (trans tag)

2012-11-27 Thread Some Developer

On 27/11/12 12:33, Tom Evans wrote:

On Mon, Nov 26, 2012 at 9:43 PM, Some Developer
 wrote:

On 10/11/12 21:49, Some Developer wrote:


In the documentation it is quite clear that the following syntax is
correct in templates:

{% load i18n %}

{% trans "my_string" as blah_string %}

{{ blah_string }}

etc etc.

This works fine if the original trans tag is inside a block but then the
blah_string variable is only valid within that block. If you place the
trans tag in a global position (outside of any blocks) the blah_string
variable does not work when you try and use it in a block (that is any
block). I am using Django 1.4.2 and think this behaviour is somewhat
strange given the documentation for this particular feature. Surely you
should be able to declare the trans tag outside of any block as the
chances are that you will want to use the blah_string variable in more
than one block (I often have three or four blocks per page for various
things).

So is this a bug or am I doing something wrong?



Any comments on this at all? I'm still not entirely sure if this behaviour
is intentional or not.



Templates have scope, so yes, this is expected. Any nodes in a derived
template that aren't {% block %} or inside a {% block %} tag are
ignored or not output*.

An alternative would be to pass a list or dictionary of shared
translations to the template.

Cheers

Tom

* I must admit, I don't know precisely how template rendering handles
this. Certain tags, eg loading tag libraries will work fine. Any tag
that outputs anything will not, and any tag that sets things in the
context will not be in scope in other blocks.



Thanks for the reply.

I have to admit to finding this behaviour both counter-intuitive and 
somewhat perplexing.


This use case in particular would benefit greatly from allowing a 
variable to be declared in a global scope and used throughout a specific 
template. I'm not suggesting that global variables be inherited by 
derived templates mearly that you can have global variables in 
individual templates.


I guess I'll have to go with the list or dictionary approach although 
I'm not that happy about it as it feels like a bit of a hack to get 
round a problem that really shouldn't exist.


--
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: Speeding up test database creation

2012-11-27 Thread John Maxwell
Hm, I tried commenting out the line

'NAME': '/home/john/database.sqlite',

and it still seems to be just as slow, if not slower...

On Monday, November 26, 2012 5:56:30 AM UTC-8, Andres Reyes Monge wrote:
>
> The tutorial uses a sqlite file database not a in memory database, try 
> omitting the name parameter and it should speed things up

-- 
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/-/yeBx31qu6sQJ.
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: Seeding Foreign Key with known object with Class Based Views

2012-11-27 Thread Lee Hinde
Thanks Sergi; I just realized my earlier response to you is still sitting
in my drafts folder.  This is helpful.



On Mon, Nov 26, 2012 at 12:08 AM, Sergiy Khohlov  wrote:

> I'm proposing  to add form_valid  function  and make  next trick
>
>
>  def form_valid(self, form)
>  # avoid to early savind od the new address
> newaddress  = form.save(commit=False)
># you need to update object by correct client id value. Keep in
> mind that I'm writing  without django from brain only :-)
> newaddress.client_id = self.client_data.id
># now  we are ready to save new address
> newaddress.save()
> return http.HttpResponseRedirect(self.get_success_url())
>
> 2012/11/25 Lee Hinde :
> >
> > On Nov 24, 2012, at 2:41 PM, Sergiy Khohlov  wrote:
> >
> >> I would like to clarify:
> >>
> >> 1) you dont need to add client id to the form
> >> (this value is already  set in your view)
> >>
> >> 2) If you dont know how to  save address let ask
> >> Of course please add your code. I can not hack your PC and understand
> >> your problem.
> >>
> >> thanks, Serge
> >> 2012/11/24 Lee Hinde :
> >>> nt to seed the client id programmatically without presenting a form
>  field to enter what's a known value
> >>
> >> --
> >
> >
> > Thanks for sticking with this.
> >
> > class AddressForm(ModelForm):
> > def __init__(self, *args, **kwargs):
> > super(AddressForm, self).__init__(*args, **kwargs)
> >
> > self.fields['city'].widget.attrs["class"] = 'capme'
> > self.fields['zip'].widget.attrs["class"] = 'zipcode'
> > self.fields['state'].widget.attrs["class"] = 'input-mini
> upper_case'
> >
> > class Meta:
> > model = Address
> > fields =
> ('street_one','street_two','city','state','zip','response_type')
> > exclude = ('client',)
> >
> >
> > class AddressNew(CreateView):
> > model = Address
> > template_name = 'letters/address.html'
> > form_class = AddressForm
> > context_object_name = 'myfields'
> >
> > def get(self, request, *args, **kwargs):
> > set_current_page(request, "", "active", "", "")
> > return super(AddressNew, self).get(request, *args, **kwargs)
> >
> > def get_context_data(self, **kwargs):
> > context = super(AddressNew, self).get_context_data(**kwargs)
> > context['client_data'] =
> get_object_or_404(Client,pk=self.kwargs["pk"])
> > return context
> >
> >
> > Then, in the template I'm putting client_data.id into a hidden field to
> be returned when the form is saved.
> >
> >
> > --
> > 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.



How to log a user in automatically after a password reset?

2012-11-27 Thread JC Briar
When a user has forgotten their password, I use 
django.contrib.auth.views.password_reset to send an email containing a 
temporary link. When the user follows that link, I use 
password_reset_confirm to let them set a new password. So far, so good.

But password_reset_confirm doesn't automatically log the user in – as a 
result, immediately after resetting their password the user has to enter it 
again in order to log in. Most users, I suspect, would find this to be 
obnoxious.

How could this be fixed? According to the auth 
documentation,
 
I need to call authenticate() and login(). But where? I could supply my own 
SetPasswordForm subclass to password_reset_confirm, and make the calls in 
its save() method... except save() doesn't have access to the HttpRequest 
object that login() requires. Or I could define my own 
password_reset_complete view... but then I wouldn't have access to the 
username and password anymore. Are there other options?

-- 
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/-/g3FZyP_IK2EJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to get the source code of an url?

2012-11-27 Thread donarb
You're not parsing XML, it's HTML and it's not well formed, for example 
your title and author tags have closing tags that don't match. Your HTML 
needs to be valid XHTML before trying to use an XML parser on it. You might 
want to try something else to parse this, like Scrapy or Beautiful Soup.

On Tuesday, November 27, 2012 3:32:16 AM UTC-8, wbc wrote:
>
> I'm trying to parse an xml url with minidom. I have an url with my xml 
> data.
>
> This is my code:
>
> url = "http://myurl.com/wsname.asp";
> datasource = urllib2.urlopen(url)
>
> dom = parse(datasource)
> handleElements(dom)
>
> my handleElements function to parse xml:
>
> def handleElements(dom):
> Elements = dom.getElementsByTagName("book")
> for item in Elements:
> getText(item.getElementsByTagName("id")[0].childNodes)
> 
>
> My xml:
>
> 
>  
>  747
>  L'alchimiste
>  Paulo Cohelo 
>   
>  ...
>
> 
>
> I get no error, but no result!
>
> my handleElements() works fine because when I copy the same data from my 
> url put it in a string and use parseString instead of parse everything 
> works fine and I get my results.
>
> But when trying to openurl, Elements is empty and the loop is not even 
> started
>
> *
> *
>
> Seems that I need to get the sourcecode of the url (not it's content) 
> (like the view-source in chrome) How can I do that?
>
> 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/-/aYygL7amauAJ.
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: Retrieve current user id in urls.py

2012-11-27 Thread Daniel Roseman
On Tuesday, 27 November 2012 15:37:19 UTC, Peter Edström wrote:

> Hello,
>
> I've set up a user profile according to 
> thisand
>  now I'm trying to access the id of the currently logged in user in my 
> urls.py, like this:
>
> # urls.py  
>> from django.contrib.auth.decorators import login_required
>> from django.views.generic import list_detail 
>> from myproj.myapp.models import App1
>>
>
>> app1_info = {
>> 'queryset': App1.objects.filter(employee=)),
>> 'template_name': 'template.html',
>> }
>>
>> urlpatterns = patterns('',
>> (r'^logged_in/$', login_required(list_detail.object_list), app1_info),
>> )
>>
>
> In App1 I have a OneToOneField to my user profile, I want to list 
> everything in App1 filtered on the currently logged in user (employee = 
> current_user).
> Every example I find in the docs uses the request.user.username, but I 
> have no request method here.
>
> Any clues?
>


This isn't something you do in the urlconf. You do that in your view, where 
the current user is available already as `request.user`.
--
DR. 

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



Formset - PlainTextOutput-Widget?

2012-11-27 Thread Stefano Probst



Hi!
I have a Table with intitialdata from my database. It is implement with a 
formset. Every row i a form. Now I want to show a text (names) per row. The 
right in the picture (in black) exist, the red is to do. It should not be 
an TextInput-widget, it should be a plain text. Like a 
PlainTextOutput-Widget.
Does anyone have tips for me?

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



Hiring full-time hybrid developer/systems person at profitable, growing startup in Austin

2012-11-27 Thread Jason Ford
FeedMagnet  is a web platform for brand 
marketers (Top Gear, GE, Verizon, Logitech, etc.) providing social/content 
aggregation and curation for websites and event screens. We're growing, 
profitable, over 3 years old, and based in Austin, TX (with a couple remote 
employees). We're looking to add a generalist/hybrid to our development & 
systems team. Someone who can master our Python/Django core technology 
stack and also our Ruby/Chef cloud automation system – working with other 
smart people to solve interesting problems, optimize and automate systems, 
and implement new technology solutions.

We value aptitude over proficiency. The ability to learn a language or a 
tool and master it quickly is more valuable than rote knowledge up front. 
We also value clean code, self-motivation, and the ability to work well in 
a flat organization with minimal supervision.

Here's the full job description on GitHub: Developer and Operations 
Engineer

Luke Sneeringer  is the 
hiring manager. He's spoken the past couple years at 
PyCon. 
You can reach him and I both at jobs-t...@feedmagnet.com.

- Jason Ford
  Founder, FeedMagnet

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



Retrieve current user id in urls.py

2012-11-27 Thread Peter Edström
Hello,

I've set up a user profile according to 
thisand
 now I'm trying to access the id of the currently logged in user in my 
urls.py, like this:

# urls.py  
> from django.contrib.auth.decorators import login_required
> from django.views.generic import list_detail 
> from myproj.myapp.models import App1
>

> app1_info = {
> 'queryset': App1.objects.filter(employee=)),
> 'template_name': 'template.html',
> }
>
> urlpatterns = patterns('',
> (r'^logged_in/$', login_required(list_detail.object_list), app1_info),
> )
>

In App1 I have a OneToOneField to my user profile, I want to list 
everything in App1 filtered on the currently logged in user (employee = 
current_user).
Every example I find in the docs uses the request.user.username, but I have 
no request method here.

Any clues?

-- 
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/-/ekD5CB78L20J.
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 Oscar "Add to basket" issue

2012-11-27 Thread Achu
 
 Thanks 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/-/y1g9onBJuI0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



django/celery - celery status: Error: No nodes replied within time constraint

2012-11-27 Thread Hector Armando Vela Santos
I'm trying to deploy a simple example of celery in my production server, 
I've followed the tutorial in the celery website about running celery as 
daemon
http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html#daemonizing, 
and I got the config file in*/etc/default/celeryd*
*
*

 1 # Name of nodes to start
  2 # here we have a single node
  3 CELERYD_NODES="w1"
  4 # or we could have three nodes:
  5 #CELERYD_NODES="w1 w2 w3"
  6 
  7 # Where to chdir at start.
  8 CELERYD_CHDIR="/home/audiwime/cidec_sw"
  9 
 10 # Python interpreter from environment.
 11 ENV_PYTHON="/usr/bin/python26"
 12 
 13 # How to call "manage.py celeryd_multi"
 14 CELERYD_MULTI="$ENV_PYTHON $CELERYD_CHDIR/manage.py celeryd_multi"
 15 
 16 # # How to call "manage.py celeryctl"
 17 CELERYCTL="$ENV_PYTHON $CELERYD_CHDIR/manage.py celeryctl"
 18 
 19 # Extra arguments to celeryd
 20 CELERYD_OPTS="--time-limit=300 --concurrency=8"
 21 
 22 # Name of the celery config module.
 23 CELERY_CONFIG_MODULE="celeryconfig"
 24 
 25 # %n will be replaced with the nodename.
 26 CELERYD_LOG_FILE="/var/log/celery/%n.log"
 27 CELERYD_PID_FILE="/var/run/celery/%n.pid"
 28 
 29 # Workers should run as an unprivileged user.
 30 CELERYD_USER="audiwime"
 31 CELERYD_GROUP="audiwime"
 32 
 33 export DJANGO_SETTINGS_MODULE="cidec_sw.settings"

but if I run

celery status

in the terminal, i got this response:

Error: No nodes replied within time constraint

I can restart celery via the celeryd script provided in
https://github.com/celery/celery/tree/3.0/extra/generic-init.d/

/etc/init.d/celeryd restart
celeryd-multi v3.0.12 (Chiastic Slide)
> w1.one.cloudwime.com: DOWN
> Restarting node w1.one.cloudwime.com: OK

I can run

python26 manage.py celeryd -l info

and my tasks in django run fine, but if I let the daemon do its work i dont 
get any results, don't even errors in */var/log/celery/w1.log*

I know that my task has been registered because I did this from celery 
import current_app def call_celery_delay(request): print current_app.tasks 
run.delay(request.GET['age']) return HttpResponse(content="celery task 
set",content_type="text/html") and I get a dictionary in wich my task appear

{'celery.chain': <@task: celery.chain>, 'celery.chunks': <@task: 
celery.chunks>, 'celery.chord': <@task: celery.chord>, 'tasks.add2': 
<@task: tasks.add2>, 'celery.chord_unlock': <@task: 
celery.chord_unlock>,*'tareas.tasks.run': 
<@task: tareas.tasks.run>*, 'tareas.tasks.add': <@task: tareas.tasks.add>, 
'tareas.tasks.test_two_minute': <@task: tareas.tasks.test_two_minute>, 
'celery.backend_cleanup': <@task: celery.backend_cleanup>, 'celery.map': 
<@task: celery.map>, 'celery.group': <@task: celery.group>, 
'tareas.tasks.test_one_minute': <@task: tareas.tasks.test_one_minute>, 
'celery.starmap': <@task: celery.starmap>}

but besides that I get nothing else, no result from my task, no error in 
the logs, nothing. Can anyone tell me what can be wrong? You are my only 
hope...

-- 
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/-/mO6feEMUlrgJ.
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 Oscar "Add to basket" issue

2012-11-27 Thread David Winterbottom
Hi Achu,

Note that there is a google group for Oscar questions - that's a better 
place to ask questions such as this.
https://groups.google.com/forum/#!forum/django-oscar

Re your question: it looks like you are missing the basket middleware.  You 
need to add 'oscar.apps.basket.middleware.BasketMiddleware' to your 
'MIDDLEWARE_CLASSES' to have the basket instance assigned to the request 
object.

See 
http://django-oscar.readthedocs.org/en/releases-0.4/getting_started.html#settings
 
for more details on installing Oscar.

Cheers, David


On Sunday, November 25, 2012 12:54:51 PM UTC, Achu wrote:
>
>
>  Hi All,
>
>  I am trying to integrate ecommerce section  to my project using Django 
> Osacr . When I try to add one product to my basket I got this error
>
> AttributeError at /store/basket/add/
>
> 'WSGIRequest' object has no attribute 'basket'
>
> Request Method: POST  Request URL: http://localhost:8000/store/basket/add/  
> Django 
> Version: 1.4.2  Exception Type: AttributeError  Exception Value: 
>
> 'WSGIRequest' object has no attribute 'basket'
>
>  Exception Location: /myProject/apps/myecommerce/basket/views.py in 
> get_form_kwargs, line 160  Python Executable: /usr/bin/python  Python 
> Version: 2.7.3  Python Path: 
>
> ['/usr/local/lib/python2.7/dist-packages/requests/packages',
>
>
>
>
> Please help me to solve this issue..
>
> 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/-/AqTqO8ykJF0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How to get the source code of an url?

2012-11-27 Thread wbc


I'm trying to parse an xml url with minidom. I have an url with my xml data.

This is my code:

url = "http://myurl.com/wsname.asp";
datasource = urllib2.urlopen(url)

dom = parse(datasource)
handleElements(dom)

my handleElements function to parse xml:

def handleElements(dom):
Elements = dom.getElementsByTagName("book")
for item in Elements:
getText(item.getElementsByTagName("id")[0].childNodes)


My xml:


 
 747
 L'alchimiste
 Paulo Cohelo 
  
 ...
   


I get no error, but no result!

my handleElements() works fine because when I copy the same data from my 
url put it in a string and use parseString instead of parse everything 
works fine and I get my results.

But when trying to openurl, Elements is empty and the loop is not even 
started

*
*

Seems that I need to get the sourcecode of the url (not it's content) (like 
the view-source in chrome) How can I do that?

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/-/dLvj123olLUJ.
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 or am I doing it wrong? (trans tag)

2012-11-27 Thread Tom Evans
On Mon, Nov 26, 2012 at 9:43 PM, Some Developer
 wrote:
> On 10/11/12 21:49, Some Developer wrote:
>>
>> In the documentation it is quite clear that the following syntax is
>> correct in templates:
>>
>> {% load i18n %}
>>
>> {% trans "my_string" as blah_string %}
>>
>> {{ blah_string }}
>>
>> etc etc.
>>
>> This works fine if the original trans tag is inside a block but then the
>> blah_string variable is only valid within that block. If you place the
>> trans tag in a global position (outside of any blocks) the blah_string
>> variable does not work when you try and use it in a block (that is any
>> block). I am using Django 1.4.2 and think this behaviour is somewhat
>> strange given the documentation for this particular feature. Surely you
>> should be able to declare the trans tag outside of any block as the
>> chances are that you will want to use the blah_string variable in more
>> than one block (I often have three or four blocks per page for various
>> things).
>>
>> So is this a bug or am I doing something wrong?
>
>
> Any comments on this at all? I'm still not entirely sure if this behaviour
> is intentional or not.
>

Templates have scope, so yes, this is expected. Any nodes in a derived
template that aren't {% block %} or inside a {% block %} tag are
ignored or not output*.

An alternative would be to pass a list or dictionary of shared
translations to the template.

Cheers

Tom

* I must admit, I don't know precisely how template rendering handles
this. Certain tags, eg loading tag libraries will work fine. Any tag
that outputs anything will not, and any tag that sets things in the
context will not be in scope in other blocks.

-- 
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 1.6.0: admin pages not using unicode methods declared in my model

2012-11-27 Thread Anton Baklanov
Hi Héctor.

check this out
https://docs.djangoproject.com/en/dev//topics/python3/#str-and-unicode-methods

--
Regards,
Anton Baklanov

-- 
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: Vim Django template syntax checker

2012-11-27 Thread Tom Evans
On Mon, Nov 26, 2012 at 3:39 PM, Some Developer
 wrote:
> I've been using Syntastic along with Vim for Django development for sometime
> but I'd like to see if I could improve my Vim configuration. The problem
> with Syntastic is that it does not work too well when checking partial HTML
> documents (which is often the case with Django because of template
> inheritance) and it certainly does not like the Django template tags in HTML
> documents.
>
> Does anyone know of a decent syntax checker for Vim that has full support
> for Django templates and partial HTML documents?
>
> As an aside I'm always on the look out for ways to improve my Vim
> configuration for Python / Django development so if you have any tips or
> plugins that you use to make development easier I'm all ears :).
>

It's not perfect, but ft=django should get you some reasonable
template highlighting, and ft=htmldjango will get mixed mode template
and html highlighting. It's built-in to my version of vim, 7.3.632.

For general python syntax, I use an updated one from vim.org:

http://www.vim.org/scripts/script.php?script_id=790

and have "let python_highlight_all=1" in my .vimrc

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: how should I get the request object?

2012-11-27 Thread Wade Williams
I share the disdain for global variables as well.

I'm fairly new to Django, and what I'm not understanding is when the 
request object is available for inclusion. I have a custom session backend 
that I've built in order to support a legacy user model and session table 
-- when I tried to simply add the request parameter from this backend, I 
got number of parameter errors, so it seems that it isn't totally available 
all of the time. 

Im currently patching this with a similarly horrible settings.request var 
that simply contains the request, so an import of settings makes this work.

But again, that's icky, and horrible, and no, so when exactly can you add 
the request parameter, and when can't you ? 


Thanks so much for the clarification. Lots of search attempts and still not 
understanding when it's automatically passed in as a parameter / how that 
even gets passed to the method. As far as I can tell, middleware and views 
both have access to the request, but is it simply the wrong thing to try 
and access the request in some other place ? 



On Monday, November 26, 2012 4:47:42 PM UTC-7, Russell Keith-Magee wrote:
>
>
> This is an often proposed solution to the problem, but one that I can't 
> recommend to anybody.
>
> The very name of your proposed middleware -- GlobalRequest -- should point 
> at why it's a bad idea. You've just defined a global variable, and you've 
> architected your entire system around the availability around that 
> global. All the usual problems that are associated with global variables 
> will apply to what you have done here.
>
> You say you've done this because it is "inconvenient" to make a request 
> object available deep within the call stack?   Frankly, I call BS. Making 
> sure the request (or data from the request) is available where it is needed 
> is just good planning. Yes, good planning requires more work -- but it's 
> also work that results in a stronger product at the end of the day, because 
> you aren't building your code on a foundation of global variables. 
>
> Adding a request argument to a few functions isn't *that* hard. Suggesting 
> that you should put everything in global variables because it's too hard to 
> pass around some arguments… I don't even know where to start.
>
> Yours,
> Russ Magee %-)
>
> On Tue, Nov 27, 2012 at 2:39 AM, Mike S >wrote:
>
>> Sometimes it is very inconvenient to make the `request` object available 
>> deep in the call stack, so I wrote a short middleware to work around this 
>> issue:
>>
>> http://djangosnippets.org/snippets/2853/
>>
>>
>> On Monday, November 26, 2012 5:16:01 AM UTC-5, Miaobing Jiang wrote:
>>>
>>> how should I get the request object when I need that object in some 
>>> places rather than in the view for each view has request as its first 
>>> parameter?
>>>
>>  -- 
>> 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/-/WiwLtFzrh1QJ.
>>
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com .
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Pzw1YdS7NhcJ.
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 1.5 custom User model error. "Manager isn't available; User has been swapped"

2012-11-27 Thread Pankaj Singh
Hi,

You need to unregister `User` model from admin site before registering new one.

admin.site.unregister(User)
admin.site.register(CustomUser, UserAdmin)

Please have a look at http://stackoverflow.com/a/2270704/353550

Pankaj Singh
http://about.me/psjinx


On Mon, Nov 26, 2012 at 9:14 PM, Benoit Petit
 wrote:
> Hi,
>
> I extend the django user model as described in the dev doc. I wan't to keep
> most of the original User model features so I extend the AbstractUser class.
> I've defined in settings.py:
>
> AUTH_USER_MODEL = 'myapp.CustomUser'
>
> My user class:
>
> class CustomUser(AbstractUser):
>   custom_field = models.ForeignKey('OtherModel')
>   objects = UserManager()
>
> Everything seems to work fine but when I try to make it managed by the admin
> site:
>
> admin.site.register(CustomUser, UserAdmin)
>
> I get this error on the admin CustomUser creation page (after validation of
> the password confirmation form):
>
> AttributeError: Manager isn't available; User has been swapped for
> 'myapp.CustomUser'
>
> The point is that I need this model managed by the admin site in order to
> have the same creation process as with the original User model (two step
> process with password validation).
>
> Thanks for any reply
>
> --
> 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/-/8VtQghtcMFgJ.
> 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.



Fwd: Ignoring _ character an showing % character in the Django

2012-11-27 Thread Satinderpal Singh
How do i write the column names in the django models so that it
ignores _ character and show % in the output label of templates.

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


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

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



Django from UML diagram

2012-11-27 Thread Abbass Khalil
Hello,
I'm a new to Django , and I'm looking for UML Tools that can generate 
Django site from UML diagram.

-- 
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/-/sN-Z0azWkDYJ.
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: Javascript in external file not working

2012-11-27 Thread lokesh

Hi,

Please check the DEBUG is True or False in settings. If the DEBUG is True 
it will not serve the static files in development server, So you need to 
serve the static files from some other server or you need to change the 
DEBUG level as False if you are in development mode.

Thanks,
Lokesh

On Tuesday, 27 November 2012 04:34:39 UTC+5:30, Loai Ghoraba wrote:
>
> Hi all
>
> When I have a script like this:
>  window.onload=function f(){}  it is working fine. but 
> when I create an external js file and put it within the static directory, 
> and call the function like this
> 
>  window.onload=f 
>
> It is not working at all. (by the way the url is mapped correctly to the 
> js file "I tested it via viewing the source of the web page")
>  
> 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/-/kQoLPu8raMkJ.
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.



pyodbc utf-8

2012-11-27 Thread Nebros
Hello community
 
i have a next problem. i have connected with pyodbc to a mssql db. i read 
values out of it, all works, but i have problems with "ä" "ö" and "ü".
on my html.page i made this into the header:
 

 
on all my pages this umlauts works, but not the values of the pyodbc...
when i only give out the row, i become something like this: Hansj\xf6rg 
,but it have to be this: Hansjörg
when i print this value out into a table, the field keeps empty.
 
it must be a problem of pyodbc, but i dont know how to fix it. i tryed 
something like this:
 
views.py 
def kundendaten(request):
ret = request.POST
form = ret['kunde']
conn = pyodbc.connect('DRIVER={SQL 
Server};SERVER=MAURITIUS;DATABASE=baan5c;UID=portal;PWD=P0rtalReader')
cursor = conn.cursor()
cursor.execute("SELECT x.t_name, x.t_user, y.t_mail FROM tttaad20 
as x, tttcmf20 as y WHERE (x.t_name = y.t_name) AND (x.t_user = 
'%s')"%form)
rows = unicode(cursor.fetchall(), 'utf-8')
now = datetime.datetime.now()
return render_to_response("kundendaten.html", { 'rows': rows, 
'current_date': now, 'form': form}, 
context_instance=RequestContext(request))
-
but the page gave this error:
TypeError at /kundendaten/

coercing to Unicode: need string or buffer, list found

 
i dont know how i can fix my problem... what i use:
win7 32bit
python 2.7
django 1.4.1
pyodbc 3.0.6
 
can someone halp me to fix this problem?

-- 
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/-/mu-OphC5QjcJ.
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.