Into trunk merged queryset-refactor branch, that makes it easy to inherit django-models. It has been known to all. But inheritance is not the only alternative, it can be also used Monkey patching.
The main idea is that Monkey patching also lets you add not only the fields, but also the functions.
For example, so will be added in the model User the field OpenID, and the additional function, that returns the nickname, if there is no name
from django.contrib.auth.models import User

User.add_to_class('openid', models.CharField(max_length=250,blank=True))

def get_user_name(self):
    if self.first_name or self.last_name:
        return self.first_name + " " + self.last_name
    return self.username

User.add_to_class("get_user_name",get_user_name)
The main benefits of the method:
additional tables are not created
in the work with the model will be used standard instruments of django

6 Votes | Average: 5 out of 56 Votes | Average: 5 out of 56 Votes | Average: 5 out of 56 Votes | Average: 5 out of 56 Votes | Average: 5 out of 5 (6 votes, average: 5 out of 5)
Loading ... Loading ...
For the storage of the element state will be sometimes used the bitmasks. For example, as state - read/unread comment to article for each user. Although it would be better for this case, to save the time of the last view of the entry, here can arise also other tasks, in which must be remembered the binary data for elements, that don't include the timefield.

You can use the M2M-connection between a user and object. But the drawback is essential resources for index and the number of entries, if there are many users and objects. Here it would make sense to use the bit mask, without this shortcoming.

(more...)

2 Votes | Average: 5 out of 52 Votes | Average: 5 out of 52 Votes | Average: 5 out of 52 Votes | Average: 5 out of 52 Votes | Average: 5 out of 5 (2 votes, average: 5 out of 5)
Loading ... Loading ...
Jared Kuolt has developed a StaticGenerator for Django - Cache Script. It is helpful, original and easy to use. But the script and nginx-configuration shown by Jared have some drawbacks:
1) actual only for web sites without authorization;
2) working with only simple links;
3) cache creating only by change/add content and/or comments.

I have corrected the StaticGenerator and added something interesting to the script and get StaticGenerator Pro.

(more...)

13 Votes | Average: 5 out of 513 Votes | Average: 5 out of 513 Votes | Average: 5 out of 513 Votes | Average: 5 out of 513 Votes | Average: 5 out of 5 (13 votes, average: 5 out of 5)
Loading ... Loading ...
Here is a small article on how to access the data directly, without request to the web server (e.g. for getting and/or updating of the data via cron).

(more...)

3 Votes | Average: 4 out of 53 Votes | Average: 4 out of 53 Votes | Average: 4 out of 53 Votes | Average: 4 out of 53 Votes | Average: 4 out of 5 (3 votes, average: 4 out of 5)
Loading ... Loading ...
To the searchengines again. Some small news about djangosearch.com.
Now will be included all resources in the search, which the users add in djangosearch, and not the several separate web-sites. I find it more optimal - there are so many valuable articles.
Here it is also possible to select an other language for search.

In addition, djangosearch is complemented with the google-translator - it was a useful advice in comments, now you can translate each article into some languages directly from the pages of djangosearch.

Creative critique and proposals are desired! Maybe you knew any articles or sites, which are useful to be included in the search engine?

6 Votes | Average: 5 out of 56 Votes | Average: 5 out of 56 Votes | Average: 5 out of 56 Votes | Average: 5 out of 56 Votes | Average: 5 out of 5 (6 votes, average: 5 out of 5)
Loading ... Loading ...

1 ... 3

Powered by Django.