How to integrate my app into a theme / template

2013-08-07 Thread Christian Erhardt
Hi,

currently i'm using pinax for my project and therefor 
pinax-theme-bootstrap. I wrote some apps and want to integrate them into my 
template. Right now, i copied the file site_base.html into my projects 
template directory and added the menu links i needed to the {% block nav %} 
in this file. 

But is there a way to integrate my app without modifying the theme itself? 
I'd like to define the apps sub-menu in my app, and as i add this app to my 
project, the menu structure gets extended. 

I tried to create a file site_base.html in my app, only adding the block 
"nav" to it, but this is ignored. Maybe there is an app for creating 
dynamic menus?

Same thing would be nice, not only for the menu, but for information shown 
on the homepage or in a users dashboard.

Regards Christian

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




How template tag can receive values JS

2013-08-01 Thread Christian Erhardt
No, what you are trying is not possible. The template tags are rendered on the 
server. They never appear on the client machine. Javascript is running on the 
client machine. They both will never see each other.

You will always have to do a roundtrip to interact between Javascript and 
django templates: send a request from Javascript to the server, server renders 
the page and returns it.

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django count

2013-07-30 Thread Christian Erhardt
Hm... there is no relation to the user? So you are trying to group by name, 
surname and then count all individual courses? There is a high risk, that 
the user has a typo in his name or the courses name, than they would appear 
twice in the list. Is this your intention?

I'd rather do it like this
 
class User(Model):
   ...user fields...

class Course(Model):
   name=CharField...
   users = models.ManyToManyField(User)
   ...course fields...

class Egitim(models.Model):
   user = ForeignKey(User)
   course = ForeignKey(Course)

Then it is possible to do this:

User.objects.all().annotate(num_of_courses_taken=Count(course))

Have a look at this tutorial, it explains everything
https://docs.djangoproject.com/en/dev/topics/db/aggregation/


Am Sonntag, 28. Juli 2013 14:16:08 UTC+2 schrieb Murat Bilal:
>
>  
> Hi all,
>  
> I have a model like this,
>  
> class Egitim(models.Model):
> name = models.CharField(max_length=200)
> surname =  models.CharField(max_length=20)
> email = models.EmailField(max_length=75)
> course_name =  models.CharField(max_length=300)
> num_of_courses_taken = models.IntegerField(max_length=100)
> def __unicode__(self):
>   return self.course_name
> class EgitimForm(ModelForm):
> class Meta:
>   model=Egitim
>   fields=('name','surname','email','course_name')
>  I want to make num_of courses_taken by a special user.when the form is 
> submitted
>  
> For ex:
> emai...@aa.comnum_of_courses_taken=12
>  
> Please 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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: What client side html layout tools are people using to speed up template development?

2013-07-30 Thread Christian Erhardt
I totally agree, use bootstrap, google fonts and the color-wheel. You'll 
have a good looking page to start with. Then extend the layout.

Am Montag, 29. Juli 2013 11:35:24 UTC+2 schrieb somecallitblues:
>
> Use http://twitter.github.io/bootstrap/ framework for your frontend. If 
> you google "django bootstrap" you'll find some apps that will help.
>
> For fonts i usually pick Google font that looks good. If you want to use 
> web safe font go to http://cssfontstack.com/
>
> As for colors, try https://kuler.adobe.com/create/color-wheel/
>
> You can also google something like "20 web designer tools" and you'll get 
> one of those blog posts that lists them all.
>
> And if you have time check out this list 
> https://github.com/dypsilon/frontend-dev-bookmarks. It's truly amazing!
>
> Cheers,
>
> M
>
>
> On 29 July 2013 19:18, Sam Walters >wrote:
>
>> Its not specific to django however i have a few small projects on the 
>> horizon where i could really save time spent on the things im not good at: 
>>
>> Graphic design CSS layouts, choosing fonts, colours that look good.
>>
>> What are the tools people are using for this these days? What are strong 
>> points of the system you are using?
>>
>> All this stuff will get partiitoned up and placed in my django templates.
>>  
>> I used to use yahoo yui gris css, 960 grid system and a few other things 
>> a couple of years back. I assume there are better things i dont know about 
>> though.
>>
>> thanks in advance!
>>  
>> -- 
>> 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 http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Multiple Form Submit with Single Submit Button

