Re: Does Django offers a way to generate data grid from database table like web2py

2014-11-28 Thread Timothy W. Cook
The Django 'admin' section provides this functionality.


On Fri, Nov 28, 2014 at 2:55 AM, Sarbjit singh 
wrote:

> What web2py GRID does is, that it takes the SQL table/query as argument,
> and return the records satisfying the query.
>
> Records which are returned are seen in bootstrap enabled table with
> features having pagintation, sorting, search, ability to edit/delete/view
> individual record, add new record etc.
>
> (See for link - web2py grid snapshot as well
> 
> )
>
> *What I want?*
>
> I just wanted to have the end result similar to as of web2py grid where
> records (satisfying any query) can be seen inside a tabular form with the
> ability to search, sort, edit/delete individual record etc.
>
> Since, I am new to Django, I am not sure if Django provides such a thing
> out of box or any third party app provides this capability.
>
> If you just click on web2py link above, snapshot of web2py grid will give
> you a clear idea.
>
> -Sarbjit
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/719e8cc9-4c8e-4aaa-900b-a030c73eb1e7%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 


Timothy Cook
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
MLHIM http://www.mlhim.org

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3XNJJrbLU_PLiEnOPb1%3D-7NgU3ktAWnO3V_7hU_0RcqDg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: i want to know how to use SlugField with slugify to generate url for detail_blog page without using get_absolute_url

2014-11-28 Thread aRkadeFR

Hello Kanchan,

Sorry to say, I didn't get your question. I don't see any get_absolute_url
in your email.

And your code seems legit.

Could you provide more information about the problem?

Thank you,

aRkadeFR

On 11/27/2014 10:26 PM, Kanchan Prasad wrote:

my model.py is
class BlogPost(models.Model):
title= models.CharField(max_length=100)
text = models.TextField()
created_on   = models.DateTimeField(auto_now_add=True,auto_now=False)
updated_on   = models.DateTimeField(auto_now_add=False,auto_now=True)
submitted_by = models.ForeignKey(User)
slug = models.SlugField(max_length=100,unique=True)
def __str__(self):
return self.title
def save(self, *args, **kwargs):
if not self.id:
self.slug = slugify(self.title)
super(BlogPost,self).save(*args,**kwargs)

urls.py

url(r'^profile/latest-quotation/(?P[\w-]+)/$',add_view, 
name='add_view'),


views.py
def add_view(request,slug):
blog = get_object_or_404(BlogPost, slug=slug)
com_form = CommentForm(request.POST or None)
if com_form.is_valid():
form = com_form.save(commit=False)
form.blogpost = blog
form.name = request.user
form.save()
return HttpResponseRedirect(reverse('socialnetwrok:add_view'))
return 
render(request,'socialnetwork/detailview.html',{'blog':blog,'com_form':com_form})


my template where i am using it
{% for quotation in latest_quotation_list %}

{{quotation.title}}


{{quotation.text|truncatewords:100}}

please help me i need help
--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to django-users+unsubscr...@googlegroups.com 
.
To post to this group, send email to django-users@googlegroups.com 
.

Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/45cb3726-5fd5-469b-b076-0eab453b95b5%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/547838C3.9050108%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Does Django offers a way to generate data grid from database table like web2py

2014-11-28 Thread aRkadeFR

Hello,

From my point of view, you're asking for a similar MySQL admin
with bootstrap style? Why not directly get a DB admin like pgadmin
or so?

The most similar thing will be the django admin as Timothy stated.

Thank you,

aRkadeFR

On 11/28/2014 05:55 AM, Sarbjit singh wrote:
What web2py GRID does is, that it takes the SQL table/query as 
argument, and return the records satisfying the query.


Records which are returned are seen in bootstrap enabled table with 
features having pagintation, sorting, search, ability to 
edit/delete/view individual record, add new record etc.


(See for link - web2py grid snapshot as well 
)


*What I want?*

I just wanted to have the end result similar to as of web2py grid 
where records (satisfying any query) can be seen inside a tabular form 
with the ability to search, sort, edit/delete individual record etc.


Since, I am new to Django, I am not sure if Django provides such a 
thing out of box or any third party app provides this capability.


If you just click on web2py link above, snapshot of web2py grid will 
give you a clear idea.


-Sarbjit

--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to django-users+unsubscr...@googlegroups.com 
.
To post to this group, send email to django-users@googlegroups.com 
.

Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/719e8cc9-4c8e-4aaa-900b-a030c73eb1e7%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/547839C9.8070402%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Multiple levels of user in django application

2014-11-28 Thread Anju SB
Dear Friends,

I want to develop a django based GIS web application.  In my application 
there are different levels of users namely station level user, circle level 
user etc.  Each user details are provided in different table,  How can I 
map/ relate the user with these tables.  Pleas help me to solve this issue. 
 

Thanks & Regards,
   
   Anju

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/db33aaea-10f5-4755-84dd-3508514ac709%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using data migration to create initial users errors

2014-11-28 Thread Guillaume Cisco
Did you find a way to use method create_user in a data migration?
I can't see a way to import the manager for using it.

Le jeudi 16 octobre 2014 23:19:43 UTC+2, Collin Anderson a écrit :
>
> Hi Ben,
>
> Yes, the custom manager objects are not available within migrations. I bet 
> you might be able to import the UserManager and stick it on the User model 
> yourself.
>
> Collin
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f7024bc8-e81f-4f66-8604-58c870963546%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


PDF not saving on Django using open()

2014-11-28 Thread George Rogers


trying to save files on static after pdfcrowd provides the file. I've tried 
adding the path to be specific it doesn't work.

from PyPDF2 import PdfFileMerger, PdfFileReaderfrom django.template import 
RequestContextfrom django.shortcuts import render_to_response, get_object_or_404
import pdfcrowdfrom django.http import HttpResponsefrom wildling.models import 
*from django.shortcuts import redirect
def home(request, template_name='brochures_form.html'):
context = RequestContext(request)
if request.method == 'POST':
context['name'] = name = request.POST.get('name','')
context['adults'] = adults = request.POST.get('adult','')
context['children'] = children = request.POST.get('child','')
context['infant'] = infant = request.POST.get('infant','')
context['start_date'] = start_date = request.POST.get('start-date','')
context['end_date'] = end_date = request.POST.get('end_date','')
context['country'] = country = request.POST.get('country','')
context['destination'] = destination = 
request.POST.get('destination','')
context['price'] = price = request.POST.get('price','')
context['background_photo'] = background_photo = 
request.POST.get('background-photo','')
context['from_user'] = from_user = request.POST.get('from','')
context['iteniary'] = iteniary = request.POST.get('iteniary','')
context['days'] = days = request.POST.get('days','')
context['destination'] = destination = 
request.POST.get('destination','')
context['property_name'] = property_name = 
request.POST.get('property','')
context['content'] = content = request.POST.get('content','')
context['iteniary'] = iteniary = request.POST.get('iteniary','')

#destinations and countries background photo created by not set
brochure = Brochures(name=name, ref_id="xxx", adults=adults, 
children=children, infant=infant,
price=price, content=content, iteneary=iteniary)
brochure.save()

request.session['br_id'] = brochure.id
return redirect('http://wilderness.maasaimara.com/generate/')

return render_to_response(template_name, context, )


def generate_pdf(request, br_id, num):
context = RequestContext(request)
list_of_pages = ["http://127.0.0.1:8000/page"+x+"/"; for x in list("123456")]
pdfs = ["page"+x+".pdf" for x in list("123456")]
merger = PdfFileMerger()
client = pdfcrowd.Client("samuel254", "86e62657536d264e8217478d56abd72e")
br_id = response.session["br_id"]
brochure = Brochures.objects.get(br_id)

# set HTTP response headers
response = HttpResponse(mimetype="application/pdf")
response["Cache-Control"] = "max-age=0"
response["Accept-Ranges"] = "none"
response["Content-Disposition"] = "attachment; filename=document-output.pdf"

for num in list("123456"):
path = 
"/home/samuel/Documents/Documents/wilderness/wilderness/static/pdf/"
html = "http://wilderness.maasaimara.com/{1}/page{0}/".format(num,br_id)
pdf = "page{0}.pdf".format(num)
pdf_file = client.convertURI(html)
local = open(pdf,'w')
local.write(pdf_file)
local.close()
merger.append(open(pdf, 'r+b'))

merger.write("document-output.pdf")
response.write(merger)
return response

The urls.py

from django.conf import settingsfrom django.conf.urls import patterns, include, 
urlfrom django.conf.urls.static import staticfrom django.views.generic import 
TemplateView
from django.contrib import adminfrom views import generate_pdf,home

