Re: Django frustrations :)

2014-08-16 Thread alghafli

Hello
I am not sure how much time you have been programming and what you have 
learned so far. I do know however that i have not taken a real computer 
science course and i did not study computer science. if i can do it 
without computer science, you certainly can do it.
One thing that helped me learn django is getting used to errors. anytime 
you learn a new library you will definitely get errors. I did get errors 
in the first time. so you have to get used to them and deal with them.
are good at reading errors? you have to learn this skill. Many times in 
django and programming generally you face one error that leads to 
another that leads to another. you get a chain of errors causing each 
other. you probably just made the root error. all other errors are made 
by the root error you made. do not panic and look for it. once you fix 
it, all 1000 errors will disappear.
If you are not good at reading errors yet, copy the errors and show them 
here so that someone can help. you will learn this skill with time.
I suggest you stick with the django tutorial in django website since 
most people here are probably familiar with it.


Best regards,
Mohammad

On السبت 16 آب 2014 21:13, Babatunde Akinyanmi wrote:


Hi Mariusz,
You won't go far in learning anything if you back out at the slightest 
resistance. When your code spews errors, you should attempt to find 
out what exactly caused the errors.


That said, Django is just pure python. Nothing special and magical 
about it.


My advice, anytime you hit such snags, ask for help on the group.

On 16 Aug 2014 17:54, "Mariusz Wilk" > wrote:


Hi guys. If I seem like a spoilt brat or sth in this post then
maybe I am, let me know.
I'm completely new to programming. I completed Python tutorial on
codecademy and completed about 20 'assignments' on CheckiO, but I
wanted to actually implement what I'd learned to a larger project
like a website (in the meantime I also got to know html/css a
little bit). So I started a tutorial on Django but got seriously
stuck plus I didn't really understand almost anything about what I
was doing. Ok..  so I went on to another Django tutorial. Again,
same thing. And for the third time.. same thing. By now I'm really
frustrated by how easy it was to learn the basics of Python, HTML
and CSS and how impossible it is to understand Django and create
sth without 1000 errors on the way. Maybe there's something I
could do that would help me understand Django tutorials before
actually doing them? Maybe I need some general computer course
that would help me understand all the jargon.
Well, that's about it. Any advice will be appreciated.
-- 
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/972bd82d-5d8f-4462-938b-ff37ffd7b3d4%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/CA%2BWjgXO0pJkFk%3D3_wWW0PTJS%3D6Lumany6hH2n81%3DEW21fgrXFg%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+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/53EFA8AA.5080908%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: running script in django database

2014-07-30 Thread alghafli

Jirka, aRkadeFR,
Thank you very much. I was able to create the command successfully.

Regards,
Mohammad

On الأربعاء 30 تـمـوز 2014 22:41, aRkadeFR wrote:

Agree with Jirka,

I'm just adding the link:
https://docs.djangoproject.com/en/1.6/howto/custom-management-commands/

On 30/07/14 07:53, jirka.vejra...@gmail.com wrote:

Hi Mohammad,

   this can be easily achieved using a custom management command - check the 
Django documentation.

   HTH

 Jirka
  
-Original Message-

From: alghafli 
Sender: django-users@googlegroups.com
Date: Wed, 30 Jul 2014 07:02:59
To: 
Reply-To: django-users@googlegroups.com
Subject: running script in django database

Hello,
I made a library application using django 1.6. currently I only need to
populate the database. at the beginning, it is easier to write the
information in a csv file and import it using a script.

the script is running fine if I use manage.py shell and import the
necessary file and call the necessary function. however, I want to make
the script run from the system commandline rather than from the python
interpreter since it is easier to pass arguments to it. I could not find
a way in the manage.py documentation page.

Is it possible?

thank you,
Mohammad

--
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/53D86E73.9060806%40gmail.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/417657233-1406705276-cardhu_decombobulator_blackberry.rim.net-1073591500-%40b4.c3.bise7.blackberry.
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/53D98587.3030602%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


running script in django database

2014-07-29 Thread alghafli

Hello,
I made a library application using django 1.6. currently I only need to 
populate the database. at the beginning, it is easier to write the 
information in a csv file and import it using a script.


the script is running fine if I use manage.py shell and import the 
necessary file and call the necessary function. however, I want to make 
the script run from the system commandline rather than from the python 
interpreter since it is easier to pass arguments to it. I could not find 
a way in the manage.py documentation page.


Is it possible?

thank you,
Mohammad

--
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/53D86E73.9060806%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: managing temporarily created files

2014-07-21 Thread alghafli

Dear Paul,
Thank you for the fast and useful reply. However, I have two questions.
According to django documentation, HttpResponse accepts string 
parameter. Does it also accept binary data. I am using python3 in which 
string is a unicode string and binary data are stored in bytes class.
Second, I am planning to use ezodf library to create odt files. It 
appears that there is no way I can access data from memory in this 
library. do you know of any good python library that can create and 
modify odt files?


Thank you

على الإثنين 21 تـمـوز 2014 18:49, كتب Paul J Stevens:


On 21-07-14 17:09, alghafli wrote:


I want to dynamically create a temporary odt file and upload it to the
client. The file is dynamically created based on GET request parameters.
It basically searches the database and fills the odt file with
information. This file is temporary and should be deleted after the
upload finishes.

tempfile.TemporaryFile is what you seem to want. The file object is
deleted automatically.

fd = tempfile.TemporaryFile()
fd.write(odt_data)
fd.seek(0)
return HttpResponse(
 fd.read(),
 content_type='application/vnd.oasis.opendocument.text'
)

But then you might as well skip the tempfile feature, and stream
directly from memory:

return HttpResponse(
 odt_data,
 content_type='application/vnd.oasis.opendocument.text'
)



Here is how I am planning to do it. The view function creates the file
and fills it with information. The file is created in a directory which
is added to the STATICFILES_DIRS. The view then redirects to the file
url and the client downloads the file.

Since your odt data is for one-time-only usage, you don't need to put
them in any kind of STATIC_FILES directory. That feature is of use to
offload download performance to the web-server, but for one-time-only
downloads there is no point.


To delete the files, I am planning to create a class that handles
temporary file creation and deletion. The class forces an upper limit to
temporary files number, say 10. Any file created after 10 files will
make the class delete older files based on modification time. I might as
well create a thread that would delete files regularly but it would be a
bit more complicated and unnecessary for this specific project.

Done already by the tempfile.TemporaryFile class, and totally redundant
when streaming from memory.




--
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/53CD4326.80404%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


managing temporarily created files

2014-07-21 Thread alghafli

Hello django community,
I am currently developing my first web application. Since I am new to 
web development, I thought I should seek advice on what I am trying to 
implement at the moment.
Before I start, here are my questions: *can django do this?**if not, is 
there a python library that can do this? if not, am I doing it right?*


I want to dynamically create a temporary odt file and upload it to the 
client. The file is dynamically created based on GET request parameters. 
It basically searches the database and fills the odt file with 
information. This file is temporary and should be deleted after the 
upload finishes.


Here is how I am planning to do it. The view function creates the file 
and fills it with information. The file is created in a directory which 
is added to the STATICFILES_DIRS. The view then redirects to the file 
url and the client downloads the file.
To delete the files, I am planning to create a class that handles 
temporary file creation and deletion. The class forces an upper limit to 
temporary files number, say 10. Any file created after 10 files will 
make the class delete older files based on modification time. I might as 
well create a thread that would delete files regularly but it would be a 
bit more complicated and unnecessary for this specific project.


Thank you,
Mohammad

--
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/53CD2D1F.8080102%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: sort by multiple fields using admin_order_field

2014-07-16 Thread alghafli

Hello Jorge
Thank you for the reply. admin_order_field can 1 and only 1 field. 
However, I want to sort by multiple fields. Something like this:

function_name.admin_order_field = [ 'topic id', 'book id' ]
Now the previous line does not work but I wrote it just to show the 
idea. if I choose to sort by the function, the admin page should sort by 
topic id first then it should sort by book id.
I have seen ModelAdmin.ordering 
<https://docs.djangoproject.com/en/1.6/ref/contrib/admin/#django.contrib.admin.ModelAdmin.ordering> 
which sort of works. However, this one only specifies default ordering 
for a model. I want to make something like this as the function ordering.


Thank you

على الخميس 17 تـمـوز 2014 05:21, كتب Jorge Andrés Vergara Ebratt:

Hey, it can be done, it's something like this:

In the Model Class where you created the function you are going to add:

function_name.admin_order_field = 'The field to order'




2014-07-16 13:25 GMT-05:00 alghafli <mailto:theb...@gmail.com>>:


Hello,
I made a library application. I have books each with its own id
number (different from the autofield added by django). the book
has several foreign keys each with its own id.

I wrote a function that returns a long id number in string format
consisting of the book id number and id number of several of its
foreign keys.
say I have a topic foreign key. the function does something like this:
book id: 122
topic id: 4
the function returns: 04-0122
I show this id number in the admin page. I want to sort this item
which is not actually in the database by topic id then by book id.
however, admin_order_field only takes 1 property.
if i have for example the following:
04-0122
03-1002
04-0043
they should be like this in the admin page after sorting:
03-1002
04-0043
04-0122

is that possible?
Thank you

-- 
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
<mailto:django-users%2bunsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto: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/53C6C3AA.1010803%40gmail.com.
For more options, visit https://groups.google.com/d/optout.




--
*Jorge Andres Vergara Ebratt*
*#SoftwareDeveloper (Or at least trying to be)*
*@javebratt*
*facebook.com/javebratt <http://facebook.com/javebratt>*
--
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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/CAAeX05G2wADNj%3DUr9vCtUGEJTkyycx7f6%2ByaOTmR3cR2ixSKhQ%40mail.gmail.com 
<https://groups.google.com/d/msgid/django-users/CAAeX05G2wADNj%3DUr9vCtUGEJTkyycx7f6%2ByaOTmR3cR2ixSKhQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.

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/53C75FA7.8010802%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how can i make django url system acept the following url http://www.yoursite.com/notifications?topic=payment&id=identificador-de-notificación-de-pago

2014-07-16 Thread alghafli

You should stop at /pago/index
the fields after ? are accessible by the GET dictionary.
I did something like this and I used (r'^search/$') expression. when I 
get a url like:

http://testsystemser.cloudapp.net/*search*/?topic=payment&id=identificador-de-notificación-de-pago
I do something like this in the view function:
def search (request):
topic = *request.GET['topic']*
id = *request.GET['id']*
#do more stuff

hope this helps

على الخميس 17 تـمـوز 2014 00:24, كتب Matias Araujo:
Hi all! im devoloping a site in django and i need to recive an http 
request with an url of this type:
http://testsystemser.cloudapp.net/pago/index?topic=payment&id=identificador-de-notificación-de-pago 

but i cant make it match with my urlconf in my project, i try with the 
following ur:
url(r'pago/index/(?P\w)/(?P\w)', 'apps.pagos.views.index', 
name='index'),
l but it didnt match so i cant handle the request and recive the 
information i 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+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/6303a363-cd4d-47cc-af1c-ea804dd77a3d%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/53C6F9AB.4010809%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


sort by multiple fields using admin_order_field

2014-07-16 Thread alghafli

Hello,
I made a library application. I have books each with its own id number 
(different from the autofield added by django). the book has several 
foreign keys each with its own id.


I wrote a function that returns a long id number in string format 
consisting of the book id number and id number of several of its foreign 
keys.

say I have a topic foreign key. the function does something like this:
book id: 122
topic id: 4
the function returns: 04-0122
I show this id number in the admin page. I want to sort this item which 
is not actually in the database by topic id then by book id. however, 
admin_order_field only takes 1 property.

if i have for example the following:
04-0122
03-1002
04-0043
they should be like this in the admin page after sorting:
03-1002
04-0043
04-0122

is that possible?
Thank you

--
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/53C6C3AA.1010803%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: validators not working in shell

2014-07-13 Thread alghafli

Thank you. That helped me solving the problem :)
على السبت 12 تـمـوز 2014 20:12, كتب tim:
Model validation is not invoked when calling model.save(). You can 
read more 
here: https://docs.djangoproject.com/en/1.6/ref/models/instances/#validating-objects


On Saturday, July 12, 2014 6:46:17 AM UTC-4, thebsom wrote:

Hello
I am creating a django library application. I have made a book
model and
it has some fields with validators. Most of them are standard
MinValueValidator and MaxValueValidator.
Using the webserver, the validators work completely fine. I see
errors
when I put invalid values. However, when I tested saving objects
using
the shell, the validators are not called. I am using the shell
because I
am planning to import the database from existing csv files.

Is there something wrong? Or am I responsible to call the validators
manually before save()?

--
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/2464d4fe-cadc-45e5-a2bc-e0276d148f31%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/53C29618.505%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


validators not working in shell

2014-07-12 Thread alghafli