2013-07-30 Thread Christian Erhardt
Can you please give a little bit more information. What is the desired 
result. How should the pages look? I'm not sure what you are trying to 
accomplish.

Am Montag, 29. Juli 2013 17:33:29 UTC+2 schrieb pattinson:
>
> I'm currently working with django project. I had to filter the data store 
> on the database based on the user input on form (at template) as looked 
> below.
>
>
> 
>
>
> On form user either enter value or leave it blank. So what I have to do is 
> first find the (valid) user input and then fire appropriate query to 
> display data as user input in the form. So final result should be displayed 
> on table at template.
>
> As I'm new to django, how should I have to pass the data and fire query to 
> represent data at multiple field. As help or link related to these type 
> problem are expected. ( I just able to filter from the database with only 
> one form and had no concept to solve this.)
>
> Model of my temp project is as below.
>
> class exReporter(models.Model):
> first_name = models.CharField(max_length=30)
> last_name = models.CharField(max_length=30)
> email = models.EmailField()
> gender = models.CharField(max_length=1)
> age = models.IntegerField()
> label = models.IntegerField()
>
>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: background image

2013-07-30 Thread Christian Erhardt
Generally speaking you could extend the users profile and add a field to 
it. Then you could store the image during registration or when a user 
updates his settings. On the page where you want to show the image you 
could check for a image in the profile and show it.

