Updating django pluggable apps after modification - django

I'm using django-basic-apps' blog app, but I have a few modification to it: added a ManyToManyField and a URLField.
Is it possible to maintain my modifications while keeping up-to-date with the most recent release of the apps?

Sure, just fork the project on GitHub. You can then regularly merge from the parent project, while keeping your modifications.
You can do this via your own git repo as well, if you don't want to make your modifications public, but GitHub is easier as it has all this set up for you already.

It might be best to extend the existing models from django-basics-apps, have a look at:
http://docs.djangoproject.com/en/1.2/topics/db/models/#model-inheritance
# custom_blog/models.py
from blog.models import Post
class CustomPost(Post):
new_field_one = ManyToManyField
new_field_two = URLField

Related

CMS for Django when upgrading app from 1.5.5 to 1.7.1

I have a huge... challenge in front of me. For about a week or two I've been migrating 1.5.5 django project to 1.7.1. A huge jump, many deprecated variables, methods and so on.
In 1.5.5 there were some south migrations done but not everywhere, as it was not implemented from the beginning. So let's say there are no migrations, they have to be created.
Also there is a wish to add a cms to the already upgraded project, but with django-cms-3.0.7 I constantly encounter some issues with migrations, south existing etc.
Is there a CMS that I can use with this app that won't be bothered by migrations and django version?
All I want to edit is the static content (text, images, maybe adding videos) before user logon. No integration with models. Just some info pages.
Any suggestions?
A maybe oversimplified solution for this could be django-front. Create your static pages and add the fields you want to edit. You edit it with a wysiwyg editor. I use it for my terms of service/privacy policy.
You will probably be always bothered by migrations and django version when using an app that brings extra functionality, but the apps should not be hard to upgrade and normally they have a warning/walk through when an important change on their arquitecture/functionality has happened.
That being said, i don't think migrations change dramatically now. The change to include them in the django project was an important (and needed) one.
If you want something even more simple (and time resistant) just create a model for your pages and render it on your template:
class Content(models.Model):
html_content = models.TextField()
image_content = models.ImageField()
Register that model to your admin and that should do the trick. For simple applications this may be enough.

Where is recommended spot for storing admin customizations for Django contrib apps?

I want to add Django Sessions to my Django Admin, and I am following an SO post about this, but it is unclear where I store this code. Do I put it in an admin.py file? Under what directory?
In short, it doesn't matter. You can put the code into any of your apps' admin.py files. However, in situations like these I tend to use a generic app in my project, usually named something like utils, that exists for the sole purpose of housing code that doesn't belong to one specific app or could be used by multiple apps.
If you want to be more specific, you can create a sessions app in your project specifically devoted to this code and any other code related to session management for your project, or perhaps an existing app that is somewhat related. For example, I put customizations to the User admin in my accounts app that holds the UserProfile model.

How to create views automatically from model as in Django admin?

I'm starting to use Django and I'm really impressed by the possibility of automatically creating views from a model.
So, I'd like to know if there is such functionality on other web frameworks. I know of RoR scaffolding, but that is not quite the same thing, since you need to change your views manually in case you change the related model.
For those who are looking for an answer here, perhaps django-baker (https://github.com/krisfields/django-baker.git) will do what you need.
pip install django-baker
Then add django_baker to INSTALLED_APPS and run
python manage.py bake your_app_name
Note that previously you need to remove urls.py and views.py from your app so they can be generated.
Then it will generate all the skeleton stuff.
https://docs.djangoproject.com/en/dev/topics/class-based-views/
I think I've found one possible solution. The concept is called model drive development. There are quite a few java frameworks that provide the ability to create a, rather simple, application directly from the model. This post presents some of them http://www.javaneverdie.com/java-frameworks/java-domain-driven-frameworks-review/

Pinax: Customize Signup and profile

I want to gather some more information when the user signs up and also display this as part of the profile information - so that the user can edit it once he creates a login.
How can I extend the sign-up and profile form and model without changing directly pinax code?
From pinax docs
Customization
As more sites are built using Pinax,
more best practices will emerge, but
for now what we recommend is:
Always work off a stable release. The most current release is 0.7.1.
Use the pinax-admin setup_project command.
Make necessary changes to the settings.py and urls.py files in your copied directory.
Change the domain and display name of the Site in the admin interface.
Develop your custom apps under your new project or anywhere on Python path.
Develop your own templates under your new project.
This thread is very relevant to your question and discusses options for overriding the default pinax apps.
It suggests looking at https://github.com/eldarion/idios, (an extensible profile app designed to replace the profiles apps in Pinax).
This blog has some comments about overriding the default pinax apps:
Overriding build-in Pinax Applications
Assuming we want to override
$PINAX_ROOT/apps/blog with
$PROJECT_ROOT/apps/blog we can do so
simply by copying the application and
make our project-local (read
individual) changes to it. Pinax will
then load $PROJECT_ROOT/apps/blog
rather than $PINAX_ROOT/apps/blog.
Those who do not care about merging in
upstream changes nor submitting
bugfixes/features upstream would just
issue cp -a $PINAX_ROOT/apps/blog
$PROJECT_ROOT/apps and be done. Those
who consider themselves good
FLOSS-country citizens however care
about contributing back as well ...
The default pinax apps you would be looking to override (if necessary), would be:
http://pinaxproject.com/docs/dev/apps/account/
http://pinaxproject.com/docs/dev/apps/profiles/
You probably want to have a go at overriding the built-in Pinax applications, which is gone over in a little detail in this article. I imagine you'd want to extend (or override) Pinax's Profile model.
This chap seems to have been in a situation that sounds like what you want, have a quick read of his chat logs to see what I mean. Sorry that this answer isn't too specific, it's more of a pointer.

How to register a model in django-tagging anywhere not in the applications?

Is it possible to register a model in django-tagging not in tagging app, nor in my app?
The standard way is to edit apps/myapp/models.py this way:
from apps import tagging
tagging.register(MyModel)
I want to keep both applications without changes, for example, to be able to pull new versions and just replace them. So I tried putting this into project settings.py, in the end, but of course this fails.
from apps.myapp.models import MyModel
from apps import tagging
tagging.register(MyModel)
(This fails when importing MyModel.)
Any other way?
You can't do that in settings.py, as the models haven't been set up yet. One possibility is to do it in urls.py - admin.autodiscover is already there, so this might be a good place for the call to tagging.register as well.
There has been quite a lot of discussion in the django-developers group about the correct place for this sort of thing, but as yet no firm policy has been reached.