Monday, October 31, 2016

Minify HTML in Django

Hi,

Is there an optimal and efficient way to minify HTML in Django?

I tried using django-htmlmin but it's affecting the performance. 

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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f7886579-ff7f-4be2-8f25-c12e3e010899%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Form Saving Related Issues

Thank you sir for the reply..
But I am using HTML forms then what should I do...?  I want error message should display instantly when user enter existing mail id..!


On 1 Nov 2016 12:05 am, "Andromeda Yelton" <andromeda.yelton@gmail.com> wrote:
If your model has the uniqueness constraint, you should get a form error message automatically. If you don't want your model to have that constraint but you still want your form to throw an error message, you can add a clean_<name of email field> and a clean_<name of mobile field> function that check for uniqueness and raise ValidationError if it fails (see examples here: https://docs.djangoproject.com/en/1.10/ref/forms/validation/ ).

When the form saves successfully, the user will be redirected to the success_url you provide. That template can have success message text. Alternately, in your form_valid function in the view, you could add a success message that will get added to whatever page you're redirecting to (as long as you make sure your template is rendering messages) -> https://docs.djangoproject.com/en/1.10/ref/contrib/messages/#adding-a-message

On Mon, Oct 31, 2016 at 1:55 AM, pradam programming <pradam.programming@gmail.com> wrote:
Hi,
Please I need an advice on the best approach to take on the following issues.
I have create a form to save user details like first name,last name,email,mobile number etc...

1.Now I need to show error message (In Models i gave email and mobile no field as unique = True) when user enter a email id if email id exists in database show message like email id exists beside the email text field(also for  the mobile no) else proceed with form.
2.After i saving the form i need to show alert of success.

regards,
Pradam Abhilash

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGGVXBOz6kQs%2BHhR%2BsrTUApOGnR7t50HHQuvSN_zJz6VMQosFw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
Andromeda Yelton
Vice President/President-Elect, Library & Information Technology Association: http://www.lita.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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFE1XCbVpkpOboCKR_Xck-oTm2NJYCVQ6ssWZsBWRaNe3pQM9Q%40mail.gmail.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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGGVXBPwq%2BGaEkfFYRx%3Df3uL3Wzbh1xn5BLKdC7%2BCp_PHapBtQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Updating mixin subclassed instances

Hi,

I am using my custom permission mixin on several of my apps's models (not all).

For the case when I need to merge from the "old - context" permission to the "new - context" permission I want to have function which changes the corresponding permission reference attribute in all models, which subclassed this mixin.

How do I know which models subclassed this permission mixin and that they have the inherited permission reference attribute?

In fact I want to have such function in my mixin:

@classmethod
def merge_to(cls, from_perm_context, to_perm_context):

    perm_context_models = []  # How to get this?

    try:
        with transaction.atomic():
            for model in perm_context_models:
                model.objects.filter(
                    perm_context=from_perm_context,
                ).update(perm_context=to_perm_context)
    except IntegrityError as e:  # or DatabaseError
        raise e



Thanks, 

Radek

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/576474f7-dace-4986-b121-0eb2e5428122%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

BaseInlineFormSet with unique_together Model

Good day,

I am new to this list, but I would like to understand better what is going on and how I can fix it the Django way.

 

I have a model similar to the ingredients list of a recipe.

class FoodItem(models.Model):

                name = models.CharField()

 

class Recipe(models.Model):

                input = models.ForeignKey(FoodItem, related_name=”recipe”, …)

                qty = models.FloatField()

                ingredient = models.ForeignKey(FoodItem, …)

 

                class Meta:

                                unique_together = (‘input’, ‘ingredient’)

 

We don’t want the recipe to list the same ingredient twice.

Then I make a basic BaseInlineFormSet.  I use Javascript to add forms and delete forms dynamically.  So let’s say I first create this data:

Input, Qty, Ingredient

Cookies, 1, Sugar

Cookies, 2, Eggs

Cookies, 4, Flour

Cookies, 1, Chocolate Chips

 