I started my project with pinax, which already hat the 
app django-user-accounts included, i then created a custom profile for my 
users (something like here: 
http://blog.tivix.com/2012/01/06/extending-user-model-in-django/). Now you 
have to adjust the forms for registering and modifying the user settings, 
so the user can set the fields you added to the profile (somewhat like 
this: http://dewful.com/?p=70). The form must contain a file upload field 
where the user can upload the image. Then i would save the image somewhere 
on the server, where you can access it from an template. 

Sorry, that i can not provide a step by step solution, but i hope i could 
push you in the right direction.

regards Christian

Am Dienstag, 30. Juli 2013 08:07:43 UTC+2 schrieb Kakar:
>
> Hello,
> What do I do to let user upload their own images, and as use it as their 
> profile's background.
> I am out of clue. Please advice me.
>
> 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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Learning how to build a web site for my python games and a blog

2013-07-29 Thread Christian Erhardt
Sry, I have no idea what you are talking about

Am Samstag, 27. Juli 2013 15:57:45 UTC+2 schrieb Randy Baxley:
>
> Is anyone working through The Django Book that would like to form a fb 
> page just for that or knows of a good tutorial where questions will get 
> answers?
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Advanced Tutorial (how to write reusable app), last step does not work

2013-07-27 Thread Christian Erhardt
Django is using a coding "style" called covention over configuration. That 
means that you don't have to configure every bit of your application instead a 
convention is used to determine where you have to place stuff so django finds 
and uses it. For the beginner it seems like django is using some sort of magic 
to connect erlverything together.
In your case, having read the tutorial a long time ago, you surely created a 
View class that is derived from the ListView base class. The convention here is 
that you create a template called _list.html. If you have a file 
with this name, the listview will use it for rendering. It seems the creation 
of this file is missing in the tutorial. But it is pretty straight forward if 
you look at the documentation of the listview base class.

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: server error (500)

2013-07-25 Thread Christian Erhardt
Set Allowed Hosts to 0.0.0.0

Am Donnerstag, 25. Juli 2013 14:19:13 UTC+2 schrieb Oliver:
>
> when you change Debug=False
>
>
>
>
> On Thursday, July 25, 2013 8:12:14 AM UTC-4, victoria wrote:
>>
>> The error log doesn't show anything. In which step following the 
>> documentation are you getting this error? 
>>
>> On Thu, Jul 25, 2013 at 12:09 PM, Oliver  wrote: 
>> > my environment is in my local pc or machine so its a development 
>> machine. 
>> > 
>> > I tried that empy field in allowed_host. 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > On Thursday, July 25, 2013 5:43:02 AM UTC-4, Mário Idival wrote: 
>> >> 
>> >> use this in your settings.py 
>> >> ALLOWED_HOSTS = [] 
>> >> 
>> >> where are you envirioment? you app there in production or development? 
>> >> Em 25/07/2013 04:35, "victoria"  escreveu: 
>> >> > 
>> >> > Hi, 
>> >> 
>> >> > 
>> >> > On Thu, Jul 25, 2013 at 4:30 AM, Oliver  wrote: 
>> >> > > If I set DEBUG = False, I get this 
>> >> > > 
>> >> > > It worked! 
>> >> > > 
>> >> > > Congratulations on your first Django-powered page. 
>> >> > > 
>> >> > > Of course, you haven't actually done any work yet. Here's what to 
>> do 
>> >> > > next: 
>> >> > > 
>> >> > > If you plan to use a database, edit the DATABASES setting in 
>> >> > > mysite/settings.py. 
>> >> > > Start your first app by running python manage.py startapp 
>> [appname]. 
>> >> > > 
>> >> > > You're seeing this message because you have DEBUG = True in your 
>> >> > > Django 
>> >> > > settings file and you haven't configured any URLs. Get to work! 
>> >> > > 
>> >> > > 
>> >> > > 
>> >> > > 
>> >> > > 
>> >> > > If I set it to true, I get the server error (500).  I created the 
>> >> > > template 
>> >> > > and static folder inside mysite folder.  Here is my setting.py. 
>> >> > > 
>> >> > 
>> >> > Can  you check the apache error log to see if you can find more 
>> >> > information there? It is located in 
>> >> > C:\BitNami\djangostack-1.5.1-0\apache2\logs 
>> >> > 
>> >> > 
>> >> > > I run the inspectdb and it went fine, no errors.   I'm new and 
>> >> > > following the 
>> >> > > tutorials at Django website documentation. 
>> >> > > 
>> >> > > I appreciate any help. 
>> >> > > 
>> >> > > 
>> >> > > 
>> >> > > 
>> >> > > 
>> >> > > 
>> >> > > 
>> >> > > # Django settings for mysite project. 
>> >> > > 
>> >> > > DEBUG = True 
>> >> > > TEMPLATE_DEBUG = DEBUG 
>> >> > > 
>> >> > > ADMINS = ( 
>> >> > > # ('mysite', 'em...@email.com'), 
>> >> 
>> >> > > ) 
>> >> > > 
>> >> > > MANAGERS = ADMINS 
>> >> > > 
>> >> > > DATABASES = { 
>> >> > > 'default': { 
>> >> > > 'ENGINE': 'django.db.backends.mysql', # Add 
>> >> > > 'postgresql_psycopg2', 
>> >> > > 'mysql', 'sqlite3' or 'oracle'. 
>> >> > > 'NAME': 'mysitedb',  # Or path to 
>> database 
>> >> > > file 
>> >> > > if using sqlite3. 
>> >> > > # The following settings are not used with sqlite3: 
>> >> > > 'USER': 'root', 
>> >> > > 'PASSWORD': '', 
>> >> > > 'HOST': '',  # Empty for localhost 
>> through 
>> >> > > domain sockets or '127.0.0.1' for localhost through TCP. 
>> >> > > 'PORT': '',  # Set to empty string for 
>> >> > > default. 
>> >> > > } 
>> >> > > } 
>> >> > > 
>> >> > > # Hosts/domain names that are valid for this site; required if 
>> DEBUG 
>> >> > > is 
>> >> > > False 
>> >> > > # See 
>> >> > > https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts 
>> >> > > ALLOWED_HOSTS = ['localhost'] 
>> >> > > 
>> >> > > # Local time zone for this installation. Choices can be found 
>> here: 
>> >> > > # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name 
>> >> > > # although not all choices may be available on all operating 
>> systems. 
>> >> > > # In a Windows environment this must be set to your system time 
>> zone. 
>> >> > > TIME_ZONE = 'EST' 
>> >> > > 
>> >> > > # Language code for this installation. All choices can be found 
>> here: 
>> >> > > # http://www.i18nguy.com/unicode/language-identifiers.html 
>> >> > > LANGUAGE_CODE = 'en-us' 
>> >> > > 
>> >> > > SITE_ID = 1 
>> >> > > 
>> >> > > # If you set this to False, Django will make some optimizations so 
>> as 
>> >> > > not 
>> >> > > # to load the internationalization machinery. 
>> >> > > USE_I18N = True 
>> >> > > 
>> >> > > # If you set this to False, Django will not format dates, numbers 
>> and 
>> >> > > # calendars according to the current locale. 
>> >> > > USE_L10N = True 
>> >> > > 
>> >> > > # If you set this to False, Django will not use timezone-aware 
>> >> > > datetimes. 
>> >> > > USE_TZ = True 
>> >> > > 
>> >> > > # Absolute filesystem path to the directory that will hold 
>> >> > > user-uploaded 
>> >> > > files. 
>> >> > > # Example: "/var/www/example.com/media/" 
>> >> > > MEDIA_ROOT = '' 
>> >> > > 
>> >> > > # URL that handles the media served from MEDIA_ROOT. Make sure to 
>> use 
>> >> > > a 
>> >> > > # trailing slash. 
>> >> > > # Examples: 

Re: new field in models

2013-07-24 Thread Christian Erhardt
I'd go with  Satinderpal Singh advice. Use South. It takes some time to get 
used to it, but when you realize how it's working, it absolutely awesome

Am Montag, 22. Juli 2013 09:53:00 UTC+2 schrieb Harjot Mann:
>
> In django when we add a new field in existing class, we need to drop 
> the table and then run the syncdb again. Is there any alternative for 
> it so that we can add the field without dropping the table?? 
>
> -- 
> Harjot Kaur Mann 
> Blog: http://harjotmann.wordpress.com/ 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Selecting values from database

2013-07-24 Thread Christian Erhardt
Just do be clear... you are mixing strings and numbers in one table on 
different rows? I think your data structure is wrong and you will not be 
able to achieve what you're trying.

I'd would be easy if the table would look like this:

+-+
|Activities   |
+-+---+
|Activity | Number|
+-+---+
|activity1|  0|
|activity2|  1|
|activity3|  2|
|activity4|  3|
|activity5|  4|
+-+---+

then you would be able to do something like this: 

Activities.objects.all().order_by("-Number")[:3]

Am Mittwoch, 24. Juli 2013 08:08:42 UTC+2 schrieb sandy:
>
> Suppose I have following table in my database : 
>
> activity1 | activity2 | activity3 | activity4 | activity5 
> 6| 7   | 5| 9   | 8 
>
> The first row are the field names and the second row are the data 
> entries. How can I get 3 maximum values out of each row of this table? 
> Like from this row, I should get 7,8,9. 
> Eagerly waiting fro your reply. 
> Thank you. 
>
> -- 
> Sandeep Kaur 
> E-Mail: mkaur...@gmail.com  
> Blog: sandymadaan.wordpress.com 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Reverse Lookup Failure on password change/reset views

2013-07-23 Thread Christian Erhardt
The problem is, as you already stated the argument for the ReverseMatch. I 
had this problem once, and the error was that i used the url tag in the 
template wrong - it changed between two django versions. My urls are 
defined as yours, in the templates i use: {% url "password_reset_done" 
parameter %} or {% url "password_reset_xy" %} - the quotation mark made the 
difference. Just a wild guess, but maybe it helps

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to Create an Auto Incrementing Integer Field

2013-07-23 Thread Christian Erhardt
you are very welcome

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: python manage.py runserver error

2013-07-22 Thread Christian Erhardt
I think you're missing some prerequisites (TypeError: ('Not a package:', 
'cgi')) 

I never use the libraries installed on the system, i always work with 
virtualenvs. A very good kickstart is written down here: 
http://www.jeffknupp.com/blog/2012/02/09/starting-a-django-project-the-right-way/

Usually i start everything from a pinax project so i'm not sure if django 
has a requirements.txt. But if it has and you have activated your 
virtualenv (. venv/bin/activate), alle requisites can installed, simply by 
executeing the following command:

pip install -r requirements.txt 

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: (Noob) - filtering spanning relationship not working

2013-07-22 Thread Christian Erhardt
Calling count() on a queryset will always aggregate the count of all rows. 
Please have a look at the annotate function in the documentation 
https://docs.djangoproject.com/en/dev/topics/db/aggregation/ Annotate will 
group your results and sum up the results. 

I think what you'll have to do is:

assignment.finished_articles = Article.objects.filter(cowcode=country, 
pubdate__range(start_date, end_date), 
articlehistory__coder=request.user.id).annotate(number_of_articlehistory_entries=Count(articlehistory__id))

This should give you a list of Articles with an extra column 
'number_of_articlehistory_entries' with the count of articlehistory entries 
per article. I'm pretty sure, that in this list all articles are shown, 
even those with 0 articlehistory entries.
If you only want those with more than 1 articlehistory entries, you should 
start the query from the articlehistory class.

assignment.finished_articles = 
ArticleHistory.objects.filter(article__cowcode=country, 
article__pubdate__range(start_date, end_date), 
coder=request.user.id).annotate(number_of_articlehistory_entries=Count(id))

A count on assignment.finished_articles should return the number of 
articles that have at least 1 connected articlehistory entry.

Hope this helps

Am Montag, 22. Juli 2013 09:51:14 UTC+2 schrieb Lukas Kawerau:
>
> I want to find the number of articles for which a specific user has 
> created articlehistoryrecords.
> The models for that look like this:
>
> class Article(models.Model):
> """The basic entity of this app.)"""
> documentID = models.CharField(blank=True, max_length=1000)
> cowcode = models.IntegerField(blank=True, null=True)
> pubdate = models.DateField(default=datetime.datetime.today)
> headline = models.CharField(blank=True, max_length=1500)
> source = models.CharField(blank=True, max_length=5000)
> text = models.TextField(blank=True, max_length=100)
> assignments = models.ManyToManyField(Assignment)
>
> class Meta:
> ordering = ['pubdate']
>
> def __unicode__(self):
> return self.headline
> class ArticleHistory(models.Model):
> """(Modelname description)"""
> article = models.ForeignKey(Article, related_name='Article History')
> coder = models.ForeignKey(User, related_name='Article History')
> last_updated = models.DateTimeField(default=datetime.datetime.now)
>
> def __unicode__(self):
> return self.last_updated
>
> The way I'm trying to do this at the moment is like this:
>
> assignment.finished_articles = 
> Article.objects.filter(cowcode=country).filter(pubdate__range=(start_date,end_date),
>  articlehistory__coder=request.user.id).count()
>
> This doesn't work, however and exhibits another weird behaviour:
> I try to do this:
>
> for assignment in assignments:
> country = assignment.country.cowcode
> start_date = assignment.start_date
> end_date = assignment.end_date
> articles = 
> Article.objects.filter(cowcode=country).filter(pubdate__range=(start_date,end_date)).select_related()
> assignment.article_num = articles.count()
> #assignment.finished_articles = 
> Article.objects.filter(cowcode=country).filter(pubdate__range=(start_date,end_date),
>  articlehistory__coder=request.user.id).count()
>
> This works fine, unless I try to include finished_articles, then 
> article_num gets shortened to one result.
>
> It would be really great if anyone has a pointer to who to solve this.
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to Create an Auto Incrementing Integer Field

2013-07-22 Thread Christian Erhardt
Have a look at this post: 
http://stackoverflow.com/questions/3123796/how-to-make-an-auto-filled-and-auto-incrementing-field-in-django-admin
 
They determine the next value by calling a function called number(). In 
your case it would look something like this:

class Cliente(models.Model):
> """This is the client data model, it holds all client information. This
>docstring has to be improved."""
> def number():
> no = Cliente.objects.all().aggregate(Max(order))
> if no == None:
> return 1
> else:
> return no + 1
>
> clientcode = models.IntegerField(_('Code'), max_length=6, unique=True, 
> \
> default=number)
>
 

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Saving data from a form.

2013-07-22 Thread Christian Erhardt
The error lies in this two rows:

form.save()
DataTable_id = DataTable.id

DataTable is the class, not the instance of the saved object! form.save() 
returns an instance of what has been saved. So your code should look like 
this:

my_new_datatable_instance = form.save()
DataTable_id = my_new_datatable_instance.id

That should do the trick


Am Montag, 22. Juli 2013 13:02:46 UTC+2 schrieb Nigel Legg:
>
> models.py:
> class DataTable(models.Model):
> datFile = models.CharField(max_length = 200)
> structFile = models.CharField(max_length = 200)
> bannerVar = models.CharField(max_length = 50)
> stubVar = models.CharField(max_length = 50)
> stubNets = models.BooleanField()
> 
> def __unicode__(self):
> return u'%s %s %s %s' % (self.datFile, self.structFile, 
> self.bannerVar, self.stubVar)
> 
> forms.py:
> class DataTableForm(forms.ModelForm):
> class Meta:
> model = DataTable
>
> views.py:
> def datatables(request):
> if request.method == 'POST':
> form = DataTableForm(request.POST)
> if form.is_valid():
> form.save()
> DataTable_id = DataTable.id
> return render(request, 'myapp/tabspec/{{DataTable_id}}.html', {
> 'DataTable_id' : DataTable.id,
> })
> else:
> form = DataTableForm()
> return render(request, 'myapp/datatables.html', {
> 'form': form,
> })
>
>
> When I input data on the form, and click "Confirm Selections", I get 
> "object DataTable has no attribute 'DataTable_id'"
> Should I be using a different method to save the data from the form to the 
> database?
>
>
> Regards,
> Nigel Legg
> 07914 740972
> http://www.trevanianlegg.co.uk
> http://twitter.com/nigellegg
> http://uk.linkedin.com/in/nigellegg
>
>  

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: can we pass objects in template tags

2013-07-03 Thread Christian Erhardt
Maybe this will help you? 

http://stackoverflow.com/questions/6400557/how-can-i-pass-objects-to-a-custom-django-template-tag-i-figured-out-a-way-but

A Filter will support objects, don't use template tags.

Am Mittwoch, 3. Juli 2013 00:24:55 UTC+2 schrieb surya:
>
> I would like to pass object into template tag, then process it.. Is it 
> possible
>
> def my_tag(parser, token):
>return Node()
>
> The token object seems to be a string!! but how to get some objects??
>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




jquery in django

2013-07-01 Thread Christian Erhardt
Hey Harjot,

i can't provide an easy answer to your question. An Ajax enabled search with 
django is nothing, that one programs in 30 minutes especially not if he has no 
understanding of query and or ajax.

I'll try to give you some hints but not a complete plug n play solution. 

First things first. Jquery is a Javascript framework. One function it provides 
is to handle ajax requests. In short: Javascript running in the users browser 
calls the server  and with help of jquery you modify the DOM of the html page. 
So you don't have to reload the html page for each request. 

Now django comes to play. Django just handles the request. So you will need a 
page which will return search results for a query you submitted. If you call a 
django page it usually returns a html page. For ajax calls you would not work 
with html. Most pages use json to serialize data. There is a plugin called 
tasrypie which we use. It provides an ajax endpoint. As i recall it has a built 
in search function. Maybe you try this first. There are more high sophisticated 
search engines for django... but i'd give tastypie a try.

If everything is set up correct you can call an endpoint for your model with a 
jquery ajax call.

But this is acomplex task!

Regards

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.