Re: Newbie question - data structure for game

2016-10-29 Thread Yaşar Arabacı
I am also quite new to django, but I will go with something like this;

class Quote(models.Model):
quote= models.CharField(max_length=100)

class EncryptedQuote(models.Model)
quote = models.ForeignKey(Quote, on_delete=models.CASCADE)
encrypted_quote = models.CharField(max_length=100)


So, you can have multiple encryptions of any quote.

On Saturday, October 29, 2016 at 3:00:14 AM UTC+3, 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+unsubscr...@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/dc31d02e-8345-4467-99df-0e4688a76a48%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Migrating custom mysql application to django orm

2016-10-29 Thread Yaşar Arabacı
Hi,

I am trying to migrate my mysql application into django orm. I need help 
converting my sql statements into it. Here are my models

class SearchableText(models.Model):
searchable_text = models.TextField()
class SearchTerm(models.Model):
searchabletext = models.ForeignKey(SearchableText, on_delete=models.CASCADE)
term = models.CharField(max_length=100)


This is basically a table to store some textual information, and another 
table to use as index of searchable terms.

Consider it like this

SearchableText
id   searchable_text
1"this is text"
2"this is another text"

SearchTerm
id  searchable_text term
1   1this
2   1is
3   1text
4   2this
5   2is
6   2another
7   2text

I would normally do a sql query like this;

Select SearchableText.*
Right Join SearchTerm on SearchTerm.searchable_text = SearchableText.id
Where term in ("is","another")
group by SearchTerm.searchable_text ORDER BY COUNT(SearchTerm.term ) DESC 
LIMIT

Right now, I don't even know where to start writing a complex sql like this 
using django-orm so any help is 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c6481fa3-1d35-4957-b70e-3d9912715546%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django tutorial, cannot add "polls" to admin

2011-10-06 Thread Yaşar Arabacı
How does your urls.py look like? Did you uncomment admin related things in
there?

2011/10/6 Ser5 

> Hi! Help me please to solve one tutorial problem.
>
> Now I'm reading the 2nd part of the tutorial and have stuck with adding
> polls app to the Django admin.
> Everything worked fine in the tutorial until I reached "Make the poll app
> modifiable in the admin" part.
>
> Here is the link to the tutorial page I'm currently at:
> https://docs.djangoproject.com/en/1.3/intro/tutorial02/
>
> I have already added admin.py file and now have mysite/polls directory with
> the following content:
> ModeLastWriteTime Length Name
> - -- 
> -a---06.10.2011 23:54 94 admin.py
> -a---07.10.2011  0:21609 models.py
> -a---06.10.2011 23:39   1478 models.pyc
> -a---06.10.2011 23:13399 tests.py
> -a---06.10.2011 23:13 27 views.py
> -a---06.10.2011 23:13  0 __init__.py
> -a---06.10.2011 23:19150 __init__.pyc
>
> admin.py contains this:
> ---
> from polls.models import Poll
> from django.contrib import admin
>
> admin.site.register(Poll)
> ---
>
>
> If this can help, models.py have this content:
> ---
> from django.db import models
> import datetime
>
>
>
> class Poll(models.Model):
> question = models.CharField(max_length=200)
> pub_date = models.DateTimeField('date published')
>
> def __unicode__(self):
> return self.question
>
> def was_published_today(self):
> return self.pub_date.date() == datetime.date.today()
>
>
>
> class Choice(models.Model):
> poll = models.ForeignKey(Poll)
> choice = models.CharField(max_length=200)
> votes = models.IntegerField()
>
> def __unicode__(self):
> return self.choice
> ---
>
>
>
> I restarted the Django development server several times.
> And I'm looking here http://127.0.0.1:8000/admin/ for the "poll" app to
> appear. But it doesn't =( Still only "Auth" and "Sites" here.
>
> Tell me please - did I miss something? Or did the tutorial miss something?
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/c0WVz5UjgFUJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to make Django pick new urls immediately

2011-10-06 Thread Yaşar Arabacı
maybe you should restart the server? And, do you include new urls in your
root url config?

2011/10/6 Kayode Odeyemi 

> Hello,
>
> I don't know if I'm the only one experiencing this. I have multiple urls.py
> in different packages based on
> the similarities of the modules. Everytime I add a new url to urls.py, it
> doesn't take effect immediately. Always returning 404 until
> I have to do something... Can't remember what I did.
>
> Is anyone experiencing the same?
>
> --
> Odeyemi 'Kayode O.
> http://www.sinati.com. t: @charyorde
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Beginner a bit lost - need some pointers please

2011-10-05 Thread Yaşar Arabacı
This documentation goes over deployment of django:
https://docs.djangoproject.com/en/1.3/howto/deployment/

2011/10/5 Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk>

> Hi Chris,
>
> I'm assuming that you don't have any experience with Python??
>
> Also - have you read the intro overview, as that pretty much answers your
> questions, unless I'm missing something
>
> https://docs.djangoproject.com/en/1.3/intro/overview/
>
> Cal
>
>
> On Wed, Oct 5, 2011 at 8:55 PM, Chris G  wrote:
>
>> I'm an experienced programmer (started around 1971 or so!) and I've done
>> lots of things over the years, much of my background is in Unix (Solaris).
>> In the last few years I have done quite a lot of web related stuff.
>>
>> I'm trying to get my mind round django.  I have it installed on my
>> unbuntu server, it works, I've worked through tutorials 1 and 2 and a
>> bit of 3.  I can get the admin screens up and the basics of the polls
>> example work.
>>
>> However two rather basic things still elude me:-
>>
>>Where/how do I actually start creating the top level/page of a web
>>site?   Do I just open vi and create some HTML and embed django
>>code?  That seems unlikely but I can't see anywhere that tells me
>>what the code that creates a django site looks like and/or where it
>>resides.   An actual example of a two or three page working django
>>based web site would be a huge help.
>>
>>I can't see anywhere that seems to tell me the issues involved with
>>moving from using the built in web server to using apache2 (or
>>whatever, I have apache2 on my system).
>>
>> I know that in a few days time when I have got over the initial hump all
>> the above will seem trivial so sorry to ask, but at the moment I'm
>> feeling a bit lost!  :-)
>>
>> --
>> Chris Green
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: best way to get started with Dajngo?

2011-10-01 Thread Yaşar Arabacı
If you didn't checked this already:
https://docs.djangoproject.com/en/1.3/intro/tutorial01/

2011/10/1 ruchita rathi 

> Hi,
>
> Can someone point to the documents/videos for getting started with Django?
>
> Best,
> Ruchita
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: CSRF with AJAX problem

2011-09-30 Thread Yaşar Arabacı
To create csrf cookie without using csrf tag, your view needs to be
decorated with django.views.decorators.csrf.ensure_csrf_cookie. Also check:
https://code.djangoproject.com/ticket/16936

2011/9/30 Kenneth Love 

> You're using AJAX and forms incorrectly, then. Any form that has a
> solid effect on your database (creating, replacing, or deleting data)
> should be POSTed and should have CSRF token.
>
> Look into pydanny's django-uni-form project (http://readthedocs.org/
> docs/dango-uni-form/en/latest/) for creating your forms. It'll create
> the CSRF token for you if you set the form method to POST (again, as
> it should be). Then, in your AJAX function that submits the form,
> submit the key & value of the CSRF token field to the endpoint. Now
> you have AJAX forms that are still safe and sane.
>
> On Sep 29, 5:15 pm, galgal  wrote:
> > Yes, but that JavaScript code is useless until {% csrf_token %} or
> get_token
> > is used. I don't use POST forms - only AJAX forms so I don't have that
> > cookie made after page load.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: sending and receiving data using ajax/html

2011-09-15 Thread Yaşar Arabacı
Check this out: http://www.micahcarrick.com/ajax-form-submission-django.html

2011/9/15 jay K. <jay.developer2...@gmail.com>

> I do not know anything about send and receiving data using forms in html
> django,
> I just heard that ajax was good for receiving and sending data (it was
> faster)
>
> any suggestions would be good
>
> 2011/9/15 Yaşar Arabacı <yasar11...@gmail.com>
>
>> Why do you want to use ajax, instead of regular form post to next page.
>> When in next page, you can create hidden form fields to store data you
>> passed from first page, and then you can post them again in any page you
>> want.
>>
>> 2011/9/15 jay K. <jay.developer2...@gmail.com>
>>
>>
>>> Hello
>>>
>>> I have a page where a user makes a selection
>>>
>>> What I want to do is to take the user's selection to the "next page"
>>> so I can process the user's request in a new page
>>>
>>> How can I do that?
>>>
>>> I know I have to use ajax (but if there is a better method please let
>>> me know), so
>>> how can I use ajax to send and receive the information?
>>>
>>> Thanks
>>>
>>> Regards
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>>
>>
>>
>> --
>> http://yasar.serveblog.net/
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: sending and receiving data using ajax/html

2011-09-15 Thread Yaşar Arabacı
Why do you want to use ajax, instead of regular form post to next page. When
in next page, you can create hidden form fields to store data you passed
from first page, and then you can post them again in any page you want.

2011/9/15 jay K. 

>
> Hello
>
> I have a page where a user makes a selection
>
> What I want to do is to take the user's selection to the "next page"
> so I can process the user's request in a new page
>
> How can I do that?
>
> I know I have to use ajax (but if there is a better method please let
> me know), so
> how can I use ajax to send and receive the information?
>
> Thanks
>
> Regards
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Pagination of more than one field

2011-09-06 Thread Yaşar Arabacı
I think your question can be solved with javascript and ajax, rather than
with django. How is your knowledge in that area?

2011/9/6 OC 

> Hi,
>
> I am new to django and I have a pagination question:
> In my web page I need to display 2 query results of two different
> tables
> Each result is displayed in a different div in the same page.
>
> How can I implement "multiple" pagination meaning that each result is
> displayed in its own panel and has its own previous and next buttons
> but doesn't affect the other's query result?
>
> For instance - I have a panel of movies, display 10 each time, and
> have a prev and next buttons dedicated to the movies only
> Plus
> In the same page, I have a panel of actors, display 10 each time, and
> have a prev and next buttons dedicated to the actors only
>
> My current (wrong) implementation is
> use pagination for the both of them but when pressing the next/
> previous button of one - it affects (as expected) the display of the
> other one because the entire page has changed.
>
> Thanks in advance,
> Osnat
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to group models month by month.

2011-09-06 Thread Yaşar Arabacı
I already read that, but I can figure out it is something to do with my
question, bu can't figure out what exactly should I do with aggreates. I
ended up doing something like this:
query_set = Post.objects.all()
years = query_set.dates("pub_date","year")
date_hierarchy = {}
for year in years:
date_hierarchy[year] = {}
months =
query_set.filter(pub_date__year=year.year).dates("pub_date","month")
for month in months:
date_hierarchy[year][month] =
query_set.filter(pub_date__year=month.year,pub_date__month=month.month).count()

Then in template:

{% for year, month_dict in date_hierarchy.items %}
{% for month,post_count in month_dict.items %}
{{ month|date:"Y
E" }} [{{ post_count }}]
{% endfor %}
{% endfor %}

2011/9/6 Andre Terra <andrete...@gmail.com>

> http://django.me/aggregation
>
>
> Cheers,
> AT
>
> 2011/9/6 Yaşar Arabacı <yasar11...@gmail.com>
>
>>
>> I have a model with datetime field. I want to get a table with three
>> columns as, year, month and number of items in time span. And I also want to
>> order them from newest to oldest. What I want to get is something like this:
>>
>> 2011 August 4
>>
>>
>> 2011 March 7
>>
>>
>>  How do you suggest I should do that?
>>
>> I am trying to add post archives to my front page in my blog. Here is link
>> to same question on StackOverflow:
>> http://stackoverflow.com/q/7320662/886669
>>  --
>> http://yasar.serveblog.net/
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How to group models month by month.

2011-09-06 Thread Yaşar Arabacı
I have a model with datetime field. I want to get a table with three columns
as, year, month and number of items in time span. And I also want to order
them from newest to oldest. What I want to get is something like this:

2011 August 4
2011 March 7

How do you suggest I should do that?

I am trying to add post archives to my front page in my blog. Here is link
to same question on StackOverflow: http://stackoverflow.com/q/7320662/886669
-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Minimal change broken my csrf validation.

2011-09-05 Thread Yaşar Arabacı
Can you please take a look at here:
http://stackoverflow.com/q/7312029/886669

-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Can I write tests for 3rd party url shortener?

2011-09-02 Thread Yaşar Arabacı
Hi,

Is there a way to test whether or not a 3rd party url shortener works. What
I have in mind is this:

get short url from third party application
send a request to that link
see if that link is redirected to what it is supposed to redirected?

-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Value Checking in Custom save method of admin site

2011-08-26 Thread Yaşar Arabacı
Hi,

I have implemented a custom save method for one of my models like this:

def save_model(self,request,obj,form,change):
if obj.slug == "" or obj.slug is None:
obj.slug = slugify(obj.title)
# I get database representation of the object to check if
# it was not published before and it is published now
# in order to set pub_date right

if change is True:
obj_db = Post.objects.get(pk=obj.id)
if obj_db.yayinlandi == False and obj.yayinlandi == True:
obj.pub_date = datetime.now()

obj.save()

And, I have a custom save method on my model like this:

def save(self,force_insert=False, force_update=False,using=None):
super(Post, self).save(force_insert, force_update,using=using)
if self.yayinlandi:
try:
ping_google('/sitemap.xml')
except:
pass
*
*


My problem is, I get a server error when trying to save, lets say, a varchar
value, which is bigger in length then specified by max_length argument. I
believe admin panel supposed to warn me when trying to save that value, and
I broke that behaviour by applying my custom save. Does anyone have an idea
what is going on an know how to fix this?

All of the project is in here: https://github.com/yasar11732/django-blog
-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Drag and drop functionality?

2011-08-26 Thread Yaşar Arabacı
It is my understanding that, drag and drop functionality depends on browser
capabilities. You may want to see these two links:

https://developer.mozilla.org/en/drag_and_drop_javascript_wrapper
https://developer.mozilla.org/en-US/demos/detail/motivational-poster

2011/8/26 francescortiz 

> By your comment it seems that your question is more about browser
> capabilities than django. If this is the case, check HTML5 to see what
> can be used for drag and drop, like files in gmail.
>
> On Aug 24, 7:22 pm, glenn hafstrom  wrote:
> > Hi Reinout
> >
> > Thanks for your input.
> > I've googled a lot but I haven't found anything where I can drag from
> > another application to my django-site
> >
> > Regards
> > glenn
> >
> > On 24 Aug, 13:30, Reinout van Rees  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > On 24-08-11 13:19, glenn hafstrom wrote:
> >
> > > > I'm new to this and I have just started with django.
> > > > I would like to have some kind of container for example I would like
> > > > to drag and drop a webaddress
> > > > to the container and then save them in my django application.
> > > > Is there any Javscript or anything else that I can use to handle
> > > > this?
> >
> > > Best way is to do it in two steps:
> >
> > > - First make a regular django form with one input field for the url and
> > > a submit button. Get that working.
> >
> > > - Second step: google for some javascript that handles it. "jquery ui"
> > > has some drag/drop support, but I don't know if that also works for
> > > items dragged from outside the browser window.
> >
> > > But get step 1 working first. Step 2 will need that functionality in
> > > place to be able to do something :-)
> >
> > > Reinout
> >
> > > --
> > > Reinout van Reeshttp://reinout.vanrees.org/
> > > rein...@vanrees.orghttp://www.nelen-schuurmans.nl/
> > > "If you're not sure what to do, make something. -- Paul Graham"
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Help with Django code.

2011-08-26 Thread Yaşar Arabacı
Try this, always worked for me,

import os
import sys
# assuming this file resides at the same directory at settings file

PROJECT_FOLDER = os.path.abspath(os.path.dirname(__file__))
UPPER_PATH = os.path.abspath(PROJECT_FOLDER + "/../")

sys.path.append(UPPER_PATH)
os.environ['DJANGO_SETTINGS_MODULE'] = "project_name.settings"

"""
At this point, you can do anything with django, as django setting module
environment variable is set
and your project is in pythonpath
"""

2011/8/26 akaariai 

> On Aug 25, 10:26 pm, Dr00p  wrote:
> > Hi, I need to get Django to run in my code and I am having trouble.
> > Every time I try to import my project (this is a seperate code I
> > created to generate polls) it gives an import error and says
> > DJANGO_SETTINGS_MODULE is not defined.
> > I have tried multiple things like
> > django.core.management.call_command('syncdb',
> > 'settings=mysite.settings')
> > django.core.management.call_command('syncdb', "pythonpath='/home/guest/
> > Downloads/Site/Django/mysite'")
> > But those give me the same error!
> > I am trying to import mysite.polls but it won't let me.
> > I have been trying to do it with out using manage.py because I don't
> > know how to do it with manage.py
> > If their is a way to use manage.py in my code I would but I personally
> > can not figure it out.
>
> Try to start your code with:
>
> import settings
> from django.core.management import setup_environ
> setup_environ(settings)
>
> > Any way you can help is great.
> > If I am being to vague, I need to generate thousands of polls(even if
> > you think this is stupid just ignore it), and to do that I created a
> > script and I need to import my project but it will not allow me.
> > I am in dire need of help!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Need Ideas On Data Migration

2011-08-24 Thread Yaşar Arabacı
Thanks, I am marking this thread as SOLVED :)
2011/8/24 Kayode Odeyemi <drey...@gmail.com>

> +1 to South
>
> Just started with it myself
>
>
> On Wed, Aug 24, 2011 at 1:25 PM, Rory Hart <hart...@gmail.com> wrote:
>
>> South[1] handles database migrations. both schema and data. It can be a
>> little tricky when first starting to use it but it is a powerful system.
>>
>> Otherwise you could alter the table yourself and copy the data using SQL
>> or the django-admin shell.
>>
>> [1] http://south.aeracode.org/
>>
>> --
>> Rory Hart
>> http://www.roryhart.net
>> http://www.relishment.com
>>
>>
>> 2011/8/24 Yaşar Arabacı <yasar11...@gmail.com>
>>
>>> Hi,
>>>
>>> I have a model with a char field. All data saved in database in that
>>> field is a valid slug. Now I want to add this model a slug field, and copy
>>> all data from char fields to slug fields like so:
>>>
>>> Table before change:
>>>
>>> text = thisisavalidslug(char field)
>>>
>>> Table after change:
>>>
>>> text=thisisavalidslug(char field)
>>> slug=thisisavalidslug(slug field)
>>>
>>> Then later, I will change all char field manually to be more human
>>> readable with non-ascii letters and spaces. I just have like 10 items.
>>> --
>>> http://yasar.serveblog.net/
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> --
> Odeyemi 'Kayode O.
> http://www.sinati.com. t: @charyorde
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Need Ideas On Data Migration

2011-08-24 Thread Yaşar Arabacı
Hi,

I have a model with a char field. All data saved in database in that field
is a valid slug. Now I want to add this model a slug field, and copy all
data from char fields to slug fields like so:

Table before change:

text = thisisavalidslug(char field)

Table after change:

text=thisisavalidslug(char field)
slug=thisisavalidslug(slug field)

Then later, I will change all char field manually to be more human readable
with non-ascii letters and spaces. I just have like 10 items.
-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: can django be used in destop application?

2011-08-23 Thread Yaşar Arabacı
I had written something about this earlier, Although the article is in
Turkish, you can still understand the django part I guess. It demonstrates
how to use django component with other applications, by creating a dummy
package manager.
http://yasar.serveblog.net/post/djangoda-paket-yoneticisi-yapalm/

2011/8/23 Andy McKay 

>
> On 2011-08-23, at 4:17 AM, smith jack wrote:
>
> > i mean not use django for web site development, but for desktop
> application,
> > it seems its orm can be used in destop application, isn't it?
>
> Yes.
> --
>  Andy McKay
>  a...@clearwind.ca
>  twitter: @andymckay
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django Development environment

2011-08-23 Thread Yaşar Arabacı
Development setup (when on my own comp.):
arch linux, vim or leafpad, sqlite, django development server

Development setup (when on my brothers comp):
cygwin, notepad++, sqlite, django development server (both inside and
outside of cygwin to make sure everything is same.)

Deployment:
ubuntu (cloud), nginx with uwsgi, supervisord, postgresql, south

MUST HAVES (on all platforms): git!

2011/8/23 Raul Alejandro Ascencio Trejo 

> Emacs (https://code.djangoproject.com/wiki/Emacs), Postgre... :|
>
>
> 2011/8/22 Mario Gudelj 
>
>> Mac, sqlite, Eclipse with Pydev or AquaMacs, apache
>>
>>
>> On 23 August 2011 13:06, Jani Tiainen  wrote:
>>
>>> Ubuntu or windows, eclipse with pydev, apache, nginx, virtualenv and
>>> Oracle.
>>>
>>> Stephen Jackson  kirjoitti 23.8.2011 kello
>>> 1.07:
>>>
>>> I am new to the world of Django. I would like to hear from other django
>>> developers describe their dev environment (tools, os, editors, etc.).
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To view this discussion on the web visit
>>> 
>>> https://groups.google.com/d/msg/django-users/-/Fq-jCVxrK7AJ.
>>>
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> --
> r-ascencio 
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Debud setting behaves weird

2011-08-23 Thread Yaşar Arabacı
This makes sense :)


Warning

This view will only work if
DEBUG
 is True.

That's because this view is *grossly inefficient* and probably *insecure*.
This is only intended for local development, and should *never be used in
production*.

2011/8/23 Martin J. Laubach 

> You might want to read the documentation at
> https://docs.djangoproject.com/en/1.3/ref/contrib/staticfiles/ --
> especially the big boxes labelled "Warning".
>
> mjl
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/IeEsxfoPtigJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Debud setting behaves weird

2011-08-23 Thread Yaşar Arabacı
I normally use my linux platform, but I am on my brothers computer which is
a win xp. I am on development server. And I just found out that I get 404
because I didn't had 500 template. Now I am getting my 500 template. So here
is sum of what is happening:

go to a static file while django dev server running, and see that file
served.
make DEBUG=False in settings
refresh page
see my 500 template

I can repeat this as much as I want.

2011/8/23 Kejun He <printer...@gmail.com>

> Hi
> Which platform did your project run?
> On the development platform or the publishing platform ?
>
> 2011/8/23 Yaşar Arabacı <yasar11...@gmail.com>
>
>> Hi,
>>
>> When I set debug=True in my settings module, my static files work. When I
>> set it to False, I get 404 on my static files. Anyone has an ide what is
>> going on here?
>>
>> --
>> http://yasar.serveblog.net/
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Debud setting behaves weird

2011-08-23 Thread Yaşar Arabacı
Hi,

When I set debug=True in my settings module, my static files work. When I
set it to False, I get 404 on my static files. Anyone has an ide what is
going on here?

-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



2 url template tag questions

2011-08-23 Thread Yaşar Arabacı
Hi,

If a use url template tag on a generic view, does urls.py supply required
arguments? For example:

urlpatterns = patterns('django.views.generic.date_based',
(r'^arsiv/(?P\d{4})/$','archive_year',{
'template_name' : 'blog/yillar.html',
'date_field' : 'pub_date',
'queryset' : Post.objects.filter(yayinlandi=True),
'extra_context' : common_data,
'make_object_list' : True,
'template_object_name' : 'makale'
}),
)

Can I access this url with {% url
django.views.generic.date_based.archive_index asdfasdf.year %}

And also, I am using rss framework like this:

from feeds import LatestPosts, TagFeed
urlpatterns += patterns('',
(r'^rss/$', LatestPosts()),
(r'^tag/(?P[^/]+)/rss/$', TagFeed()),
)

Can I access this via url template tag?
-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: dynamic form with popup

2011-08-22 Thread Yaşar Arabacı
If you want to dynamically update your Cart without refreshing the page, yes
you will need to write some heavy ajax. But if you are okey with page
refreshing, you can temprorarily save your cart in session and use formsets
as shawn suggested.

2011/8/23 ozgur yilmaz 

> thanks,
>
> but i think i have to use a suitable js for adding a new product. am i
> wrong?
>
> 2011/8/23 Shawn Milochik :
> > On 08/22/2011 05:21 PM, ozgur yilmaz wrote:
> >>
> >> thats not the answer. you can add item to basket by clicking a button
> >> "add to basket" on every item page. My purpose is to fill a single
> >> form, with 1 or many products. Than a single button, saves a checkout
> >> object and many product object.
> >
> > Use formsets, or dynamically generate HTML input fields with prefixes in
> the
> > names and, in your view, dynamically instantiate ModelForm instances with
> > each prefix and save them.
> >
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
> >
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: dynamic form with popup

2011-08-22 Thread Yaşar Arabacı
And also, I suggest that you create Cart model, with ManyToMany field to
your product. And you can add your checkout date there too, and other cart
related information like total price etc. Keep your cart as a session
variable until checked out, you can then save your cart. So that you could
have see checked out Carts on the admin panel.

23 Ağustos 2011 00:12 tarihinde Yaşar Arabacı <yasar11...@gmail.com> yazdı:

> I don't know the answer, but you may want to check this out:
> http://www.satchmoproject.com/
>
>
> 2011/8/23 ozgur yilmaz <yelb...@gmail.com>
>
>> Hi, I have a problem.
>>
>> I have two models:
>>
>> class CheckOut(models.Model):
>>   models.DateField()
>>
>> class Product(models.Model):
>>   checkout = models.ForeignKey( CheckOut )
>>   name = models.CharField()
>>   price = models.FloatField()
>>
>> With these models, i want to contruct a CheckOut form, and select
>> multiple products, calculate the amount ( price * item_number ).
>>
>> What is the most popular or best way to achieve this thought?
>>
>> I want to use popup windows to select a product and item number for
>> checkout. If i can use a "add product" link in the form, and show a
>> popup window to select the product and number, and return the values
>> to the form, i would be glad.
>>
>> Thanks for your help,
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>
>
> --
> http://yasar.serveblog.net/
>
>


-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: dynamic form with popup

2011-08-22 Thread Yaşar Arabacı
I don't know the answer, but you may want to check this out:
http://www.satchmoproject.com/

2011/8/23 ozgur yilmaz 

> Hi, I have a problem.
>
> I have two models:
>
> class CheckOut(models.Model):
>   models.DateField()
>
> class Product(models.Model):
>   checkout = models.ForeignKey( CheckOut )
>   name = models.CharField()
>   price = models.FloatField()
>
> With these models, i want to contruct a CheckOut form, and select
> multiple products, calculate the amount ( price * item_number ).
>
> What is the most popular or best way to achieve this thought?
>
> I want to use popup windows to select a product and item number for
> checkout. If i can use a "add product" link in the form, and show a
> popup window to select the product and number, and return the values
> to the form, i would be glad.
>
> Thanks for your help,
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Admin Stopped Saving Record Changes!

2011-08-21 Thread Yaşar Arabacı
Well, that is because no error occured :)

2011/8/21 Lee 

> Solved: in the process of fixing indentation errors I accidentally
> indented "obj.save()" so that it only fired on inserts not updates.
> Interesting that Admin still generated the "Successful" message when
> no save occurred.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Port of Django Template Language to PHP

2011-08-21 Thread Yaşar Arabacı
I am considering writing about it, but I want to test it first. Since I am
not on my own computer, that will need to wait a little :)

2011/8/21 Rune Kaagaard 

> @Yaşar: Thanks a lot, would love to see the post if you really do write it!
>
> @Kenneth+@Masklinn: You are right, there are a lot of template
> languages already, but this particular wheel is - unlike twig - not a
> compiled language but implemented in pure PHP as an Iterator, allowing
> it to blend in as an extension to your existing PHP templates.
>
> Thanks for your interest!
>
> On Sun, Aug 21, 2011 at 4:09 AM, kenneth gonsalves
>  wrote:
> > On Sat, 2011-08-20 at 21:28 +0200, Masklinn wrote:
> >> > Those of you moonlighting in PHP, might be interested in a pure PHP
> >> > port of the Django Template Language that I've just released. It's
> >> > called Chano and has doc pages at http://chano.readthedocs.org and a
> >> > github account at https://github.com/runekaagaard/php-chano .
> >> This sounds like a huge duplication of effort: there's already
> >> Twig[0],
> >> a port of Jinja2[1] which is basically a reimplementation and
> >> extension
> >> of Django's own templating language.
> >
> > if people did not keep reinventing the wheel we would be still in the
> > age of oxcarts.
> > --
> > regards
> > Kenneth Gonsalves
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> >
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Port of Django Template Language to PHP

2011-08-20 Thread Yaşar Arabacı
Wow, this is definitely going into my blog :) Keep up the good work!

2011/8/20 Rune Kaagaard 

> Dear Django Users
>
> Those of you moonlighting in PHP, might be interested in a pure PHP
> port of the Django Template Language that I've just released. It's
> called Chano and has doc pages at http://chano.readthedocs.org and a
> github account at https://github.com/runekaagaard/php-chano .
>
> Thanks for your time!
> Rune Kaagaard
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Suspicious mail from django-users mail group

2011-08-20 Thread Yaşar Arabacı
Hi,

I got a mail, which I suspect that might be some kind of personal
information stealing thingy. It askes me enable images or click some links.
Does anyone else got similiar mails? I am attaching original mail. I tried
to locate the sender, but, couldn't find the exact location.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




   
Delivered-To: yasar11...@gmail.com
Received: by 10.231.42.197 with SMTP id t5cs29774ibe;
Sat, 20 Aug 2011 10:50:05 -0700 (PDT)
Received: by 10.101.132.12 with SMTP id j12mr641579ann.157.1313862604374;
Sat, 20 Aug 2011 10:50:04 -0700 (PDT)
Return-Path: 
Received: from www29.interneet.com (www29.interneet.com [64.124.221.251])
by mx.google.com with ESMTP id s29si5958100anh.1.2011.08.20.10.50.04;
Sat, 20 Aug 2011 10:50:04 -0700 (PDT)
Received-SPF: neutral (google.com: 64.124.221.251 is neither permitted nor 
denied by domain of django-users@googlegroups.com) client-ip=64.124.221.251;
Authentication-Results: mx.google.com; spf=neutral (google.com: 64.124.221.251 
is neither permitted nor denied by domain of django-users@googlegroups.com) 
smtp.mail=django-users@googlegroups.com
Date: Sat, 20 Aug 2011 10:50:04 -0700 (PDT)
Message-Id: <4e4ff3cc.1df5640a.772c.997fsmtpin_ad...@mx.google.com>
Received: from localhost (unknown [192.168.30.184])
by www29.interneet.com (Postfix) with ESMTP id A86C6A84008
for ; Sat, 20 Aug 2011 10:50:03 -0700 (PDT)
From: django-users@googlegroups.com
To: =?ISO-8859-9?Q?Ya=FEar_Arabac=FD?= 
Subject: Re: 
MIME-Version: 1.0
Content-Type: text/html; charset=UTF-8

I am out of office right now on a short vacation and will get back 
to you when I return. If you don't hear from me, my assistant should contact 
you shortly.  You should check this site to see how I scored the best travel 
deal for my trip..Click
 HereEnable images or click
 hereLet me know what you think after you have a chance to 
review.Cheers!
 If you no longer wish to receive emails, please unsubscribe866-288-18805150 yarmouth ave, 
Encino, CA 91316On , =?ISO-8859-9?Q?Ya=FEar_Arabac=FD?= 
 wrote:

Re: Missing datepicker in Django 1.3 admin

2011-08-20 Thread Yaşar Arabacı
Did you copy admin static files to your static path? They are stored in
{DJANGO_ROOT_DIR}/contrib/admin/media . You need to copy all of them to
{YOUR_STATIC_ROOT}/admin

2011/8/20 George <gmiddlec...@gmail.com>

> Yep, that's what I did .. ADMIN_MEDIA_PREFIX = '/static/admin/'  ...
> was there by default. It does't show even with a new Project!
>
> On Aug 20, 9:39 pm, Yaşar Arabacı <yasar11...@gmail.com> wrote:
> > If that is what kenneth says, I might suggest creating a new project and
> see
> > default settings for static files. it might help you figure out what is
> > going on.
> >
> > 2011/8/20 George <gmiddlec...@gmail.com>
> >
> >
> >
> >
> >
> >
> >
> > > Thanks Kenneth
> >
> > > I commented that out .. I'm still not seeing the datepicker icons in
> > > admin!
> >
> > > On Aug 20, 2:51 pm, kenneth gonsalves <law...@thenilgiris.com> wrote:
> > > > On Sat, 2011-08-20 at 01:53 -0700, George wrote:
> > > > > ADMIN_MEDIA_PREFIX = '/static/admin/'
> >
> > > > this does not exist in 1.3 - please read the docs on
> > > > django.contrib.staticfiles
> > > > --
> > > > regards
> > > > Kenneth Gonsalves
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Django users" group.
> > > To post to this group, send email to django-users@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Missing datepicker in Django 1.3 admin

2011-08-20 Thread Yaşar Arabacı
If that is what kenneth says, I might suggest creating a new project and see
default settings for static files. it might help you figure out what is
going on.

2011/8/20 George 

> Thanks Kenneth
>
> I commented that out .. I'm still not seeing the datepicker icons in
> admin!
>
> On Aug 20, 2:51 pm, kenneth gonsalves  wrote:
> > On Sat, 2011-08-20 at 01:53 -0700, George wrote:
> > > ADMIN_MEDIA_PREFIX = '/static/admin/'
> >
> > this does not exist in 1.3 - please read the docs on
> > django.contrib.staticfiles
> > --
> > regards
> > Kenneth Gonsalves
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: View-Voodoo: Calling functions in a view does weird things

2011-08-20 Thread Yaşar Arabacı
Do it like this:

def myview(request):
   if request.method =="POST":
   return call_my_other_func(request)
   else: rtr("index.html")

def call_my_other_func(request):
   # do something with the data
   messages.info(request, "hello world")
   return rtr("index.html", context_instance=RequestContext())

2011/8/20 dm03514 

> I think you're 'call_my_other_function' is returning to the 'myview'
> function
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Strange behavior in model.save()

2011-08-19 Thread Yaşar Arabacı
I don't quite understand what you did there, but, it seems to me it is the
same thing with your initial post.

ref = getattr(self, f.name) -> you are getting a field here, this field is a
empty descriptor, doesn't hold any data yet.
ref.full_save(*args,*kwargs) -> you populated your field with data here by
calling full_save on it
setattr(self,f.name,ref) -> you are assigning this field to be a part of
parent object, where you got it initially

then you are saving the parent object.





2011/8/19 David Jacquet 

>
> Thanks Yaşar and Jani for your fast replies!
>
>
> I understand that normally one would assign in the reverse order. However I
> do not understand exactly what happens when I do
> meeting.place = meeting.place
> never in my programming experience have I seen an example when
> x=x
> really does something. Isn't this strange?
>
>
> Anyway, the reason for me wanting to go around normal behavior is that I
> have a quite complicated and nested datamodel. Then I offer an api where
> people can post JSON object. The will posts will be heavily nested ojbects
> and I do not want save it to db by rewriting the whole save-chain in my
> code. I have solved this by creating the class AREM below. When I have a
> dictionary d representing a class A (subclass to AREM) and I want it saved I
> do:
>
> a = A().from_dict(d)
> a.full_save()
>
> I have gotten it to work, but not before I added the (for me very strange)
> row
>
> setattr(self, f.name, ref) #Without this everything collapses
>
> residing on the second most bottom row in the code below. The problem is
> that I do not know what it does, nor if there is a more elegant, faster or
> better way to do it.
>
> Best Regards
> David
>
>
>
> #class AbstractRecursiveEnabledModel(models.Model):
> class AREM(AMCS):
> class Meta:
> abstract = True
>
> def from_dict(self, d):
> if not isinstance(d, dict):
> return d
> fl = self._meta.fields
> for f in fl:
> if d.has_key(f.name) and f.rel and d[f.name] is not None:
> d[f.name] = f.rel.to().from_dict(d[f.name])
> self.__init__(**d)
> return self
>
> def full_save(self,*args, **kwargs):fl = self._meta.fields
>
> for f in fl:
> if f.rel:
> ref = getattr(self, f.name)
> if ref is not None and ref.pk is None and ref is not self:
> ref.full_save(*args, **kwargs)
> setattr(self, f.name, ref) #Without this everything
> collapses
> super(AREM, self).save(*args, **kwargs)
>
>
>
>
>
>
>
> On Fri, Aug 19, 2011 at 2:34 PM, Jani Tiainen  wrote:
>
>> On 08/19/2011 03:15 PM, Jacco wrote:
>>
>>> I am having great difficulties in saving nested models in an easy
>>> way.
>>>
>>>
>>> #Two (almost) identical functions:
>>> def test1():
>>> place = Place(where='Paris')
>>>
>>
>> place is not saved, thus it does not have a primary key (id)
>>
>>
>>  meeting = Meeting(place=place, when='2011-01-01')
>>>
>>
>> You assign non saved instance to a meeting. Probably what happened
>> internally is that place.pk is copied to meeting.place_id.
>>
>>  place.save()
>>>
>>
>> You saved place. Changes in model are not reflected to referred model.
>>
>>  meeting.save()
>>>
>>
>> You save meeting with still (partially) stale place pk. thus resulting an
>> exception.
>>
>>
>>  def test2():
>>> place = Place(where='Paris')
>>> meeting = Meeting(place=place, when='2011-01-01')
>>>
>>> place.save()
>>> meeting.place = meeting.place  #BY setting meeting.place to
>>> itself, it works 
>>>
>>
>> You updated your meeting internal structure.
>>
>>  meeting.save()
>>> return meeting
>>>
>>> --
>>>
>>>
>>>
>>> - Running test1() results in crash "null value in column "place_id"
>>> violates not-null constraint"
>>> - Running test2() results in OK.
>>> - Only difference is the dummy line "meting.place = meeting.place".
>>>
>>> Could someone who really understands this explain what is going on?
>>>
>>>
>> What's going on that you have done it incorrect order.
>>
>> place = Place(where='Paris')
>> place.save() # Place saved, PK assigned.
>>
>>
>> meeting = Meeting(place=place, when='2011-01-01')
>> meeting.save() # Meeting saved with correct place.
>>
>> --
>>
>> Jani Tiainen
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> 

Re: Initialization code that should only run under a web server

2011-08-19 Thread Yaşar Arabacı
I didn't try this but might work. You can create a second manage.py called
for example manage2.py  file with following contents:

#!/usr/bin/env python
from django.core.management import execute_manager
import imp
try:
  imp.find_module('alternative_settings') # Assumed to be in the same
directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the
directory containing %r. It appears you've customized things.\nYou'll have
to run django-admin.py, passing it your settings module.\n" % __file__)
sys.exit(1)

import alternative_settings
if __name__ == "__main__":
  execute_manager(alternative_settings)

Then create an alternative_settings.py file, all the same but don't make
heavy calculations there.


2011/8/19 Boaz Leskes 

> Hi,
>
> I have some computationally intensive initialization logic that
> should
> run when a new process is started up by the web server. Following
> advice on the web, I've imported the module with the initialization
> code from settings.py, which works perfectly as advertised. However,
> it has one side effect which is very cumbersome - the code runs with
> every manage command as well. Every syncdb (and migration as we use
> South) takes forever. This is a problem during deployment.
>
> What's the best way to run initialization code only when it is
> executed under a server? (runserver & mod_wsgi) - is there any way to
> tell that a manage command is active at the moment and what it is? I
> could then not run the code for anything but runserver.
>
> Thanks,
> Boaz
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Strange behavior in model.save()

2011-08-19 Thread Yaşar Arabacı
And your second function works because when you set  meeting.place =
meeting.place, unsaved place object gets changed with saved place object :)
Nice catch though.

19 Ağustos 2011 15:28 tarihinde Yaşar Arabacı <yasar11...@gmail.com> yazdı:

> It is because you are creating meeting object, before saving "place" in db.
> So place object doesn't have any id yet. So test 1 should be:
>
>place = Place(where='Paris')
>place.save()
>meeting = Meeting(place=place, when='2011-01-01')
>
>
>
>meeting.save()
>return meeting
> 2011/8/19 Jacco <jacquet.da...@gmail.com>
>
>> I am having great difficulties in saving nested models in an easy
>> way.
>>
>>
>> Consider the following Example :
>>
>> --
>> class Place(models.Model):
>>where   = models.CharField(max_length=10)
>> class Meeting(models.Model):
>>place = models.ForeignKey(Place)
>>when  = models.DateField()
>>
>> #Two (almost) identical functions:
>> def test1():
>>place = Place(where='Paris')
>>meeting = Meeting(place=place, when='2011-01-01')
>>
>>place.save()
>>
>>meeting.save()
>>return meeting
>>
>> def test2():
>>place = Place(where='Paris')
>>meeting = Meeting(place=place, when='2011-01-01')
>>
>>place.save()
>>meeting.place = meeting.place  #BY setting meeting.place to
>> itself, it works 
>>meeting.save()
>>return meeting
>>
>> --
>>
>>
>>
>> - Running test1() results in crash "null value in column "place_id"
>> violates not-null constraint"
>> - Running test2() results in OK.
>> - Only difference is the dummy line "meting.place = meeting.place".
>>
>> Could someone who really understands this explain what is going on?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Strange behavior in model.save()

2011-08-19 Thread Yaşar Arabacı
It is because you are creating meeting object, before saving "place" in db.
So place object doesn't have any id yet. So test 1 should be:

   place = Place(where='Paris')
   place.save()
   meeting = Meeting(place=place, when='2011-01-01')



   meeting.save()
   return meeting
2011/8/19 Jacco 

> I am having great difficulties in saving nested models in an easy
> way.
>
>
> Consider the following Example :
>
> --
> class Place(models.Model):
>where   = models.CharField(max_length=10)
> class Meeting(models.Model):
>place = models.ForeignKey(Place)
>when  = models.DateField()
>
> #Two (almost) identical functions:
> def test1():
>place = Place(where='Paris')
>meeting = Meeting(place=place, when='2011-01-01')
>
>place.save()
>
>meeting.save()
>return meeting
>
> def test2():
>place = Place(where='Paris')
>meeting = Meeting(place=place, when='2011-01-01')
>
>place.save()
>meeting.place = meeting.place  #BY setting meeting.place to
> itself, it works 
>meeting.save()
>return meeting
>
> --
>
>
>
> - Running test1() results in crash "null value in column "place_id"
> violates not-null constraint"
> - Running test2() results in OK.
> - Only difference is the dummy line "meting.place = meeting.place".
>
> Could someone who really understands this explain what is going on?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Getting and modifying url parameters in template: howto?

2011-08-19 Thread Yaşar Arabacı
You can either send required information from your view to your template, or
do some javascript on the browser side.

2011/8/19 samuele.mattiuzzo 

> Yeah, i was thinking about that...
>
> A template tag like {% my_url   %}
>
> could be something like that...
>
> On Aug 18, 6:36 pm, Andre Terra  wrote:
> > Assuming I understood what you're trying to do, why not write a template
> tag
> > (more specifically, an inclusion tag)?
> >
> > Cheers,
> > AT
> >
> > On Thu, Aug 18, 2011 at 11:47 AM, samuele.mattiuzzo  >wrote:
> >
> >
> >
> >
> >
> >
> >
> > > I'm not using haystack, since is strictly model-related. My solr
> > > instance isnt' bound to any model (since i don't use any backend DB to
> > > store my data)
> >
> > > i need something like get_full_path or get_absolute_url, but not
> > > modell-related in this case...
> >
> > > On 18 Ago, 16:37, Andre Terra  wrote:
> > > > Searching with Django =http://haystacksearch.org/
> >
> > > > Behold the power of pluggable apps.
> >
> > > > Cheers,
> > > > AT
> >
> > > > On Thu, Aug 18, 2011 at 11:34 AM, samuele.mattiuzzo <
> samum...@gmail.com
> > > >wrote:
> >
> > > > > Hi!
> > > > > I'm stuck with a problem... more confused than stuck, actually.
> >
> > > > > I have a search engine i'm working on, and we're using GET method
> to
> > > > > perform searches. In the listing page, i have my search results on
> the
> > > > > left and some filters on the right, something like google's filter.
> >
> > > > > my filters are all blabla
> >
> > > > > what i need to do, and i don't know how, is:
> >
> > > > > 1 - get url parameters
> > > > > 2 - for each filter modify the correct parameter
> >
> > > > > example:
> >
> > > > >www.mysite.com/?name=apple=now=male
> >
> > > > > for "name" filters:
> >
> > > > > new_val
> >
> > > > > i don't know what to look for, maybe the {{ url }} tag can help me,
> > > > > but i don't know how to get_and_modify a specific param :(
> >
> > > > > can anybody help me? thanks!
> >
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > Groups
> > > > > "Django users" group.
> > > > > To post to this group, send email to django-users@googlegroups.com
> .
> > > > > To unsubscribe from this group, send email to
> > > > > django-users+unsubscr...@googlegroups.com.
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/django-users?hl=en.
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Django users" group.
> > > To post to this group, send email to django-users@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



M2M with self throught int. table, how to access related items?

2011-08-16 Thread Yaşar Arabacı
Hi,

I have tried to sent this e-mail before, but I guess it didn't make its way
to the groups so I am trying to resent it, if this is a double post, I am
sorry. I am having trouble understanding m2m relation to self with a
intermediary table. Here is my table setup stripped:

   class Post(models.Model):

   relevancy =
models.ManyToManyField("self",
through="Traffic",symmetrical=False,related_name="relevant",blank=True)

   class Traffic(models.Model):
   tfrom = models.ForeignKey(Post,related_name="tfrom")
   tto = models.ForeignKey(Post,related_name="tto")
   count = models.PositiveIntegerField(default=0)

This is to be a simple visitor tendency tool, which I keep records of
which link clicked on which post. I am confused about, getting related
items. For example, given a post, how to get set of posts which have
traffic from the post (post.tfrom_set ? ), or how to get post with a
max "count" which is trafficked to the post
( post.tto_set.max("count") ? ) etc.

And also, what is the recommended way of getting, for example, given a post,
which is the post with max "count" value from this post. Like, get a list of
traffics where tfrom is given post, and get a Traffic object with max
"count" and get tto post of that traffic.

PS: English is not my main language. Sorry if I wasn't clear

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: model save question

2011-08-16 Thread Yaşar Arabacı
Absence of **kwargs would cause problems if for example save method is
called with "using" keyword argument. You could either list all the
available keyword arguments or use **kwargs.

By the way, is there any other kwarg for save?

2011/8/16 Mike Dewhirst 

> When using save() in a model, what is the difference between ...
>
> save(self, force_insert=False, force_update=False) or
> save(self, force_insert=False, force_update=False, **kwargs)
># whatever
>super(Xyz, self).save(force_insert, force_update) or
>super(Xyz, self).save(force_insert, force_update, **kwargs)
>
> and
>
> save(self, *arg, **kwargs)
># whatever
>super(Xyz, self).save(*args, **kwargs)
>
> I see the former in a fair bit of django example code around the place and
> the latter in the docs here
>
>
> https://docs.djangoproject.com/en/dev/topics/db/models/#overriding-predefined-model-methods
>
> Thanks for any insights
>
> Mike
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



M2M with self throught int. table, how to access related items?

2011-08-16 Thread Yaşar Arabacı
Hi,

I am not a django guru (yet) and I am having what I would guess a
trivial django question. Here is my table setup stripped:

class Post(models.Model):

relevancy =
models.ManyToManyField("self",through="Traffic",symmetrical=False,related_name="relevant",blank=True)

class Traffic(models.Model):
tfrom = models.ForeignKey(Post,related_name="tfrom")
tto = models.ForeignKey(Post,related_name="tto")
count = models.PositiveIntegerField(default=0)

This is to be a simple visitor tendency tool, which I keep records of
which link clicked on which post. I am confused about, getting related
items. For example, given a post, how to get set of posts which have
traffic from the post (post.tfrom_set ? ), or how to get post with a
max "count" which is trafficked to the post
( post.tto_set.max("count") ? ) etc.

PS: English is not my main language. Sorry if I wasn't clear

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.