It’s perfect.  Then I go back and try to update the data.  I remove the Flour from the recipe.  It gets marked for deletion and hidden from the user.  Then I think, “Oh wait!  That was supposed to be 6 of the Flour!”  So I add a new data entry form to the formset with this data:

Cookies, 6, Flour

 

I click on save, and I get a validation error.  That input and ingredient already exist.  And it’s right.  The form marked for deletion that has 4 Flour does not get deleted until the call to formset.save().  But the new form is not valid because it violates the unique constraint on the model.  I did develop a roundabout way of dealing with the situation: I simply delete all the instances from the database for forms that are marked for deletion before calling formset.is_valid().  But I keep thinking to myself that there must be something I am missing.

 

Thank you,

Matthew Pava

 

 

 

Re: Form Saving Related Issues

If your model has the uniqueness constraint, you should get a form error message automatically. If you don't want your model to have that constraint but you still want your form to throw an error message, you can add a clean_<name of email field> and a clean_<name of mobile field> function that check for uniqueness and raise ValidationError if it fails (see examples here: https://docs.djangoproject.com/en/1.10/ref/forms/validation/ ).

When the form saves successfully, the user will be redirected to the success_url you provide. That template can have success message text. Alternately, in your form_valid function in the view, you could add a success message that will get added to whatever page you're redirecting to (as long as you make sure your template is rendering messages) -> https://docs.djangoproject.com/en/1.10/ref/contrib/messages/#adding-a-message

On Mon, Oct 31, 2016 at 1:55 AM, pradam programming <pradam.programming@gmail.com> wrote:
Hi,
Please I need an advice on the best approach to take on the following issues.
I have create a form to save user details like first name,last name,email,mobile number etc...

1.Now I need to show error message (In Models i gave email and mobile no field as unique = True) when user enter a email id if email id exists in database show message like email id exists beside the email text field(also for  the mobile no) else proceed with form.
2.After i saving the form i need to show alert of success.

regards,
Pradam Abhilash

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGGVXBOz6kQs%2BHhR%2BsrTUApOGnR7t50HHQuvSN_zJz6VMQosFw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
Andromeda Yelton
Vice President/President-Elect, Library & Information Technology Association: http://www.lita.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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFE1XCbVpkpOboCKR_Xck-oTm2NJYCVQ6ssWZsBWRaNe3pQM9Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Redirect after Form

Many thanks, works fine and looks much better to me.

Dne pondělí 31. října 2016 10:21:37 UTC+1 Michal Petrucha napsal(a):
On Sun, Oct 30, 2016 at 06:39:19AM -0700, Moreplavec wrote:
> I found in Django Tutorial solution:
> https://docs.djangoproject.com/en/1.10/intro/tutorial04/ :
>
> Now i have:
>
> return HttpResponseRedirect(reverse('crm:company_detail', args=(company.pk,)))
> #return redirect('views.company_detail', pk=company.pk)
>
>
> And it works fine!

Just for the record, you should also be able to use this::

    return redirect('crm:company_detail', company.pk)

(That should be equivalent to the explicit HttpResponseRedirect with
reverse().)

Cheers,

Michal

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/914fbb8f-9568-4f06-8e7d-6a6d7ade3da5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Using django pagination or slicing

Thanks fedowag.

On Oct 31, 2016 12:01 PM, "王安刚" <fedowag@gmail.com> wrote:
hi 
i prefer method 2

you can get all the list from db and store it in redis using zadd
each time an ajax request comes, you get the data you need using zrange


在 2016年10月31日星期一 UTC+8上午9:05:07,ADEWALE ADISA写道:

Hello,
Please I need an advice on the best approach to take on the following issues.
I have a database table consist of about 1000 record. I need to be displaying like 20 records at a time on a page such that when the user scroll the browser another batches will be append to the browser.
Below are the 3 ways am aiming to achieve this:

1. Using django pagination feature.

2. Everytime records need to be appended to the browser , an ajax call is made to the view, then the queryset is slice using appropriate lower and upper band. Then the returned record is appended to the browser.

3. Fetch the whole records from the database and transfer everything to the browser, then JavaScript is now use to slice and be appending as needed.

