Search Results

Search found 3555 results on 143 pages for 'django reinhardt'.

Page 120/143 | < Previous Page | 116 117 118 119 120 121 122 123 124 125 126 127  | Next Page >

  • Normalising book titles - Python

    - by RadiantHex
    Hi folks, I have a list of books titles: "The Hobbit: 70th Anniversary Edition" "The Hobbit" "The Hobbit (Illustrated/Collector Edition)[There and Back Again]" "The Hobbit: or, There and Back Again" "The Hobbit: Gift Pack" and so on... I thought that if I normalised the titles somehow, it would be easier to implement an automated way to know what book each edition is referring to. normalised = ''.join([char for char in title if char in (string.ascii_letters + string.digits)]) or normalised = '' for char in title: if char in ':/()|': break normalised += char return normalised But obviously they are not working as intended, as titles can contain special characters and editions can basically have very different title layouts. Help would be very much appreciated! Thanks :)

    Read the article

  • Design question?

    - by Mohamed
    I am building music app, where user can do several tasks including but not limited to listening song, like song, recommend song to a friend and extra. currently I have this model: class Activity(models.Model): activity = models.TextField() user = models.ForeignKey(User) date = models.DateTimeField(auto_now=True) so far I thought about two solutions. 1. saving a string to database. e.g "you listened song xyz" 2. create a dictionary about the activity and save to the database using pickle or json. e.g. dict_ = {"activity_type":"listening", "song":song_obj} I am leaning to the second implementation, but not quite sure. so what do you think about those two methods? do you know better way to achieve the goal?

    Read the article

  • using javascript with help of jquery

    - by tazim
    Code written by me based on previous suggestions as follows . Any help to efficinetly use jquery in order to make this code work . Thanks in advance $(document).ready(function() { self.setInterval("clock()",1000); $("button").click(function() { clock; }); function clock() { clock(); time=new Date(); var s = "<p>" + time + "</p>"; $(s).appendTo("div"); } }); <button > Click Me button </div> <div id="someid"></div>

    Read the article

  • importing data using get or create - identity error 1062

    - by hamackey
    I am importing data from a mssql database into mysql. Works except when it encounters the id of a previous entry. id is unique. I need to get entries that already exist so that they can be placed in the work of the day. Error is IntegrityError: (1062, "Duplicate entry '001355338' for key 2") This entry is already in the database. I need it entered for that day, but can not have it added to the table. It is already there. def handle(self, *args, **options): 59 #patients_local = Patient.objects.all() 60 #attendings_local = Attending.objects.all() 61 connection = pyodbc.connect("XXXXXXXXXXX") 62 cursor = connection.cursor() 63 cursor.execute(COMMAND) 64 rows = cursor.fetchall() 65 for row in rows: 66 # get_or_create returns (object, boolean) 67 p, created = Patient.objects.get_or_create( 68 first_name = row.Firstname, 69 middle_name = '', 70 last_name = row.Lastname, 71 id = row.id, 72 )

    Read the article

  • displaying the file data in correct format

    - by tazim
    hi, In views.py def showfiledata(request): with open("/home/tazim/webexample/tmp.txt") as f: read_data = f.read() f.closed return_dict = {'filedata':read_data} json = simplejson.dumps(return_dict) return HttpResponse(json,mimetype="application/json") In the template: < html < head < script type="text/javascript" src="/jquerycall/" < script type="text/javascript" $(document).ready(function() { $("button").click(function() { $.ajax({ type:"POST", url:"/showfiledata/", datatype:"json", success:function(data) { var s = data.filedata; $("#someid").html(s); } }); }); }); < /script < /head < body < form method="post" < button type="button"Click Me< /button < div id="someid"< /div < /form < /body < /html I am suppose to display file line by line . But, right now the lines get displayed withoout any linebreaks.

    Read the article

  • There is a system alert of (13, 'Permission denied'), how to solve that?

    - by Semanty
    def upload_file(request, step_id): def handle_uploaded_file (file): current_step = Step.objects.get(pk=step_id) current_project = Project.objects.get(pk=current_step.project.pk) path = "%s/upload/file/%s/%s" % (settings.MEDIA_ROOT, current_project.project_no, current_step.name) if not os.path.exists (path): os.makedirs(path) fd = open(path) for chunk in file.chunks(): fd.write(chunk) fd.close() if request.method == 'POST': form = UploadFileForm(request.POST, request.FILES) if form.is_valid(): handle_uploaded_file(request.FILES['file']) return HttpResponseRedirect('/success/url/') else: form = UploadFileForm() return render_to_response('projects/upload_file.html', { 'step_id': step_id, 'form': form, })

    Read the article

  • Building a user subscription application

    - by Tristan O'Neil
    Hello, I'm trying to come up with the best way to handle user subscription and management for our magazine website. What I want to happen is a user purchases a subscription and they are granted online access of a certain membership role for a certain amount of time depending on how many years they subscribed for. I would also like the system to be able to send out emails when a subscription is almost up. I've seen some third party projects to help accomplish this but I'd prefer to write this from scratch as I want total control over how it works. Any suggestions would be helpful. The main thing I can't figure out is how to have an expiring membership. You must keep track of when the user signed up and how long until they should expire.

    Read the article

  • Tools and tips for switching CMS

    - by Jimmy
    I work for a university, and in the past year we finally broke away from our static HTML site of several thousand pages and moved to a Drupal site. This obviously entails massive amounts of data entry. What if you're already using a CMS and are switching to another one that better suits your needs? How do you minimize the mountain of data entry during such a huge change? Are there tools built for this, or some best practices one should follow?

    Read the article

  • Tallying records using annotate() not working as should.

    - by 47
    I have two classes: Vehicle and Issues....a Vehicle object can have several issues recorded in the Issues class. What I want to do is to have a list of all issues, with each vehicle appearing only once and the total number of issues shown, plus other details....clicking on the record will then take the user to another page with all those issues for a selected vehicle shown in detail now. I tried this out using annotate, but I could only access the count and vehicle foreign key, but none of the other fields in the Vehicle class. class Issues(models.Model): vehicle = models.ForeignKey(Vehicle) description = models.CharField('Issue Description', max_length=30,) type = models.CharField(max_length=10, default='Other') status = models.CharField(max_length=12, default='Pending') priority = models.IntegerField(default='8', editable=False) date_time_added = models.DateTimeField(default=datetime.today, editable=False) last_updated = models.DateTimeField(default=datetime.today, editable=False) def __unicode__(self): return self.description The code I was using to annotate is: issues = Issues.objects.all().values('vehicle').annotate(count=Count('id')) What could be the problem?

    Read the article

  • Problem with validating ModelForm

    - by user561640
    I use ModelForm to create my form. All works fine except 1 thing - validating the unique field. Code: class Article(models.Model): ... title = models.CharField(max_length=255, unique=True, error_messages={'max_length' : 'max translation', 'unique' : 'unique translation', 'required' : 'req translation',}) ... class ArticleForm(ModelForm): ... title = forms.CharField(max_length=255, min_length=3, error_messages={'required' : 'req translation', 'min_length' : 'min translation', 'max_length' : 'max translation', 'unique' : 'unique translation',}) But when I save my form with non-unique title I don't get my custom translated error but I get default error. How to fix it, that my unique field error is displayed?

    Read the article

  • How can I measure distance with tastypie and geodjango?

    - by Twitch
    Using Tastypie and GeoDjango, I'm trying to return results of buildings located within 1 mile of a point. The TastyPie documentation states that distance lookups are not yet supported, but I am finding examples of people getting it work, such as this discussion and this discussion on StackOverflow, but no working code examples that can be applied. The idea that I am trying to work with is if I append a GET command to the end of a URL, then nearby locations are returned, for example: http://website.com/api/?format=json&building_point__distance_lte=[{"type": "Point", "coordinates": [153.09537, -27.52618]},{"type": "D", "m" : 1}] But when I try that, all I get back is: {"error": "Invalid resource lookup data provided (mismatched type)."} I've been pouring over the Tastypie document for days now and just can't figure out how to implement this. I'd provide more examples, but I know they'd be all terrible. All advice is appreciated, thank you!

    Read the article

  • Python: UTF-8 problems (again...)

    - by blahblah
    I have a database which is synchronized against an external web source twice a day. This web source contains a bunch of entries, which have names and some extra information about these names. Some of these names are silly and I want to rename them when inserting them into my own database. To rename these silly names, I have a standard dictionary as such: RENAME_TABLE = { "Wsird" : "Weird", ... } As you can see, this is where UTF-8 comes into play. This is the function which performs renaming of all the problematic entries: def rename_all_entries(): all_keys = RENAME_TABLE.keys() entries = Entry.objects.filter(name__in=all_keys) for entry in entries: entry.name = RENAME_TABLE[entry.name] entry.save() So it tries to find the old name in RENAME_TABLE and renames the entry if found. However, I get a KeyError exception when using RENAME_TABLE[entry.name]. Now I'm lost, what do I do? I have... # -*- coding: utf-8 -*- ...in the top of the Python file.

    Read the article

  • Edit form not being instanciated

    - by 47
    I have two models like this: class OptionsAndFeatures(models.Model): options = models.TextField(blank=True, null=True) entertainment = models.TextField(blank=True, null=True) seats_trim = models.TextField(blank=True, null=True) convenience = models.TextField(blank=True, null=True) body_exterior = models.TextField(blank=True, null=True) lighting = models.TextField(blank=True, null=True) safety = models.TextField(blank=True, null=True) powertrain = models.TextField(blank=True, null=True) suspension_handling = models.TextField(blank=True, null=True) specs_dimensions = models.TextField(blank=True, null=True) offroad_capability = models.TextField(blank=True, null=True) class Vehicle(models.Model): ... options_and_features = models.ForeignKey(OptionsAndFeatures, blank=True, null=True) I have a model form for the OptionsAndFeaturesclass that I'm using in both the add and edit views. In the add view it works just fine. But the edit view renders the OptionsAndFeatures as blank. The code for the edit view is as follows: def edit_vehicle(request, stock_number=None): vehicle = get_object_or_404(Vehicle, stock_number=stock_number) if request.method == 'POST': # save info else: vehicle_form = VehicleForm(instance=vehicle) photos = PhotosFormSet(instance=vehicle) options = OptionsForm(instance=vehicle) #render_to_reponse What could be the problem here?

    Read the article

  • Update single field

    - by 47
    I have a Customer class which has a representative field....this field is initially blank but when the user opens up the details page of the chosen customer, they'll be given the open of representing this customer by clicking on a link. The template layout I was thinking of is this: <strong>Representative: </strong> {% if customer.representative %} {{ customer.representative }} {% else %} <a href="{% url representCustomer customer.id %}">Represent this customer.</a> {% endif %} All that remains is the view to effect this...this is where I'm stuck.

    Read the article

  • Count Records in Listing View

    - by 47
    I have these two models: class CommonVehicle(models.Model): year = models.ForeignKey(Year) series = models.ForeignKey(Series) engine = models.ForeignKey(Engine) body_style = models.ForeignKey(BodyStyle) ... class Vehicle(models.Model): objects = VehicleManager() stock_number = models.CharField(max_length=6, blank=False) vin = models.CharField(max_length=17, blank=False) common_vehicle = models.ForeignKey(CommonVehicle) .... What I want to do is to have a count of how many times a given CommonVehicle object is used in the Vehicle class. So far my attempts are giving me one number, which is a total of all the records. How can I have the count being the total appearances for each CommonVehicle

    Read the article

< Previous Page | 116 117 118 119 120 121 122 123 124 125 126 127  | Next Page >