Search Results

Search found 23428 results on 938 pages for 'django related manager'.

Page 3/938 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Django foreign key question

    - by Hulk
    All, i have the following model defined, class header(models.Model): title = models.CharField(max_length = 255) created_by = models.CharField(max_length = 255) def __unicode__(self): return self.id() class criteria(models.Model): details = models.CharField(max_length = 255) headerid = models.ForeignKey(header) def __unicode__(self): return self.id() class options(models.Model): opt_details = models.CharField(max_length = 255) headerid = models.ForeignKey(header) def __unicode__(self): return self.id() AND IN MY VIEWS I HAVE p= header(title=name,created_by=id) p.save() Now the data will be saved to header table .My question is that for this id generated in header table how will save the data to criteria and options table..Please let me know.. Thanks..

    Read the article

  • Django admin site auto populate combo box based on input

    - by user292652
    hi i have to following model class Match(models.Model): Team_one = models.ForeignKey('Team', related_name='Team_one') Team_two = models.ForeignKey('Team', related_name='Team_two') Stadium = models.CharField(max_length=255, blank=True) Start_time = models.DateTimeField(auto_now_add=False, auto_now=False, blank=True, null=True) Rafree = models.CharField(max_length=255, blank=True) Judge = models.CharField(max_length=255, blank=True) Winner = models.ForeignKey('Team', related_name='winner', blank=True) updated = models.DateTimeField('update date', auto_now=True ) created = models.DateTimeField('creation date', auto_now_add=True ) def save(self, force_insert=False, force_update=False): pass @models.permalink def get_absolute_url(self): return ('view_or_url_name') class MatchAdmin(admin.ModelAdmin): list_display = ('Team_one','Team_two', 'Winner') search_fields = ['Team_one','Team_tow'] admin.site.register(Match, MatchAdmin) i was wondering is their a way to populated the winner combo box once the team one and team two is selected in admin site ?

    Read the article

  • Default value for field in Django model

    - by Daniel Garcia
    Suppose I have a model: class SomeModel(models.Model): id = models.AutoField(primary_key=True) a = models.IntegerField(max_length=10) b = models.CharField(max_length=7) Currently I am using the default admin to create/edit objects of this type. How do I set the field 'a' to have the same number as id? (default=???) Other question Suppose I have a model: event_date = models.DateTimeField( null=True) year = models.IntegerField( null=True) month = models.CharField(max_length=50, null=True) day = models.IntegerField( null=True) How can i set the year, month and day fields by default to be the same as event_date field?

    Read the article

  • How to manually render a Django template for an inlineformset_factory with can_delete = True / False

    - by chefsmart
    I have an inlineformset with a custom Modelform. So it looks something like this: MyInlineFormSet = inlineformset_factory(MyMainModel, MyInlineModel, form=MyCustomInlineModelForm) I am rendering this inlineformset manually in a template so that I have more control over widgets and javascript. So I go in a loop like {% for form in myformset.forms %} and then manually render each field as described on this page http://docs.djangoproject.com/en/dev/topics/forms/#customizing-the-form-template The formset has can_delete = True or can_delete = False depending on whether the user is creating new objects or editing existing ones. Question is, how do I manually render the can_delete checkbox?

    Read the article

  • Django updating db for selected ids

    - by Hulk
    In the following, New row values in DB are 6,8.They are the ids of a field I want to update these some other fields in the table based on these values row_newid=request.POST.get('row_updated_id') //Array row_newdata=request.POST.get('row_updated_data') //Array for newrow in row_newid: //how to update row_newdata for newrow values No for all the ids in row_newid how do i update row_newdata. row_newdata has the values 'a' and 'b' for example. thanks....

    Read the article

  • Upload Image with Django Model Form

    - by jmitchel3
    I'm having difficulty uploading the following model with model form. I can upload fine in the admin but that's not all that useful for a project that limits admin access. #Models.py class Profile(models.Model): name = models.CharField(max_length=128) user = models.ForeignKey(User) profile_pic = models.ImageField(upload_to='img/profile/%Y/%m/') #views.py def create_profile(request): try: profile = Profile.objects.get(user=request.user) except: pass form = CreateProfileForm(request.POST or None, instance=profile) if form.is_valid(): new = form.save(commit=False) new.user = request.user new.save() return render_to_response('profile.html', locals(), context_instance=RequestContext(request)) #Profile.html <form enctype="multipart/form-data" method="post">{% csrf_token %} <tr><td>{{ form.as_p }}</td></tr> <tr><td><button type="submit" class="btn">Submit</button></td></tr> </form> Note: All the other data in the form saves perfectly well, the photo does not upload at all. Thank you for your help!

    Read the article

  • Django: Prefill a ManytoManyField

    - by Emile Petrone
    I have a ManyToManyField on a settings page that isn't rendering. The data was filled when the user registered, and I am trying to prefill that data when the user tries to change it. Thanks in advance for the help! The HTML: {{form.types.label}} {% if add %} {{form.types}} {% else %} {% for type in form.types.all %} {{type.description}} {% endfor %} {% endif %} The View: @csrf_protect @login_required def edit_host(request, host_id, template_name="host/newhost.html"): host = get_object_or_404(Host, id=host_id) if request.user != host.user: return HttpResponseForbidden() form = HostForm(request.POST) if form.is_valid(): if request.method == 'POST': if form.cleaned_data.get('about') is not None: host.about = form.cleaned_data.get('about') if form.cleaned_data.get('types') is not None: host.types = form.cleaned_data.get('types') host.save() form.save_m2m() return HttpResponseRedirect('/users/%d/' % host.user.id) else: form = HostForm(initial={ "about":host.about, "types":host.types, }) data = { "host":host, "form":form } return render_to_response(template_name, data, context_instance=RequestContext(request)) Form: class HostForm(forms.ModelForm): class Meta: model = Host fields = ('types', 'about', ) types = forms.ModelMultipleChoiceField( widget=forms.CheckboxSelectMultiple, queryset=Type.objects.all(), required=True) about = forms.CharField( widget=forms.Textarea(), required=True) def __init__(self, *args, **kwargs): super(HostForm, self).__init__(*args, **kwargs) self.fields['about'].widget.attrs = { 'placeholder':'Hello!'}

    Read the article

  • Select a subset of foreign key elements in inlineformset_factory in Django

    - by Enis Afgan
    Hello, I have a model with two foreign keys: class Model1(models.Model): model_a = models.ForeignKey(ModelA) model_b = models.ForeignKey(ModelB) value = models.IntegerField() Then, I create an inline formset class, like so: an_inline_formset = inlineformset_factory(ModelA, Model1, fk_name="model_a") and then instantiate it, like so: a_formset = an_inline_formset(request.POST, instance=model_A_object) Once this formset gets rendered in a template/page, there is ChoiceField associated with the model_b field. The problem I'm having is that the elements in the resulting drop down menu include all of the elements found in ModelB table. I need to select a subset of those based on some criteria from ModelB. At the same time, I need to keep the reference to the instance of model_A_object when instantiating inlineformset_factory and, therefore, I can't just use this example. Any suggestions?

    Read the article

  • Django models avoid duplicates

    - by Hulk
    In models, class Getdata(models.Model): title = models.CharField(max_length=255) state = models.CharField(max_length=2, choices=STATE, default="0") name = models.ForeignKey(School) created_by = models.ForeignKey(profile) def __unicode__(self): return self.id() In templates <form> <input type="submit" save the data/> </form> If the user clicks on the save button and the above data is saved in the table how to avoid the duplicates,i.e, if the user again clicks on the same submit button there should not be another entry for the same values.Or is it some this that has to be handeled in views Thanks..

    Read the article

  • Default value for hidden field in Django model

    - by Daniel Garcia
    I have this Model: class Occurrence(models.Model): id = models.AutoField(primary_key=True, null=True) reference = models.IntegerField(null=True, editable=False) def save(self): self.collection = self.id super(Occurrence, self).save() I want for the reference field to be hidden and at the same time have the same value as id. This code works if the editable=True but if i want to hide it it doesnt change the value of reference. how can i fix that?

    Read the article

  • Django models avaoid duplicates

    - by Hulk
    In models, class Getdata(models.Model): title = models.CharField(max_length=255) state = models.CharField(max_length=2, choices=STATE, default="0") name = models.ForeignKey(School) created_by = models.ForeignKey(profile) def __unicode__(self): return self.id() In templates <form> <input type="submit" save the data/> </form> If the user clicks on the save button and the above data is saved in the table how to avoid the duplicates,i.e, if the user again clicks on the same submit button there should not be another entry for the same values.Or is it some this that has to be handeled in views Thanks..

    Read the article

  • Django make model field name a link

    - by Daniel Garcia
    what Im looking to do is to have a link on the name of a field of a model. So when im filling the form using the admin interface i can access some information. I know this doesn't work but shows what i want to do class A(models.Model): item_type = models.CharField(max_length=100, choices=ITEMTYPE_CHOICES, verbose_name="<a href='http://www.quackit.com/html/codes'>Item Type</a>") Other option would be to put a description next to the field. Im not even sure where to start from.

    Read the article

  • Multiple model forms with some pre-populated fields

    - by jimbocooper
    Hi! Hope somebody can help me, since I've been stuck for a while with this... I switched to another task, but now back to the fight I still can't figure out how to come out from the black hole xD The thing is as follows: Let's say I've got a product model, and then a set of Clients which have rights to submit data for the products they've been subscribed (Many to Many from Client to Product). Whenever my client is going to submit data, I need to create as many forms as products he's subscribed, and pre-populate each one of them with the "product" field as long as perform a quite simple validation (some optional fields have to be completed if it's client's first submission). I would like one form "step" for each product submission, so I've tried formWizards... but the problem is you can't pre-assign values to the forms... this can be solved afterwards when submitting, though... but not the problem that it doesn't allow validation either, so at the end of each step I can check some data before rendering next step. Then I've tried model formsets, but then there's no way to pre-populate the needed fields. I came across some django plugins, but I'm not confident yet if any of them will make it.... Did anybody has a similar problem so he can give me a ray of light? Thanks a lot in advance!! :) edit: The code I used in the formsets way is as follows: prods = Products.objects.filter(Q(start_date__lte=today) & Q(end_date__gte=today), requester=client) num = len(prods) PriceSubmissionFormSet = modelformset_factory(PriceSubmission, extra=num) formset = PriceSubmissionFormSet(queryset=PriceSubmission.objects.none())

    Read the article

  • Django: What's an awesome plugin to maintain images in the admin?

    - by meder
    I have an articles entry model and I have an excerpt and description field. If a user wants to post an image then I have a separate ImageField which has the default standard file browser. I've tried using django-filebrowser but I don't like the fact that it requires django-grappelli nor do I necessarily want a flash upload utility - can anyone recommend a tool where I can manage image uploads, and basically replace the file browse provided by django with an imagepicking browser? In the future I'd probably want it to handle image resizing and specify default image sizes for certain article types. Edit: I'm trying out adminfiles now but I'm having issues installing it. I grabbed it and added it to my python path, added it to INSTALLED_APPS, created the databases for it, uploaded an image. I followed the instructions to modify my Model to specify adminfiles_fields and registered but it's not applying in my admin, here's my admin.py for articles: from django.contrib import admin from django import forms from articles.models import Category, Entry from tinymce.widgets import TinyMCE from adminfiles.admin import FilePickerAdmin class EntryForm( forms.ModelForm ): class Media: js = ['/media/tinymce/tiny_mce.js', '/media/tinymce/load.js']#, '/media/admin/filebrowser/js/TinyMCEAdmin.js'] class Meta: model = Entry class CategoryAdmin(admin.ModelAdmin): prepopulated_fields = { 'slug': ['title'] } class EntryAdmin( FilePickerAdmin ): adminfiles_fields = ('excerpt',) prepopulated_fields = { 'slug': ['title'] } form = EntryForm admin.site.register( Category, CategoryAdmin ) admin.site.register( Entry, EntryAdmin ) Here's my Entry model: class Entry( models.Model ): LIVE_STATUS = 1 DRAFT_STATUS = 2 HIDDEN_STATUS = 3 STATUS_CHOICES = ( ( LIVE_STATUS, 'Live' ), ( DRAFT_STATUS, 'Draft' ), ( HIDDEN_STATUS, 'Hidden' ), ) status = models.IntegerField( choices=STATUS_CHOICES, default=LIVE_STATUS ) tags = TagField() categories = models.ManyToManyField( Category ) title = models.CharField( max_length=250 ) excerpt = models.TextField( blank=True ) excerpt_html = models.TextField(editable=False, blank=True) body_html = models.TextField( editable=False, blank=True ) article_image = models.ImageField(blank=True, upload_to='upload') body = models.TextField() enable_comments = models.BooleanField(default=True) pub_date = models.DateTimeField(default=datetime.datetime.now) slug = models.SlugField(unique_for_date='pub_date') author = models.ForeignKey(User) featured = models.BooleanField(default=False) def save( self, force_insert=False, force_update= False): self.body_html = markdown(self.body) if self.excerpt: self.excerpt_html = markdown( self.excerpt ) super( Entry, self ).save( force_insert, force_update ) class Meta: ordering = ['-pub_date'] verbose_name_plural = "Entries" def __unicode__(self): return self.title Edit #2: To clarify I did move the media files to my media path and they are indeed rendering the image area, I can upload fine, the <<<image>>> tag is inserted into my editable MarkItUp w/ Markdown area but it isn't rendering in the MarkItUp preview - perhaps I just need to apply the |upload_tags into that preview. I'll try adding it to my template which posts the article as well.

    Read the article

  • Ubuntu 12.04 - after update it boots in command line only (no windows manager)

    - by ZSW
    I have Ubuntu 12.04, which has been working great for me since I installed it a year ago. Yesterday I ran the updates that update manager recommended. (Last time I ran updates before was about a week ago). After the updates were installed, it asked me to reboot. So I rebooted it, and then it stopped at login prompt (as a command line, with no windows). I logged in and tried to manually start the windows manager, and the screen went blank, and stayed blank I waited several minutes, and then turned it off. How can I figure out what is the problem? Which logs should I check?

    Read the article

  • Problem with messages framework in Django 1.2

    - by Konstantin
    Hello! I'm running Django 1.2 beta and trying out the new feature: message framework. http://docs.djangoproject.com/en/dev/ref/contrib/messages/ Everything seems to work, but when I try to output the messages, I get nothing. Seems that messages variable is empty. I double checked all the settings, they seem to be just like in the manual. What could be wrong? settings.py MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', #send messages to users 'django.middleware.locale.LocaleMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', #debug tool 'debug_toolbar.middleware.DebugToolbarMiddleware', ) TEMPLATE_CONTEXT_PROCESSORS = ( 'django.contrib.messages.context_processors.messages', #send messages to users 'django.core.context_processors.auth', ) #Store messages in sessions MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'; INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', #'django.contrib.sites', 'django.contrib.admin', 'django.contrib.messages', 'debug_toolbar', #my apps #... ) views.py def myview(request): from django.contrib import messages messages.error(request, 'error test'); messages.success(request, 'success test'); return render_to_response('mytemplate.html', locals()); mytemplate.html {% for message in messages %} {{ message }}<br /> {% endfor %} In template nothing is outputted.

    Read the article

  • Django 1.4.1 error loading MySQLdb module when attempting 'python manage.py shell'

    - by Paul
    I am trying to set up MySQL, and can't seem to be able to enter the Django manage.py shell interpreter. Getting the output below: rrdhcp-10-32-44-126:django pavelfage$ python manage.py shell Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line utility.execute() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv self.execute(*args, **options.__dict__) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute output = self.handle(*args, **options) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle return self.handle_noargs(**options) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/shell.py", line 45, in handle_noargs from django.db.models.loading import get_models File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/__init__.py", line 40, in <module> backend = load_backend(connection.settings_dict['ENGINE']) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/__init__.py", line 34, in __getattr__ return getattr(connections[DEFAULT_DB_ALIAS], item) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 92, in __getitem__ backend = load_backend(db['ENGINE']) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 24, in load_backend return import_module('.base', backend_name) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module __import__(name) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 16, in <module> raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named _mysql Any suggestions really appreciated.

    Read the article

  • How to resolve user registration and activation email error in Django registration?

    - by user2476295
    So I was just trying to setup a basic user authentication in Django and downloaded a django registration app with templates. Now when I run the server at 127.0.0.1:8000/accounts/register/ I get a basic registration page, I fill in the details and when I click submit I get this error "NoReverseMatch at /accounts/register/" Error during template rendering In template Users/sudhasinha/mysite/mysite/registration/templates/registration/activation_email.txt, error at line 4 'url' requires a non-empty first argument. The syntax changed in Django 1.5, see the docs. 1 {% load i18n %} 2 {% trans "Activate account at" %} {{ site.name }}: 3 4 http://{{ site.domain }}{**% url registration_activate activation_key %**} 5 6 {% blocktrans %}Link is valid for {{ expiration_days }} days.{% endblocktrans %} 7 This is what my activation_email.txt looks like: {% load i18n %} {% trans "Activate account at" %} {{ site.name }}: http://{{ site.domain }}{% url registration_activate activation_key %} {% blocktrans %}Link is valid for {{ expiration_days }} days.{% endblocktrans %} And this is what my registration_form.html looks like: {% extends "base.html" %} {% load i18n %} {% block content %} <form method="post" action="."> {{ form.as_p }} <input type="submit" value="{% trans 'Submit' %}" /> </form> {% endblock %} I have very minimal experience with Django and would appreciate some help to resolve this error. My urls seem to be setup correctly but I will post it if needed. Also pardon my horrible formatting

    Read the article

  • Can Django admin handle a one-to-many relationship via related_name?

    - by Mat
    The Django admin happily supports many-to-one and many-to-many relationships through an HTML <SELECT> form field, allowing selection of one or many options respectively. There's even a nice Javascript filter_horizontal widget to help. I'm trying to do the same from the one-to-many side through related_name. I don't see how it's much different from many-to-many as far as displaying it in the form is concerned, I just need a multi-select SELECT list. But I cannot simply add the related_name value to my ModelAdmin-derived field list. Does Django support one-to-many fields in this way? My Django model something like this (contrived to simplify the example): class Person(models.Model): ... manager = models.ForeignKey('self', related_name='staff', null=True, blank=True, ) From the Person admin page, I can easily get a <SELECT> list showing all possible staff to choose this person's manager from. I also want to display a multiple-selection <SELECT> list of all the manager's staff. I don't want to use inlines, as I don't want to edit the subordinates details; I do want to be able to add/remove people from the list. (I'm trying to use django-ajax-selects to replace the SELECT widget, but that's by-the-by.)

    Read the article

  • Django - no module named app

    - by Koran
    Hi, I have been trying to get an application written in django working - but it is not working at all. I have been working on for some time too - and it is working on dev-server perfectly. But I am unable to put in the production env (apahce). My project name is apstat and the app name is basic. I try to access it as following Blockquote http://hostname/apstat But it shows the following error: MOD_PYTHON ERROR ProcessId: 6002 Interpreter: 'domU-12-31-39-06-DD-F4.compute-1.internal' ServerName: 'domU-12-31-39-06-DD-F4.compute-1.internal' DocumentRoot: '/home/ubuntu/server/' URI: '/apstat/' Location: '/apstat' Directory: None Filename: '/home/ubuntu/server/apstat/' PathInfo: '' Phase: 'PythonHandler' Handler: 'django.core.handlers.modpython' Traceback (most recent call last): File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch default=default_handler, arg=req, silent=hlist.silent) File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1229, in _process_target result = _execute_target(config, req, object, arg) File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1128, in _execute_target result = object(arg) File "/usr/lib/pymodules/python2.6/django/core/handlers/modpython.py", line 228, in handler return ModPythonHandler()(req) File "/usr/lib/pymodules/python2.6/django/core/handlers/modpython.py", line 201, in __call__ response = self.get_response(request) File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py", line 134, in get_response return self.handle_uncaught_exception(request, resolver, exc_info) File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py", line 154, in handle_uncaught_exception return debug.technical_500_response(request, *exc_info) File "/usr/lib/pymodules/python2.6/django/views/debug.py", line 40, in technical_500_response html = reporter.get_traceback_html() File "/usr/lib/pymodules/python2.6/django/views/debug.py", line 114, in get_traceback_html return t.render(c) File "/usr/lib/pymodules/python2.6/django/template/__init__.py", line 178, in render return self.nodelist.render(context) File "/usr/lib/pymodules/python2.6/django/template/__init__.py", line 779, in render bits.append(self.render_node(node, context)) File "/usr/lib/pymodules/python2.6/django/template/debug.py", line 81, in render_node raise wrapped TemplateSyntaxError: Caught an exception while rendering: No module named basic Original Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/django/template/debug.py", line 71, in render_node result = node.render(context) File "/usr/lib/pymodules/python2.6/django/template/debug.py", line 87, in render output = force_unicode(self.filter_expression.resolve(context)) File "/usr/lib/pymodules/python2.6/django/template/__init__.py", line 572, in resolve new_obj = func(obj, *arg_vals) File "/usr/lib/pymodules/python2.6/django/template/defaultfilters.py", line 687, in date return format(value, arg) File "/usr/lib/pymodules/python2.6/django/utils/dateformat.py", line 269, in format return df.format(format_string) File "/usr/lib/pymodules/python2.6/django/utils/dateformat.py", line 30, in format pieces.append(force_unicode(getattr(self, piece)())) File "/usr/lib/pymodules/python2.6/django/utils/dateformat.py", line 175, in r return self.format('D, j M Y H:i:s O') File "/usr/lib/pymodules/python2.6/django/utils/dateformat.py", line 30, in format pieces.append(force_unicode(getattr(self, piece)())) File "/usr/lib/pymodules/python2.6/django/utils/encoding.py", line 71, in force_unicode s = unicode(s) File "/usr/lib/pymodules/python2.6/django/utils/functional.py", line 201, in __unicode_cast return self.__func(*self.__args, **self.__kw) File "/usr/lib/pymodules/python2.6/django/utils/translation/__init__.py", line 62, in ugettext return real_ugettext(message) File "/usr/lib/pymodules/python2.6/django/utils/translation/trans_real.py", line 286, in ugettext return do_translate(message, 'ugettext') File "/usr/lib/pymodules/python2.6/django/utils/translation/trans_real.py", line 276, in do_translate _default = translation(settings.LANGUAGE_CODE) File "/usr/lib/pymodules/python2.6/django/utils/translation/trans_real.py", line 194, in translation default_translation = _fetch(settings.LANGUAGE_CODE) File "/usr/lib/pymodules/python2.6/django/utils/translation/trans_real.py", line 180, in _fetch app = import_module(appname) File "/usr/lib/pymodules/python2.6/django/utils/importlib.py", line 35, in import_module __import__(name) ImportError: No module named basic My settings.py is as follows: INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'apstat.basic', 'django.contrib.admin', ) If I remove the apstat.basic, it goes through, but that is not a solution. Is it something I am doing in apache? My apache - settings are - <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /home/ubuntu/server/ <Directory /> Options None AllowOverride None </Directory> <Directory /home/ubuntu/server/apstat> AllowOverride None Order allow,deny allow from all </Directory> <Location "/apstat"> SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE apstat.settings PythonOption django.root /home/ubuntu/server/ PythonDebug On PythonPath "['/home/ubuntu/server/'] + sys.path" </Location> </VirtualHost> I have now sat for more than a day on this. If someone can help me out, it would be very nice.

    Read the article

  • Error after installing Django (supposed PATH or PYTHONPATH "error")

    - by illuminated
    Hi all, I guess this is a PATH/PYTHONPATH error, but my attempts failed so far to make django working. System is Ubuntu 10.04, 64bit: mx:~/webapps$ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=10.04 DISTRIB_CODENAME=lucid DISTRIB_DESCRIPTION="Ubuntu 10.04 LTS" Python version: 2.6.5: @mx:~/webapps$ python -V Python 2.6.5 When I run django-admin.py, the following happens: mx:~/webapps$ django-admin.py Traceback (most recent call last): File "/usr/local/bin/django-admin.py", line 2, in <module> from django.core import management ImportError: No module named django.core Similar when I import django in python shell: mx:~/webapps$ python Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import django Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named django >>> quit() More details: mx:~/webapps$ python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()" /usr/lib/python2.6/dist-packages Within python shell: Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> print sys.path ['', '/usr/lib/python2.6/dist-packages/django', '/usr/local/lib/python2.6/dist-packages/django/bin', '/usr/local/lib/python2.6/dist-packages/django', '/home/petra/webapps', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/pymodules/python2.6'] django-admin.py can be found here: mx:~/webapps$ locate django-admin.py ~/install/sources/Django-1.2.1/build/lib.linux-i686-2.6/django/bin/django-admin.py ~/install/sources/Django-1.2.1/build/scripts-2.6/django-admin.py ~/install/sources/Django-1.2.1/django/bin/django-admin.py /usr/local/bin/django-admin.py /usr/local/lib/python2.6/dist-packages/django/bin/django-admin.py /usr/local/lib/python2.6/dist-packages/django/bin/django-admin.pyc and in the end this doesn't help: export PYTHONPATH="/usr/lib/python2.6/dist-packages/django:$PYTHONPATH" nor this: export PYTHONPATH="/usr/local/lib/python2.6/dist-packages/django:$PYTHONPATH" How to solve this !? Thanks all in advance! :)

    Read the article

  • django internationalization doesn't work

    - by xRobot
    I have: created translation strings in the template and in the application view. run this command: django-admin.py makemessages -l it and the file it/LC_MESSAGES/django.po has been created run this command: django-admin.py compilemessages and I receive: processing file django.po in /home/jobber/Desktop/library/books/locale/it/LC_MESSAGES set the language code in settings.py: LANGUAGE_CODE = 'it-IT' but.... translation doesn't work !! I always see english text. Why ?

    Read the article

  • ** EDITED ** 'NoneType' object has no attribute 'day'

    - by Asinox
    Hi guy, i dont know where is my error, but Django 1.2.1 is give this error: 'NoneType' object has no attribute 'day' when i try to save form from the Administrator Area models.py from django.db import models from django.contrib.auth.models import User class Editorial(models.Model): titulo = models.CharField(max_length=250,help_text='Titulo del editorial') editorial = models.TextField(help_text='Editorial') slug = models.SlugField(unique_for_date='pub_date') autor = models.ForeignKey(User) pub_date = models.DateTimeField(auto_now_add=True) activa = models.BooleanField(verbose_name="Activa") enable_comments = models.BooleanField(verbose_name="Aceptar Comentarios",default=False) editorial_html = models.TextField(editable=False,blank=True) def __unicode__(self): return unicode(self.titulo) def get_absolute_url(self): return "/editorial/%s/%s/" % (self.pub_date.strftime("%Y/%b/%d").lower(), self.slug) class Meta: ordering=['-pub_date'] verbose_name_plural ='Editoriales' def save(self,force_insert=False, force_update=False): from markdown import markdown if self.editorial: self.editorial_html = markdown(self.editorial) super(Editorial,self).save(force_insert,force_update) i dont know why this error, COMPLETED ERROR: Traceback: File "C:\wamp\bin\Python26\lib\site-packages\django\core\handlers\base.py" in get_response 100. response = callback(request, *callback_args, **callback_kwargs) File "C:\wamp\bin\Python26\lib\site-packages\django\contrib\admin\options.py" in wrapper 239. return self.admin_site.admin_view(view)(*args, **kwargs) File "C:\wamp\bin\Python26\lib\site-packages\django\utils\decorators.py" in _wrapped_view 76. response = view_func(request, *args, **kwargs) File "C:\wamp\bin\Python26\lib\site-packages\django\views\decorators\cache.py" in _wrapped_view_func 69. response = view_func(request, *args, **kwargs) File "C:\wamp\bin\Python26\lib\site-packages\django\contrib\admin\sites.py" in inner 190. return view(request, *args, **kwargs) File "C:\wamp\bin\Python26\lib\site-packages\django\utils\decorators.py" in _wrapper 21. return decorator(bound_func)(*args, **kwargs) File "C:\wamp\bin\Python26\lib\site-packages\django\utils\decorators.py" in _wrapped_view 76. response = view_func(request, *args, **kwargs) File "C:\wamp\bin\Python26\lib\site-packages\django\utils\decorators.py" in bound_func 17. return func(self, *args2, **kwargs2) File "C:\wamp\bin\Python26\lib\site-packages\django\db\transaction.py" in _commit_on_success 299. res = func(*args, **kw) File "C:\wamp\bin\Python26\lib\site-packages\django\contrib\admin\options.py" in add_view 777. if form.is_valid(): File "C:\wamp\bin\Python26\lib\site-packages\django\forms\forms.py" in is_valid 121. return self.is_bound and not bool(self.errors) File "C:\wamp\bin\Python26\lib\site-packages\django\forms\forms.py" in _get_errors 112. self.full_clean() File "C:\wamp\bin\Python26\lib\site-packages\django\forms\forms.py" in full_clean 269. self._post_clean() File "C:\wamp\bin\Python26\lib\site-packages\django\forms\models.py" in _post_clean 345. self.validate_unique() File "C:\wamp\bin\Python26\lib\site-packages\django\forms\models.py" in validate_unique 354. self.instance.validate_unique(exclude=exclude) File "C:\wamp\bin\Python26\lib\site-packages\django\db\models\base.py" in validate_unique 695. date_errors = self._perform_date_checks(date_checks) File "C:\wamp\bin\Python26\lib\site-packages\django\db\models\base.py" in _perform_date_checks 802. lookup_kwargs['%s__day' % unique_for] = date.day Exception Type: AttributeError at /admin/editoriales/editorial/add/ Exception Value: 'NoneType' object has no attribute 'day' thanks guys sorry with my English

    Read the article

  • So now that Django 1.2 is officially out...

    - by Fedor
    Since I have Django 1.1x on my Debian setup - how can I use virtualenv or similar and not have it mess up my system's default django version which in turn would break all my sites? Detailed instructions or a great tutorial link would very much be appreciated - please don't offer vague advice since I'm still a noob. Currently I store all my django projects in ~/django-sites and I am using Apache2 + mod_wsgi to deploy.

    Read the article

  • Django-Registration & Django-Profile, using your own custom form

    - by Issy
    Hey All, I am making use of django-registration and django-profile to handle registration and profiles. I would like to create a profile for the user at the time of registration. I have created a custom registration form, and added that to the urls.py using the tutorial on: http://dewful.com/?p=70 The basic idea in the tutorial is to override the default registration form to create the profile at the same time. forms.py - In my profiles app from django import forms from registration.forms import RegistrationForm from django.utils.translation import ugettext_lazy as _ from profiles.models import UserProfile from registration.models import RegistrationProfile attrs_dict = { 'class': 'required' } class UserRegistrationForm(RegistrationForm): city = forms.CharField(widget=forms.TextInput(attrs=attrs_dict)) def save(self, profile_callback=None): new_user = RegistrationProfile.objects.create_inactive_user(username=self.cleaned_data['username'], password=self.cleaned_data['password1'], email=self.cleaned_data['email']) new_profile = UserProfile(user=new_user, city=self.cleaned_data['city']) new_profile.save() return new_user In urls.py from profiles.forms import UserRegistrationForm and url(r'^register/$', register, {'backend': 'registration.backends.default.DefaultBackend', 'form_class' : UserRegistrationForm}, name='registration_register'), The form is displayed, and i can enter in City, however it does not save or create the entry in the DB.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >