django

django:: run manage.py from within django code

How can I run the manage.py script from withing django code? ...

Whats the best way to start learning django?

I really want tobuild a web application (something simple, maybe a database of pokemon cards for instance..) I've heard excellent things about django, wheres the best place to start? ...

How to add custom control to django admin site?

Hey, I want to add custom buttom to the django admin site, and the users must be administrators, I do not expect you tell me how to do in each step, but please brief write the right approach, if you also can provide some reading URLs, that's gonna be awesome. ...

Getting blank statement in django model charfield with mysql

I just migrated my django application from sqlite3 to mysql 5.1.41. I have a charfield in a model defined like this: class HostData(models.Model): Host = models.CharField(max_length=50, null=True) HostStatus = models.CharField(max_length=200, null=True) Alarm = models.BooleanField() Everything works the same except HostStatus, w...

How to validate django form only when adding not editing

Hi, How could we make the django form to not validate if we are editing, not adding a new record. The code as following : class PageForm(forms.Form): name = forms.CharField(max_length=100,widget=forms.TextInput(attrs={'class':'textInput'})) description = forms.CharField(max_length=300, required=False,widget=forms.TextInput(attrs={'class...

django admin printer friendly stylesheet

Has anyone got or know if a printer friendly css file is available for the Django Admin site? ...

Django Apps extendability - How to make your django apps easily extendable?

What are your best practises for making your django application easily extendable for other developers? What are your approaches for enabling other to overwrite your views forms templates models classes In a way that enables a healthy environment for extensions to work well together? ...

Django creating object from POST

Hello, I have a question regarding Djanog views here is a sample code def example register ( request ) : if request.method == ’POST ’ : username = request.POST.get ( ’ username ’ ) password = request.POST.get ( ’ password ’ ) email = request.POST.get (’email’) user = User.objects .create_user ( username , email , password ) user . sa...

Disable session creation in Django

I'm looking to disable the automatic session creation in Django for certain URLs. I have /api/* and each client that hits that gets a new Django session. Is there a way to ignore certain urls? ...

I need to return a link generated after the completion of ModelForm

part of forms.py class FormPublicar(forms.ModelForm): class Meta: model = Publicacao exclude = ('usuario', 'aprovado', 'cadastrado_em', 'slug') def enviar(self): titulo = 'mensagem enviada pelo site' destino = self.cleaned_data['emailp'] mensagem = u""" Message that will be sent after completing the form. H...

SQLAlchemy equivalent to Django's annotate() method

I'm doing a join like this in SQLAlchemy: items = Item.query\ .outerjoin((ItemInfo, ItemInfo.item_id==Item.id)) items.add_columns(ItemInfo.count) This causes SQLAlchemy to return tuples: >>> items.first() (<Item ...>, 2) I'd much prefer it if the "count" value would instead be returned as an attribute of the item, i.e. I wa...

Having a problem displaying a manytomany fields

Hello, I seem to have a problem displaying work orders. in my app. The clients does not have the same problem so why does the work orders not show up. Actually it is as almost as a black space appears rather than text that should appear from my database. The problem seems to be because work orders have a many-to-many field. If I have {{...

Form loses ability to send POST requests after 2 ajax updates

I have an included object's form: <form method="post" class="object_form" id="event-core-form" action="{% url save_event_core_data event.id %}" enctype="multipart/form-data"> {{ form.as_p }} <p> <input class="object-submit" id="object-data-save" type="submit" value="Save data"> </p> </form> After hitting 'submit' b...

CSV only taking first record

I have been working on my CSV upload for a little while now, and I finally got it working (sort of haha) As it stands right now, my code will only pull the first record from the CSV file, and I have been looking at it too long, and Im sure I am missing something. Here is my views.py @login_required def importClient(request): print "i...

Django Testing - How do I do it now?

Hi everyone, I am running django on twisted. I have a special variable which is my engine being passed to each request. Take a loook at the following code: # Django setup sys.path.append("shoout_web") os.environ['DJANGO_SETTINGS_MODULE'] = 'shoout_web.settings' from django.core.handlers.wsgi import WSGIHandler def wsgi_resource(): ...

Scaling disqus using Django, horizontal and vertical partitioning helper methods, please explain

http://www.slideshare.net/zeeg/djangocon-2010-scaling-disqus Vertical partitioning helper: class ApplicationRouter(object) def db_for_read(self, model, **hints): instance = hints.get('instance') if not instance: return None app_label = instance._meta.app_label return get_application_...

"Add another" popup with django-ajax-selects

I try to use django-ajax-selects in a form used in a view (not in the admin). I sucessfully get the autocomplete field working (with lookup), but I don't know how to add the "+" button to add a new record. My current code looks like: -- models.py class Address(models.Model): partner = models.ForeignKey(Partner, related_name='addre...

Unit testing with django-celery?

I am trying to come up with a testing methodology for our django-celery project. I have read the notes in the documentation, but it didn't give me a good idea of what to actually do. I am not worried about testing the tasks in the actual daemons, just the functionality of my code. Mainly I am wondering: How can we bypass task.delay(...

Why is my Django view being hit twice with every page view?

I can't seem to find the problem for the life of me. Very simply, I have a database object that I'm pulling from the database, incrementing it's "views" by one, and saving. My view display's the incremented value, but then my logs show that the value is incremented AGAIN. g=Game.objects.filter(slug=slug).distinct()[0] g.views += 1 g.sav...

In Django's template engine, how do I display a datetime object in a meaningful way?

{{ p.date }} is displayed as: Date: 2010-10-29 21:56:39.226000 How do I make changes to how that's displayed? ...