Tuesday, July 30, 2013

Re: User Permissions

On Tue, 30 Jul 2013 16:39:27 -0300
Carlos Leite <caduado@gmail.com> wrote:

> Django do not have a "per-row" permission system in the box.
> You will have to create that by yourself.

That is slightly incorrect - Django _does_ have foundation for object (row) level permission system. There is just no default implementation in standard auth
module. User methods get_group_permissions, get_all_permissions, has_perm and has_perms does accept optional second parameter "obj" which if set anything else but None will check permission for spesific object instead of model.

<https://docs.djangoproject.com/en/1.5/topics/auth/customizing/> contains more info about customizing authentication backend.

> You may start adding something like "owner" to your content type.
> this field will be somthing like
>
> owner = models.ForeignKey(User)
>
> then, based on "request.user" in your views (for instance),
> you may filter objects using .objects.filter(owner=requet.user)
>
> hope that helps.
>
>
>
> On Tue, Jul 30, 2013 at 12:39 PM, <ghinfey@screenscene.ie> wrote:
> > Hi All,
> >
> > I have a very simple django site.
> > The site allows the administrator to create a model which contains 5 text
> > items and then stores that to the sqlite database.
> > I have also created a user login page from a tutorial on youtube.
> > I want to be able to control which model the logged in user has access to.
> > For instance I want user "John" to be able to see logged model entries 1-5
> > and not 6-7.
> > Is this simple? How should I go about setting permissions?
> >
> > Any help is appreciated. If you would like specific code please ask.
> >
> > Thanks
> >
> >
> >
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to django-users+unsubscribe@googlegroups.com.
> > To post to this group, send email to django-users@googlegroups.com.
> > Visit this group at http://groups.google.com/group/django-users.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
>
>
>
> --
> --------------------
> Cadu Leite
> twitter: @cadu_leite
> http://people.python.org.br/
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--

Jani Tiainen

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Using standard Django admin User forms for Custom User model?

Hi,

When you add a Django User through the admin, it presents you with a initial screen to enter a username and password  (/admin/auth/user/add/), and then handles hashing for you.

Also, when you go to edit a User, it gives you a Change Password form (e.g. /admin/auth/user/2/password/)

I'm using a custom user model in my Django app, by inheriting from AbstractCustomer.

If I add this to the admin now, password is just a standard textbox, and obviously if I create a user through that, I can't login since I assume it's not hashing the password.

Is there any way I can use the normal Django User admin forms with a custom User model?

Secondly, I tried creating a user via the create_user() method on my custom User object - I still wasn't able to login to the admin using that username/password, which I thought was weird.

Cheers,
Victor

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Re: Django Dashboard


On Tue, Jul 30, 2013 at 3:16 PM, Charly Román <chack14rock@gmail.com> wrote:

You can try with pydashie, a python port of ruby version:
https://github.com/evolvedlight/pydashie


Except that's Flask, not Django.


Cheers,
AT

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Re: Help getting started: Which server setup for a beginner? Apache? lighttpd? To use or not virtualenv?

Thanks everyone!
This was all very useful advice. Wish I had known all this days ago...




On Tue, Jul 30, 2013 at 9:00 AM, Javier Guerra Giraldez <javier@guerrag.com> wrote:
On Tue, Jul 30, 2013 at 10:48 AM, Jared Nielsen <nielsen.jared@gmail.com> wrote:
> I started setting up Apache with mod_wsgi, but ran into innumerable config
> errors. After some Googling about, I found a number of suggestions to use
> lighttpd instead. Installed that and more troubleshooting. And what's this
> about gunicorn?


if you're a total beginer, and doesn't have any previous experience
setting up and deploying web servers, I'd advice to just avoid the
issue until you're comfortable with Django itself.