NOTE: The webpage would work like yahoo.com mobile site.
Please with approach is the best in term of performance and speed.

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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/022fd700-0edb-419c-9a0d-6e9714229599%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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMGzuy-s8X495UAXuQTibAXe9VLumhMvSUEhzo_rb55T4%3DsQ7g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Using django pagination or slicing

Thanks very much Ludovic for the advice.

On Oct 31, 2016 9:53 AM, "ludovic coues" <couesl@gmail.com> wrote:
I would use 1 + 2 from your list.

3 might work on 1000 record, depending on how much data there is per
record. But if you grow to more than 10,000 record, the page loading
can take minutes. I have experienced that issue with two different
project.

Django pagination by itself won't give you the infinite scroll you are
expecting. But it should give you an easy interface for slicing the
data from your db.

An easier way might be class based view. The following exemple create
a view to a list of object, paginated:

    from django.http import JsonResponse
    from django.views.generic import ListView

    class ModelListView(ListView):
        model = RecordModel
        paginate_by = 20

It will try to use the template at app/record_model_list.html, the
context will have the keys paginator, page, is_paginated, object_list.
You can override the method render_to_response to return a json
response.
The documentation on ListView is at [1] and there is an exemple for
returning JsonResponse at [2]


[1] https://docs.djangoproject.com/en/1.10/topics/class-based-views/generic-display/
[2] https://docs.djangoproject.com/en/1.10/topics/class-based-views/mixins/#more-than-just-html




2016-10-31 2:04 GMT+01:00 ADEWALE ADISA <solixzsystem@gmail.com>:
> Hello,
> Please I need an advice on the best approach to take on the following
> issues.
> I have a database table consist of about 1000 record. I need to be
> displaying like 20 records at a time on a page such that when the user
> scroll the browser another batches will be append to the browser.
> Below are the 3 ways am aiming to achieve this:
>
> 1. Using django pagination feature.
>
> 2. Everytime records need to be appended to the browser , an ajax call is
> made to the view, then the queryset is slice using appropriate lower and
> upper band. Then the returned record is appended to the browser.
>
> 3. Fetch the whole records from the database and transfer everything to the
> browser, then JavaScript is now use to slice and be appending as needed.
>
> NOTE: The webpage would work like yahoo.com mobile site.
> Please with approach is the best in term of performance and speed.
>
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMGzuy8cK7ueHGPwuCjbrV-SdfZwkYYhg7_t7-Dmmt%3D6g787YA%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



--

Cordialement, Coues Ludovic
+336 148 743 42

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEuG%2BTaPWphYQAwa9-rPW5VZ93yyA3kL%3Dz8JAecdLRMiKdjihA%40mail.gmail.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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMGzuy_Tu7mdL4RTvNGWY%3Dm5PL0ttT4wv9QKeMfiLqd43MiaVw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: question about returning file (pdf,image,zip...) in a request that made from temporary URL

You could use a whole deployment setup. Forward Django though nginx by using WSGI (Gnuicorn, etc). Then everything should work.

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5df18a18-7656-4741-bb8a-948db39b8bcd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Redirect after Form

On Sun, Oct 30, 2016 at 06:39:19AM -0700, Moreplavec wrote:
> I found in Django Tutorial solution:
> https://docs.djangoproject.com/en/1.10/intro/tutorial04/ :
>
> Now i have:
>
> return HttpResponseRedirect(reverse('crm:company_detail', args=(company.pk,)))
> #return redirect('views.company_detail', pk=company.pk)
>
>
> And it works fine!

Just for the record, you should also be able to use this::

return redirect('crm:company_detail', company.pk)

(That should be equivalent to the explicit HttpResponseRedirect with
reverse().)

Cheers,

Michal

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20161031092105.GJ8307%40koniiiik.org.
For more options, visit https://groups.google.com/d/optout.

Re: Using django pagination or slicing

I would use 1 + 2 from your list.

3 might work on 1000 record, depending on how much data there is per
record. But if you grow to more than 10,000 record, the page loading
can take minutes. I have experienced that issue with two different
project.

Django pagination by itself won't give you the infinite scroll you are
expecting. But it should give you an easy interface for slicing the
data from your db.

An easier way might be class based view. The following exemple create
a view to a list of object, paginated:

from django.http import JsonResponse
from django.views.generic import ListView

class ModelListView(ListView):
model = RecordModel
paginate_by = 20

It will try to use the template at app/record_model_list.html, the
context will have the keys paginator, page, is_paginated, object_list.
You can override the method render_to_response to return a json
response.
The documentation on ListView is at [1] and there is an exemple for
returning JsonResponse at [2]


[1] https://docs.djangoproject.com/en/1.10/topics/class-based-views/generic-display/
[2] https://docs.djangoproject.com/en/1.10/topics/class-based-views/mixins/#more-than-just-html




2016-10-31 2:04 GMT+01:00 ADEWALE ADISA <solixzsystem@gmail.com>:
> Hello,
> Please I need an advice on the best approach to take on the following
> issues.
> I have a database table consist of about 1000 record. I need to be
> displaying like 20 records at a time on a page such that when the user
> scroll the browser another batches will be append to the browser.
> Below are the 3 ways am aiming to achieve this:
>
> 1. Using django pagination feature.
>
> 2. Everytime records need to be appended to the browser , an ajax call is
> made to the view, then the queryset is slice using appropriate lower and
> upper band. Then the returned record is appended to the browser.
>
> 3. Fetch the whole records from the database and transfer everything to the
> browser, then JavaScript is now use to slice and be appending as needed.
>
> NOTE: The webpage would work like yahoo.com mobile site.
> Please with approach is the best in term of performance and speed.
>
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMGzuy8cK7ueHGPwuCjbrV-SdfZwkYYhg7_t7-Dmmt%3D6g787YA%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



--

Cordialement, Coues Ludovic
+336 148 743 42

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEuG%2BTaPWphYQAwa9-rPW5VZ93yyA3kL%3Dz8JAecdLRMiKdjihA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Using django pagination or slicing

hi 
i prefer method 2

you can get all the list from db and store it in redis using zadd
each time an ajax request comes, you get the data you need using zrange


在 2016年10月31日星期一 UTC+8上午9:05:07,ADEWALE ADISA写道:

Hello,
Please I need an advice on the best approach to take on the following issues.
I have a database table consist of about 1000 record. I need to be displaying like 20 records at a time on a page such that when the user scroll the browser another batches will be append to the browser.
Below are the 3 ways am aiming to achieve this:

1. Using django pagination feature.

2. Everytime records need to be appended to the browser , an ajax call is made to the view, then the queryset is slice using appropriate lower and upper band. Then the returned record is appended to the browser.

3. Fetch the whole records from the database and transfer everything to the browser, then JavaScript is now use to slice and be appending as needed.

NOTE: The webpage would work like yahoo.com mobile site.
Please with approach is the best in term of performance and speed.

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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/022fd700-0edb-419c-9a0d-6e9714229599%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sunday, October 30, 2016

Form Saving Related Issues

Hi,
Please I need an advice on the best approach to take on the following issues.
I have create a form to save user details like first name,last name,email,mobile number etc...

1.Now I need to show error message (In Models i gave email and mobile no field as unique = True) when user enter a email id if email id exists in database show message like email id exists beside the email text field(also for  the mobile no) else proceed with form.
2.After i saving the form i need to show alert of success.

regards,
Pradam Abhilash

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGGVXBOz6kQs%2BHhR%2BsrTUApOGnR7t50HHQuvSN_zJz6VMQosFw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Need help with a hostel management system project using django

Hi,

You can create 3 groups and put each user to specific group. Set the permission on the group an all te group member will have the specified permission for Create, Read, Update, Delete.

Mulianto

Sent from my iPhone

On 30 Okt 2016, at 22:37, YOGITHA A N <yogitha1997@gmail.com> wrote:

I need to create 3 kinds of users with 3 different permissions. One being that of the student , mess contractor and hostel warden.
How do I create 3 differnt kinds of login and user profiles.

On Sunday, October 30, 2016 at 7:39:56 PM UTC+5:30, bob gailer wrote:

On Oct 30, 2016 9:53 AM, "YOGITHA A N" <yogit...@gmail.com> wrote:
>
> I am beginner in django please help me out with my project
To help us help you be more specific. What kind of help do you need?
>
> --
> 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...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/35fed150-9a4e-4ba9-a81b-1a5301119f7f%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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b3f43cf2-6692-4cdd-8ec3-130b6552893d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Using django pagination or slicing

Hello,
Please I need an advice on the best approach to take on the following issues.
I have a database table consist of about 1000 record. I need to be displaying like 20 records at a time on a page such that when the user scroll the browser another batches will be append to the browser.
Below are the 3 ways am aiming to achieve this:

1. Using django pagination feature.

2. Everytime records need to be appended to the browser , an ajax call is made to the view, then the queryset is slice using appropriate lower and upper band. Then the returned record is appended to the browser.

3. Fetch the whole records from the database and transfer everything to the browser, then JavaScript is now use to slice and be appending as needed.

NOTE: The webpage would work like yahoo.com mobile site.
Please with approach is the best in term of performance and speed.

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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMGzuy8cK7ueHGPwuCjbrV-SdfZwkYYhg7_t7-Dmmt%3D6g787YA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: question about returning file (pdf,image,zip...) in a request that made from temporary URL

thanks for reply
 i setup the x-sendfile but there's a problem :

django return a x-sendfile response successfully but since i'm using django development area and the development area runs on port 8000 the return response will be on port 8000 but the apache web server runs on port 80 so the response wont go to apache  so it cause me to download the file with 0 byte size

how can i solve this problem ?

On Friday, October 28, 2016 at 6:29:53 PM UTC+3:30, ali Eblice wrote:
hello
think of a downloading website:
when we create a temporary link in django and map it to actual URL or file path in database like this:

id -- temporary_URL -- origin_URL  --  file_path

so when a user used a temporary URL and directed to some view , how should i return that file from that view for user to be able to download that file?
i know that i can use "FileResponse"  or  "StreamingHttpResponse" but in django documentation says that we should use these for short-lived requests but downloading a big file can take long time, so what should i do ?
i appreciate any help and idea

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9d0fc69a-ca82-4b2f-81ce-82ba58afdf92%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Newbie question - data structure for game

You'll probably need jQuery. Bear in mind "size" is not absolute as it will depend on font family and font height.

On Sunday, 30 October 2016 01:27:59 UTC+2, Ken Albright wrote:
Sounds good. Thanks for the advice. Now if I could only figure out how to get forms to expand and contract to match the size of the quote...

Thanks.

On Friday, October 28, 2016 at 5:00:14 PM UTC-7, Ken Albright wrote:
I'm just learning Python and Django so please be gentle...

I've written a quote decryption game (like you see in the newspaper) in Python. I'd like to put it on a web page with Django. However, I'm not sure of the best way to structure the data. The original quote and the encrypted quote need to have a one-to-one relationship at the letter level. So it could be two strings on the same row (same id) or a set of tuples, a dictionary, or ???

How to set up the database and models.py?

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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/600aea7e-54fc-4856-9c71-fc56469d3712%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: how to create 2 different kind of user profiles using django python

You can start by designing your warden and student models in which each of them inherit the django inbuilt user model class.
Each model would then have attribute that is peculiar to it alone.

On Oct 30, 2016 2:53 PM, "YOGITHA A N" <yogitha1997@gmail.com> wrote:
Hey,

I am new to django . Please let me know how to create 2 various kind of user profiles in django. I am doing a hostel management system using django where in I have 2 kinds of users one is a student and the other is the warden. 

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/22ce8644-2a9d-430c-a565-39ab94664d88%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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMGzuy8%2BEMTJBo76UZjQwNdbDJ%3DN4aA07SBCUEcRva9L66L3Cg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Need help with a hostel management system project using django

I need to create 3 kinds of users with 3 different permissions. One being that of the student , mess contractor and hostel warden.
How do I create 3 differnt kinds of login and user profiles.

On Sunday, October 30, 2016 at 7:39:56 PM UTC+5:30, bob gailer wrote:

On Oct 30, 2016 9:53 AM, "YOGITHA A N" <yogit...@gmail.com> wrote:
>
> I am beginner in django please help me out with my project
To help us help you be more specific. What kind of help do you need?
>
> --
> 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...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/35fed150-9a4e-4ba9-a81b-1a5301119f7f%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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b3f43cf2-6692-4cdd-8ec3-130b6552893d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: how to create 2 different kind of user profiles using django python

Hi
If student and warden have similar attributes and only differ in permission level than you could use the same User model for both of them and to provide different access levels by creating two different authorization groups for student and warden.
https://docs.djangoproject.com/en/1.10/topics/auth/default/#topic-authorization

On Sun, Oct 30, 2016 at 7:59 PM, Amandeep Singh <amangujral@hotmail.com> wrote:
Hi
If student and warden have similar attributes and only differ in permission level than you could use the same User model for both of them and to provide different access levels by creating two different authorization groups for student and warden.
https://docs.djangoproject.com/en/1.10/topics/auth/default/#topic-authorization

On Sun, Oct 30, 2016 at 7:18 PM, YOGITHA A N <yogitha1997@gmail.com> wrote:
Hey,

I am new to django . Please let me know how to create 2 various kind of user profiles in django. I am doing a hostel management system using django where in I have 2 kinds of users one is a student and the other is the warden. 

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/22ce8644-2a9d-430c-a565-39ab94664d88%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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMi_2%3DFipXyvWwj%2BDOTr_Ac67mSRcpLZMSOEyZZGu0QfYkve_w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Need help with a hostel management system project using django

On Oct 30, 2016 9:53 AM, "YOGITHA A N" <yogitha1997@gmail.com> wrote:
>
> I am beginner in django please help me out with my project
To help us help you be more specific. What kind of help do you need?
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/35fed150-9a4e-4ba9-a81b-1a5301119f7f%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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAP1rxO5GPt155WmMB8NUO7fbwz7%3DP%2Brq0NaEbLJsQ7UXeUjqtA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Need help with a hostel management system project using django

I am beginner in django please help me out with my project

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/35fed150-9a4e-4ba9-a81b-1a5301119f7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

how to create 2 different kind of user profiles using django python

Hey,

I am new to django . Please let me know how to create 2 various kind of user profiles in django. I am doing a hostel management system using django where in I have 2 kinds of users one is a student and the other is the warden. 

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/22ce8644-2a9d-430c-a565-39ab94664d88%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Redirect after Form

I found in Django Tutorial solution: https://docs.djangoproject.com/en/1.10/intro/tutorial04/ :

Now i have: 

return HttpResponseRedirect(reverse('crm:company_detail', args=(company.pk,)))
#return redirect('views.company_detail', pk=company.pk)