urlpatterns = patterns("",
url(r"^$", home, name="home"),
url(r"^(?Pd{4})/page(?P[0-9]+)/", generate_pdf),

url(r"^admin/", include(admin.site.urls)),
url(r"^account/", include("account.urls")),)

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

I need to confirm where the file is going, it's not crashing and returns 
the document-output.pdf but it's blank.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cfc4823d-1ee3-475d-be96-8e183b01830e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using data migration to create initial users errors

2014-11-28 Thread Markus Holtermann
Hey all together,

unfortunately there isn't a way to add users through their manager in 
RunPython yet. The only solution I can see so far, is doing it manually, 
e.g. doing what your `create_user` method does inside RunPython. There is a 
patch though #23822 [1] that needs some tests and docs, but hopefully makes 
it into 1.8.

[1] https://code.djangoproject.com/ticket/23822

/Markus

On Friday, November 28, 2014 11:47:24 AM UTC+1, Guillaume Cisco wrote:
>
> Did you find a way to use method create_user in a data migration?
> I can't see a way to import the manager for using it.
>
> Le jeudi 16 octobre 2014 23:19:43 UTC+2, Collin Anderson a écrit :
>>
>> Hi Ben,
>>
>> Yes, the custom manager objects are not available within migrations. I 
>> bet you might be able to import the UserManager and stick it on the User 
>> model yourself.
>>
>> Collin
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/39df0514-e249-467c-8ad6-c0ff1f6151b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Test client to a redirect requiring a login doesn't set redirect_chain properly? [2nd follow-up]

2014-11-28 Thread Tim Chase
On 2014-11-27 20:32, Tim Chase wrote:
> As a bit of follow-up information, if I use runserver and browse to
> the view, it redirects me to /admin/common/region/add/ but it
> displays as the login screen.  Am I missing why this wouldn't do a
> redirect to my named login URL?

A careful reading of [1] suggests that the admin provides its own
login page via the login_template setting: "Path to a custom template
that will be used by the admin site login view."  It apparently
renders this at the URL of the destination page rather than
redirecting to the regular (contrib.auth or some named auth-URL) and
providing a "next={{original_url}}"

Is there any way to get the admin to just use the contrib.auth login
page that I already have in place?

-tkc

[1]
https://docs.djangoproject.com/en/1.6/ref/contrib/admin/#django.contrib.admin.AdminSite.login_template



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20141128064754.48bc95a2%40bigbox.christie.dr.
For more options, visit https://groups.google.com/d/optout.


nested inclusion tag that takes context

2014-11-28 Thread Florian Auer
Hi folks

I have written 2 simple inclusion tags where one is nested inside the other.
(settings.html uses the {% version %} tag)

Both ones refer to the request object inside the context.
The reason for this is, that I have a middleware that sets some flag 
variables to determine what type of client i'm serving.

code example:
@register.inclusion_tag('inclusion/settings.html', takes_context=True)
def settings(context):
request = context['request']

#needed for the template
return {'is_mobile:': request.is_mobile,
'is_tablet': request.is_tablet,
'is_phone': request.is_phone,
'user': request.user
}
@register.inclusion_tag('inclusion/version.html', takes_context=True)
def version(context):
request = context['request']

version_nr = '0.0.0'
version_date = '01.01.1970'
f = open(os.path.join(BASE_DIR, 'version.txt'), 'r')
for line in f:
token = line.split(':')
if token[0] == 'version':
version_nr = token[1]
elif token[0] == 'datum':
version_date = token[1]
f.close()

return {'is_mobile:': request.is_mobile,
'is_tablet': request.is_tablet,
'is_phone': request.is_phone,
'version_nr': version_nr,
'version_date': version_date
}

If i now user the {% version %} tag inside the settings.html th system 
complains that context['request'] is not defined for the version() function.
It seems I can fix this by putting the request object into the return 
object of the settings funktion like:
@register.inclusion_tag('inclusion/settings.html', takes_context=True)
def settings(context):
request = context['request']

return {'request': request,
'is_mobile:': request.is_mobile,
'is_tablet': request.is_tablet,
'is_phone': request.is_phone,
'user': request.user
}
But is this the correct way?


Also interesting is:
If I leave out the addiotion sending the request insite the result of 
settings back, the context object inside the version function seems to have 
an unnamed property at the second index that may to be some kind of request 
object.