Hello
I am creating a django library application. I have made a book model and 
it has some fields with validators. Most of them are standard 
MinValueValidator and MaxValueValidator.
Using the webserver, the validators work completely fine. I see errors 
when I put invalid values. However, when I tested saving objects using 
the shell, the validators are not called. I am using the shell because I 
am planning to import the database from existing csv files.


Is there something wrong? Or am I responsible to call the validators 
manually before save()?


--
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/53C11168.9020803%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django beginner

2014-07-01 Thread alghafli

Hi,
I am also new to django and I started by reading the django tutorial.
https://docs.djangoproject.com/en/1.6/intro/overview/
It covers installation then shows how to construct a django application. 
It takes you step by step in constructing an example application.
I believe it is a very good place to start and understand what django is 
and how it works.


Regards,
Mohammad

على الأربعاء 2 تـمـوز 2014 09:22, كتب ngangsia akumbo:

I am new to django

i have been given a task to build a website using django . I dont know 
where to start.

I am suppose to include a services page, events, booking and a blog

This is my first project, can i have some tips ? 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+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/2bc06d81-c21e-458e-ac7c-e78aab15e76e%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/53B3ABCA.7060100%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to read part of many-to-many field in the template

2014-06-15 Thread alghafli

Thank you for the fast reply. I did what you suggested and it worked fine :)

على الأحد 15 حزيران 2014 16:39, كتب Elliot Bradbury:

Hi Mohammad,

Check out slice 
<https://docs.djangoproject.com/en/1.6/ref/templates/builtins/#slice>.


It's a builtin template filter that can be used like this:

{% for author in book.authors.all|slice:"3" %}
  {# HTML up in here #}
{% endfor %}

Good luck,
Elliot


On Sun, Jun 15, 2014 at 9:31 AM, alghafli <mailto:theb...@gmail.com>> wrote:


Hello django users. I am working on my first django project and I
faced a little problem.
I have a library database with books. A book element may have
several authors.
In the view function I query the database for books. I want to
show the *first three* authors. I was thinking to do something
similar to the following python code but using the template language:

authors_to_show = book.authors.get_queryset() [0:3]
for author in authors_to_show:
#html code here

However, it appears that I cannot define variables in the template
unless I extend the language a bit. Note that I have several books
to process and I can do that using the for loop in the template
language. But I want to ignore some authors in each book.
Any idea of a proper way to do this.

Thank you in advance,
Mohammad
-- 
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
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto: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/539DA033.4060100%40gmail.com

<https://groups.google.com/d/msgid/django-users/539DA033.4060100%40gmail.com?utm_medium=email&utm_source=footer>.
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 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/CAAErR_z4JoZu0Xe7M7LiJq-3M4pR%2BYwTxaEnJk56AqZnX-nZHg%40mail.gmail.com 
<https://groups.google.com/d/msgid/django-users/CAAErR_z4JoZu0Xe7M7LiJq-3M4pR%2BYwTxaEnJk56AqZnX-nZHg%40mail.gmail.com?utm_medium=email&utm_source=footer>.

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/539DA777.2030404%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to read part of many-to-many field in the template

2014-06-15 Thread alghafli
Hello django users. I am working on my first django project and I faced 
a little problem.
I have a library database with books. A book element may have several 
authors.
In the view function I query the database for books. I want to show the 
*first three* authors. I was thinking to do something similar to the 
following python code but using the template language:


authors_to_show = book.authors.get_queryset() [0:3]
for author in authors_to_show:
#html code here

However, it appears that I cannot define variables in the template 
unless I extend the language a bit. Note that I have several books to 
process and I can do that using the for loop in the template language. 
But I want to ignore some authors in each book.

Any idea of a proper way to do this.

Thank you in advance,
Mohammad

--
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/539DA033.4060100%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to localize database fields

2014-05-13 Thread alghafli
Hello django users. I am new to django and a bit new to databases. This 
is actually my first time making a web and database project.
What I want to do is to localize database field names so that the field 
name appears differently in the admin and user sites depending on the 
language chosen.


for example an author field name would appear as "Author" for english, 
"مؤلف" for arabic and "作家" for japanese. I believe translation 
reference will help me in custom pages I make but how about the admin 
page that comes with django?


any idea or reference that can help me?

thank you very much,

Mohammad

--
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/53720EAE.20208%40gmail.com.
For more options, visit https://groups.google.com/d/optout.