And it works fine!

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/020ebfa1-2bd0-4cba-91bc-5797dee25e5c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: How will I Run the Django Project (https://github.com/django/django) in my laptop ?

Django by itself does not "run" or do anything. Django only does something when provided with settings and applications. If all you want is to run the test suite, to verify that a change you made to Django itself did something, you can do that by following the instructions in the documentation.

On Sun, Oct 30, 2016 at 6:10 AM, Srinivasulu Reddy <srinivasulur55.s@gmail.com> wrote:
I'm talking about the Django install in github project. Not talking about using django how to create the project. I'm an member in all the groups. How will i contribute the coding part of django. How will i assign tickets to myself ?. How will i run the github django project ? To support the django community.

On Sunday, October 30, 2016 at 5:50:30 PM UTC+5:30, James Bennett wrote:
To install and run Django, I recommend reading through the official Django tutorial, which explains how to install Django and create a project you can work with and run:


Additionally, there is documentation on how to contribute to Django, which is useful to read:



On Sun, Oct 30, 2016 at 4:20 AM, Srinivasulu Reddy <srinivas...@gmail.com> wrote:
Hi Guys,

How will i contribute to the django project(https://github.com/django/django) ? I'm trying to install the django project local laptop. I'm unable to run the project. I changed the project name `{{ project_name }}.settings` in django/conf/project_template/project_name/ and run the server (runserver). I'm not able to find the other apps. How will i contribute to the tickets `https://code.djangoproject.com/query?status=!closed&easy=1&stage=Accepted&order=priority`.

--
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...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6738a4a5-f650-406e-bc67-d0f42043f8ea%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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b1d078c0-ca9e-4519-9bcd-fce3a3d30a66%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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAL13Cg9KnZ0ntw3MZA2737D5vhF_uKM%2B%3DeBhoXa02boQfqG8aA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: How will I Run the Django Project (https://github.com/django/django) in my laptop ?

I'm talking about the Django install in github project. Not talking about using django how to create the project. I'm an member in all the groups. How will i contribute the coding part of django. How will i assign tickets to myself ?. How will i run the github django project ? To support the django community.

On Sunday, October 30, 2016 at 5:50:30 PM UTC+5:30, James Bennett wrote:
To install and run Django, I recommend reading through the official Django tutorial, which explains how to install Django and create a project you can work with and run:


Additionally, there is documentation on how to contribute to Django, which is useful to read:



On Sun, Oct 30, 2016 at 4:20 AM, Srinivasulu Reddy <srinivas...@gmail.com> wrote:
Hi Guys,

How will i contribute to the django project(https://github.com/django/django) ? I'm trying to install the django project local laptop. I'm unable to run the project. I changed the project name `{{ project_name }}.settings` in django/conf/project_template/project_name/ and run the server (runserver). I'm not able to find the other apps. How will i contribute to the tickets `https://code.djangoproject.com/query?status=!closed&easy=1&stage=Accepted&order=priority`.

--
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...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6738a4a5-f650-406e-bc67-d0f42043f8ea%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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b1d078c0-ca9e-4519-9bcd-fce3a3d30a66%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: How will I Run the Django Project (https://github.com/django/django) in my laptop ?



On Sunday, October 30, 2016 at 4:50:18 PM UTC+5:30, Srinivasulu Reddy wrote:
Hi Guys,

How will i contribute to the django project(https://github.com/django/django) ? I'm trying to install the django project local laptop. I'm unable to run the project. I changed the project name `{{ project_name }}.settings` in django/conf/project_template/project_name/ and run the server (runserver). I'm not able to find the other apps. How will i contribute to the tickets `https://code.djangoproject.com/query?status=!closed&easy=1&stage=Accepted&order=priority`.

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c17cfc7b-feb6-4feb-95a4-f7a7a31f7cbf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Redirect after Form

Greetings,

trying to create new app with simple Form to create and update Company info. My view looks like:

def company_new(request):
if request.method == "POST":
form = CompanyForm(request.POST)
if form.is_valid():
company = form.save(commit=False)
company.save()
return redirect('views.company_detail', pk=company.pk)
else:
form = CompanyForm()
return render(request, 'crm/company_edit.html', {'form': form})

with urls.py:


app_name = 'crm'
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^index_previous', views.index_previous, name='index_previous'),
url(r'^report_money', views.report_money, name='report_money'),
url(r'^report_works', views.report_works, name='report_works'),
url(r'^company/(?P<pk>[0-9]+)/$', views.company_detail, name='company_detail'),
url(r'^work/(?P<pk>[0-9]+)/$', views.work_detail, name='work_detail'),
url(r'^company/new/$', views.company_new, name='company_new'),
url(r'^company/edit/(?P<pk>[0-9]+)/$', views.company_edit, name='company_edit'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


But when i save my new company, i get info: 

Page not found (404)

Request Method:GET
Request URL:http://localhost:8000/company/new/views.company_detail


So Django takes whole URL + my redirect. Is it possible to force to use my urls.py? I found something like "return HttpResponseRedirect('/')", but it's strange solution. Another way is to point to exact path, but i don't like too, i'd like to use urls.py to redirect.

Thanks for tips, i hope it's some simple trick or import i'm missing.

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/24f7f6b7-2b9a-452f-9d15-325e1e467793%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.