IOW: stay with the development server (the one that runs with "python
manage.py runserver").  When you have a project or two that want to
deploy, then start planning your deployment strategy.

in any case, i think many people agree that gunicorn is one of the
easiest to setup.  I myself like nginx+uWSGI, and many others like
Apache+mod_wsgi, but none of these are needed for development.

--
Javier

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/W6r8f-Ec7lY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.





--
http://jarednielsen.com
http://thehelloworldprogram.com
http://dototot.com


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Re:

Shouldn't you dedicate a specific path to your flat pages, like this: (r'^pages/', include('django.contrib.flatpages.urls'))? The documentation also indicates that you can use a "catchall" pattern, but AFTER any other URL patterns.

I am not a Django expert by any mean, but I don't think (r'', include('django.contrib.flatpages.urls')) works, since the regex is empty...

Regards,
Phil

On Tuesday, July 30, 2013 1:02:53 PM UTC-3, Robin Lery wrote:


---------- Forwarded message ----------
From: Robin Lery <robi...@gmail.com>
Date: Tue, Jul 30, 2013 at 9:22 PM
Subject:
To: django...@googlegroups.com


Hello,
I am stuck at a point where i should be able to type in a search query on the page and it django should get back a list of matching pages if any. But it doesnt show me any pages, even though its there, and gives me an erros:

Page not found (404)

No FlatPage matches the given query.


Please point me as to where am doing wrong. Thank you.

my views.py:

from django.http import HttpResponse
from django.template import loader, Context
from django.contrib.flatpages.models import FlatPage

def search(request):
query = request.GET['q']
resuts = FlatPage.objects.filter(content__icontains=query)
template = loader.get_template('search/search.html')
context = Context({
'query':query,
'resuts':resuts
})
response = template.render(context)
return HttpResponse(response)

urls.py:

from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)),
    (r'^tinymce/(?P<path>.*)$', 'django.views.static.serve', { 'document_root': 'C:/Users/Kakar/web/cms/static/js/tinymce/' }),
    (r'', include('django.contrib.flatpages.urls')),
    (r'^search/$', 'search.views.search'),
)

settings.py:
In the installed-apps, I have installed 'search'.

default.html:

<html>
<head>
<title>{{ flatpage.title }}</title>
</head>
<body>
<form method="get" action="/search/">
{% csrf_token %}
<p><label for="id_q">Search:</label>
<input type="text" name="q" id="id_q" />
<input type="submit" value="Submit" /></p>
</form>
<h1>{{ flatpage.title }}</h1>
{{ flatpage.content }}
</body>
</html>

search.html:

<html>
<head>
<title>Search</title>
</head>
<body>
<p>You searched for "{{query}}"; the results are listed below.</p>
{% if results %}
<ul>
{% for page in results %}
<li>
<a href="{{page.get_absolute_url}}">{{page.title}}</a>
</li>
{% endfor %}
</ul>
{% else %}
<p>No results.</p>
{% endif %}
</body>
</html>


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Re: User Permissions

Take a look at django-guardian. (http://pythonhosted.org/django-guardian/)

John

On Jul 30, 2013, at 12:39 PM, Carlos Leite <caduado@gmail.com> wrote:

> Django do not have a "per-row" permission system in the box.
> You will have to create that by yourself.
>
> You may start adding something like "owner" to your content type.
> this field will be somthing like
>
> owner = models.ForeignKey(User)
>
> then, based on "request.user" in your views (for instance),
> you may filter objects using .objects.filter(owner=requet.user)
>
> hope that helps.
>
>
>
> On Tue, Jul 30, 2013 at 12:39 PM, <ghinfey@screenscene.ie> wrote:
>> Hi All,
>>
>> I have a very simple django site.
>> The site allows the administrator to create a model which contains 5 text
>> items and then stores that to the sqlite database.
>> I have also created a user login page from a tutorial on youtube.
>> I want to be able to control which model the logged in user has access to.
>> For instance I want user "John" to be able to see logged model entries 1-5
>> and not 6-7.
>> Is this simple? How should I go about setting permissions?
>>
>> Any help is appreciated. If you would like specific code please ask.
>>
>> Thanks
>>
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscribe@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>
>
>
> --
> --------------------
> Cadu Leite
> twitter: @cadu_leite
> http://people.python.org.br/
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Re: User Permissions

Django do not have a "per-row" permission system in the box.
You will have to create that by yourself.

You may start adding something like "owner" to your content type.
this field will be somthing like

owner = models.ForeignKey(User)

then, based on "request.user" in your views (for instance),
you may filter objects using .objects.filter(owner=requet.user)

hope that helps.



On Tue, Jul 30, 2013 at 12:39 PM, <ghinfey@screenscene.ie> wrote:
> Hi All,
>
> I have a very simple django site.
> The site allows the administrator to create a model which contains 5 text
> items and then stores that to the sqlite database.
> I have also created a user login page from a tutorial on youtube.
> I want to be able to control which model the logged in user has access to.
> For instance I want user "John" to be able to see logged model entries 1-5
> and not 6-7.
> Is this simple? How should I go about setting permissions?
>
> Any help is appreciated. If you would like specific code please ask.
>
> Thanks
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
--------------------
Cadu Leite
twitter: @cadu_leite
http://people.python.org.br/

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.