[{'None': None, 'True': True, 'False': False}, 
 {'is_mobile:': True, 'user': >, 'is_phone': 
False, 'csrf_token': .__proxy__ object at 
0x054A7828>, 'is_tablet': True}
]





-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54e95b28-adb2-46af-8e5d-d55b0d60780c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Constructing query

2014-11-28 Thread termopro
I have 2 models:
Companies and Tags.

A company may have several tags associated with it, so Tag contains 
many-to-many relation to Company.

If i'd like to get Tags starting with "A" i'd write:
tags = Tag.objects.filter(name__startswith='A').order_by('name').all()

But how do i get the list of tags (beginning with letter 'A') which are 
associated with at least 1 company ?

In sql it would be something like:

SELECT * FROM
tag
WHERE
name LIKE 'A%' AND id IN (SELECT tag_id FROM tag_organization)


*?*

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/971edb11-b972-4163-83bf-90f0435985fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Does Django offers a way to generate data grid from database table like web2py

2014-11-28 Thread donarb
On Wednesday, November 26, 2014 10:33:25 PM UTC-8, Sarbjit singh wrote:
>
> Hi,
>
> I have been using web2py for sometime. I am exploring Django now, in 
> web2py there is a way to generate data grids (using SQLFORM.grid) which 
> generates very net grid based on the data model with support to add new 
> field/edit record/delete record/view record etc.
>
> Does Django (or any other package based on django) provides this 
> capability?
>
> Regards,
> Sarbjit
>


There's a couple of Django packages that provide datagrid capability. 
Haven't used any of them, so I can't say what's best.

https://github.com/djblets/djblets
https://github.com/agiliq/django-datagrid


 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/17a5cdff-962e-43d2-bd62-0578446f6c70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple levels of user in django application

2014-11-28 Thread Scot Hacker

On Friday, November 28, 2014 3:16:41 AM UTC-8, Anju SB wrote:
>
> Dear Friends,
>
> I want to develop a django based GIS web application.  In my application 
> there are different levels of users namely station level user, circle level 
> user etc.  Each user details are provided in different table,  How can I 
> map/ relate the user with these tables.  Pleas help me to solve this issue. 
>  
>

I think of situations like this as having two prongs:

1) Various groups have various permission levels in portions of the project
2) Group members may have additional data/fields associated with their 
profiles.

For #1, use Django's Groups system to assign group memberships and 
 permissions as needed. You can start using those permissions throughout 
your project immediately.

For #2, you can create additional profile sub-types, keyed to a base 
profile. e.g. maybe everyone gets a UserProfile, while instructors also get 
an InstructorProfile that's FK'd to UserProfile. You can use post-save 
signals or other mechanisms to make sure that everyone has the right 
additional profile fields. Now let's say a user is looking at their profile 
editor - you could say "If user in group Instructors, also let them edit 
their associated InstructorProfile."

There are many ways to skin this cat...

./s

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d4ee0831-d6c9-4c9e-8c90-61ef7b140292%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple levels of user in django application

2014-11-28 Thread Anju SB
Thank you Scot Hacker.   
 But my application needs more than one user from the same group. 





On Friday, 28 November 2014 23:24:34 UTC+5:30, Scot Hacker wrote:
>
>
> On Friday, November 28, 2014 3:16:41 AM UTC-8, Anju SB wrote:
>>
>> Dear Friends,
>>
>> I want to develop a django based GIS web application.  In my application 
>> there are different levels of users namely station level user, circle level 
>> user etc.  Each user details are provided in different table,  How can I 
>> map/ relate the user with these tables.  Pleas help me to solve this issue. 
>>  
>>
>
> I think of situations like this as having two prongs:
>
> 1) Various groups have various permission levels in portions of the project
> 2) Group members may have additional data/fields associated with their 
> profiles.
>
> For #1, use Django's Groups system to assign group memberships and 
>  permissions as needed. You can start using those permissions throughout 
> your project immediately.
>
> For #2, you can create additional profile sub-types, keyed to a base 
> profile. e.g. maybe everyone gets a UserProfile, while instructors also get 
> an InstructorProfile that's FK'd to UserProfile. You can use post-save 
> signals or other mechanisms to make sure that everyone has the right 
> additional profile fields. Now let's say a user is looking at their profile 
> editor - you could say "If user in group Instructors, also let them edit 
> their associated InstructorProfile."
>
> There are many ways to skin this cat...
>
> ./s
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5750f591-276b-49da-bfc5-61c4d0a51f07%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.